home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / ENTERPRS / CPM / TERMS / ZMP-SRC.LZH / ZMINIT.C < prev    next >
Text File  |  2000-06-30  |  3KB  |  137 lines

  1. /******************** Initialisation Overlay for ZMP ***********************/
  2.  
  3. #define  INIT
  4. #include "zmp.h"
  5.  
  6. #ifdef   AZTEC_C
  7. #include "libc.h"
  8. #else
  9. #include <stdio.h>
  10. #endif
  11.  
  12. ovmain()
  13.  
  14. {
  15.     unsigned u;
  16.  
  17.     userin();    /* perform user-defined entry routine */
  18.     title();
  19.     getconfig();
  20.     initvector();                 /* set up interrupt vector */
  21.     u = (unsigned) *Mspeed;
  22.     if ( !u || u > 13 )
  23.         initializemodem();    /* initialise uart as well */
  24.     else
  25.     {
  26.         Current.cbaudindex = (int) (*Mspeed);
  27.         Current.cparity = Line.parity;        /* Only update */
  28.         Current.cdatabits = Line.databits;    /*  internal   */
  29.         Current.cstopbits = Line.stopbits;    /*  variables  */
  30.     }
  31.     Currdrive = Invokdrive;
  32.     Curruser = Invokuser;
  33.     reset(Currdrive,Curruser);
  34.     showcurs();
  35. }
  36.  
  37.  
  38. title()
  39. {
  40.     static char line1[] = "ZMP - A ZMODEM Program for CP/M";
  41.     static char line3[] = "Developed from HMODEM II";
  42.     static char line4[] = "by Ron Murray";
  43.  
  44.     cls();
  45.     LOCATE(7,ctr(line1));
  46.     printf(line1);
  47.     LOCATE(9,ctr(Version));
  48.     printf(Version);
  49.     LOCATE(10,ctr(line3));
  50.     printf(line3);
  51.     LOCATE(11,ctr(line4));
  52.     printf(line4);
  53.     LOCATE(14,0);
  54.     hidecurs();
  55.     flush();
  56. }
  57.  
  58. /* Initialise the modem */
  59. initializemodem()
  60. {
  61.     resetace();
  62.     mstrout("\n\n",FALSE);
  63.     mstrout(Modem.init,FALSE);
  64.     while(readline(10) != TIMEOUT);    /* gobble echoed characters */
  65. }
  66.  
  67. /* Read the .CFG file into memory */
  68. getconfig()
  69.  
  70. {
  71.     int i;
  72.     FILE *fd;
  73.  
  74.     strcpy(Pathname,Cfgfile);
  75.     addu(Pathname,Overdrive,Overuser);
  76.     fd = fopen(Pathname,"rb");
  77.     if (fd)
  78.     {
  79.         fscanf(fd,"%d %d %d %d %d",&Crcflag,&Wantfcs32,&XonXoff,
  80.             &Filter,&ParityMask);
  81.         for (i = 0; i < 10; i++)
  82.             xfgets(KbMacro[i],22,fd);
  83.         xfgets(Mci,20,fd);
  84.         xfgets(Sprint,20,fd);
  85.         xfgets(Modem.init,40,fd);
  86.         xfgets(Modem.dialcmd,8,fd);
  87.         xfgets(Modem.dialsuffix,8,fd);
  88.         xfgets(Modem.connect,20,fd);
  89.         xfgets(Modem.busy1,20,fd);
  90.         xfgets(Modem.busy2,20,fd);
  91.         xfgets(Modem.busy3,20,fd);
  92.         xfgets(Modem.busy4,20,fd);
  93.         xfgets(Modem.hangup,20,fd);
  94.         fscanf(fd,"%d %d",&Modem.timeout,&Modem.pause);
  95.         fscanf(fd,"%d %c %d %d",&Line.baudindex,&Line.parity,
  96.             &Line.databits,&Line.stopbits);
  97.         fscanf(fd,"%d %d %c %d %d",&Zrwindow,&Pbufsiz,&Maxdrive,
  98.             &Chardelay,&Linedelay);
  99.         fclose(fd);
  100.     }
  101. }
  102.  
  103. /* Read a string from a file and remove the newline characters */
  104. xfgets(buf,max,fd)
  105. char *buf;
  106. int max;
  107. FILE *fd;
  108.  
  109. {
  110.     short noerror = 1;
  111.     char *p, *index();
  112.     char tbuf[81];
  113.  
  114.     tbuf[0] = '\0';
  115.     while (!strlen(tbuf) && noerror)
  116.     {
  117.         noerror = (short) fgets(tbuf,80,fd);
  118.         while ( p = index(tbuf,'\12'))
  119.             strcpy(p, p + 1);
  120.         while ( p = index(tbuf,'\15'))
  121.             strcpy(p, p + 1);
  122.     }
  123.     strncpy(buf,tbuf,max);
  124. }
  125.  
  126. resetace()  /* to default values */
  127. {
  128.     Current.cparity = Line.parity;
  129.     Current.cdatabits = Line.databits;
  130.     Current.cstopbits = Line.stopbits;
  131.     Current.cbaudindex = Line.baudindex;
  132.     initace(Current.cbaudindex,Current.cparity,
  133.         Current.cdatabits,Current.cstopbits);
  134. }
  135.  
  136. /* End of initialisation overlay */
  137.