home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1996 October / PCO_10.ISO / filesbbs / bsrc_260.arj / INCLUDE.ZIP / hydra.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-20  |  14.7 KB  |  259 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software, Co.                       */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          Freely Available<tm> Software.                 */
  7. /*        \ 1011 /                                                          */
  8. /*         ------                                                           */
  9. /*                                                                          */
  10. /*              (C) Copyright 1987-96, Bit Bucket Software Co.              */
  11. /*                                                                          */
  12. /*             This header file was written by Michael Buenter              */
  13. /*               Based on original header file by Arjen Lentz               */
  14. /*                Hydra Protocol definitions for BinkleyTerm                */
  15. /*                                                                          */
  16. /*                                                                          */
  17. /*    For complete  details  of the licensing restrictions, please refer    */
  18. /*    to the License  agreement,  which  is published in its entirety in    */
  19. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.260.    */
  20. /*                                                                          */
  21. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  22. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  23. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  24. /*    NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  25. /*    SOFTWARE CO.  AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  26. /*    SHOULD YOU  PROCEED TO USE THIS FILE  WITHOUT HAVING  ACCEPTED THE    */
  27. /*    TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  28. /*    AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.      */
  29. /*                                                                          */
  30. /*                                                                          */
  31. /* You can contact Bit Bucket Software Co. at any one of the following      */
  32. /* addresses:                                                               */
  33. /*                                                                          */
  34. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:343/491             */
  35. /* P.O. Box 460398                AlterNet 7:42/1491                        */
  36. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  37. /*                                Internet f491.n343.z1.fidonet.org         */
  38. /*                                                                          */
  39. /* Please feel free to contact us at any time to share your comments about  */
  40. /* our software and/or licensing policies.                                  */
  41. /*                                                                          */
  42. /*                                                                          */
  43. /*--------------------------------------------------------------------------*/
  44.  
  45. /*=============================================================================
  46.  
  47.                               HydraCom Version 1.08
  48.                              (+ rev. upto 18 dec 93)
  49.  
  50.                          A sample implementation of the
  51.                    HYDRA Bi-Directional File Transfer Protocol
  52.  
  53.                              HydraCom was written by
  54.                    Arjen G. Lentz, LENTZ SOFTWARE-DEVELOPMENT
  55.                   COPYRIGHT (C) 1991-1993; ALL RIGHTS RESERVED
  56.  
  57.                        The HYDRA protocol was designed by
  58.                  Arjen G. Lentz, LENTZ SOFTWARE-DEVELOPMENT and
  59.                             Joaquim H. Homrighausen
  60.                   COPYRIGHT (C) 1991-1993; ALL RIGHTS RESERVED
  61.  
  62.  
  63.   Revision history:
  64.   06 Sep 1991 - (AGL) First tryout
  65.   .. ... .... - Internal development
  66.   11 Jan 1993 - HydraCom version 1.00, Hydra revision 001 (01 Dec 1992)
  67.   13 Mar 1993 - HydraCom version 1.03, Hydra revision 001 (01 Dec 1992)
  68.   ..
  69.   Changes made by Michael Buenter:
  70.   03 Dec 1993 - adapted hydra for BT-EE and BT 2.58, many changes
  71.   ..
  72.   Updated source fixes by Arjen Lentz:
  73.   04 Sep 1993 - HydraCom version 1.08, Hydra revision 001 (01 Dec 1992)
  74.   23 Dec 1993 - updated to post-1.08 revisions upto 18 Dec 1993
  75.  
  76.   For complete details of the Hydra and HydraCom licensing restrictions,
  77.   please refer to the license agreements which are published in their entirety
  78.   in HYDRACOM.C and LICENSE.DOC, and also contained in the documentation file
  79.   HYDRACOM.DOC
  80.  
  81.   Use of this file is subject to the restrictions contained in the Hydra and
  82.   HydraCom licensing agreements. If you do not find the text of this agreement
  83.   in any of the aforementioned files, or if you do not have these files, you
  84.   should immediately contact LENTZ SOFTWARE-DEVELOPMENT and/or Joaquim
  85.   Homrighausen at one of the addresses listed below. In no event should you
  86.   proceed to use this file without having accepted the terms of the Hydra and
  87.   HydraCom licensing agreements, or such other agreement as you are able to
  88.   reach with LENTZ SOFTWARE-DEVELOMENT and Joaquim Homrighausen.
  89.  
  90.  
  91.   Hydra protocol design and HydraCom driver:         Hydra protocol design:
  92.   Arjen G. Lentz                                     Joaquim H. Homrighausen
  93.   LENTZ SOFTWARE-DEVELOPMENT                         389, route d'Arlon
  94.   Langegracht 7B                                     L-8011 Strassen
  95.   3811 BT  Amersfoort                                Luxembourg
  96.   The Netherlands
  97.   FidoNet 2:283/512, AINEX-BBS +31-33-633916         FidoNet 2:270/17
  98.   arjen_lentz@f512.n283.z2.fidonet.org               joho@ae.lu
  99.  
  100.   Please feel free to contact us at any time to share your comments about our
  101.   software and/or licensing policies.
  102.  
  103. =============================================================================*/
  104.  
  105. /* HYDRA Some stuff to aid readability of the source and prevent typos ----- */
  106. #define h_crc16test(crc)   (((crc) == CRC16TEST) ? 1 : 0)    /*AGL:10mar93*/
  107. #define h_crc32test(crc)   (((crc) == CRC32TEST) ? 1 : 0)    /*AGL:10mar93*/
  108. #define h_uuenc(c)         (((c) & 0x3f) + '!')
  109. #define h_uudec(c)         (((c) - '!') & 0x3f)
  110. #define h_long1(buf)       (*((long *) (buf)))
  111. #define h_long2(buf)       (*((long *) ((buf) + ((int) sizeof (long)))))
  112. #define h_long3(buf)       (*((long *) ((buf) + (2 * ((int) sizeof (long))))))
  113. typedef ULONG h_timer;
  114.  
  115. #define h_timer_get()      (ULONG)(time(NULL))    /*AGL:15jul93*/
  116. #define h_timer_set(t)     (ULONG)(h_timer_get() + (t))    /*AGL:15jul93*/
  117. #define h_timer_running(t) (t != 0L)
  118. #define h_timer_expired(t, now) ((now) > (t))    /*AGL:15jul93*/
  119. #define h_timer_reset()    (0L)
  120.  
  121. /* HYDRA Specification Revision/Timestamp ---------Revision------Date------- */
  122. #define H_REVSTAMP   0x2b1aab00L/* 001           01 Dec 1992 */
  123. #define H_REVISION   1
  124.  
  125. /* HYDRA Basic Values ------------------------------------------------------ */
  126. #ifndef XON
  127. #define XON          ('Q' - '@')/* Ctrl-Q (^Q) xmit-on character     */
  128. #define XOFF         ('S' - '@')/* Ctrl-S (^S) xmit-off character    */
  129. #endif
  130. #define H_DLE        ('X' - '@')/* Ctrl-X (^X) HYDRA DataLinkEscape  */
  131. #define H_MINBLKLEN    64        /* Min. length of a HYDRA data block */
  132. #define H_MAXBLKLEN  2048        /* Max. length of a HYDRA data block */
  133. #define H_OVERHEAD      8        /* Max. no. control bytes in a pkt   */
  134. #define H_MAXPKTLEN  ((H_MAXBLKLEN + H_OVERHEAD + 5) * 3)    /* Encoded pkt */
  135. #define H_BUFLEN     (H_MAXPKTLEN + 16)    /* Buffer sizes: max.enc.pkt + slack */
  136. #define H_PKTPREFIX    31        /* Max length of pkt prefix string   */
  137. #define H_FLAGLEN       3        /* Length of a flag field            */
  138. #define H_RETRIES      10        /* No. retries in case of an error   */
  139. #define H_MINTIMER     10        /* Minimum timeout period            */
  140. #define H_MAXTIMER     60        /* Maximum timeout period            */
  141. #define H_START         5        /* Timeout for re-sending startstuff */
  142. #define H_IDLE         20        /* Idle? tx IDLE pkt every 20 secs   */
  143. #define H_BRAINDEAD   120        /* Braindead in 2 mins (120 secs)    */
  144.  
  145. /* HYDRA Return codes ------------------------------------------------------ */
  146. #define XFER_ABORT    (-1)        /* Failed on this file & abort xfer  */
  147. #define XFER_SKIP       0        /* Skip this file but continue xfer  */
  148. #define XFER_OK         1        /* File was sent, continue transfer  */
  149.  
  150. /* HYDRA Transmitter States ------------------------------------------------ */
  151. #define HTX_DONE        0        /* All over and done                 */
  152. #define HTX_START       1        /* Send start autostr + START pkt    */
  153. #define HTX_SWAIT       2        /* Wait for any pkt or timeout       */
  154. #define HTX_INIT        3        /* Send INIT pkt                     */
  155. #define HTX_INITACK     4        /* Wait for INITACK pkt              */
  156. #define HTX_RINIT       5        /* Wait for HRX_INIT -> HRX_FINFO    */
  157. #define HTX_FINFO       6        /* Send FINFO pkt                    */
  158. #define HTX_FINFOACK    7        /* Wait for FINFOACK pkt             */
  159. #define HTX_XDATA       8        /* Send next packet with file data   */
  160. #define HTX_DATAACK     9        /* Wait for DATAACK packet           */
  161. #define HTX_XWAIT      10        /* Wait for HRX_END                  */
  162. #define HTX_EOF        11        /* Send EOF pkt                      */
  163. #define HTX_EOFACK     12        /* End of file, wait for EOFACK pkt  */
  164. #define HTX_REND       13        /* Wait for HRX_END && HTD_DONE      */
  165. #define HTX_END        14        /* Send END pkt (finish session)     */
  166. #define HTX_ENDACK     15        /* Wait for END pkt from other side  */
  167.  
  168. #ifdef HYDRADEV
  169. /* HYDRA Device Packet Transmitter States ---------------------------------- */
  170. #define HTD_DONE        0        /* No device data pkt to send        */
  171. #define HTD_DATA        1        /* Send DEVDATA pkt                  */
  172. #define HTD_DACK        2        /* Wait for DEVDACK pkt              */
  173. #endif
  174.  
  175. /* HYDRA Receiver States --------------------------------------------------- */
  176. #define HRX_DONE        0        /* All over and done                 */
  177. #define HRX_INIT        1        /* Wait for INIT pkt                 */
  178. #define HRX_FINFO       2        /* Wait for FINFO pkt of next file   */
  179. #define HRX_DATA        3        /* Wait for next DATA pkt            */
  180.  
  181. /* HYDRA Packet Types ------------------------------------------------------ */
  182. #define HPKT_START     'A'        /* Startup sequence                  */
  183. #define HPKT_INIT      'B'        /* Session initialisation            */
  184. #define HPKT_INITACK   'C'        /* Response to INIT pkt              */
  185. #define HPKT_FINFO     'D'        /* File info (name, size, time)      */
  186. #define HPKT_FINFOACK  'E'        /* Response to FINFO pkt             */
  187. #define HPKT_DATA      'F'        /* File data packet                  */
  188. #define HPKT_DATAACK   'G'        /* File data position ACK packet     */
  189. #define HPKT_RPOS      'H'        /* Transmitter reposition packet     */
  190. #define HPKT_EOF       'I'        /* End of file packet                */
  191. #define HPKT_EOFACK    'J'        /* Response to EOF packet            */
  192. #define HPKT_END       'K'        /* End of session                    */
  193. #define HPKT_IDLE      'L'        /* Idle - just saying I'm alive      */
  194. #ifdef HYDRADEV
  195. #define HPKT_DEVDATA   'M'        /* Data to specified device          */
  196. #define HPKT_DEVDACK   'N'        /* Response to DEVDATA pkt           */
  197. #endif
  198.  
  199. #define HPKT_HIGHEST   'N'        /* Highest known pkttype in this imp */
  200.  
  201. /* HYDRA Internal Pseudo Packet Types -------------------------------------- */
  202. #define H_NOPKT         0        /* No packet (yet)                   */
  203. #define H_CANCEL      (-1)        /* Received cancel sequence 5*Ctrl-X */
  204. #define H_CARRIER     (-2)        /* Lost carrier                      */
  205. #define H_SYSABORT    (-3)        /* Aborted by operator on this side  */
  206. #define H_TXTIME      (-4)        /* Transmitter timeout               */
  207. #define H_DEVTXTIME   (-5)        /* Device transmitter timeout        */
  208. #define H_BRAINTIME   (-6)        /* Braindead timeout (quite fatal)   */
  209.  
  210. /* HYDRA Packet Format: START[<data>]<type><crc>END ------------------------ */
  211. #define HCHR_PKTEND    'a'        /* End of packet (any format)        */
  212. #define HCHR_BINPKT    'b'        /* Start of binary packet            */
  213. #define HCHR_HEXPKT    'c'        /* Start of hex encoded packet       */
  214. #define HCHR_ASCPKT    'd'        /* Start of shifted 7bit encoded pkt */
  215. #define HCHR_UUEPKT    'e'        /* Start of uuencoded packet         */
  216.  
  217. /* HYDRA Local Storage of INIT Options (Bitmapped) ------------------------- */
  218. #define HOPT_XONXOFF  (0x00000001L)    /* Escape XON/XOFF                   */
  219. #define HOPT_TELENET  (0x00000002L)    /* Escape CR-'@'-CR (Telenet escape) */
  220. #define HOPT_CTLCHRS  (0x00000004L)    /* Escape ASCII 0-31 and 127         */
  221. #define HOPT_HIGHCTL  (0x00000008L)    /* Escape above 3 with 8th bit too   */
  222. #define HOPT_HIGHBIT  (0x00000010L)    /* Escape ASCII 128-255 + strip high */
  223. #define HOPT_CANBRK   (0x00000020L)    /* Can transmit a break signal       */
  224. #define HOPT_CANASC   (0x00000040L)    /* Can transmit/handle ASC packets   */
  225. #define HOPT_CANUUE   (0x00000080L)    /* Can transmit/handle UUE packets   */
  226. #define HOPT_CRC32    (0x00000100L)    /* Packets with CRC-32 allowed       */
  227. #define HOPT_DEVICE   (0x00000200L)    /* DEVICE packets allowed            */
  228. #define HOPT_FPT      (0x00000400L)    /* Can handle filenames with paths   */
  229.  
  230. /* What we can do */
  231. #ifndef HYDRADEV
  232. #define HCAN_OPTIONS  (HOPT_XONXOFF|HOPT_TELENET|HOPT_CTLCHRS|HOPT_HIGHCTL|HOPT_HIGHBIT|HOPT_CANBRK|HOPT_CANASC|HOPT_CANUUE|HOPT_CRC32)
  233. #else
  234. #define HCAN_OPTIONS  (HOPT_XONXOFF|HOPT_TELENET|HOPT_CTLCHRS|HOPT_HIGHCTL|HOPT_HIGHBIT|HOPT_CANBRK|HOPT_CANASC|HOPT_CANUUE|HOPT_CRC32|HOPT_DEVICE)
  235. #endif
  236. /* Vital options if we ask for any; abort if other side doesn't support them */
  237. #define HNEC_OPTIONS  (HOPT_XONXOFF|HOPT_TELENET|HOPT_CTLCHRS|HOPT_HIGHCTL|HOPT_HIGHBIT|HOPT_CANBRK)
  238. /* Non-vital options; nice if other side supports them, but doesn't matter */
  239. #define HUNN_OPTIONS  (HOPT_CANASC|HOPT_CANUUE|HOPT_CRC32|HOPT_DEVICE)
  240. /* Default options */
  241. #define HDEF_OPTIONS  (0x0L)
  242. /* rxoptions during init (needs to handle ANY link yet unknown at that point */
  243. #define HRXI_OPTIONS  (HOPT_XONXOFF|HOPT_TELENET|HOPT_CTLCHRS|HOPT_HIGHCTL|HOPT_HIGHBIT)
  244. /* ditto, but this time txoptions */
  245. #define HTXI_OPTIONS  (0x0L)
  246.  
  247. /* HYDRA Prototypes */
  248. void hydra_init (ULONG want_options);
  249. void hydra_deinit (void);
  250. int hydra (char *txpathname, char *txalias);
  251.  
  252. #ifdef HYDRADEV
  253. BOOL hydra_devfree (void);
  254. BOOL hydra_devsend (char *dev, byte * data, word len);
  255. BOOL hydra_devfunc (char *dev, void (*func) (byte * data, word len));
  256.  
  257. #endif
  258. /* end of hydra.h */
  259.