home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff236.lzh / XprZmodem / defs.h < prev    next >
C/C++ Source or Header  |  1989-08-09  |  6KB  |  158 lines

  1. /*  defs.h: Definitions for xprzmodem.library;
  2.     Version 1.0, 29 July 1989, by Rick Huebner.
  3.     Released to the Public Domain; do as you like with this code.  */
  4.  
  5.  
  6. /* #define DEBUG 1 */
  7.  
  8. /* Return codes */
  9. #define OK        0
  10. #define ERROR   (-1)
  11. #define TIMEOUT (-2)
  12. #define RCDO    (-3)
  13.  
  14. /* Relevant control characters */
  15. #define CR     ('M'&0x1F)        /* ^M */
  16. #define DLE    ('P'&0x1F)        /* ^P */
  17. #define XON    ('Q'&0x1F)        /* ^Q */
  18. #define XOFF   ('S'&0x1F)        /* ^S */
  19. #define CAN    ('X'&0x1F)        /* ^X */
  20. #define CPMEOF ('Z'&0x1F)        /* ^Z */
  21.  
  22. /* Misc. program constants */
  23. #define LZMANAG          0       /* Default ZMODEM file management mode */
  24. #define LZTRANS          0       /* Default ZMODEM file transport mode */
  25. #define PATHLEN        256       /* What's the max legal path size? */
  26. #define CONFIGLEN       32       /* Max length of transfer options string */
  27. #define KSIZE         1024       /* Max allowable packet size */
  28. #define MINBLOCK        32       /* Min allowable packet size */
  29. #define MAXGOODNEEDED 8192       /* Max # good bytes required to bump packet size */
  30.  
  31. /* Provision for future 7-bit ZMODEM; for now, there's no difference */
  32. #define sendline xsendline
  33.  
  34.  
  35. /* Replacement for global variables normally used, in order to make code
  36.    fully reentrant; each invocation allocs their own Vars, and passes the
  37.    struct pointer down through the entire program so they're always available.
  38.    Pointer to this struct is usually able to be a register variable, so access
  39.    is no worse than any stack variable (all register-relative).  Kinda
  40.    kludgey, but the original ZModem code design depended on lots of globals,
  41.    and I didn't want to redesign the whole damn thing.  Besides, it's more
  42.    efficient than constantly pushing & popping args all over the place. */
  43.  
  44. struct Vars {
  45.   struct XPR_IO io;              /* Copy of XProtocol IO struct passed in by term prog. */
  46.   struct XPR_UPDATE xpru;        /* Scratchpad xpr_update() control struct */
  47.   UBYTE Zconv;                   /* ZMODEM file conversion request */
  48.   UBYTE Zmanag;                  /* ZMODEM file management request */
  49.   UBYTE Ztrans;                  /* ZMODEM file transport request */
  50.   UBYTE Lastsent;                /* Last text char written by putsec() */
  51.   UBYTE Lastzsent;               /* Last char sent by zsendline() */
  52.   UBYTE Fileflush;               /* Flush file I/O buffer before closing? */
  53.   UBYTE Msgbuf[128];             /* Scratchpad buffer for printing messages */
  54.   UBYTE Filename[PATHLEN];       /* Name of the file being up/downloaded */
  55.   UBYTE Modembuf[256];           /* Input buffer for data from modem */
  56.   UBYTE *Modemchar;              /* Next char to get from Modembuf */
  57.   UBYTE *Filebuf;                /* File I/O buffer address */
  58.   UBYTE *Filebufptr;             /* Current position within Filebuf */
  59.   char Rxbinary;                 /* Force binary mode download? */
  60.   char Rxascii;                  /* Force text mode download? */
  61.   char Thisbinary;               /* Receive this file in binary mode? */
  62.   char Lzconv;                   /* Suggested binary/text mode for uploads */
  63.   char Eofseen;                  /* Text-mode EOF marker (^Z) received on download? */
  64.   short Filcnt;                  /* Number of files opened for transmission */
  65.   short Errcnt;                  /* Number of files unreadable */
  66.   short Noroom;                  /* Flags 'insufficient disk space' errors */
  67.   short Rxbuflen;                /* Largest frame they're willing to xfer */
  68.   short Tframlen;                /* Largest frame we're willing to xfer */
  69.   short Rxtimeout;               /* Tenths of seconds to wait for something */
  70.   short Tryzhdrtype;             /* Header type to send corresponding to Last rx close */
  71.   short Modemcount;              /* Number of bytes available in Modembuf */
  72.   long File;                     /* Handle of file being transferred */
  73.   long Oldstatus;                /* Original terminal program's modem settings */
  74.   long Baud;                     /* BPS setting of modem */
  75.   long Strtpos;                  /* Starting byte position of transfer */
  76.   long Starttime;                /* Time transfer started */
  77.   long Fsize;                    /* Size of file being transferred */
  78.   long Rxbytes;                  /* Number of bytes received so far */
  79.   long Filebufpos;               /* File offset of data in Filebuf */
  80.   long Filebufmax;               /* Size of Filebuf */
  81.   long Filebuflen;               /* Number of bytes currently stored in Filebuf */
  82.   long Filebufcnt;               /* Number of bytes remaining/written in Filebuf */
  83.   UBYTE Pktbuf[KSIZE];           /* File data packet buffer */
  84.   UBYTE Rxhdr[4];                /* Received header */
  85.   UBYTE Txhdr[4];                /* Transmitted header */
  86.   UBYTE Attn[ZATTNLEN+1];        /* Attention string rx sends to tx on err */
  87.   short Rxframeind;              /* ZBIN or ZHEX; type of frame received */
  88.   short Rxtype;                  /* Type of header received */
  89.   short Rxcount;                 /* Count of data bytes received */
  90.   short Znulls;                  /* Number of nulls to send at beginning of ZDATA hdr */
  91.   long Rxpos;                    /* Received file position */
  92.   long Txpos;                    /* Transmitted file position */
  93. };
  94.  
  95.  
  96. /* Function declarations; change to ANSI prototypes when Manx gets their act together */
  97.  
  98. long  XProtocolSend();
  99. short getzrxinit();
  100. void  sendbatch();
  101. short sendone();
  102. short sendname();
  103. short zsendfile();
  104. short zsendfdata();
  105. short getinsync();
  106. void  saybibi();
  107.  
  108. long  XProtocolReceive();
  109. short rcvbatch();
  110. short tryz();
  111. short rzfiles();
  112. short rzfile();
  113. short procheader();
  114. short putsec();
  115. void  ackbibi();
  116.  
  117. long  XProtocolSetup();
  118. long  XProtocolCleanup();
  119. struct Vars *setup();
  120. void  canit();
  121. void  zmputs();
  122. void  xsendline();
  123. short readock();
  124. char  char_avail();
  125. void  update_rate();
  126. long  bfopen();
  127. void  bfclose();
  128. void  bfseek();
  129. long  bfread();
  130. long  brwrite();
  131. void  ioerr();
  132. void  upderr();
  133. void  updmsg();
  134. long  getfree();
  135. char  exist();
  136.  
  137. void  zsbhdr();
  138. void  zshhdr();
  139. void  zsdata();
  140. short zrdata();
  141. short zgethdr();
  142. short zrbhdr();
  143. short zrhhdr();
  144. void  zputhex();
  145. void  zsendline();
  146. short zgethex();
  147. short zdlread();
  148. short noxrd7();
  149. void  stohdr();
  150. long  rclhdr();
  151.  
  152. long calla();
  153. long callaa();
  154. long callad();
  155. long calladda();
  156. long calld();
  157. long calldaa();
  158.