home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / fido / pup_v2b.zip / PUPPY.H < prev    next >
C/C++ Source or Header  |  1988-01-26  |  9KB  |  289 lines

  1. /*
  2.     Puppy's include file
  3.     T. Jennings 25 Jan 88
  4.  
  5. "Fido" is a trademark of Tom Jennings. It you utter it send me a dollar.
  6. "FidoNet" is a also registered trademark of Tom Jennings. If you even think 
  7. it send me two dollars. If you use both, send me ten dollars and your first
  8. born child. All rights reserved. So there.
  9.  
  10.  
  11. Puppy (k) All Rights Reversed
  12.  
  13.     Fido Software
  14.     164 Shipley
  15.     San Francisco CA 94107
  16.     (415)-764-1629, FidoSW BBS
  17.     (415)-882-9835, ch@os, one day will be known as 1:125/164
  18. */
  19.  
  20. /* These are my assumptions as to data element sizes for the source here. You
  21. will need to change these if the following assumptions arent right:
  22.  
  23. char            8 bits or more, signed or not
  24. int             more than 8 bits, though 8 will work 99% of the time
  25.             (that last 1% if left as an exercise for the programmer)
  26.  
  27. long            more than 16 bits, preferably 32. Note as above
  28.  
  29. FLAG            at least one bit long; set to 0 or 1, and tested
  30.             for != 0
  31. BYTE            8 bits long. You can define as necessary.
  32. WORD            16 bits. Ditto
  33. LONG            32 bits. Ditto Ditto
  34.  
  35. BYTE, WORD and LONG are used for two reasons: to take advantage of the word
  36. length in modulo arithmetic (ie. XMODEM block numbers, 0...255) or because
  37. they are an interface to other code, ie. WORD baud rates passed to the 
  38. drivers. Changing these assumptions may not be trivial, since they are
  39. frequently buried into the algorithms. (Check out XMODEM.C for a classic
  40. example of this.) */
  41.  
  42. #define FLAG char    /* just a boolean */
  43. #define BYTE char    /* Lattice chars are 8 bit */
  44. #define WORD unsigned    /* Lattice unsigneds are 16 bits */
  45. #define LONG long    /* Lattice ... */
  46.  
  47. #define BITSWORD 16    /* bits per WORD, above */
  48.  
  49. /* 
  50. Time and date are stored compressed in a 16 bit integer each. This has
  51. obvious advantages for storage, but also for comparison; time and date
  52. may be treated as integers; less than, greater than, etc. This is also 
  53. the MSDOS internal storage format.
  54.  
  55. TIME:    h h h h h m m m m m m s s s s s
  56.  
  57.     h = (time >> 11) & 0x1f
  58.     m = (time >> 5) & 0x3f
  59.     s = (time < 1) & 0x3f
  60.  
  61. NOTE: seconds has a resolution of 2 seconds, since there are only 5 bits
  62. available to store it.
  63.  
  64.  
  65. DATE:    0 y y y y y y m m m m d d d d d
  66.  
  67.     y = (date >> 9) & 0x3f
  68.     m = (date >> 5) & 0x0f
  69.     d = date & 0x1f
  70. */
  71.  
  72.  
  73.  
  74. /* Absolute Truths (current version ...) */
  75.  
  76. #define SS 80                /* standard, universal, string size */
  77. #define TSYNC 0xae            /* FidoNet sync character */
  78.  
  79. /* Fancy numbers for protocol module. */
  80.  
  81. #define TELINK 1            /* extended nightmare */
  82. #define MODEM7 2            /* modemers nightmare */
  83. #define XMODEM 3            /* Volkswagen */
  84. #define KERMIT 4            /* disgusto blob */
  85. #define FIDONET 5            /* XMODEM with diverter */
  86. #define IFNA 6                /* design by default */
  87. #define SEALINK 7            /* trademark SEA Associates */
  88.  
  89. #define NULL 0                /* nothing */
  90.  
  91. #define MINS_HR    60            /* minutes in an hour */
  92. #define DAYS_WK 7            /* days in a week */
  93. #define MINS_DAY (24 * 60)        /* minutes in an hour */
  94. #define MINS_WK (MINS_DAY * DAYS_WK)
  95.  
  96. /* Standard node structure used throughout Fido. This is buried within all
  97. the other major structures. */
  98.  
  99. struct _node {
  100.     int zone;        /* zone number */
  101.     int net;        /* net number */
  102.     int number;        /* node number */
  103. };
  104.  
  105. /*
  106. The date is stored in a single WORD as:
  107.  
  108.     0 y y y y y y m m m m d d d d d
  109. */
  110.  
  111. /* These are all in the "library", MS-C.C and MS-ASM.ASM. */
  112.  
  113. char *str_node();
  114. char *skip_delim();
  115. char *next_arg();
  116. char *strip_path();
  117. char *getarg();
  118.  
  119. /* These are in the msg base mostly */
  120.  
  121. struct _msg *getmsg();
  122. struct _msg *newmsg();
  123.  
  124. /* These are elsewhere */
  125.  
  126. long lseek();
  127. char *getmem();
  128.  
  129.  
  130. /* OK, OK already, lets start a caller file. I hate caller files. */
  131.  
  132. struct _clr {
  133.     char name[36];            /* the miserable SOBs name, */
  134.     WORD date[BITSWORD];        /* newest read for each topic */
  135.     WORD topic;            /* last topic(s) selected */
  136.     char lines;            /* number of lines, */
  137.     char cols;            /* number of columns, */
  138.     int calls;            /* sigh ... how many times, */
  139.     int extra;
  140. };
  141.  
  142. /* Message header structure: the headers are contained in a single file;
  143. the message bodies are contained in another. The headers are kept in
  144. memory at all times. */
  145.  
  146. struct _msg {
  147.     char from[36];        /* who from, */
  148.     char to[36];        /* who to, */
  149.     char subj[36];        /* message subject, */
  150.     WORD date;        /* message creation date, */
  151.     WORD time;        /* message creation time, */
  152.     WORD extra;        /* unused space */
  153.     WORD attr;        /* attribute bits (see below) */
  154.     WORD topic;        /* topic selection(s) */
  155.     WORD topic_map;        /* shared topics */
  156. };
  157.  
  158. /* Message attribute bits */
  159.  
  160. #define MSGEXISTS 1        /* message slot occupied */
  161. #define MSGREAD 2        /* read by addressee */
  162. #define MSGSENT 4        /* sent OK (remote) */
  163. #define MSGTAG 8        /* general purpose tag bit */            
  164.  
  165.  
  166. #define SCHEDS 35        /* size of scheduler event table */
  167.  
  168. /* Scheduler event structure within PUP.SYS. Tags defined:
  169.  
  170. A - W        FIDONET events
  171. X        ERRORLEVEL event
  172. all others    RESERVED
  173. */
  174.  
  175. struct _sched {
  176.     char bits;        /* see below */
  177.     char tag;        /* event type, above, */
  178.     char hr;        /*   hour, */
  179.     char min;        /*   minute, */
  180.     int len;        /* event length, or ERRORLEVEL for tag X */
  181. };
  182.  
  183. #define SCHED_OPTIONAL 1    /* this event may be skipped */
  184. #define SCHED_COMPLETE 2    /* this event already run */
  185.  
  186. /* PUPPY.SYS: This is where Puppy keeps its shit together. */
  187.  
  188. struct _pup {
  189.     long callers;        /* number of callers to the system */
  190.     long quote_pos;        /* quote file position */
  191.     struct _node id;    /* our node ID */
  192.     int nlimit;        /* normal callers limit, */
  193.     int klimit;        /* K byte limit, */
  194.     int top;        /* current top of the pile */
  195.     unsigned msgnbr;    /* current highest message number */
  196.  
  197.     unsigned callsize;    /* maximum number of callers in caller file*/
  198.     int messages;        /* total messages allowed */
  199.     int msgsize;        /* size of each message body record */
  200.     struct {
  201.         char name[8];    /* topic name, */
  202.         char desc[24];    /* its description */
  203.     } topic[BITSWORD];    /* 16 of 'em */
  204.  
  205.     int maxbaud;        /* maximum baud rate */
  206.     char mdmstr[SS];    /* modem initialization string */
  207.     WORD cd_bit;        /* bit to test for Carrier Detect, */
  208.     int iodev;        /* default serial channel number */    
  209.  
  210.     int tries;        /* FidoNet dial attempts w/o connects */
  211.     int connects;        /* FidoNet dial attempts w/ connects */
  212.  
  213.     struct _sched sched[SCHEDS]; /* the schedulers event table */
  214.  
  215.     char filepref[SS];    /* file upload & download prefix */
  216. };
  217.  
  218.  
  219. /* This is the structure used to make getinfo() calls, and both returns
  220. the desired information and stores information needed by the getinfo()
  221. function itself between interations. The first half is the interface part;
  222. Pup code depends on those fields being there. The lower half is used by
  223. the getinfo() function itself. Change as you see fit. */
  224.  
  225. struct _fileinfo {
  226.  
  227.     char name[13];        /* REQUIRED filename (no path, drive, etc) */
  228.     long size;        /* REQUIRED file size */
  229.     WORD date;        /* REQUIRED creation date (may be 0's) */
  230.     WORD time;        /* REQUIRED creation time (may be 0's) */
  231.  
  232. /* This is the block of shit that getinfo() uses internally. */
  233.  
  234.     struct {
  235.         char s_attrib;    /* Search attribute */
  236.         char x[21];
  237.         WORD time;    /* MSDOS packed time */
  238.         WORD date;    /* MSDOS packed date */
  239.         long fsize;    /* MSDOS file size */
  240.         char name[13];    /* MSDOS packed name */
  241.     } xfbuf;
  242. };
  243.  
  244. /* The topic map is the list that ties topics to the outside world. */
  245.  
  246. struct _tm {
  247.     struct _node node;    /* the node number, */
  248.     WORD topic;        /* topic(s) this node sees, */
  249.     WORD date;        /* last time updated */
  250.     WORD time;
  251.     unsigned bits;        /* attributes, see below */
  252.  
  253.     char tries;        /* number of tries to call, */
  254.     char connects;        /* number of times it connected */
  255.     unsigned connect_time;    /* total connect time */
  256.  
  257.     char phone[SS];        /* ALPHA phone number */
  258.     unsigned baud;        /* ALPHA baud rate */
  259. };
  260.  
  261. #define TM_HOLD 1        /* hold for pickup */
  262.  
  263. /* Message packet header. The "illegal" (ie. not in FSC001) definitions
  264. are in the interim Packet Type 2. */
  265.  
  266. #define PKTVER 2        /* v10 = 1, v11 = 2, v12 = ... */
  267.  
  268. /* PUBLIC */
  269. struct _pkthdr {
  270.     int orig_number;    /* v9 originating Node # */
  271.     int dest_number;    /* v9 destination node */
  272.     int year,month,day,hour,minute,second;
  273.     int rate;        /* v9 OBSO RESERVED baud rate */
  274.     int ver;        /* packet version */
  275.  
  276.     int orig_net;        /* v11 originating net number */
  277.     int dest_net;        /* v11 destination net number */
  278.  
  279.     char product1;        /* v11 product type */
  280.     char product2;        /* v11 extra byte */
  281.     char pwd[8];        /* password */
  282.  
  283.     int orig_zone;        /* originating zone */
  284.     int dest_zone;        /* destination zone */
  285.  
  286.     char extra[16];        /* extra bytes */
  287.     long prod;        /* product dependent */
  288. };
  289.