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 / BEEHIVE / COMMS / YAM.ARC / YAM.H < prev    next >
Text File  |  1990-09-20  |  8KB  |  239 lines

  1. /*
  2. >>: yam.h
  3. */
  4. #include "yamsys.h"        /* installation specific stuff */
  5.  
  6. #ifndef VERSION
  7. #define VERSION " Rev 3.12 : 02-Jun-83"    /* (diff 14-11-81) */
  8. #endif
  9.  
  10. #ifndef XMODEM
  11. #define lprintf printf
  12. #endif
  13. /*
  14.  * yam    -Yet Another Modem program
  15.  *        Chuck Forsberg 10-18-81
  16.  *
  17.  *    Design goals: A general program performing the functions
  18.  *    of MODEM and XMODEM, easily portable to non-timesharing
  19.  *    computer systems.
  20.  *
  21.  *    Coding style is/was aimed at portability and clarity.
  22.  *    File transfer routines are written without timing assumptions
  23.  *      allowing error free high speed operation even if view selected
  24.  *
  25.  *    Comments to me at:
  26.  *    Chuck Forsberg
  27.  *        Computer Development Inc
  28.  *        6700 S.W. 105th
  29.  *        Beaverton OR 97005 503/646-1599
  30.  *        Home 503/621-3406 Voice
  31.  *        RBBS RCP/M 503/621-3193    (latest source code)
  32.  *          At 300, 450, or 1200 bps(212modem)    Random hours
  33.  *        CBBS NW 503/284-5260
  34.  *        Source TCE022
  35.  *        RTTY Autostart 3627.5 "ZCZC WRU WA7KGX CR/LF msg... NNNN"
  36.  *
  37.  *    Files:
  38.  *        yam.h        header and globals
  39.  *        yamsys.h    Modem port adresses, installation specific data
  40.  *        yam1.c        First time initialization
  41.  *                    Main command decoding
  42.  *        yam2.c        Christensen protocol handler
  43.  *        yam3.c        Conversation with data capture
  44.  *                    File xmsn w/o error checking.
  45.  *
  46.  *        yam5.c        Misc modem related functions, such as baudrate
  47.  *        yam7.c        Disk i/o open,close, directory
  48.  *                    Wild card expansion, CP/M related stuff
  49.  *        yam8.asm    CRCK calculation routine.
  50.  *        yam9.asm    CRC calculation routine.
  51.  *        yam10.c        USQ function (not used unless USQ defined)
  52.  *        yam11.c        Direct console IO, Lprinf Pstat Lpstat etc
  53.  *
  54.  *        keyb.crl    Essential keyboard routines for EXIDY SORCERER
  55.  *
  56.  *        compiled with -e 6200 for all files and -o for yam[235]
  57.  *        (-e 6000 for XYAM with RESTRICTED)
  58.  *        (add 500 if USQ is defined)
  59.  */
  60.  
  61. #ifdef CPM
  62. char defdisk;        /* default disk */
  63. char user;
  64. #define PATHLEN 20    /* plenty long */
  65. #endif            /* endif for CPM */
  66.  
  67. #ifdef BDSC
  68. #define FLAG char
  69. struct _buf fin,fout;
  70. int logfd;        /* used by logfile */
  71. #define stdin 0
  72. #define stdout 1
  73. #define stderr 1
  74. char cfast;        /* BDS C fastest access is to extern's */
  75. char checksum;        /* delcared here for speed */
  76. unsigned oldcrc;    /* accumulates CRC checksum */
  77. int wcj, firstch;
  78. FLAG firstsec;        /* first sector, C instead of NAK for crc */
  79. #endif             /* endif for BDSC */
  80.  
  81. #ifndef IOTYPE        /* iotype may be unsigned for memory mapped i/o */
  82. #define IOTYPE char
  83. #endif            /* endif for IOTYPE */
  84.  
  85. #define CMDLEN 132
  86.  
  87. #define ENQ 005
  88. #define CAN ('X'&037)
  89. #define XOFF ('s'&037)
  90. #define XON ('q'&037)
  91. #define SOH 01
  92. #define EOT 4
  93. #define ACK 6
  94. #define WANTCRC 0103    /* send C not NAK to get crc not checksum */
  95. #define NAK 025
  96. #define TIMEOUT (-2)
  97. #define ERRORMAX 5
  98. #define RETRYMAX 5
  99.  
  100. char commbyte;        /* command byte for UART */
  101.  
  102. /* declare all globally used functions not returning int */
  103. char putcty(), *index(), *cisubstr();
  104.  
  105. FLAG Quiet;
  106. char Ttycol, Lpcol;    /* column for tab expansion */
  107. unsigned Numsecs;    /* Number of 128 byte sectors, used by compsec */
  108. unsigned Numblks;    /* Number of CP/M blocks, used by compsec */
  109. unsigned Numfiles;    /* Total number of files expanded */
  110. unsigned Secpblk;    /* Number of sectors per block */
  111. FLAG Rfile;        /* receiving into a file */
  112. FLAG Tfile;        /* transmitting from a file */
  113. FLAG Crcflg;        /* 1 if using crc, 0 otherwise */
  114. FLAG Batch;        /* Batch (multi-file) xfer */
  115. FLAG Creamfile;        /* true means o.k. to blast old file on rx */
  116. FLAG Txgo;        /* file sending start/stop (XON/XOFF) */
  117. FLAG Dumping;        /* not Squelched ^R */
  118. FLAG Pflag;        /* printing the rx stuff */
  119. FLAG Ctlview;        /* Term function shows control chars as ^char */
  120. FLAG View;        /* View data being transmitted/received if file xfer \
  121.             also causes putcty to use putchar, allowing ^P, etc. */
  122. FLAG Type;        /* Duplicate sendcon char to sendline */
  123. FLAG Echo;        /* Echo modem data back to itself only in chat */
  124. FLAG Hdx;        /* Half Duplex connection -no echo from far end */
  125. FLAG Chat;        /* treat kbd \r as crlf when chatting */
  126. FLAG Gototerm;        /* go to term after file xfer */
  127. FLAG Exoneof;        /* exit from term() when finished with file */
  128. FLAG Sysfil;        /* does YAM see system files? ('y' flag)  */
  129.  
  130. /* Following flags affect data as it is written to file, not captured */
  131.  
  132. FLAG Image;        /* Tell it like it is. */
  133. FLAG Zeof;        /* Terminate data capture & close file on ^Z */
  134. FLAG Squelch;        /* Turn capture on after ^R, off before ^T */
  135. char GOchar;        /* normally \n; resumes sending in EOL _ CRWAIT mode */
  136. char *Txmoname;        /* ascii string corresponding to Txeoln mode */
  137. FLAG Txeoln;        /* what to do at the end of a line */
  138. #define EOL_NOTHING 0    /* send it all as is */
  139. #define EOL_CR    1    /* send /r only */
  140. #define EOL_NL    2    /* send \n only */
  141. #define EOL_CRWAIT 3    /* send \r then wait for GOchar echo */
  142. #define EOL_CRPROMPT 4    /* send \r then wait for silence. */
  143. #define TX_BINARY 0200    /* don't stop on CPMEOF or whatever **/
  144.  
  145. /* For controls based on time since last RX char mostly */
  146.  
  147. unsigned Timeout;    /* measure of how long since last rx char */
  148. unsigned Tpause;    /* when ++Timeout==Tpause, do something ... */
  149. FLAG Xoffflg;        /* !=0 if we sent XOFF to stop the bubble machine */
  150. FLAG Waitecho;        /* Wait for echo to stop when sending file */
  151.  
  152. /* If Waitbunch, Wait for Throttle loops each waitnum tx chars */
  153.  
  154. FLAG Waitbunch;
  155. unsigned Waitnum;    /* do Waitecho each time chars_sent == Waitnum */
  156. unsigned Throttle;
  157. FLAG Txwait;        /* used with throttle */
  158. unsigned Txtimeout;    /* counted down to 0, then Txwait becomes false */
  159.  
  160. unsigned T1pause;    /* for setting 0.1 second timeout for readline */
  161. char Lastrx;        /* last char received, for detecting CAN CAN */
  162.  
  163. /*
  164.  * start, end, input, output, printer-output pointers and marker
  165.  * used with data capture
  166.  */
  167.  
  168. char *bufst, *bufend, *bufcq, *bufcdq, *buffcdq, *bufpcdq, *bufmark;
  169. char *abptr;        /* pointer to string to be sent, else 0 */
  170. char *abend;        /* first character after string to be sent */
  171. unsigned Free;        /* Number of characters free in capture buf */
  172. unsigned Low;        /* when free==low, send the XOFF */
  173. unsigned Bufsize;
  174. FLAG Wrapped;        /* Buffer insertion pointer has wrapped around */
  175. IOTYPE Dport,Sport;    /* data and status port addresses */
  176. char Mstatus;        /* contents of modem error register if modem error */
  177. unsigned Baudrate;    /* current baudrate */
  178. unsigned Commbyte;    /* current UART command byte */
  179. FLAG Originate;        /* Originate mode requested */
  180. FLAG Parity;
  181.  
  182. #define SEND8 0        /* RAW on Unix */
  183. #define NORMAL 1    /* cooked o.k. on Unix */
  184.  
  185. /* following would be CBREAK on Unix */
  186.  
  187. #define EVEN7 2
  188. #define ODD7 3
  189. #define EVEN8 4
  190. #define ODD8 5
  191.  
  192. #ifndef KBMASK
  193. #define KBMASK 0177    /* default strip parity bits from console kbd */
  194. #endif
  195.  
  196. #ifdef USQ
  197. #define RECOGNIZE 0xFF76    /* unlikely pattern */
  198.  
  199. /* External declarations for USQ feature */
  200.  
  201. #define NUMVALS 257    /* 256 data values plus SPEOF*/
  202.  
  203. /* Decoding tree */
  204.  
  205. struct {
  206.     int children[2];    /* left, right */
  207. } dnode[NUMVALS - 1];
  208. int bpos;        /* last bit position read */
  209. int curin;        /* last byte value read */
  210.  
  211. /* Variables associated with repetition decoding */
  212.  
  213. int repct;        /*Number of times to return value*/
  214. int value;        /*current byte value or EOF */
  215. #endif            /* endif for USQ */
  216.  
  217. char cmdbuf[CMDLEN+2], *cp;  /* for commands entered directly (not argv) */
  218. char Rname[PATHLEN], Tname[PATHLEN];    /* saved file names */
  219. char Phone[80];        /* phone number read in from file */
  220.  
  221. /*
  222.  * Unix is a trademark of Western Electric
  223.  * CP/M, Digital Research
  224.  * Coherent, Mark Willams Co., Chicago IL
  225.  * IDRIS, Whitesmiths Co.
  226.  */
  227.  
  228. /*
  229. Some #DEFINES you should know about:
  230.     USERINIT this generates a call to userinit() from init()
  231.     IOBYTE define this unsigned to point to memory mapped ports
  232.     DEFBAUD if not defined, baudrate is read from the port
  233.     USQ includes code to automatically type SQUEEZED files
  234.     RESTRICTED disallows downloading of $SYS|TAG2 files, upload .com>.obj
  235.     LOGFILE logs all file xmsn attempts, also is the file
  236.     TERMRESET string initializes terminal to desired mode
  237.     PHONES file with phone numbers
  238. */
  239.