home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 4 / CDPD_IV.bin / networking / uucp / amigauucpsrc / bms / defs.h < prev    next >
C/C++ Source or Header  |  1994-06-29  |  9KB  |  322 lines

  1.  
  2. /*
  3.  *  DEFS.H
  4.  */
  5.  
  6. #ifndef DEFS_H
  7. #define DEFS_H
  8.  
  9. #include <exec/types.h>
  10. #include <exec/lists.h>
  11. #include <exec/nodes.h>
  12. #include <dos/dos.h>
  13. #include <clib/exec_protos.h>
  14. #include <clib/alib_protos.h>
  15. #include <clib/dos_protos.h>
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <string.h>
  19. #include <stdarg.h>
  20. #include <fcntl.h>
  21. #include <time.h>
  22. #include <lists.h>
  23.  
  24. #ifndef DEBUG_TIMEMPX
  25. #define DEBUG_TIMEMPX 1
  26. #endif
  27.  
  28. #define Prototype extern
  29. #define arysize(ary)    (sizeof(ary)/sizeof((ary)[0]))
  30. #define markersize(type) offsetof(type,DBMarker)
  31. #define NO  'n'
  32. #define YES 'y'
  33.  
  34. typedef struct Node Node;
  35. typedef struct List List;
  36. typedef struct FileInfoBlock FileInfoBlock;
  37.  
  38. typedef unsigned char ubyte;
  39. typedef unsigned short uword;
  40. typedef unsigned long ulong;
  41. typedef long bool_t;
  42.  
  43. #include "database.h"
  44. #include "protocol.h"
  45.  
  46. /*
  47.  *  Comm    Communications, including source & destination id's
  48.  *  Param   Operating Parameters
  49.  *  Stat    Statistics
  50.  */
  51.  
  52. typedef struct Comm {
  53.     short   com_Flags;
  54.     short   com_Control;    /*    who controls this connection?    */
  55.     long    com_SID;        /*    source identifier    */
  56.     long    com_CID;        /*    cache identifier    */
  57.     long    com_DID;        /*    destination identifier    */
  58.     long    com_SeqNo;        /*    so out of order STOP/STARTs not misinterpreted */
  59.     short   com_State;        /*    operating state     */
  60.     short   com_Flags;        /*    various flags        */
  61.     short   com_Retries;    /*    retries taken        */
  62.     short   com_TmpFileNo;  /*    semi-temporary files    */
  63.     short   com_Reserved;
  64.  
  65.     long    com_TxReq;        /*    amount of data we have to send        */
  66.     long    com_TxOk;        /*    amount of data we are allowed to send    */
  67.     long    com_TmpTx;        /*    temporary storage, max tx bytes this session */
  68.     long    com_RemTxBpd;   /*    eventually takes into acct remote node    */
  69.     long    com_RemTxBpw;   /*    eventually takes into acct remote node    */
  70.  
  71.     long    com_TOTime;     /*    timeout time left (as a double check)   */
  72.     long    com_TOStamp;    /*    timeout time stamp            */
  73.     long    com_TOMisc;     /*    misc, depends on protocol        */
  74.  
  75.     long    DBMarker;        /*    database marker end of structure    */
  76.  
  77.     char    *com_Msg;
  78.     record_t com_RId;        /*    record id            */
  79.     record_t com_MId;
  80. } Comm;
  81.  
  82. typedef struct Param {
  83.     short   pm_Flags;
  84.     short   pm_Reserved;
  85.     long    pm_MaxRxBpd;
  86.     long    pm_MaxTxBpd;
  87.     long    pm_MaxRxBpw;
  88.     long    pm_MaxTxBpw;
  89.     long    pm_MaxRxMail;
  90.     long    pm_MaxTxMail;
  91.     long    pm_MinMail;
  92.     long    pm_MirRxBpd;
  93.     long    pm_MirTxBpd;
  94.     long    pm_CacBwPerc;
  95.     long    pm_ReqSwamp;
  96.     long    pm_MirSwamp;
  97.  
  98.     long    DBMarker;        /*    database marker end of structure    */
  99.  
  100.     record_t pm_RId;
  101. } Param;
  102.  
  103. typedef struct Stat {
  104.     short   st_Flags;
  105.     short   st_Reserved;
  106.     long    st_BytesOut;    /*  bytes sent            */
  107.     long    st_BytesIn;     /*  bytes received        */
  108.     long    st_BytesResent;    /*  transmitted bytes resent    */
  109.     long    st_BytesDup;    /*  received bytes duplicated    */
  110.  
  111.     long    DBMarker;        /*    database marker end of structure    */
  112.  
  113.     record_t st_RId;
  114. } Stat;
  115.  
  116. /*
  117.  *  RegNode    - Registration node (\0 name indicates default node)
  118.  *  CtlNode    - High level control node
  119.  *  FilNode    - Low level control node, for each queued file/directory
  120.  */
  121.  
  122. typedef struct RegNode {
  123.     Node    rn_Node;        /*    ln_Name == dest path        */
  124.     short   rn_Flags;
  125.     char    *rn_RetPath;    /*    specified return path        */
  126.     char    *rn_Alias;        /*    specified node alias        */
  127.     long    rn_CommId;        /*    next allocatable id        */
  128.  
  129.     long    DBMarker;        /*    database marker end of structure    */
  130.  
  131.     record_t rn_RId;
  132.     record_t rn_NId;
  133.     record_t rn_RPId;
  134.     record_t rn_ALId;
  135.     record_t rn_TxHId;
  136.     record_t rn_FAId;
  137.  
  138.     List    rn_HistList;    /*    histogram of data sent            */
  139.     List    rn_CtlList;     /*    list of control nodes            */
  140.     List    rn_AccList;     /*    file access list            */
  141.  
  142.     Comm    rn_Comm;        /*    communications                */
  143.     Param   rn_Param;        /*    parameters                */
  144.     Stat    rn_Stat;        /*    statistics                */
  145. } RegNode;
  146.  
  147. typedef struct CtlNode {
  148.     Node    cn_Node;        /*    ln_Name holds control argument(s)   */
  149.     short   cn_Flags;
  150.  
  151.     long    DBMarker;        /*    database marker end of structure    */
  152.  
  153.     record_t cn_RId;
  154.     record_t cn_NId;        /*    cn_Node.ln_Name             */
  155.     List    cn_FileList;    /*    list of files & directories        */
  156.     Comm    cn_Comm;        /*    communications                */
  157.     Stat    cn_Stat;        /*    statistics                */
  158. } CtlNode;
  159.  
  160. #define CNF_DONE    0x0100  /*    cn_Flags, operation DONE flag        */
  161.  
  162. /*
  163.  *  The FileAccess structure is a permanent subtree under a RegNode
  164.  *  which holds the overall file permissions.  Entries are of the
  165.  *  form:   +name or -name
  166.  */
  167.  
  168. typedef struct FileAccess {
  169.     Node    fa_Node;
  170.     short    fa_Flags;
  171.  
  172.     long    DBMarker;
  173.  
  174.     record_t    fa_RId;
  175.     record_t    fa_NId;
  176. } FileAccess;
  177.  
  178. #define FAF_RESTRICT    0x0100
  179.  
  180. /*
  181.  *  The FileNode structure serves as a placeholder during a file
  182.  *  transfer.  It contains FileChunks indicating which parts of the
  183.  *  file have been received or transmitted.  Directories are converted
  184.  *  into a flat namespace of multiple FileNode's for the purposes of
  185.  *  the file transfer.
  186.  *
  187.  *  For the transmitter, fn_Files is set to the total number of nodes
  188.  *  to be sent (this value is sent with every file).  fn_FilNo
  189.  *  individually identifies each file allowing the receiver to
  190.  *  request a retry.
  191.  */
  192.  
  193. typedef struct FileNode {
  194.     Node    fn_Node;
  195.     short   fn_Flags;
  196.     long    fn_Files;        /*  total number of files        */
  197.     long    fn_FileNo;        /*  entry number            */
  198.     long    fn_Size;        /*  file size                */
  199.     long    fn_Date[3];     /*  AmigaDOS date            */
  200.     long    fn_Protection;    /*  file protection(s)              */
  201.  
  202.     long    DBMarker;        /*  database marker end of struct   */
  203.  
  204.     char    *fn_RemFileName;    /*  remote file name            */
  205.     char    *fn_LocFileName;    /*  local file name            */
  206.     char    *fn_Comment;    /*  comment field, if any        */
  207.     List    fn_ChunkList;    /*  list of FileChunks            */
  208.  
  209.     record_t fn_RId;        /*  Record ID for this structure    */
  210.     record_t fn_LFId;        /*  fn_LocFileName            */
  211.     record_t fn_RFId;        /*  fn_RemFileName            */
  212.     record_t fn_CMId;        /*  fn_Comment                */
  213.     record_t fn_FCId;        /*  DBTYPE_CHUNK root            */
  214. } FileNode;
  215.  
  216. #define FNF_ILLEGAL 0x0100
  217. #define FNF_BAD     0x0200
  218. #define FNF_DONE    0x0400    /*  also effects file name  */
  219. #define FNF_SIZE    0x0800    /*  size is known        */
  220. #define FNF_DIR     0x1000    /*  is a directory        */
  221. #define FNF_MASTER  0x2000    /*  get, master (root) node */
  222.  
  223. /*
  224.  *  FileChunk
  225.  *
  226.  *  A FileChunk contains part of a file.  A FileChunk does not contain
  227.  *  actual data, that is assembled in the file itself (for recv) or
  228.  *  extracted (for transmit)
  229.  */
  230.  
  231. typedef struct FileChunk {
  232.     Node    fc_Node;
  233.     short   fc_Flags;
  234.     long    fc_Offset;
  235.     long    fc_Bytes;
  236.  
  237.     long    DBMarker;
  238.  
  239.     record_t fc_RId;
  240. } FileChunk;
  241.  
  242.  
  243. /*
  244.  *  A HistNode contains information relating to bytes sent and bytes
  245.  *  received over a period of time.
  246.  */
  247.  
  248. typedef struct HistNode {
  249.     Node    hn_Node;
  250.     time_t    hn_TimeStamp;    /*  when    */
  251.     long    hn_Bytes;    /*  how much    */
  252.     short    hn_Flags;
  253.     short    hn_Reserved;
  254.  
  255.     long    DBMarker;
  256.  
  257.     record_t    hn_RId;
  258. } HistNode;
  259.  
  260. /*
  261.  *  Global Flags
  262.  */
  263.  
  264. #define GF_DELETED  0x0001
  265. #define GF_MODIFIED 0x0002
  266. #define GF_LOADED   0x0004
  267. #define GF_MARKED   0x0008  /*    RegNode only        */
  268. #define GF_ALERT    0x0010  /*    alert state machine    */
  269. #define GF_NODISP   0x0020  /*    do not display - 'done' or 'dequeued' wait states  */
  270. #define GF_COMMENT  0x0040  /*    expect comment field (FileNode)   */
  271.  
  272. #define GF_CUSTOM   0xFF00
  273.  
  274. /*
  275.  *  Database TYPEs.  Bit 31 reserved by database to mark 'deleted' nodes.
  276.  */
  277.  
  278. #define DBTYPE_COMM        0x00000010    /*  Comm sub structure    */
  279. #define DBTYPE_COMM_MSG     0x00000011    /*  com_Msg        */
  280.  
  281. #define DBTYPE_PARAM        0x00000020    /*  Param sub structure */
  282. #define DBTYPE_STAT        0x00000030    /*  Stat sub structure    */
  283.  
  284. #define DBTYPE_REG        0x00000040    /*  RegNode        */
  285. #define DBTYPE_REG_NAME     0x00000041
  286. #define DBTYPE_REG_RETPATH  0x00000042    /*  rn_RetPath        */
  287. #define DBTYPE_REG_ALIAS    0x00000043    /*  rn_Alias        */
  288.  
  289.  
  290. #define DBTYPE_CTL        0x00000050    /*  CtlNode        */
  291. #define DBTYPE_CTL_NAME     0x00000051
  292.  
  293. #define DBTYPE_FILE        0x00000060    /*  FileNode        */
  294. #define DBTYPE_FILE_REMNAME 0x00000061    /*  fn_LocFileName  */
  295. #define DBTYPE_FILE_LOCNAME 0x00000062    /*  fn_RemFileName  */
  296. #define DBTYPE_FILE_COMMENT 0x00000063    /*  fn_Comment        */
  297.  
  298. #define DBTYPE_CHUNK        0x00000070    /*  subtree root    */
  299. #define DBTYPE_CHUNK_NODE   0x00000071    /*  FileChunk        */
  300.  
  301. #define DBTYPE_TXHIST        0x00000080    /*  under RegNode   */
  302. #define DBTYPE_TXHIST_NODE  0x00000081    /*  HistNode        */
  303.  
  304. #define DBTYPE_ACCESS        0x00000090    /*  subtree root    */
  305. #define DBTYPE_ACCESS_NODE  0x00000091    /*  File Access     */
  306. #define DBTYPE_ACCESS_NAME  0x00000092    /*  fa_Node.ln_Name    */
  307.  
  308. #define DBTYPE_CONTROL        0x00010000    /*  formatted data for email    */
  309. #define DBTYPE_CONTROL_MASK 0x0000FFFF    /*  bits protocol.h can play w/ */
  310.  
  311. /*
  312.  *  Prototypes
  313.  */
  314.  
  315.  
  316. #ifndef TEST
  317. #include "bms-protos.h"
  318. #endif
  319.  
  320. #endif
  321.  
  322.