home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / BBS / SMB_111.ZIP / SMBDEFS.H < prev    next >
C/C++ Source or Header  |  1994-04-21  |  13KB  |  410 lines

  1. /* SMBDEFS.H */
  2.  
  3. #ifndef _SMBDEFS_H
  4. #define _SMBDEFS_H
  5.  
  6. /**********/
  7. /* Macros */
  8. /**********/
  9.  
  10. #define SMB_VERSION         0x0110        /* High byte major, low byte minor */
  11.  
  12.                                         /* Control characters */
  13. #define TAB                 0x09        /* Horizontal tabulation    ^I */
  14. #define LF                    0x0a        /* Line feed                ^J */
  15. #define FF                    0x0c        /* Form feed                ^L */
  16. #define CR                    0x0d        /* Carriage return            ^M */
  17. #define ESC                 0x1b        /* Escape                    ^[ */
  18. #define SP                    0x20        /* Space                       */
  19.  
  20. #define ulong                unsigned long
  21. #define ushort                unsigned short
  22. #define uchar                unsigned char
  23.  
  24. #if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
  25. #define MALLOC  farmalloc
  26. #define REALLOC farrealloc
  27. #define FREE    farfree
  28. #else
  29. #define MALLOC  malloc
  30. #define REALLOC realloc
  31. #define FREE    free
  32. #endif
  33.  
  34. #define SDT_BLOCK_LEN        256         /* Size of data blocks */
  35. #define SHD_BLOCK_LEN        256         /* Size of header blocks */
  36.  
  37. #define SMB_STACK_LEN        4            /* Max msg bases in smb_stack()     */
  38. #define SMB_STACK_POP        0            /* Pop a msg base off of smb_stack() */
  39. #define SMB_STACK_PUSH        1            /* Push a msg base onto smb_stack() */
  40.  
  41.                                         /* Time zone macros for when_t.zone */
  42. #define DAYLIGHT            0x8000        /* Daylight savings is active */
  43. #define US_ZONE             0x4000        /* U.S. time zone */
  44. #define WESTERN_ZONE        0x2000        /* Non-standard zone west of UT */
  45. #define EASTERN_ZONE        0x1000        /* Non-standard zone east of UT */
  46.  
  47.                                         /* US Time Zones (standard) */
  48. #define AST                 0x40F0        // Atlantic             (-04:00)
  49. #define EST                 0x412C        // Eastern                (-05:00)
  50. #define CST                 0x4168        // Central                (-06:00)
  51. #define MST                 0x41A4        // Mountain             (-07:00)
  52. #define PST                 0x41E0        // Pacific                (-08:00)
  53. #define YST                 0x421C        // Yukon                (-09:00)
  54. #define HST                 0x4258        // Hawaii/Alaska        (-10:00)
  55. #define BST                 0x4294        // Bering                (-11:00)
  56.  
  57.                                         /* US Time Zones (daylight) */
  58. #define ADT                 0xC0F0        // Atlantic             (-03:00)
  59. #define EDT                 0xC12C        // Eastern                (-04:00)
  60. #define CDT                 0xC168        // Central                (-05:00)
  61. #define MDT                 0xC1A4        // Mountain             (-06:00)
  62. #define PDT                 0xC1E0        // Pacific                (-07:00)
  63. #define YDT                 0xC21C        // Yukon                (-08:00)
  64. #define HDT                 0xC258        // Hawaii/Alaska        (-09:00)
  65. #define BDT                 0xC294        // Bering                (-10:00)
  66.  
  67.                                         /* Non-standard Time Zones */
  68. #define MID                 0x2294        // Midway                (-11:00)
  69. #define VAN                 0x21E0        // Vancouver            (-08:00)
  70. #define EDM                 0x21A4        // Edmonton             (-07:00)
  71. #define WIN                 0x2168        // Winnipeg             (-06:00)
  72. #define BOG                 0x212C        // Bogota                (-05:00)
  73. #define CAR                 0x20F0        // Caracas                (-04:00)
  74. #define RIO                 0x20B4        // Rio de Janeiro        (-03:00)
  75. #define FER                 0x2078        // Fernando de Noronha    (-02:00)
  76. #define AZO                 0x203C        // Azores                (-01:00)
  77. #define LON                 0x1000        // London                (+00:00)
  78. #define BER                 0x103C        // Berlin                (+01:00)
  79. #define ATH                 0x1078        // Athens                (+02:00)
  80. #define MOS                 0x10B4        // Moscow                (+03:00)
  81. #define DUB                 0x10F0        // Dubai                (+04:00)
  82. #define KAB                 0x110E        // Kabul                (+04:30)
  83. #define KAR                 0x112C        // Karachi                (+05:00)
  84. #define BOM                 0x114A        // Bombay                (+05:30)
  85. #define KAT                 0x1159        // Kathmandu            (+05:45)
  86. #define DHA                 0x1168        // Dhaka                (+06:00)
  87. #define BAN                 0x11A4        // Bangkok                (+07:00)
  88. #define HON                 0x11E0        // Hong Kong            (+08:00)
  89. #define TOK                 0x121C        // Tokyo                (+09:00)
  90. #define SYD                 0x1258        // Sydney                (+10:00)
  91. #define NOU                 0x1294        // Noumea                (+11:00)
  92. #define WEL                 0x12D0        // Wellington            (+12:00)
  93.  
  94.                                         /* Valid hfield_t.types */
  95. #define SENDER                0x00
  96. #define SENDERAGENT         0x01
  97. #define SENDERNETTYPE        0x02
  98. #define SENDERNETADDR        0x03
  99. #define SENDEREXT            0x04
  100. #define SENDERPOS            0x05
  101. #define SENDERORG            0x06
  102.  
  103. #define AUTHOR                0x10
  104. #define AUTHORAGENT         0x11
  105. #define AUTHORNETTYPE        0x12
  106. #define AUTHORNETADDR        0x13
  107. #define AUTHOREXT            0x14
  108. #define AUTHORPOS            0x15
  109. #define AUTHORORG            0x16
  110.  
  111. #define REPLYTO             0x20
  112. #define REPLYTOAGENT        0x21
  113. #define REPLYTONETTYPE        0x22
  114. #define REPLYTONETADDR        0x23
  115. #define REPLYTOEXT            0x24
  116. #define REPLYTOPOS            0x25
  117. #define REPLYTOORG            0x26
  118.  
  119. #define RECIPIENT            0x30
  120. #define RECIPIENTAGENT        0x31
  121. #define RECIPIENTNETTYPE    0x32
  122. #define RECIPIENTNETADDR    0x33
  123. #define RECIPIENTEXT        0x34
  124. #define RECIPIENTPOS        0x35
  125. #define RECIPIENTORG        0x36
  126.  
  127. #define FORWARDTO            0x40
  128. #define FORWARDTOAGENT        0x41
  129. #define FORWARDTONETTYPE    0x42
  130. #define FORWARDTONETADDR    0x43
  131. #define FORWARDTOEXT        0x44
  132. #define FORWARDTOPOS        0x45
  133. #define FORWARDTOORG        0x46
  134.  
  135. #define FORWARDED            0x48
  136.  
  137. #define RECEIVEDBY            0x50
  138. #define RECEIVEDBYAGEN        0x51
  139. #define RECEIVEDBYNETTYPE    0x52
  140. #define RECEIVEDBYNETADDR    0x53
  141. #define RECEIVEDBYEXT        0x54
  142. #define RECEIVEDBYPOS        0x55
  143. #define RECEIVEDBYORG        0x56
  144.  
  145. #define RECEIVED            0x58
  146.  
  147. #define SUBJECT             0x60
  148. #define SUMMARY             0x61
  149. #define COMMENT             0x62
  150. #define CARBONCOPY            0x63
  151. #define GROUP                0x64
  152. #define EXPIRATION            0x65
  153. #define PRIORITY            0x66
  154.  
  155. #define FILEATTACH            0x70
  156. #define DESTFILE            0x71
  157. #define FILEATTACHLIST        0x72
  158. #define DESTFILELIST        0x73
  159. #define FILEREQUEST         0x74
  160. #define FILEPASSWORD        0x75
  161. #define FILEREQUESTLIST     0x76
  162. #define FILEPASSWORDLIST    0x77
  163.  
  164. #define IMAGEATTACH         0x80
  165. #define ANIMATTACH            0x81
  166. #define FONTATTACH            0x82
  167. #define SOUNDATTACH         0x83
  168. #define PRESENTATTACH        0x84
  169. #define VIDEOATTACH         0x85
  170. #define APPDATAATTACH        0x86
  171.  
  172. #define IMAGETRIGGER        0x90
  173. #define ANIMTRIGGER         0x91
  174. #define FONTTRIGGER         0x92
  175. #define SOUNDTRIGGER        0x93
  176. #define PRESENTTRIGGER        0x94
  177. #define VIDEOTRIGGER        0x95
  178. #define APPDATATRIGGER        0x96
  179.  
  180. #define FIDOCTRL            0xa0
  181. #define FIDOAREA            0xa1
  182. #define FIDOSEENBY            0xa2
  183. #define FIDOPATH            0xa3
  184. #define FIDOMSGID            0xa4
  185. #define FIDOREPLYID         0xa5
  186. #define FIDOPID             0xa6
  187. #define FIDOFLAGS            0xa7
  188.  
  189. #define RFC822HEADER        0xb0
  190. #define RFC822MSGID         0xb1
  191. #define RFC822REPLYID        0xb2
  192.  
  193. #define UNKNOWN             0xf1
  194. #define UNKNOWNASCII        0xf2
  195. #define UNUSED                0xff
  196.  
  197.                                         /* Valid dfield_t.types */
  198. #define TEXT_BODY            0x00
  199. #define TEXT_SOUL            0x01
  200. #define TEXT_TAIL            0x02
  201. #define TEXT_WING            0x03
  202. #define IMAGEEMBED            0x20
  203. #define ANIMEMBED            0x21
  204. #define FONTEMBED            0x22
  205. #define SOUNDEMBED            0x23
  206. #define PRESENTEMBED        0x24
  207. #define VIDEOEMBED            0x25
  208. #define APPDATAEMBED        0x26
  209. #define UNUSED                0xff
  210.  
  211.  
  212.                                         /* Message attributes */
  213. #define MSG_PRIVATE         (1<<0)
  214. #define MSG_READ            (1<<1)
  215. #define MSG_PERMANENT        (1<<2)
  216. #define MSG_LOCKED            (1<<3)
  217. #define MSG_DELETE            (1<<4)
  218. #define MSG_ANONYMOUS        (1<<5)
  219. #define MSG_KILLREAD        (1<<6)
  220. #define MSG_MODERATED        (1<<7)
  221. #define MSG_VALIDATED        (1<<8)
  222.  
  223.                                         /* Auxillary header attributes */
  224. #define MSG_FILEREQUEST     (1<<0)        // File request
  225. #define MSG_FILEATTACH        (1<<1)        // File(s) attached to Msg
  226. #define MSG_TRUNCFILE        (1<<2)        // Truncate file(s) when sent
  227. #define MSG_KILLFILE        (1<<3)        // Delete file(s) when sent
  228. #define MSG_RECEIPTREQ        (1<<4)        // Return receipt requested
  229. #define MSG_CONFIRMREQ        (1<<5)        // Confirmation receipt requested
  230. #define MSG_NODISP            (1<<6)        // Msg may not be displayed to user
  231.  
  232.                                         /* Message network attributes */
  233. #define MSG_LOCAL            (1<<0)        // Msg created locally
  234. #define MSG_INTRANSIT        (1<<1)        // Msg is in-transit
  235. #define MSG_SENT            (1<<2)        // Sent to remote
  236. #define MSG_KILLSENT        (1<<3)        // Kill when sent
  237. #define MSG_ARCHIVESENT     (1<<4)        // Archive when sent
  238. #define MSG_HOLD            (1<<5)        // Hold for pick-up
  239. #define MSG_CRASH            (1<<6)        // Crash
  240. #define MSG_IMMEDIATE        (1<<7)        // Send Msg now, ignore restrictions
  241. #define MSG_DIRECT            (1<<8)        // Send directly to destination
  242. #define MSG_GATE            (1<<9)        // Send via gateway
  243. #define MSG_ORPHAN            (1<<10)     // Unknown destination
  244. #define MSG_FPU             (1<<11)     // Force pickup
  245. #define MSG_TYPELOCAL        (1<<12)     // Msg is for local use only
  246. #define MSG_TYPEECHO        (1<<13)     // Msg is for conference distribution
  247. #define MSG_TYPENET         (1<<14)     // Msg is direct network mail
  248.  
  249.  
  250. enum {
  251.      NET_NONE
  252.     ,NET_UNKNOWN
  253.     ,NET_FIDO
  254.     ,NET_POSTLINK
  255.     ,NET_QWK
  256.     ,NET_INTERNET
  257.  
  258. /* Add new ones here */
  259.  
  260.     ,NET_TYPES
  261.     };
  262.  
  263. enum {
  264.      AGENT_PERSON
  265.     ,AGENT_PROCESS
  266.  
  267. /* Add new ones here */
  268.  
  269.     ,AGENT_TYPES
  270.     };
  271.  
  272. enum {
  273.      XLAT_NONE              // No translation/End of translation list
  274.     ,XLAT_ENCRYPT           // Encrypted data
  275.     ,XLAT_ESCAPED           // 7-bit ASCII escaping for ctrl and 8-bit data
  276.     ,XLAT_HUFFMAN           // Static and adaptive Huffman coding compression
  277.     ,XLAT_LZW               // Limpel/Ziv/Welch compression
  278.     ,XLAT_MLZ78             // Modified LZ78 compression
  279.     ,XLAT_RLE               // Run length encoding compression
  280.     ,XLAT_IMPLODE           // Implode compression (PkZIP)
  281.     ,XLAT_SHRINK            // Shrink compression (PkZIP)
  282.  
  283. /* Add new ones here */
  284.  
  285.     ,XLAT_TYPES
  286.     };
  287.  
  288.  
  289. /************/
  290. /* Typedefs */
  291. /************/
  292.  
  293. typedef struct {
  294.  
  295.     ulong    time;            // Local time (unix format)
  296.     short    zone;            // Time zone
  297.  
  298.     } when_t;
  299.  
  300. typedef struct {
  301.  
  302.     ushort    to;             // 16-bit CRC of recipient name (lower case)
  303.     ushort    from;            // 16-bit CRC of sender name (lower case)
  304.     ushort    subj;            // 16-bit CRC of subject (lower case, w/o RE:)
  305.     ushort    attr;            // attributes (read, permanent, etc.)
  306.     ulong    offset;         // offset into header file
  307.     ulong    number;         // number of message (1 based)
  308.     ulong    time;            // time/date message was imported/posted
  309.  
  310.     } idxrec_t;
  311.  
  312. typedef struct {
  313.  
  314.     uchar   id[4];          // text or binary unique hdr ID
  315.     ushort  version;        // version number (initially 100h for 1.00)
  316.     ushort  length;         // length including this struct
  317.  
  318.     } smbhdr_t;
  319.  
  320. typedef struct {
  321.  
  322.     ulong    last_msg;        // last message number
  323.     ulong    total_msgs;     // total messages
  324.     ulong    header_offset;    // byte offset to first header record
  325.     ulong    max_crcs;        // Maximum number of CRCs to keep in history
  326.     ulong   max_msgs;       // Maximum number of message to keep in sub
  327.     ushort  max_age;        // Maximum age of message to keep in sub (in days)
  328.     ushort    reserved;        // Reserved for future use
  329.  
  330.     } smbstatus_t;
  331.  
  332. typedef struct {
  333.  
  334.     uchar    id[4];            // SHD<^Z>
  335.     ushort  type;           // Message type (normally 0)
  336.     ushort  version;        // Version of type (initially 100h for 1.00)
  337.     ushort  length;         // Total length of fixed record + all fields
  338.     ushort    attr;            // Attributes (bit field) (duped in SID)
  339.     ulong    auxattr;        // Auxillary attributes (bit field)
  340.     ulong   netattr;        // Network attributes
  341.     when_t    when_written;    // Time message was written (unix format)
  342.     when_t    when_imported;    // Time message was imported
  343.     ulong   number;         // Message number
  344.     ulong   thread_orig;    // Original message number in thread
  345.     ulong   thread_next;    // Next message in thread
  346.     ulong   thread_first;   // First reply to this message
  347.     uchar    reserved[16];    // Reserved for future use
  348.     ulong   offset;         // Offset for buffer into data file (0 or mod 256)
  349.     ushort    total_dfields;    // Total number of data fields
  350.  
  351.     } msghdr_t;
  352.  
  353. typedef struct {
  354.  
  355.     ushort    type;            // Type of data field
  356.     ulong   offset;         // Offset into buffer 
  357.     ulong   length;         // Length of data field
  358.  
  359.     } dfield_t;
  360.  
  361. typedef struct {
  362.  
  363.     ushort    type;
  364.     ushort    length;         // Length of buffer
  365.  
  366.     } hfield_t;
  367.  
  368. typedef struct {
  369.  
  370.     ushort    zone;
  371.     ushort    net;
  372.     ushort    node;
  373.     ushort    point;
  374.  
  375.     } fidoaddr_t;
  376.  
  377. typedef struct {
  378.  
  379.     ushort  type;
  380.     void    *addr;
  381.  
  382.     } net_t;
  383.  
  384. typedef struct {
  385.  
  386.     idxrec_t    idx;            // Index
  387.     msghdr_t    hdr;            // Header record (fixed portion)
  388.     uchar        *to,            // To name
  389.                 *to_ext,        // To extension
  390.                 *from,            // From name
  391.                 *from_ext,        // From extension
  392.                 *replyto,        // Reply-to name
  393.                 *replyto_ext,    // Reply-to extension */
  394.                 *subj;            // Subject
  395.     ushort        to_agent,        // Type of agent message is to
  396.                 from_agent,     // Type of agent message is from
  397.                 replyto_agent;    // Type of agent replies should be sent to
  398.     net_t        to_net,         // Destination network type and address
  399.                 from_net,       // Origin network address
  400.                 replyto_net;    // Network type and address for replies
  401.     ushort        total_hfields;    // Total number of header fields
  402.     hfield_t    *hfield;        // Header fields (fixed length portion)
  403.     void        **hfield_dat;    // Header fields (variable length portion)
  404.     dfield_t    *dfield;        // Data fields (fixed length portion)
  405.     ulong        offset;         // Offset (number of records) into index
  406.  
  407.     } smbmsg_t;
  408.  
  409. #endif /* Don't add anything after this #endif statement */
  410.