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