1 /* 2 ** Adapted for MSGAPI by Fedor Lizunkov 2:5020/960@FidoNet 3 ** 4 ** JAM(mbp) - The Joaquim-Andrew-Mats Message Base Proposal 5 ** 6 ** C API 7 ** 8 ** Written by Joaquim Homrighausen. 9 ** 10 ** ---------------------------------------------------------------------- 11 ** 12 ** 13 ** Prototypes and definitions for the JAM message base format 14 ** 15 ** Copyright 1993 Joaquim Homrighausen, Andrew Milner, Mats Birch, and 16 ** Mats Wallin. ALL RIGHTS RESERVED. 17 ** 18 ** 93-06-28 JoHo 19 ** Initial coding. 20 */ 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 #ifndef __API_JAM_H__ 26 #define __API_JAM_H__ 27 28 #include <huskylib/compiler.h> 29 #include <huskylib/huskyext.h> 30 31 /* 32 ** File extensions 33 */ 34 #define EXT_HDRFILE ".jhr" 35 #define EXT_TXTFILE ".jdt" 36 #define EXT_IDXFILE ".jdx" 37 #define EXT_LRDFILE ".jlr" 38 39 /* 40 ** Revision level and header signature 41 */ 42 #define CURRENTREVLEV 1 43 #define HEADERSIGNATURE "JAM" 44 45 /* 46 ** Header file information block, stored first in all .JHR files 47 */ 48 typedef struct 49 { 50 byte Signature[4]; /* <J><A><M> followed by <NUL> */ 51 dword DateCreated; /* Creation date */ 52 dword ModCounter; /* Last processed counter */ 53 dword ActiveMsgs; /* Number of active (not deleted) msgs */ 54 dword PasswordCRC; /* CRC-32 of password to access */ 55 dword BaseMsgNum; /* Lowest message number in index file */ 56 dword highwater; /* Number of the last msg scanned */ 57 byte RSRVD[996]; /* Reserved space */ 58 } 59 JAMHDRINFO, *JAMHDRINFOptr; 60 61 #define HDRINFO_SIZE (1000 + (4 * 6)) 62 63 /* 64 ** Message status bits 65 */ 66 #define JMSG_LOCAL 0x00000001L /* Msg created locally */ 67 #define JMSG_INTRANSIT 0x00000002L /* Msg is in-transit */ 68 #define JMSG_PRIVATE 0x00000004L /* Private */ 69 #define JMSG_READ 0x00000008L /* Read by addressee */ 70 #define JMSG_SENT 0x00000010L /* Sent to remote */ 71 #define JMSG_KILLSENT 0x00000020L /* Kill when sent */ 72 #define JMSG_ARCHIVESENT 0x00000040L /* Archive when sent */ 73 #define JMSG_HOLD 0x00000080L /* Hold for pick-up */ 74 #define JMSG_CRASH 0x00000100L /* Crash */ 75 #define JMSG_IMMEDIATE 0x00000200L /* Send Msg now, ignore restrictions */ 76 #define JMSG_DIRECT 0x00000400L /* Send directly to destination */ 77 #define JMSG_GATE 0x00000800L /* Send via gateway */ 78 #define JMSG_FILEREQUEST 0x00001000L /* File request */ 79 #define JMSG_FILEATTACH 0x00002000L /* File(s) attached to Msg */ 80 #define JMSG_TRUNCFILE 0x00004000L /* Truncate file(s) when sent */ 81 #define JMSG_KILLFILE 0x00008000L /* Delete file(s) when sent */ 82 #define JMSG_RECEIPTREQ 0x00010000L /* Return receipt requested */ 83 #define JMSG_CONFIRMREQ 0x00020000L /* Confirmation receipt requested */ 84 #define JMSG_ORPHAN 0x00040000L /* Unknown destination */ 85 #define JMSG_ENCRYPT 0x00080000L /* Msg text is encrypted */ 86 #define JMSG_COMPRESS 0x00100000L /* Msg text is compressed */ 87 #define JMSG_ESCAPED 0x00200000L /* Msg text is seven bit ASCII */ 88 #define JMSG_FPU 0x00400000L /* Force pickup */ 89 #define JMSG_TYPELOCAL 0x00800000L /* Msg is for local use only (not for export) */ 90 #define JMSG_TYPEECHO 0x01000000L /* Msg is for conference distribution */ 91 #define JMSG_TYPENET 0x02000000L /* Msg is direct network mail */ 92 #define JMSG_NODISP 0x20000000L /* Msg may not be displayed to user */ 93 #define JMSG_LOCKED 0x40000000L /* Msg is locked, no editing possible */ 94 #define JMSG_DELETED 0x80000000L /* Msg is deleted */ 95 96 /* 97 ** Message header 98 */ 99 typedef struct 100 { 101 byte Signature[4]; /* <J><A><M> followed by <NUL> */ 102 word Revision; /* CURRENTREVLEV */ 103 word ReservedWord; /* Reserved */ 104 dword SubfieldLen; /* Length of subfields */ 105 dword TimesRead; /* Number of times message read */ 106 dword MsgIdCRC; /* CRC-32 of MSGID line */ 107 dword ReplyCRC; /* CRC-32 of REPLY line */ 108 dword ReplyTo; /* This msg is a reply to.. */ 109 dword Reply1st; /* First reply to this msg */ 110 dword ReplyNext; /* Next msg in reply chain */ 111 dword DateWritten; /* When msg was written */ 112 dword DateReceived; /* When msg was received/read */ 113 dword DateProcessed; /* When msg was processed by packer */ 114 dword MsgNum; /* Message number (1-based) */ 115 dword Attribute; /* Msg attribute, see "Status bits" */ 116 dword Attribute2; /* Reserved for future use */ 117 dword TxtOffset; /* Offset of text in text file */ 118 dword TxtLen; /* Length of message text */ 119 dword PasswordCRC; /* CRC-32 of password to access msg */ 120 dword Cost; /* Cost of message */ 121 } 122 JAMHDR, *JAMHDRptr; 123 124 #define HDR_SIZE (8 + (4 * 17)) 125 126 /* 127 ** Message header subfield types 128 */ 129 #define JAMSFLD_OADDRESS 0 130 #define JAMSFLD_DADDRESS 1 131 #define JAMSFLD_SENDERNAME 2 132 #define JAMSFLD_RECVRNAME 3 133 #define JAMSFLD_MSGID 4 134 #define JAMSFLD_REPLYID 5 135 #define JAMSFLD_SUBJECT 6 136 #define JAMSFLD_PID 7 137 #define JAMSFLD_TRACE 8 138 #define JAMSFLD_ENCLFILE 9 139 #define JAMSFLD_ENCLFWALIAS 10 140 #define JAMSFLD_ENCLFREQ 11 141 #define JAMSFLD_ENCLFILEWC 12 142 #define JAMSFLD_ENCLINDFILE 13 143 #define JAMSFLD_EMBINDAT 1000 144 #define JAMSFLD_FTSKLUDGE 2000 145 #define JAMSFLD_SEENBY2D 2001 146 #define JAMSFLD_PATH2D 2002 147 #define JAMSFLD_FLAGS 2003 148 #define JAMSFLD_TZUTCINFO 2004 149 #define JAMSFLD_UNKNOWN 0xffff 150 151 /* 152 ** Message header subfield 153 */ 154 155 typedef struct JAMSUBFIELD2struct 156 { 157 word LoID; 158 word HiID; 159 dword DatLen; 160 byte *Buffer; 161 } JAMSUBFIELD2, *JAMSUBFIELD2ptr; 162 163 typedef struct JAMSUBFIELD2LISTstruct 164 { 165 dword subfieldCount; 166 dword arraySize; 167 JAMSUBFIELD2 subfield[1]; 168 } JAMSUBFIELD2LIST, *JAMSUBFIELD2LISTptr; 169 170 typedef struct 171 { 172 word LoID; /* Field ID, 0 - 0xffff */ 173 word HiID; /* Reserved for future use */ 174 dword DatLen; /* Length of buffer that follows */ 175 byte Buffer[1]; /* DatLen bytes of data */ 176 } 177 JAMSUBFIELD1, *JAMSUBFIELD1ptr; 178 179 typedef struct 180 { 181 word LoID; /* Field ID, 0 - 0xffff */ 182 word HiID; /* Reserved for future use */ 183 dword DatLen; /* Length of buffer that follows */ 184 } 185 JAMBINSUBFIELD, *JAMBINSUBFIELDptr; 186 #define JAM_SF_HEADER_SIZE 8 187 /* 188 ** Message index record 189 */ 190 typedef struct 191 { 192 dword UserCRC; /* CRC-32 of destination username */ 193 dword HdrOffset; /* Offset of header in .JHR file */ 194 } 195 JAMIDXREC, *JAMIDXRECptr; 196 197 #define IDX_SIZE 8 198 199 /* 200 ** Lastread structure, one per user 201 */ 202 typedef struct 203 { 204 dword UserCRC; /* CRC-32 of user name (lowercase) */ 205 dword UserID; /* Unique UserID */ 206 dword LastReadMsg; /* Last read message number */ 207 dword HighReadMsg; /* Highest read message number */ 208 } 209 JAMLREAD, *JAMLREADptr; 210 211 typedef struct { 212 dword IdxOffset; /* Offset Idx file */ 213 dword TrueMsg; /* JAMIDXREC.HdrOffset */ 214 dword UserCRC; /* CRC-32 of user name (lowercase) */ 215 JAMHDR hdr; /* Message header */ 216 JAMSUBFIELD2LISTptr subfield; /* Message subfields */ 217 } JAMACTMSG, *JAMACTMSGptr; 218 219 /* struct jam base */ 220 221 typedef struct { 222 byte *BaseName; /* Path for message base */ 223 int HdrHandle; /* File handle for .JHR file */ 224 int TxtHandle; /* File handle for .JDT file */ 225 int IdxHandle; /* File handle for .JDX file */ 226 int LrdHandle; /* File handle for .JLR file */ 227 JAMHDRINFO HdrInfo; /* Message header info */ 228 JAMACTMSGptr actmsg; 229 word msgs_open; 230 word actmsg_read; /* ??? 0, 1 or 2; 0 of not read, 1 if header fit in core, 2 otherwise*/ 231 mode_t permissions; 232 word mode; 233 word modified; 234 MSGA *jm; 235 void *jbNext; 236 } JAMBASE, *JAMBASEptr; 237 238 HUSKYEXT int read_hdrinfo(int handle, JAMHDRINFO *HdrInfo); 239 HUSKYEXT int read_idx(int handle, JAMIDXREC *Idx); 240 HUSKYEXT int read_hdr(int handle, JAMHDR *Hdr); 241 HUSKYEXT int read_subfield(int handle, JAMSUBFIELD2LISTptr *subfield, dword *SubfieldLen); 242 HUSKYEXT int copy_subfield(JAMSUBFIELD2LISTptr *to, JAMSUBFIELD2LISTptr from); 243 244 HUSKYEXT int read_allidx(JAMBASEptr jmb); 245 246 HUSKYEXT int write_hdrinfo(int handle, JAMHDRINFO *HdrInfo); 247 HUSKYEXT int write_idx(int handle, JAMIDXREC *Idx); 248 HUSKYEXT int write_hdr(int handle, JAMHDR *Hdr); 249 HUSKYEXT int write_subfield(int handle, JAMSUBFIELD2LISTptr *subfield, dword SubfieldLen); 250 251 #endif /* __JAM_H__ */ 252 253 #ifdef __cplusplus 254 } 255 #endif 256 257