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