home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol158 / yamc86.h < prev    next >
Encoding:
C/C++ Source or Header  |  1984-04-29  |  9.6 KB  |  259 lines

  1. /*
  2. >>:yam.h 12-14-83
  3.  *
  4.  * Computer Innovations C86 version
  5.  */
  6. #include "yamsys.h"        /* installation specific stuff */
  7.  
  8. #ifndef XMODEM
  9. #define lprintf printf
  10. #endif
  11. /*
  12.  * yam    -Yet Another Modem program
  13.  *        Chuck Forsberg 10-18-81
  14.  *        (C86 conversion:  Paul Homchick 11-09-83)
  15.  *
  16.  *    Design goals: A general program performing the functions
  17.  *    of MODEM and XMODEM, easily portable to non-timesharing
  18.  *    computer systems. YAM facilitates communications and s/w exchange
  19.  *    via timesharing, RCP/M, and Bulletin Board 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.  *
  26.  *    +++++++++++++++++++++++++++++++++++++++++++++++++
  27.  *
  28.  *    C86 conversion by:
  29.  *        Paul Homchick
  30.  *        Chimitt Gilman Homchick, Inc.
  31.  *        One Radnor Station Suite 300
  32.  *        Radnor, PA 19087
  33.  *        Compuserve 71445,527
  34.  *
  35.  *    +++++++++++++++++++++++++++++++++++++++++++++++++
  36.  *
  37.  *
  38.  *    Files:
  39.  *        yam.h        header and globals
  40.  *        yamsys.h    Modem port adresses, installation specific data
  41.  *        yam1.c        First time initialization
  42.  *                    Main command decoding
  43.  *        yam2.c        Christensen protocol handler
  44.  *        yam3.c        Conversation with data capture
  45.  *                    File xmsn w/o error checking.
  46.  *
  47.  *        yam4.c        CIS A Protocol handler (see MYSYSYTEM below)
  48.  *        yam5.c        Misc modem related functions, such as baudrate
  49.  *                  (see yam5pmmi.c, yam5smi4.c, etc.)
  50.  *        yam7.c        Disk i/o open,close, directory
  51.  *                    Wild card expansion, O/S related stuff
  52.  *        crc.a86        CRCK calculation routine.
  53.  *        updcrc.a86    CRC calculation routine, yterm().
  54.  *        yam10.c        USQ and some time critical functions
  55.  *
  56.  *
  57.  *        These files should be linked with yam10 first, because it
  58.  *        the largest set of "local globals" (i.e., cheating!).
  59.  */
  60.  
  61. #define TRUE    1
  62. #define FALSE    0
  63. #define ERROR  -1
  64. #define OK    0
  65.  
  66. /* C86 fopen() definitions */
  67.  
  68. #define BREAD    "rb"        /* binary read */
  69. #define BWRITE    "wb"        /* binary write */
  70. #define BAPPEND    "ab"        /* binary append */
  71.  
  72. #ifdef CPM
  73. EXTERN char defdisk;        /* default disk */
  74. EXTERN char user;
  75. #define PATHLEN 20    /* plenty long */
  76. #endif
  77.  
  78. #define FLAG int
  79. EXTERN FILE *fin,*fout;
  80. EXTERN int logfd;        /* used by logfile */
  81. EXTERN int cfast;
  82. EXTERN unsigned char checksum;    /* delcared here for speed */
  83. EXTERN unsigned oldcrc;    /* accumulates CRC checksum */
  84. EXTERN int wcj, firstch, errors;
  85. EXTERN FLAG firstsec;        /* first sector, C instead of NAK for crc */
  86.  
  87. #ifndef IOTYPE        /* may be char* or unsigned for memory mapped i/o */
  88. #define IOTYPE int
  89. #endif
  90.  
  91. #define CMDLEN 132
  92. #define SNARFBUNCH 2056    /* minimum size of buffer arranged by snarfbuf() */
  93. #define LOWWATER 2000    /* low water value causes term to send XOFF */
  94. #define SOH 1
  95. #define STX 2
  96. #define ETX 3
  97. #define EOT 4
  98. #define ENQ 5
  99. #define ACK 6
  100. #define SO 016
  101. #define SI 017
  102. #define DLE 020
  103. #define XON 021
  104. #define XOFF 023
  105. #define NAK 025
  106. #define CAN 030
  107. #define ESC 033
  108. #define WANTCRC 0103    /* send C not NAK to get crc not checksum */
  109. #define TIMEOUT (-2)
  110. #define ERRORMAX 5
  111. #define RETRYMAX 5
  112. #define CPMEOF 0x1A
  113. #define SECSIZ 128    /* Sector size for CP/M read/write calls */
  114. #define KSIZE    1024    /* block length with k option */
  115.  
  116. /* declare all globally used functions not returning int */
  117. char getcty(), putcty(), *index(), *cisubstr();
  118. unsigned getfree();
  119. long getfre3();
  120. FILE *fopen();
  121.  
  122. EXTERN char *Version;        /* version number and rev date, pointer to */
  123. EXTERN FLAG Quiet;
  124. EXTERN char Ttycol, Lpcol;    /* column for tab expansion */
  125. EXTERN unsigned Numsecs; /* Number of 128 byte sectors, used by compsec */
  126. EXTERN unsigned Numblks;    /* Number of CP/M blocks, used by compsec */
  127. EXTERN unsigned Numfiles;    /* Total number of files expanded */
  128. EXTERN unsigned Secpblk;    /* Number of sectors per block */
  129. EXTERN FLAG Onetrip;        /* causes exit before next prompt */
  130. EXTERN FLAG Rfile;        /* receiving into a file */
  131. EXTERN FLAG Tfile;        /* transmitting from a file */
  132. EXTERN FLAG Crcflg;        /* 1 if using crc, 0 otherwise */
  133. EXTERN FLAG Batch;        /* Batch (multi-file) xfer */
  134. EXTERN int Wcsmask;        /* 7 or 8 bit mask for Christensen Protocol */
  135. EXTERN FLAG Creamfile;        /* true means o.k. to blast old file on rx */
  136. EXTERN int blklen;        /* length of blocks for s and r, usually 128 */
  137. EXTERN unsigned totsecs;    /* accumulator of number of sectors sent/received */
  138. EXTERN unsigned toterrs;    /* total number of errors in xfer(s) */
  139. EXTERN FLAG Txgo;        /* file sending start/stop (XON/XOFF) */
  140. EXTERN FLAG Dumping;        /* not Squelched ^R */
  141. EXTERN FLAG Pflag;        /* printing the rx stuff */
  142. EXTERN FLAG Twxmode;        /* Respond to a/b requests */
  143. EXTERN FLAG Cis02;        /* Special functions for CIS02 access to Compuserve */
  144. EXTERN FLAG Ctlview;        /* Term function shows control chars as ^char */
  145. EXTERN FLAG Jovemode;    /* EMACS compatible mode for term() */
  146. EXTERN FLAG View;    /* View data being transmitted/received if file xfer */
  147. EXTERN FLAG UsePutchar;    /* Putcty usees putchar, allowing ^P to LST:, etc. */
  148. EXTERN FLAG Echo;    /* Echo modem data back to itself only in chat */
  149. EXTERN FLAG Hdx;    /* Half Duplex connection -no echo from far end */
  150. EXTERN FLAG Chat;    /* treat kbd \r as crlf when chatting */
  151. EXTERN FLAG Gototerm;    /* go to term after file xfer */
  152. EXTERN FLAG Exoneof;    /* exit from term() when finished with file */
  153. /* Following flags affect data as it is written to file, not captured */
  154. EXTERN FLAG Image;    /* Tell it like it is. */
  155. EXTERN FLAG Zeof;    /* Terminate data capture & close file on ^Z */
  156. EXTERN FLAG Squelch;    /* Turn capture on after ^R, off before ^T */
  157. EXTERN char GOchar;    /* normally \n; resumes sending in EOL _ CRWAIT mode */
  158. EXTERN char *Txmoname;        /* asciz string corresponding to Txeoln mode */
  159. EXTERN FLAG Txeoln;    /* what to do at the end of a line */
  160. #define EOL_NOTHING 0    /* send it all as is */
  161. #define EOL_CR    1        /* send /r only */
  162. #define EOL_NL    2        /* send \n only */
  163. #define EOL_CRWAIT 3    /* send \r then wait for GOchar echo */
  164. #define EOL_CRPROMPT 4    /* send \r then wait for silence. */
  165. #define TX_BINARY 0200    /* don't stop on CPMEOF or whatever **/
  166.  
  167. /* For controls based on time since last RX char mostly */
  168. EXTERN unsigned Timeout;    /* measure of how long since last rxchar */
  169. EXTERN unsigned Tpause;    /* when ++Timeout==Tpause, do something ... */
  170. EXTERN FLAG Xoffflg;        /* !=0 if we sent XOFF to stop the bubble machine */
  171. EXTERN FLAG Waitecho;        /* Wait for echo to stop when sending file */
  172.  
  173. /* If Waitbunch, Wait for Throttle loops each waitnum txchars */
  174. EXTERN FLAG Waitbunch;
  175. EXTERN unsigned Waitnum;    /* do Waitecho each time chars_sent == Waitnum */
  176. EXTERN unsigned Throttle;
  177. EXTERN FLAG Txwait;        /* used with throttle */
  178. EXTERN unsigned Txtimeout;    /* counted down to 0, then Txwait becomes false */
  179.  
  180. EXTERN unsigned T1pause;    /* for setting 0.1 second timeout for readline */
  181. EXTERN int Exitchar;        /* 0 or special character for exiting from term */
  182. EXTERN int Lastrx;        /* last char received, for detecting CAN CAN */
  183.  
  184. /*
  185.  * start, end, input, output, printer-output pointers and marker
  186.  * used with data capture
  187.  */
  188. EXTERN char *bufst, *bufend, *bufcq, *bufcdq, *buffcdq, *bufpcdq, *bufmark;
  189. EXTERN char *lkbufcq;        /* value of bufcq when last kbd char sent */
  190. EXTERN char *reptr;        /* local used by replot for speed */
  191. EXTERN char *abptr;        /* pointer to string to be sent, else 0 */
  192. EXTERN char *abend;        /* first character after string to be sent */
  193. EXTERN unsigned Lskcnt;    /* Count of lines received since last kbdchar */
  194. EXTERN unsigned Nfree;        /* Number of characters free in capture buf */
  195. EXTERN unsigned Bufsize;
  196. EXTERN FLAG Wrapped;        /* Buffer insertion pointer has wrapped around */
  197. EXTERN IOTYPE Dport;        /* data port address */
  198. EXTERN IOTYPE Sport;        /* status port address */
  199. EXTERN unsigned char Mstatus;        /* contents of modem error register if modem error */
  200. EXTERN unsigned Baudrate;  /* current baudrate */
  201. EXTERN FLAG Originate;    /* Originate mode requested */
  202. EXTERN FLAG Parity;
  203. #define SEND8 0    /* RAW on Unix */
  204. #define NORMAL 1    /* cooked o.k. on Unix */
  205.     /* following would be CBREAK on Unix */
  206. #define EVEN7 2
  207. #define ODD7 3
  208. #define EVEN8 4
  209. #define ODD8 5
  210.  
  211. #ifndef KBMASK
  212. #define KBMASK 0177    /* default strip parity bits from console kbd */
  213. #endif
  214.  
  215.  
  216. EXTERN unsigned char cmdbuf[CMDLEN+2], *cp;  /* for commands entered directly (not argv) */
  217. EXTERN char Rname[PATHLEN], Tname[PATHLEN];    /* saved file names */
  218.  
  219. /* Some declarations for USQ feature */
  220. #define SQMAGIC 0xFF76    /* SQueezed file prefix */
  221. #define NUMVALS 257    /* 256 data values plus SPEOF*/
  222. EXTERN union {
  223.     FILE *ufbuf;
  224.     char ubuf[KSIZE];
  225.     /* Decoding tree for usq feature */
  226.     struct {
  227.         int children[2];    /* left, right */
  228.     } dnode[NUMVALS - 1];
  229. } Utility;
  230.  
  231. EXTERN char Phone[80];        /* phone number read in from file */
  232. /*
  233.  * Unix is a trademark of Western Electric
  234.  * CP/M, Digital Research
  235.  * Coherent, Mark Willams Co., Chicago IL
  236.  * IDRIS, Whitesmiths Co.
  237.  */
  238.  
  239. /*
  240. Some #DEFINES you should know about:
  241.     USERINIT this generates a call to userinit() from init()
  242.     IOBYTE define this unsigned to point to memory mapped ports
  243.     DEFBAUD if not defined, baudrate is read from the port
  244.     USQ includes code to automatically type SQUEEZED files
  245.     RESTRICTED disallows downloading of $SYS|TAG2 files, upload .cmd>.obj
  246.     LOGTX log file name for completed file transmissions omit for no log
  247.     LOGRX likewise, for files received omit for no log
  248.     LOGFILE must be defined if logrx or logtx is defined.
  249.     LOGUSER user number for log and lastcalr
  250.     LASTCALR pathname for current caller (lastcalr with entbbs)
  251.     TERMINIT string initializes terminal to default mode.
  252.     TERMREPLOT string sets mode for replot; should disable line wrap.
  253.     TERMRESET string sets terminal to mode for conversation with remote.
  254.     PHONES file with phone numbers
  255.     MYSYSTEM is string required by CIS A protocol ESC I request. If not
  256.         defined, yam4 is not needed.
  257.     FLIP define this if you have a "flip" routine (see yam5pmmi.c)
  258. */
  259.