1 // This may look like C code, but it is really -*- C++ -*- 2 3 // ------------------------------------------------------------------ 4 // The Goldware Library 5 // Copyright (C) 1990-1999 Odinn Sorensen 6 // Copyright (C) 1999-2000 Alexander S. Aganichev 7 // ------------------------------------------------------------------ 8 // This library is free software; you can redistribute it and/or 9 // modify it under the terms of the GNU Library General Public 10 // License as published by the Free Software Foundation; either 11 // version 2 of the License, or (at your option) any later version. 12 // 13 // This library is distributed in the hope that it will be useful, 14 // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 // Library General Public License for more details. 17 // 18 // You should have received a copy of the GNU Library General Public 19 // License along with this program; if not, write to the Free 20 // Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 // MA 02111-1307, USA 22 // ------------------------------------------------------------------ 23 // $Id: gmojamm.h,v 1.6 2005/10/07 12:41:11 stas_degteff Exp $ 24 // ------------------------------------------------------------------ 25 // JAM msgbase definitions and structures. 26 // ------------------------------------------------------------------ 27 // This implementation is based on information in the document 28 // JAM-001, revision 001, dated 93-07-01 and the associated example 29 // "JAM API". Here is the JAM copyright notice: 30 // 31 // "JAM(mbp) - Copyright 1993 Joaquim Homrighausen, Andrew Milner, 32 // Mats Birch, Mats Wallin. 33 // ALL RIGHTS RESERVED." 34 // ------------------------------------------------------------------ 35 36 37 // ------------------------------------------------------------------ 38 // Only include once! 39 40 #ifndef __GM_JAMM_H 41 #define __GM_JAMM_H 42 43 44 // ------------------------------------------------------------------ 45 46 #include <gmoarea.h> 47 48 49 // ------------------------------------------------------------------ 50 51 #if defined(GOLD_CANPACK) 52 #pragma pack(1) 53 #endif 54 55 56 // ------------------------------------------------------------------ 57 // JAM constants 58 59 #define JAM_REVISION 1 60 #define JAM_SIGNATURE "JAM\0" 61 #define JAM_MAXDATLEN 100 62 63 64 // ------------------------------------------------------------------ 65 // Message status bits 66 67 #define JAMATTR_LOCAL 0x00000001L // Msg created locally 68 #define JAMATTR_INTRANSIT 0x00000002L // Msg is in-transit 69 #define JAMATTR_PRIVATE 0x00000004L // Private 70 #define JAMATTR_READ 0x00000008L // Read by addressee 71 #define JAMATTR_SENT 0x00000010L // Sent to remote 72 #define JAMATTR_KILLSENT 0x00000020L // Kill when sent 73 #define JAMATTR_ARCHIVESENT 0x00000040L // Archive when sent 74 #define JAMATTR_HOLD 0x00000080L // Hold for pick-up 75 #define JAMATTR_CRASH 0x00000100L // Crash 76 #define JAMATTR_IMMEDIATE 0x00000200L // Send Msg now, ignore restrictions 77 #define JAMATTR_DIRECT 0x00000400L // Send directly to destination 78 #define JAMATTR_GATE 0x00000800L // Send via gateway 79 #define JAMATTR_FILEREQUEST 0x00001000L // File request 80 #define JAMATTR_FILEATTACH 0x00002000L // File(s) attached to Msg 81 #define JAMATTR_TRUNCFILE 0x00004000L // Truncate file(s) when sent 82 #define JAMATTR_KILLFILE 0x00008000L // Delete file(s) when sent 83 #define JAMATTR_RECEIPTREQ 0x00010000L // Return receipt requested 84 #define JAMATTR_CONFIRMREQ 0x00020000L // Confirmation receipt requested 85 #define JAMATTR_ORPHAN 0x00040000L // Unknown destination 86 #define JAMATTR_ENCRYPT 0x00080000L // Msg text is encrypted 87 #define JAMATTR_COMPRESS 0x00100000L // Msg text is compressed 88 #define JAMATTR_ESCAPED 0x00200000L // Msg text is seven bit ASCII 89 #define JAMATTR_FPU 0x00400000L // Force pickup 90 #define JAMATTR_TYPELOCAL 0x00800000L // Msg is for local use only (not for export) 91 #define JAMATTR_TYPEECHO 0x01000000L // Msg is for conference distribution 92 #define JAMATTR_TYPENET 0x02000000L // Msg is direct network mail 93 #define JAMATTR_NODISP 0x20000000L // Msg may not be displayed to user 94 #define JAMATTR_LOCKED 0x40000000L // Msg is locked, no editing possible 95 #define JAMATTR_DELETED 0x80000000L // Msg is deleted 96 97 98 // ------------------------------------------------------------------ 99 // Message header subfield types 100 101 #define JAMSUB_OADDRESS 0 102 #define JAMSUB_DADDRESS 1 103 #define JAMSUB_SENDERNAME 2 104 #define JAMSUB_RECEIVERNAME 3 105 #define JAMSUB_MSGID 4 106 #define JAMSUB_REPLYID 5 107 #define JAMSUB_SUBJECT 6 108 #define JAMSUB_PID 7 109 #define JAMSUB_TRACE 8 110 #define JAMSUB_ENCLOSEDFILE 9 111 #define JAMSUB_ENCLOSEDFILEWALIAS 10 112 #define JAMSUB_ENCLOSEDFREQ 11 113 #define JAMSUB_ENCLOSEDFILEWCARD 12 114 #define JAMSUB_ENCLOSEDINDIRECFILE 13 115 #define JAMSUB_EMBINDAT 1000 116 #define JAMSUB_FTSKLUDGE 2000 117 #define JAMSUB_SEENBY2D 2001 118 #define JAMSUB_PATH2D 2002 119 #define JAMSUB_FLAGS 2003 120 #define JAMSUB_TZUTCINFO 2004 121 122 #define JAMSUB_OADDRESS_LEN 100 123 #define JAMSUB_DADDRESS_LEN 100 124 #define JAMSUB_SENDERNAME_LEN 100 125 #define JAMSUB_RECEIVERNAME_LEN 100 126 #define JAMSUB_MSGID_LEN 100 127 #define JAMSUB_REPLYID_LEN 100 128 #define JAMSUB_SUBJECT_LEN 100 129 #define JAMSUB_PID_LEN 40 130 #define JAMSUB_TRACE_LEN ((uint32_t)(-1)) 131 #define JAMSUB_ENCLOSEDFILE_LEN ((uint32_t)(-1)) 132 #define JAMSUB_ENCLOSEDFILEWALIAS_LEN ((uint32_t)(-1)) 133 #define JAMSUB_ENCLOSEDFREQ_LEN ((uint32_t)(-1)) 134 #define JAMSUB_ENCLOSEDFILEWCARD_LEN ((uint32_t)(-1)) 135 #define JAMSUB_ENCLOSEDINDIRECFILE_LEN ((uint32_t)(-1)) 136 #define JAMSUB_EMBINDAT_LEN ((uint32_t)(-1)) 137 #define JAMSUB_FTSKLUDGE_LEN 255 138 #define JAMSUB_SEENBY2D_LEN ((uint32_t)(-1)) 139 #define JAMSUB_PATH2D_LEN ((uint32_t)(-1)) 140 #define JAMSUB_FLAGS_LEN ((uint32_t)(-1)) 141 #define JAMSUB_TZUTCINFO_LEN ((uint32_t)(-1)) 142 143 144 // ------------------------------------------------------------------ 145 // .JHR file header 146 147 struct JamHdrInfo { 148 149 char signature[4]; // <J><A><M> followed by <NUL> 150 time32_t datecreated; // Creation date 151 uint32_t modcounter; // Update counter 152 uint32_t activemsgs; // Number of active (not deleted) msgs 153 uint32_t passwordcrc; // CRC-32 of password to access 154 uint32_t basemsgnum; // Lowest message number in index file 155 uint32_t highwatermark; // Number of the last msg scanned 156 byte reserved[996]; // Reserved space 157 }; 158 159 160 // ------------------------------------------------------------------ 161 // .JHR message headers 162 163 struct JamHdr { 164 165 char signature[4]; // <J><A><M> followed by <NUL> 166 word revision; // Revision level of header 167 word reservedword; // Reserved for future use 168 uint32_t subfieldlen; // Length of subfields 169 uint32_t timesread; // Number of times message read 170 uint32_t msgidcrc; // CRC-32 of MSGID line 171 uint32_t replycrc; // CRC-32 of REPLY line 172 uint32_t replyto; // This msg is a reply to.. 173 uint32_t reply1st; // First reply to this msg 174 uint32_t replynext; // Next msg in reply chain 175 time32_t datewritten; // When msg was written 176 time32_t datereceived; // When msg was read by recipient 177 time32_t dateprocessed; // When msg was processed by tosser/scanner 178 uint32_t messagenumber; // Message number (1-based) 179 uint32_t attribute; // Msg attribute, see "Msg Attributes" 180 uint32_t attribute2; // Reserved for future use 181 uint32_t offset; // Offset of text in ????????.JDT file 182 uint32_t txtlen; // Length of message text 183 uint32_t passwordcrc; // CRC-32 of password to access message 184 uint32_t cost; // Cost of message 185 }; 186 187 188 // ------------------------------------------------------------------ 189 // .JHR subfield headers 190 191 struct JamSubFieldHdr { 192 193 word loid; // Field ID, 0-65535 194 word hiid; // Reserved for future use 195 uint32_t datlen; // Length of buffer that follows 196 }; 197 198 199 // ------------------------------------------------------------------ 200 // .JHR subfields 201 202 struct JamSubField { 203 204 word loid; // Field ID, 0-65535 205 word hiid; // Reserved for future use 206 uint32_t datlen; // Length of buffer that follows 207 char buffer[101]; // DATLEN bytes of data 208 }; 209 210 211 // ------------------------------------------------------------------ 212 // .JDX message index 213 214 struct JamIndex { 215 216 dword usercrc; // CRC-32 of destination username 217 uint32_t hdroffset; // Offset of header in .JHR file 218 }; 219 220 221 // ------------------------------------------------------------------ 222 // .JLR lastread records 223 224 struct JamLast { 225 226 dword usercrc; // CRC-32 of user name (lowercase) 227 dword userid; // Unique UserID 228 dword lastread; // Last read message number 229 dword highread; // Highest read message number 230 }; 231 232 233 // ------------------------------------------------------------------ 234 235 #if defined(GOLD_CANPACK) 236 #pragma pack() 237 #endif 238 239 240 // ------------------------------------------------------------------ 241 242 struct JamData { 243 int fhjhr; 244 int fhjdt; 245 int fhjdx; 246 int fhjlr; 247 int fhjhw; // highwater if available 248 int islocked; // Area is locked? 249 int timesposted; 250 int32_t lastpos; // Lastread position 251 int32_t highwater; 252 JamLast lastrec; // .JLR Lastread record 253 JamHdrInfo hdrinfo; // .JHR Header info record 254 }; 255 256 257 // ------------------------------------------------------------------ 258 259 struct JamWide { 260 dword usercrc; 261 dword userid; 262 int lookreplies; 263 const char* jampath; 264 int harddelete; 265 int smapihw; 266 }; 267 268 269 // ------------------------------------------------------------------ 270 271 class JamArea : public gmo_area { 272 273 protected: 274 275 JamData* data; 276 JamWide* wide; 277 278 int just_scanning; 279 280 void data_open(); 281 void data_close(); 282 283 void open_area(); 284 285 void raw_open(); 286 void raw_close(); 287 288 void save_lastread(); 289 290 int test_open(const char* file); 291 292 void raw_scan(int __keep_index, int __scanpm=false); 293 294 int load_message(int __mode, gmsg* __msg, JamHdr& __hdr); 295 296 void add_subfield(JamHdr& __hdr, byte*& __subfield, word __loid, word __hiid, char* __data, uint32_t maxlen); 297 298 void save_message(int __mode, gmsg* __msg, JamHdr& __hdr); 299 300 public: 301 JamArea()302 JamArea() { wide = NULL; data = NULL; just_scanning = false; } ~JamArea()303 virtual ~JamArea() {} 304 issoftdelete()305 virtual bool issoftdelete() const { return (wide != NULL) ? not wide->harddelete : true; } 306 307 // ---------------------------------------------------------------- 308 // Messagebase member functions 309 310 void open(); 311 void close(); 312 313 void suspend(); 314 void resume(); 315 316 void lock(); 317 void unlock(); 318 319 void scan(); 320 void scan_area(); 321 void scan_area_pm(); 322 323 int load_hdr(gmsg* msg); 324 int load_msg(gmsg* msg); 325 326 void save_hdr(int mode, gmsg* msg); 327 void save_msg(int mode, gmsg* msg); 328 329 void del_msg(gmsg* msg); 330 331 void new_msgno(gmsg* msg); 332 char* user_lookup(char* lookfor); 333 int renumber(); 334 335 void update_timesread(gmsg* msg); 336 337 Line* make_dump_msg(Line*& lin, gmsg* msg, char* lng_head); 338 }; 339 340 341 // ------------------------------------------------------------------ 342 343 extern JamWide* jamwide; 344 extern JamData* jamdata; 345 extern int jamdatano; 346 347 348 // ------------------------------------------------------------------ 349 350 char *jamstrlwr(char *str); 351 352 353 // ------------------------------------------------------------------ 354 355 #endif 356 357 // ------------------------------------------------------------------ 358 359