1 #ifndef __JAM_H__ 2 #define __JAM_H__ 3 4 /* 5 ** File extensions 6 */ 7 #define EXT_HDRFILE ".jhr" 8 #define EXT_TXTFILE ".jdt" 9 #define EXT_IDXFILE ".jdx" 10 #define EXT_LRDFILE ".jlr" 11 12 /* 13 ** Revision level and header signature 14 */ 15 #define CURRENTREVLEV 1 16 #define HEADERSIGNATURE "JAM" 17 18 /* 19 ** Header file information block, stored first in all .JHR files 20 */ 21 typedef struct 22 { 23 byte Signature[4]; /* <J><A><M> followed by <NUL> */ 24 dword DateCreated; /* Creation date */ 25 dword ModCounter; /* Last processed counter */ 26 dword ActiveMsgs; /* Number of active (not deleted) msgs */ 27 dword PasswordCRC; /* CRC-32 of password to access */ 28 dword BaseMsgNum; /* Lowest message number in index file */ 29 dword highwater; /* Number of the last msg scanned */ 30 byte RSRVD[996]; /* Reserved space */ 31 } 32 JAMHDRINFO, *JAMHDRINFOptr; 33 34 #define HDRINFO_SIZE (1000 + (4 * 6)) 35 36 /* 37 ** Message status bits 38 */ 39 #define JMSG_LOCAL 0x00000001L /* Msg created locally */ 40 #define JMSG_INTRANSIT 0x00000002L /* Msg is in-transit */ 41 #define JMSG_PRIVATE 0x00000004L /* Private */ 42 #define JMSG_READ 0x00000008L /* Read by addressee */ 43 #define JMSG_SENT 0x00000010L /* Sent to remote */ 44 #define JMSG_KILLSENT 0x00000020L /* Kill when sent */ 45 #define JMSG_ARCHIVESENT 0x00000040L /* Archive when sent */ 46 #define JMSG_HOLD 0x00000080L /* Hold for pick-up */ 47 #define JMSG_CRASH 0x00000100L /* Crash */ 48 #define JMSG_IMMEDIATE 0x00000200L /* Send Msg now, ignore restrictions */ 49 #define JMSG_DIRECT 0x00000400L /* Send directly to destination */ 50 #define JMSG_GATE 0x00000800L /* Send via gateway */ 51 #define JMSG_FILEREQUEST 0x00001000L /* File request */ 52 #define JMSG_FILEATTACH 0x00002000L /* File(s) attached to Msg */ 53 #define JMSG_TRUNCFILE 0x00004000L /* Truncate file(s) when sent */ 54 #define JMSG_KILLFILE 0x00008000L /* Delete file(s) when sent */ 55 #define JMSG_RECEIPTREQ 0x00010000L /* Return receipt requested */ 56 #define JMSG_CONFIRMREQ 0x00020000L /* Confirmation receipt requested */ 57 #define JMSG_ORPHAN 0x00040000L /* Unknown destination */ 58 #define JMSG_ENCRYPT 0x00080000L /* Msg text is encrypted */ 59 #define JMSG_COMPRESS 0x00100000L /* Msg text is compressed */ 60 #define JMSG_ESCAPED 0x00200000L /* Msg text is seven bit ASCII */ 61 #define JMSG_FPU 0x00400000L /* Force pickup */ 62 #define JMSG_TYPELOCAL 0x00800000L /* Msg is for local use only (not for export) */ 63 #define JMSG_TYPEECHO 0x01000000L /* Msg is for conference distribution */ 64 #define JMSG_TYPENET 0x02000000L /* Msg is direct network mail */ 65 #define JMSG_NODISP 0x20000000L /* Msg may not be displayed to user */ 66 #define JMSG_LOCKED 0x40000000L /* Msg is locked, no editing possible */ 67 #define JMSG_DELETED 0x80000000L /* Msg is deleted */ 68 69 /* 70 ** Message header 71 */ 72 typedef struct 73 { 74 byte Signature[4]; /* <J><A><M> followed by <NUL> */ 75 word Revision; /* CURRENTREVLEV */ 76 word ReservedWord; /* Reserved */ 77 dword SubfieldLen; /* Length of subfields */ 78 dword TimesRead; /* Number of times message read */ 79 dword MsgIdCRC; /* CRC-32 of MSGID line */ 80 dword ReplyCRC; /* CRC-32 of REPLY line */ 81 dword ReplyTo; /* This msg is a reply to.. */ 82 dword Reply1st; /* First reply to this msg */ 83 dword ReplyNext; /* Next msg in reply chain */ 84 dword DateWritten; /* When msg was written */ 85 dword DateReceived; /* When msg was received/read */ 86 dword DateProcessed; /* When msg was processed by packer */ 87 dword MsgNum; /* Message number (1-based) */ 88 dword Attribute; /* Msg attribute, see "Status bits" */ 89 dword Attribute2; /* Reserved for future use */ 90 dword TxtOffset; /* Offset of text in text file */ 91 dword TxtLen; /* Length of message text */ 92 dword PasswordCRC; /* CRC-32 of password to access msg */ 93 dword Cost; /* Cost of message */ 94 } 95 JAMHDR, *JAMHDRptr; 96 97 #define HDR_SIZE (8 + (4 * 17)) 98 99 /* 100 ** Message header subfield types 101 */ 102 #define JAMSFLD_OADDRESS 0 103 #define JAMSFLD_DADDRESS 1 104 #define JAMSFLD_SENDERNAME 2 105 #define JAMSFLD_RECVRNAME 3 106 #define JAMSFLD_MSGID 4 107 #define JAMSFLD_REPLYID 5 108 #define JAMSFLD_SUBJECT 6 109 #define JAMSFLD_PID 7 110 #define JAMSFLD_TRACE 8 111 #define JAMSFLD_ENCLFILE 9 112 #define JAMSFLD_ENCLFWALIAS 10 113 #define JAMSFLD_ENCLFREQ 11 114 #define JAMSFLD_ENCLFILEWC 12 115 #define JAMSFLD_ENCLINDFILE 13 116 #define JAMSFLD_EMBINDAT 1000 117 #define JAMSFLD_FTSKLUDGE 2000 118 #define JAMSFLD_SEENBY2D 2001 119 #define JAMSFLD_PATH2D 2002 120 #define JAMSFLD_FLAGS 2003 121 #define JAMSFLD_TZUTCINFO 2004 122 #define JAMSFLD_UNKNOWN 0xffff 123 124 /* 125 ** Message header subfield 126 */ 127 typedef struct 128 { 129 word LoID; /* Field ID, 0 - 0xffff */ 130 word HiID; /* Reserved for future use */ 131 dword DatLen; /* Length of buffer that follows */ 132 byte Buffer[1]; /* DatLen bytes of data */ 133 } 134 JAMSUBFIELD, *JAMSUBFIELDptr; 135 136 typedef struct 137 { 138 word LoID; /* Field ID, 0 - 0xffff */ 139 word HiID; /* Reserved for future use */ 140 dword DatLen; /* Length of buffer that follows */ 141 } 142 JAMBINSUBFIELD, *JAMBINSUBFIELDptr; 143 144 /* 145 ** Message index record 146 */ 147 typedef struct 148 { 149 dword UserCRC; /* CRC-32 of destination username */ 150 dword HdrOffset; /* Offset of header in .JHR file */ 151 } 152 JAMIDXREC, *JAMIDXRECptr; 153 154 #define IDX_SIZE 8 155 156 /* 157 ** Lastread structure, one per user 158 */ 159 typedef struct 160 { 161 dword UserCRC; /* CRC-32 of user name (lowercase) */ 162 dword UserID; /* Unique UserID */ 163 dword LastReadMsg; /* Last read message number */ 164 dword HighReadMsg; /* Highest read message number */ 165 } 166 JAMLREAD, *JAMLREADptr; 167 168 #define fop_wpb (O_CREAT | O_TRUNC | O_RDWR | O_BINARY) 169 #define fop_rpb (O_RDWR | O_BINARY) 170 #define fop_rob (O_RDONLY | O_BINARY) 171 /* 172 #define get_dword(ptr) \ 173 ((dword)((unsigned char)(ptr)[0]) | \ 174 (((dword)((unsigned char)(ptr)[1])) << 8) | \ 175 (((dword)((unsigned char)(ptr)[2])) << 16) | \ 176 (((dword)((unsigned char)(ptr)[3])) << 24)) \ 177 */ 178 179 int read_hdrinfo(int handle, JAMHDRINFO *HdrInfo); 180 int read_idx(int handle, JAMIDXREC *Idx); 181 int read_hdr(int handle, JAMHDR *Hdr); 182 int read_subfield(int handle, JAMSUBFIELDptr *subfield, dword *SubfieldLen); 183 184 int write_hdrinfo(int handle, JAMHDRINFO *HdrInfo); 185 int write_idx(int handle, JAMIDXREC *Idx); 186 int write_hdr(int handle, JAMHDR *Hdr); 187 int write_subfield(int handle, JAMSUBFIELDptr *subfield, dword SubfieldLen); 188 189 #if defined(UNIX) 190 #define chsize ftruncate 191 #endif 192 193 #endif /* __JAM_H__ */ 194 195 196