Annotation of sbbs/sbbs2/smb/smbdefs.h, revision 1.1.1.2

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.