home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / DOOR / BD2K260A.ZIP / INCLUDE.ZIP / INCLUDE / BINK.H
C/C++ Source or Header  |  1998-10-03  |  33KB  |  959 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. /*                                                                          */
  13. /*                                                                          */
  14. /*                  Major definitions used in 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. /* LEGIBLE SECTION.  Definitions to make "C" look like a real language.     */
  46. /*--------------------------------------------------------------------------*/
  47.  
  48. #ifndef BINK_DEFINED
  49. #define BINK_DEFINED
  50.  
  51. /* Force Y2K fixes to be compiled.
  52.  */
  53. #define Y2K_FIXES
  54. #define TWO_DIGIT_YEAR(y) (y >= 100? y - 100 : y)
  55.  
  56. #ifndef max
  57. #define max(a,b)     ((a)>(b)?(a):(b))
  58. #endif
  59.  
  60. #ifndef min
  61. #define min(a,b)     ((a)<=(b)?(a):(b))
  62. #endif
  63.  
  64. /*
  65.  * updcrc macro derived from article Copyright (C) 1986 Stephen Satchell.
  66.  *  NOTE: First argument must be in range 0 to 255.
  67.  *        Second argument is referenced twice.
  68.  *
  69.  * Programmers may incorporate any or all code into their programs,
  70.  * giving proper credit within the source. Publication of the
  71.  * source routines is permitted so long as proper credit is given
  72.  * to Stephen Satchell, Satchell Evaluations and Chuck Forsberg,
  73.  * Omen Technology.
  74.  */
  75.  
  76. #define updcrc(cp, crc) ( crctab[((crc >> 8) & 255) ^ cp] ^ (crc << 8))
  77.  
  78. /* We need it the other way around for BinkleyTerm */
  79. #define xcrc(crc,cp) ( crctab[((crc >> 8) & 255) ^ cp] ^ (crc << 8))
  80.  
  81. typedef unsigned bit;
  82. typedef unsigned short word;
  83. typedef unsigned char byte;
  84.  
  85. #define fallthrough
  86.  
  87. #define LOCAL        static
  88. #define empty_str    ""
  89.  
  90. /* The following changes by Greylock Software, to facilitate the MEWEL
  91.  * version of Bink.
  92.  */
  93.  
  94. #define PRDCT_NM(m)     PrdctTbl[m]
  95. #define WELCOME_LEN     2048
  96.  
  97. #define POLL_POPUP
  98. #define EventSub()
  99.  
  100. struct _lang_hdr
  101. {
  102.     short ElemCnt;
  103.     short PoolSize;
  104. };
  105.  
  106. struct _key_fnc
  107. {
  108.     short FncIdx;
  109.     short ScanCode;
  110. };
  111.  
  112. struct _key_fnc_hdr
  113. {
  114.     short KeyFncCnt;
  115.     short *KeyFncAry;
  116.     struct _key_fnc *KeyFncTbl;
  117. };
  118.  
  119. #define FA_RDONLY   0x01        /* File is readonly */
  120. #define FA_HIDDEN   0x02        /* File is hidden   */
  121. #define FA_SYSTEM   0x04        /* System file      */
  122. #define FA_VOLID    0x08        /* Volume ID        */
  123. #define FA_SUBDIR   0x10        /* Subdirectory     */
  124. #define FA_ARCH     0x20        /* Archive file     */
  125.  
  126. struct FILEINFO
  127. {
  128.     char rsvd[21];
  129.     char attr;
  130.     long time;
  131.     long size;
  132.     char name[13];
  133.     char nill;
  134. };
  135.  
  136. #define DENY_ALL   0
  137. #define DENY_NONE  1
  138. #define DENY_READ  2
  139. #define DENY_RDWR  3
  140. #define DENY_WRITE 4
  141.  
  142. typedef struct pnums
  143. {
  144.     char num[20];
  145.     char pre[20];
  146.     char suf[20];
  147.     short len;
  148.     struct pnums *next;
  149. } PN_TRNS;
  150.  
  151. typedef struct anums
  152. {
  153.     char *num;
  154.     char *alt;
  155.     struct anums *next;
  156. } ANUMS, *P_ANUMS;
  157.  
  158. typedef struct mnums
  159. {
  160.     byte mdm;
  161.     char pre[50];
  162.     char suf[50];
  163.     struct mnums *next;
  164. } MDM_TRNS;
  165.  
  166. /* Used to parse result codes. Filled in by user in BTCONFIG or
  167.    by default in B_INITVA. */
  168.  
  169. struct resp_str
  170. {
  171.     char *resp;
  172.     unsigned disp;
  173. };
  174.  
  175. /* Values for resp_str.disp. */
  176.  
  177. #define FAILURE   0
  178. #define IGNORE    1
  179. #define CONNECTED 2
  180. #define RINGING   3
  181. #define INCOMING  4
  182. #define    DIALRETRY 5
  183. #define FAX       16            /* Fax starts at 16 */
  184. #define ZYXFAX    17            /* Fax or'ed with 1. Next fax type = 18, then 20 */
  185.  
  186. struct prototable
  187. {
  188.     char first_char;
  189.     short entry;
  190. };
  191.  
  192. typedef struct j_types
  193. {
  194.     char j_match[30];
  195.     struct j_types *next;
  196. } J_TYPES, *J_TYPESP;
  197.  
  198. /* mailtypes bit field definitions */
  199. #define MAIL_CRASH   0x0001
  200. #define MAIL_HOLD    0x0002
  201. #define MAIL_DIRECT  0x0004
  202. #define MAIL_NORMAL  0x0008
  203. #define MAIL_REQUEST 0x0010
  204. #define MAIL_WILLGO  0x0020
  205. #define MAIL_TRIED   0x0040
  206. #define MAIL_TOOBAD  0x0080
  207. #define MAIL_UNKNOWN 0x0100
  208. #define MAIL_RES0200 0x0200
  209. #define MAIL_QSMALL  0x0400
  210. #define MAIL_RES0800 0x0800
  211. #define MAIL_RES1000 0x1000
  212. #define MAIL_RES2000 0x2000
  213. #define MAIL_RES4000 0x4000
  214. #define MAIL_RES8000 0x8000
  215.  
  216. typedef struct finfo
  217. {
  218.     int info_size;
  219.     char curr_fossil;
  220.     char curr_rev;
  221.     char far *id_string;
  222.     int ibufr;
  223.     int ifree;
  224.     int obufr;
  225.     int ofree;
  226.     byte swidth;
  227.     byte sheight;
  228.     char baud;
  229. } FOSINFO;
  230.  
  231. typedef short (*PFI3) (short, short, short, short);
  232.  
  233. typedef struct
  234. {
  235.     unsigned short background;
  236.     unsigned short settings;
  237.     unsigned short history;
  238.     unsigned short hold;
  239.     unsigned short call;
  240.     unsigned short file;
  241.     unsigned short calling;
  242.     unsigned short popup;
  243. } SB_COLORS;
  244.  
  245. /*--------------------------------------------------------------------------*/
  246. /* Sealink and Telink header structure                                      */
  247. /*--------------------------------------------------------------------------*/
  248.  
  249. #define HEADER_NAMESIZE  17
  250.  
  251. struct zero_block
  252. {
  253.     long size;                    /* file length                    */
  254.     long time;                    /* file date/time stamp           */
  255.     char name[HEADER_NAMESIZE];    /* original file name             */
  256.     char moi[15];                /* sending program name           */
  257.     char noacks;                /* for SLO                        */
  258. };
  259.  
  260. /*--------------------------------------------------------------------------*/
  261. /* NodeList.Sys                                                             */
  262. /*                                                                          */
  263. /*    NET > 0 and NODE > 0    Normal node                                   */
  264. /*                                                                          */
  265. /*    NET > 0 and NODE <= 0   Host node                                     */
  266. /*                               Net host........node== 0                   */
  267. /*                               Regional host...node==-1                   */
  268. /*                               Country host....node==-2                   */
  269. /*                                                                          */
  270. /*    NET == -1      Nodelist.Sys revision                                  */
  271. /*                                                                          */
  272. /*    NET == -2      Nodelist statement                                     */
  273. /*                                                                          */
  274. /*--------------------------------------------------------------------------*/
  275.  
  276. /*--------------------------------------------------------------------------*/
  277. /* NODE                                                                     */
  278. /* Please note the NewStyle structure (below).  Time is running out for the */
  279. /* existing `_node' structure!  Opus currently uses the old style node      */
  280. /* structure, but not for long.                                             */
  281. /*--------------------------------------------------------------------------*/
  282.  
  283. struct _node
  284. {
  285.     short number;                /* node number                              */
  286.     short net;                    /* net number                               */
  287.     short cost;                    /* cost of a message to this node           */
  288.     short rate;                    /* baud rate                                */
  289.     char name[20];                /* node name                                */
  290.     char phone[40];                /* phone number                             */
  291.     char city[40];                /* city and state                           */
  292. };
  293.  
  294. /*--------------------------------------------------------------------------*/
  295. /* THE NEWSTYLE NODE LIST IS NOW BEING USED BY OPUS 1.10                    */
  296. /*--------------------------------------------------------------------------*/
  297.  
  298. struct _newnode
  299. {
  300.     word NetNumber;
  301.     word NodeNumber;
  302.     word Cost;                    /* cost to user for a message */
  303.     char SystemName[34];        /* node name */
  304.     char PhoneNumber[40];        /* phone number */
  305.     char MiscInfo[30];            /* city and state */
  306.     char Password[8];            /* WARNING: not necessarily null-terminated */
  307.     word RealCost;                /* phone company's charge */
  308.     word HubNode;                /* this node's hub, or point number if a point */
  309.     byte BaudRate;                /* baud rate divided by 300 */
  310.     byte ModemType;                /* RESERVED for modem type */
  311.     word NodeFlags;                /* set of flags (see below) */
  312.     word NodeFiller;
  313. };
  314.  
  315. /*--------------------------------------------------------------------------*/
  316. /* nodex.ndx                                                                */
  317. /*                                                                          */
  318. /* Version 7 Nodelist Index structure.  This is a 512-byte record, which    */
  319. /* is defined by three structures:  Record 0 is the Control Record, then    */
  320. /* some number of Leaf Node (LNode) Records, then the Index Node (INode)    */
  321. /* Records.  This defines an unbalanced binary tree.                        */
  322. /*                                                                          */
  323. /* This description is based on Scott Samet's CBTREE.PAS program.           */
  324. /*                                                                          */
  325. /*--------------------------------------------------------------------------*/
  326.  
  327. struct _ndx
  328. {
  329.     union
  330.     {
  331.         struct _CtlBlk
  332.         {
  333.             word CtlBlkSize;    /* Blocksize of Index Blocks   */
  334.             long CtlRoot;        /* Block number of Root        */
  335.             long CtlHiBlk;        /* Block number of last block  */
  336.             long CtlLoLeaf;        /* Block number of first leaf  */
  337.             long CtlHiLeaf;        /* Block number of last leaf   */
  338.             long CtlFree;        /* Head of freelist            */
  339.             word CtlLvls;        /* Number of index levels      */
  340.             word CtlParity;        /* XOR of above fields         */
  341.         } CtlBlk;
  342.  
  343.         struct _INodeBlk
  344.         {
  345.             long IndxFirst;        /* Pointer to next lower level */
  346.             long IndxBLink;        /* Pointer to previous link    */
  347.             long IndxFLink;        /* Pointer to next link        */
  348.             short IndxCnt;        /* Count of Items in block     */
  349.             word IndxStr;        /* Offset in block of 1st str  */
  350.  
  351.             /* If IndxFirst is NOT -1, this is INode:          */
  352.  
  353.             struct _IndxRef
  354.             {
  355.                 word IndxOfs;    /* Offset of string into block */
  356.                 word IndxLen;    /* Length of string            */
  357.                 long IndxData;    /* Record number of string     */
  358.                 long IndxPtr;    /* Block number of lower index */
  359.             } IndxRef[20];
  360.         } INodeBlk;
  361.  
  362.         struct _LNodeBlk
  363.         {
  364.             /* IndxFirst is -1 in LNodes   */
  365.  
  366.             long IndxFirst;        /* Pointer to next lower level */
  367.             long IndxBLink;        /* Pointer to previous link    */
  368.             long IndxFLink;        /* Pointer to next link        */
  369.             short IndxCnt;        /* Count of Items in block     */
  370.             word IndxStr;        /* Offset in block of 1st str  */
  371.             struct _LeafRef
  372.             {
  373.                 word KeyOfs;    /* Offset of string into block */
  374.                 word KeyLen;    /* Length of string            */
  375.                 long KeyVal;    /* Pointer to data block       */
  376.             } LeafRef[30];
  377.         } LNodeBlk;
  378.  
  379.         char RawNdx[512];
  380.  
  381.     } ndx;
  382. };
  383.  
  384. /*--------------------------------------------------------------------------*/
  385. /*                                                                          */
  386. /* OPUS 1.20 Version 7 Nodelist structure. Copyright 1991 Wynn Wagner III   */
  387. /* and Doug Boone. Used by permission.                                      */
  388. /*                                                                          */
  389. /*--------------------------------------------------------------------------*/
  390.  
  391. struct _vers7
  392. {
  393.     short Zone;
  394.     short Net;
  395.     short Node;
  396.     short HubNode;                /* If a point, this is point number. */
  397.     word CallCost;                /* phone company's charge */
  398.     word MsgFee;                /* Amount charged to user for a message */
  399.     word NodeFlags;                /* set of flags (see below) */
  400.     byte ModemType;                /* RESERVED for modem type */
  401.     byte Phone_len;
  402.     byte Password_len;
  403.     byte Bname_len;
  404.     byte Sname_len;
  405.     byte Cname_len;
  406.     byte pack_len;
  407.     byte BaudRate;                /* baud rate divided by 300 */
  408. };
  409.  
  410. /*--------------------------------------------------------------------------*/
  411. /* Values for the `NodeFlags' field                                         */
  412. /*--------------------------------------------------------------------------*/
  413.  
  414. #define B_hub    0x0001        /* node is a net hub        0000 0000 0000 0001 */
  415. #define B_host   0x0002        /* node is a net host       0000 0000 0000 0010 */
  416. #define B_region 0x0004        /* node is region coord     0000 0000 0000 0100 */
  417. #define B_zone   0x0008        /* is a zone gateway        0000 0000 0000 1000 */
  418. #define B_CM     0x0010        /* runs continuous mail     0000 0000 0001 0000 */
  419. #define B_res1   0x0020        /* reserved by Opus         0000 0000 0010 0000 */
  420. #define B_res2   0x0040        /* reserved by Opus         0000 0000 0100 0000 */
  421. #define B_res3   0x0080        /* reserved by Opus         0000 0000 1000 0000 */
  422. #define B_res4   0x0100        /* reserved by Opus         0000 0001 0000 0000 */
  423. #define B_res5   0x0200        /* reserved for non-Opus    0000 0010 0000 0000 */
  424. #define B_res6   0x0400        /* reserved for non-Opus    0000 0100 0000 0000 */
  425. #define B_res7   0x0800        /* reserved for non-Opus    0000 1000 0000 0000 */
  426. #define B_point  0x1000        /* node is a point          0001 0000 0000 0000 */
  427. #define B_res9   0x2000        /* reserved for non-Opus    0010 0000 0000 0000 */
  428. #define B_resa   0x4000        /* reserved for non-Opus    0100 0000 0000 0000 */
  429. #define B_resb   0x8000        /* reserved for non-Opus    1000 0000 0000 0000 */
  430.  
  431. /*--------------------------------------------------------------------------*/
  432. /* Nodelist.Idx                                                             */
  433. /* (File is terminated by EOF)                                              */
  434. /*--------------------------------------------------------------------------*/
  435.  
  436. struct _ndi
  437. {
  438.     short node;                /* node number  */
  439.     short net;                /* net number   */
  440. };
  441.  
  442. /*--------------------------------------------------------------------------*/
  443. /* QuickBBS 2.00 QNL_IDX.BBS                                                */
  444. /* (File is terminated by EOF)                                              */
  445. /*--------------------------------------------------------------------------*/
  446.  
  447. struct QuickNodeIdxRecord
  448. {
  449.     unsigned short QI_Zone;
  450.     unsigned short QI_Net;
  451.     unsigned short QI_Node;
  452.     byte QI_NodeType;
  453. };
  454.  
  455. /*--------------------------------------------------------------------------*/
  456. /* QuickBBS 2.00 QNL_DAT.BBS                                                */
  457. /* (File is terminated by EOF)                                              */
  458. /*--------------------------------------------------------------------------*/
  459.  
  460. struct QuickNodeListRecord
  461. {
  462.     byte QL_NodeType;
  463.     unsigned short QL_Zone;
  464.     unsigned short QL_Net;
  465.     unsigned short QL_Node;
  466.     char QL_Name[21];            /* Pascal! 1 byte count, up to 20 chars */
  467.     char QL_City[41];            /* 1 + 40 */
  468.     char QL_Phone[41];            /* 1 + 40 */
  469.     char QL_Password[9];        /* 1 + 8 */
  470.     word QL_Flags;                /* Same as flags in new nodelist structure */
  471.     word QL_BaudRate;
  472.     word QL_Cost;
  473. };
  474.  
  475. /* SEAdog NETLIST.DOG format */
  476.  
  477. struct netls
  478. {
  479.     short netnum;
  480.     char netname[14];
  481.     char netcity[40];
  482.     short havehost;
  483.     short nethost;
  484.     short havegate;
  485.     short netgate;
  486.     long nodeptr;
  487.     short numnodes;
  488. };
  489.  
  490. /* SEAdog NODELIST.DOG format */
  491.  
  492. struct nodels
  493. {
  494.     short nodenum;
  495.     char nodename[14];
  496.     char nodecity[40];
  497.     char nodephone[40];
  498.     short havehub;
  499.     short nodehub;
  500.     short nodecost;
  501.     short nodebaud;
  502. };
  503.  
  504. /* Things most nodelists don't contain, but Binkley likes to have */
  505.  
  506. struct extrastuff
  507. {
  508.     char password[8];
  509.     unsigned short flags1;
  510.     byte modem;
  511.     char extra[5];                /* for future expansion */
  512. };
  513.  
  514. /* Format of a XMODEM block */
  515.  
  516. typedef struct
  517. {
  518.     unsigned char header;
  519.     unsigned char block_num;
  520.     unsigned char block_num_comp;
  521.     unsigned char data_bytes[128];
  522.     unsigned char data_check[2];
  523. } XMDATA, *XMDATAP;
  524.  
  525. /* Format of Telink block 0 */
  526.  
  527. typedef struct
  528. {
  529.     unsigned char header;
  530.     unsigned char block_num;
  531.     unsigned char block_num_comp;
  532.     long filelength;
  533.     union
  534.     {
  535.         struct
  536.         {
  537.             unsigned short time;
  538.             unsigned short date;
  539.         } twowords;
  540.  
  541.         struct
  542.         {
  543.             unsigned long timedate;
  544.         } oneword;
  545.     } filetime;
  546.     char filename[16];
  547.     char nullbyte;
  548.     char sendingprog[15];
  549.     char noacks;
  550.     unsigned char crcmode;
  551.     char fill[86];
  552.     unsigned char data_check[2];
  553. } TLDATA, *TLDATAP;
  554.  
  555. /* Format of SEAlink block 0 */
  556.  
  557. typedef struct
  558. {
  559.     unsigned char header;
  560.     unsigned char block_num;
  561.     unsigned char block_num_comp;
  562.     long filelength;
  563.     unsigned long timedate;
  564.     char filename[17];
  565.     char sendingprog[15];
  566.     char SLO;
  567.     char Resync;
  568.     char MACFLOW;
  569.     char fill[85];
  570.     unsigned char data_check[2];
  571. } SEADATA, *SEADATAP;
  572.  
  573. typedef struct
  574. {
  575.     unsigned int SEAlink:1;        /* Can do SEAlink */
  576.     unsigned int SLO:1;            /* Can do SEAlink with Overdrive */
  577.     unsigned int Resync:1;        /* Can do SEAlink with Resync */
  578.     unsigned int MacFlow:1;        /* Can do SEAlink with Macintosh flow control */
  579.     unsigned int do_CRC:1;        /* Should do CRC instead of checksum */
  580.     unsigned int TeLink:1;        /* We saw a TeLink header */
  581. } TRANS, *TRANSP;
  582.  
  583. typedef struct
  584. {
  585.     char *state_name;
  586.     short (*state_func) (void *);
  587. } STATES, *STATEP;
  588.  
  589. typedef struct
  590. {
  591.     long control;                /* We will always have a long on top */
  592.     long filler;                /* Just to be sure. Min size, 8 bytes*/
  593. } STATEBASE, *STATEBASEP;
  594.  
  595. typedef struct
  596. {
  597.     long control;                /* These must always start with a long! */
  598.     TRANS options;                /* Transfer options */
  599.     short result;                /* Result from last operation */
  600.     short sub_results;            /* Extra result codes */
  601.     long T1;                    /* General purpose timer */
  602.     long T2;                    /* General purpose timer */
  603.     short Window;                /* SEAlink window size */
  604.     long SendBLK;                /* Current block to be sent */
  605.     long NextBLK;                /* Next block we will try to send */
  606.     long ACKBLK;                /* Block that was last ACK'd */
  607.     long LastBlk;                /* Last block in file */
  608.     long ARBLK;                    /* Used in ACK Check calculations */
  609.     long WriteBLK;                /* Block number to write to file */
  610.     long filelen;                /* Length of file being sent */
  611.     long curr_byte;                /* Current byte offset of sending or receiving */
  612.     long prev_bytes;            /* Bytes that we are resyncing over */
  613.     long total_blocks;            /* Total number of blocks in file to be received */
  614.     long resync_block;            /* Block number we received to resync to */
  615.     short NumNAK;                /* Number of NAK's received this block */
  616.     short ACKsRcvd;                /* Number of ACK's received since file start */
  617.     short ACKST;                /* Current state of the ack/nak state variable */
  618.     short tries;                /* Number of tries thus far */
  619.     short goodfile;                /* 0 if file was bad, 1 if file was good */
  620.     short datalen;                /* Length of data in this block */
  621.     short recblock;                /* Block number received */
  622.     short sent_ACK;                /* Whether or not we sent an ACK already */
  623.     short tot_errs;                /* Total number of errors */
  624.     unsigned char ARBLK8;        /* 8 bit value of ARBLK */
  625.     unsigned char blocknum;        /* 8 bit value of SendBLK */
  626.     unsigned char check;        /* checksum value */
  627.     unsigned char save_header;    /* Received header from first block */
  628.     short CHR;                    /* General purpose receive character */
  629.     union                        /* File date and time in Telink or SEAlink format */
  630.     {
  631.         struct
  632.         {
  633.             unsigned short time;
  634.             unsigned short date;
  635.         } twowords;
  636.  
  637.         struct
  638.         {
  639.             unsigned long timedate;
  640.         } oneword;
  641.     }
  642.     save_filetime;
  643.     char received_name[20];        /* Received filename from Telink or SEAlink */
  644.     char m7name[12];            /* Filename in Modem7 format */
  645.     char sending_program[16];    /* Sending program name                    */
  646.     char *filename;                /* The filename to be sent or received */
  647.     char *path;                    /* Just the path to the file to be sent/received */
  648.     char *fptr;                    /* Pointer into character fields */
  649.     char *temp_name;            /* Temporary name for receiving */
  650.     FILE *file_pointer;            /* The pointer for read/write/seek operations */
  651.  
  652.     unsigned char header;
  653.     unsigned char block_num;
  654.     unsigned char block_num_comp;
  655.     unsigned char data[128];
  656.     unsigned char data_check[2];
  657. } XMARGS, *XMARGSP;
  658.  
  659. #define DID_RESYNC 1
  660.  
  661. typedef struct
  662. {
  663.     long control;                /* These must always start with a long! */
  664.     short tries;
  665.     short barklen;
  666.     short barkok;
  667.     long T1;
  668.     short nfiles;
  669.     char *inbound;
  670.     char *filename;
  671.     char barkpacket[128];
  672.     char *barkpw;
  673.     char *barktime;
  674. } BARKARGS, *BARKARGSP;
  675.  
  676. /*--------------------------------------------------------------------------*/
  677. /* FIDONET ADDRESS STRUCTURE                                                */
  678. /*--------------------------------------------------------------------------*/
  679.  
  680. typedef struct _ADDRESS
  681. {
  682.     word Zone;
  683.     word Net;
  684.     word Node;
  685.     word Point;
  686.     char *Domain;
  687. } ADDR, *ADDRP;
  688.  
  689. typedef struct _DOMAINKLUDGE
  690. {
  691.     word zone;
  692.     word domain;
  693. } DOMAINKLUDGE;
  694.  
  695. typedef struct mail
  696. {
  697.     ADDR mail_addr;                /* Addressee */
  698.     unsigned short numfiles;    /* Total number of packets and files      */
  699.     unsigned short mailtypes;    /* Bitmask of types we have for addressee */
  700.     unsigned long mailsize;        /* Total amount of mail for addressee     */
  701.     unsigned long callsize;        /* Amount of mail that isn't on hold      */
  702.     unsigned long oldest;        /* time_t of oldest mail                  */
  703.     struct mail *next;
  704.     struct mail *prev;
  705. } MAIL, *MAILP;
  706.  
  707. typedef int (*nfunc) (ADDR *, int);
  708. typedef void (*ufunc) (char *, ADDR *);
  709.  
  710. #define    MAX_EXTERN    8
  711. #define    ALIAS_CNT    25
  712.  
  713. /*--------------------------------------------------------------------------*/
  714. /* Matrix mask                                                              */
  715. /* Undefined bits are reserved by Opus                                      */
  716. /*--------------------------------------------------------------------------*/
  717.  
  718. #define NO_TRAFFIC    0x0001
  719. #define LOCAL_ONLY    0x0002
  720. #define OPUS_ONLY    0x0004
  721.  
  722. #define NO_EXITS    0x2000
  723. #define MAIL_ONLY    0x4000
  724. #define TAKE_REQ    0x8000
  725.  
  726. /*--------------------------------------------------------------------------*/
  727. /* Message packet header                                                    */
  728. /*--------------------------------------------------------------------------*/
  729.  
  730. #define PKTVER    2
  731.  
  732. /*--------------------------------------------*/
  733. /* POSSIBLE VALUES FOR `product' (below)      */
  734. /*                                            */
  735. /* NOTE: These product codes are assigned by  */
  736. /* the FidoNet<tm> Technical Stardards Com-   */
  737. /* mittee.  If you are writing a program that */
  738. /* builds packets, you will need a product    */
  739. /* code.  Please use ZERO until you get your  */
  740. /* own.  For more information on codes, write */
  741. /* to FTSC at 115/333.                        */
  742. /*                                            */
  743. /*--------------------------------------------*/
  744.  
  745. #define isFIDO        0
  746. #define isANXCLO    4
  747. #define isOPUS        5
  748. #define isIGOR        65
  749. #define isTIMS        66
  750. #define isBITBRAIN    0x1b
  751. #define isDBRIDGE    0x1d
  752. #define isMILQUE    0xac
  753.  
  754. #ifndef PRDCT_CODE
  755. #define PRDCT_CODE        isBITBRAIN
  756. #endif
  757.  
  758. #ifndef PRDCT_MAJOR
  759. #define PRDCT_MAJOR        2
  760. #endif
  761.  
  762. #ifndef PRDCT_MINOR
  763. #define PRDCT_MINOR        60
  764. #endif
  765.  
  766. #ifndef PRDCT_PRFX
  767. #define PRDCT_PRFX        "BINKLEY"
  768. #endif
  769.  
  770. #ifndef PRDCT_PRTY
  771. #define PRDCT_PRTY        "BinkleyTerm"
  772. #endif
  773.  
  774. #ifndef PRD_SH_PRTY
  775. #define PRD_SH_PRTY        "Binkley"
  776. #endif
  777.  
  778. #ifndef PRDCT_SHRT
  779. #define PRDCT_SHRT        "Bink"
  780. #endif
  781.  
  782. #ifndef PRDCT_VRSN
  783. #ifdef Y2K_FIXES
  784. #define PRDCT_VRSN        "2.60A"
  785. #else
  786. #define PRDCT_VRSN        "2.60"
  787. #endif
  788. #endif
  789.  
  790. struct _pkthdr
  791. {
  792.     short orig_node;        /* originating node               */
  793.     short dest_node;        /* destination node               */
  794.     /* [Y2K] The year value is used (in different places) as
  795.      * a two digit year (year-1980) and a four digit year.  The FTSC
  796.      * docs say it's four digits, so we'll make it four everywhere.
  797.      */
  798.     short year;                /* 0..99  when packet was created */
  799.     short month;            /* 0..11  when packet was created */
  800.     short day;                /* 1..31  when packet was created */
  801.     short hour;                /* 0..23  when packet was created */
  802.     short minute;            /* 0..59  when packet was created */
  803.     short second;            /* 0..59  when packet was created */
  804.     short rate;                /* destination's baud rate        */
  805.     short ver;                /* packet version, must be 2      */
  806.     short orig_net;            /* originating network number     */
  807.     short dest_net;            /* destination network number     */
  808.     char product;            /* product type                   */
  809.     char serial;            /* serial number (some systems)   */
  810.  
  811.     byte password[8];        /* session/pickup password        */
  812.     short orig_zone;        /* originating zone               */
  813.     short dest_zone;        /* Destination zone               */
  814.     byte B_fill2[16];
  815.     long B_fill3;
  816. };
  817.  
  818. struct _pkthdr45            /* FSC-0045 (2.2) packet type     */
  819. {
  820.     short orig_node;        /* originating node               */
  821.     short dest_node;        /* destination node               */
  822.     short orig_point;        /* originating point              */
  823.     short dest_point;        /* destination point              */
  824.     byte b_fill1[8];        /* Unused, must be zero           */
  825.     short subver;            /* packet subversion, must be 2   */
  826.     short ver;                /* packet version, must be 2      */
  827.     short orig_net;            /* originating network number     */
  828.     short dest_net;            /* destination network number     */
  829.     char product;            /* product type                   */
  830.     char serial;            /* serial number (some systems)   */
  831.  
  832.     byte password[8];        /* session/pickup password        */
  833.     short orig_zone;        /* originating zone               */
  834.     short dest_zone;        /* Destination zone               */
  835.     byte orig_domain[8];    /* originating domain             */
  836.     byte dest_domain[8];    /* destination domain             */
  837.     long B_fill3;
  838. };
  839.  
  840. struct _pkthdr39            /* FSC-0039 packet type           */
  841. {
  842.     short orig_node;        /* originating node               */
  843.     short dest_node;        /* destination node               */
  844.     /* [Y2K] See _pkthdr note, above.
  845.      */
  846.     short year;                /* 0..99  when packet was created */
  847.     short month;            /* 0..11  when packet was created */
  848.     short day;                /* 1..31  when packet was created */
  849.     short hour;                /* 0..23  when packet was created */
  850.     short minute;            /* 0..59  when packet was created */
  851.     short second;            /* 0..59  when packet was created */
  852.     short rate;                /* destination's baud rate        */
  853.     short ver;                /* packet version, must be 2      */
  854.     short orig_net;            /* originating network number     */
  855.     short dest_net;            /* destination network number     */
  856.     byte product_low;        /* FTSC product type (low byte)   */
  857.     byte prod_rev_low;        /* product rev (low byte)         */
  858.  
  859.     byte password[8];        /* session/pickup password        */
  860.     short zone_ignore[2];    /* Zone info from other software  */
  861.     byte B_fill1[2];
  862.     short CapValid;            /* CapWord with bytes swapped.    */
  863.     byte product_hi;        /* FTSC product type (high byte)  */
  864.     byte prod_rev_hi;        /* product rev (hi byte)          */
  865.     short CapWord;            /* Capability word                */
  866.     short orig_zone;        /* originating zone               */
  867.     short dest_zone;        /* Destination zone               */
  868.     short orig_point;        /* originating point              */
  869.     short dest_point;        /* destination point              */
  870.     long ProdData;            /* Product-specific data          */
  871. };
  872.  
  873. /*--------------------------------------------------------------------------*/
  874. /* WaZOO                                                                    */
  875. /*--------------------------------------------------------------------------*/
  876.  
  877. #ifndef ACK
  878. #define ACK    0x06
  879. #endif
  880.  
  881. #ifndef NAK
  882. #define NAK    0x15
  883. #endif
  884.  
  885. #ifndef ENQ
  886. #define ENQ    0x05
  887. #endif
  888.  
  889. #ifndef YOOHOO
  890. #define YOOHOO 0x00f1
  891. #endif
  892.  
  893. #ifndef  TSYNC
  894. #define  TSYNC 0x00ae
  895. #endif
  896.  
  897. struct _Hello
  898. {
  899.     word signal;            /* always 'o'     (0x6f)                   */
  900.     word hello_version;        /* currently 1    (0x01)                   */
  901.     word product;            /* product code                            */
  902.     word product_maj;        /* major revision of the product           */
  903.     word product_min;        /* minor revision of the product           */
  904.     char my_name[60];        /* Other end's name                        */
  905.     char sysop[20];            /* sysop's name                            */
  906.     word my_zone;            /* 0== not supported                       */
  907.     word my_net;            /* out primary net number                  */
  908.     word my_node;            /* our primary node number                 */
  909.     word my_point;            /* 0== not supported                       */
  910.     byte my_password[8];    /* ALL 8 CHARACTERS ARE SIGNIFICANT !!!!!  */
  911.     byte reserved2[8];        /* reserved by Opus                        */
  912.     word capabilities;        /* see below                               */
  913.     byte reserved3[12];        /* available to non-Opus                   */
  914.                             /* systems by prior "approval" of 124/108. */
  915. };                            /* size 128 bytes */
  916.  
  917. /*--------------------------------------------------------------------------*/
  918. /* YOOHOO<tm> CAPABILITY VALUES                                             */
  919. /*--------------------------------------------------------------------------*/
  920.  
  921. #define Y_DIETIFNA    0x0001
  922. #define FTB_USER    0x0002
  923. #define ZED_ZIPPER    0x0004
  924. #define ZED_ZAPPER    0x0008
  925. #define DOES_IANUS    0x0010
  926. #define DOES_HYDRA    0x0020
  927. #define Bit_6        0x0040
  928. #define Bit_7        0x0080
  929. #define Bit_8        0x0100
  930. #define Bit_9        0x0200
  931. #define Bit_a        0x0400
  932. #define Bit_b        0x0800
  933. #define Bit_c        0x1000
  934. #define Bit_d        0x2000
  935. #define DO_DOMAIN    0x4000
  936. #define WZ_FREQ        0x8000
  937.  
  938. /*--------------------------------------------------------------------------*/
  939. /* EMSI                                                                     */
  940. /*--------------------------------------------------------------------------*/
  941.  
  942. /* Indexes into the emsistr array for use by EMSI parsing */
  943.  
  944. #define EMSI_REQ   0
  945. #define EMSI_DAT   1
  946. #define EMSI_HBT   2
  947. #define EMSI_NAK   3
  948. #define EMSI_ACK   4
  949. #define EMSI_INQ   5
  950. #define EMSI_CLI   6
  951.  
  952. #define EMSI_LEN   14     /* longest emsi string */
  953. #define EMSI_MAX   6      /* highest emsi string */
  954.  
  955. #endif                /* BINK_DEFINED */
  956.  
  957. /* END OF FILE: bink.h */
  958.  
  959.