1 /*****************************************************************************/ 2 /* */ 3 /* (C) Copyright 1991-1997 Alberto Pasquale */ 4 /* */ 5 /* A L L R I G H T S R E S E R V E D */ 6 /* */ 7 /*****************************************************************************/ 8 /* */ 9 /* This source code is NOT in the public domain and it CANNOT be used or */ 10 /* distributed without written permission from the author. */ 11 /* */ 12 /*****************************************************************************/ 13 /* */ 14 /* How to contact the author: Alberto Pasquale of 2:332/504@fidonet */ 15 /* Viale Verdi 106 */ 16 /* 41100 Modena */ 17 /* Italy */ 18 /* */ 19 /*****************************************************************************/ 20 21 // BbsGenLb.Hpp 101 22 23 #ifndef BBSGENLB_HPP 24 #define BBSGENLB_HPP 25 26 27 #include <stdio.h> 28 #include <time.h> 29 30 31 #if defined (__OS2__) 32 #include <os2def.h> 33 #elif defined (__NT__) 34 #include <windows.h> 35 #else 36 #define TRUE 1 37 #define FALSE 0 38 typedef int BOOL; 39 #endif 40 41 #include <smapi/msgapi.h> 42 43 #include <newarea.h> 44 #include <limits.h> 45 46 #pragma pack (1) 47 48 typedef NETADDR ADR; 49 50 51 // Implementation in Fview.Cpp 52 53 54 typedef void (*VShow) (char *strfmt, ...); 55 56 int fview (char *filename, VShow vshow); 57 58 // filename is an archive full filename 59 // sc is a function that must be called to output 60 // each and every line of the content 61 // returns 0 on success 62 63 64 // Implementation in StrLst.Cpp 65 66 // for EchoToss.Log or FileChng.Log 67 // Generates a file with a list of strings 68 69 // Use Add for each string to be listed. 70 // Use Close when completed. 71 // The OutFile will be deleted if Append = FALSE 72 // and no Add done. 73 74 // Nothing will be output if no default OutName and no OutNameCfg 75 // is found. 76 77 class StrLst { 78 private: 79 char *OutNameCfg; 80 char *OutName; // output file name 81 BOOL Append; 82 FILE *Outf; 83 public: 84 StrLst (char *OutNameCfg, BOOL Append = FALSE, char *OutName = NULL); 85 // OutNameCfg is the name of the config statement 86 // that specifies the name of the output file. 87 // Append: TRUE if the output must be appended. 88 // When Append == FALSE, a '+' sign as the first 89 // character of the outfilename will set 90 // Append = TRUE anyway. 91 // OutName specifies a default for OutName, in the case 92 // no OutNameCfg is encountered. 93 ~StrLst (void); 94 void SetDefCfg (char *OutName); 95 // Sets default values, in the case cfg statements are not 96 // found. Can be issued any time before Add. 97 // Useless if already set in StrLst constructor. 98 BOOL ParseCfg (const char *clnline); 99 // Parses clnline in search for a cfg statement 100 // clnline must be a line with: 101 // - comments removed 102 // - no terminating spaces 103 // - no terminating newline 104 // - no tabs 105 // returns TRUE when cfg line recognized 106 int Add (const char *tag); 107 // Adds tag to the output list 108 // returns 0 on success 109 int Close (void); 110 // returns 0 on success 111 }; 112 113 114 // Implementation in OutWrap.Cpp 115 116 // To output with left/right justification: e.g. for descriptions 117 118 // The cfg statement "<WrapCfg> [<indent> [<right>]]" allows to specify 119 // the indentation for 2nd and up lines and the maximum right column. 120 // When the statement is not found, wrap is disabled. 121 // <indent> defaults to 0, <right> to 79. 122 123 // Newlines '\n' in source are recognized as line separators. 124 125 typedef int (*OWShow) (const char *line, void *prm); 126 127 // Is called for each line to output. 128 // line does not contain trailing newline. 129 // prm can be used to pass some parameter. 130 // Must return 0 on success. 131 132 #define OWcfgFound 0 // for ParseCfg 133 #define OWcfgNotFound 1 134 #define OWcfgError -1 135 #define OWcfgDupe -2 136 137 138 class OutWrap { 139 private: 140 char *WrapCfg; // name of the cfg statement for wrap specs 141 BOOL CfgDone; // Cfg statement already found 142 int wrapcol, // blank columns at left (-1 = no wrapping) 143 wrapend; // tot # of columns 144 char *LineBuf; // buffer for line to be output 145 int fwrap (const char *src, int begin, OWShow ows, void *prm); 146 // return bytes written from b, EOF on error 147 148 public: 149 OutWrap (const char *WrapCfg); 150 ~OutWrap (); 151 int ParseCfg (const char *clnline); 152 // Parses clnline in search for a cfg statement 153 // clnline must be a line with: 154 // - comments removed 155 // - no terminating spaces 156 // - no terminating newline 157 // - no tabs 158 // returns OWcfgFound on statement found 159 // OWcfgNotFound on statement not found 160 // OWcfgError on error in statement 161 // OWcfgDupe on dupe statement 162 int Out (const char *source, OWShow ows, void *prm = NULL); 163 // source is the string to be output, no trailing newline 164 // ows is a pointer to a function of type OWShow. 165 // prm is pointer to optional parameters. 166 // Returns 0 on success. 167 }; 168 169 // Implementation in SqTagPat.Cpp 170 171 // Class to convert a Squish TAG to the path and type of area. 172 173 struct _SqTagSearch { 174 const char *Tag; // pointer to area TAG in cfg data (input) 175 char **Path; // pointer to path pointer (must be allocated and assigned) 176 word *Type; // pointer to area type in cfg data (to be assigned) 177 ADR *adr; // pointer to adr in cfg data or NULL 178 char **origin; // pointer to origin pointer or NULL 179 dword *attr; // pointer to attributes or NULL 180 _SqTagSearch *next; 181 }; 182 183 184 typedef void (*CharPVoid) (const char *); // to be invoked for each Tag 185 // that is not found ! 186 187 class SqTag2Path { 188 private: 189 _SqTagSearch *sqhead; 190 _SqTagSearch **sqtail; 191 ADR *primary; 192 int parsesq (char *linebuf, char *echotag, char *path, word *type, 193 ADR *adr); 194 public: 195 SqTag2Path (); 196 ~SqTag2Path (); 197 void AddTag (const char *Tag, char **Path, word *Type, ADR *adr = NULL, 198 char **origin = NULL, dword *attr = NULL); 199 // Tag: input tag 200 // Path: pointer to char * to be assigned; 201 // *Path must be NULL !!!! 202 // Type: pointer to word to be assigned; 203 // specifies Squish/SDM and ECHO. 204 // Path and Type will be assigned by ParseSquish. 205 // *adr is filled with the primary address found in 206 // SquishCfg (including -p<adr> override) 207 // *origin is set NULL for netmail areas 208 // *attr is set to P for netmail areas; 209 // The setting of the Local flag is up to the application. 210 int ParseSquishCfg (char *SquishCfg, CharPVoid sqtnf = NULL); 211 // Squish's "Include" Statement supported 212 // 0 on SquishCfg successfully accessed. 213 // -1 on SquishCfg not found 214 // -2 on Error in SquishCfg (no Address) 215 }; 216 217 218 // Implementation in Misc.Cpp 219 220 // for flags, bitwise 221 #define MSC_SrcMov 0x01 // advance input char ptr 222 #define MSC_Allow_NoLevel 0x02 // Allow "/<keys>", w no <level> 223 224 225 #define MSC_AcsStrSize 39 // space for <level>/<keys> 226 227 228 int strto4Dadr (const char *&adrs, ADR *adr); 229 230 // adrs is a pointer to a 4D address string that must not necessarily 231 // be terminated just after the address specification; 232 // spaces and tabs are allowed before the address; space, tab, newline, 233 // @ are allowed after the address. 234 // adr is a pointer to a 4D address. 235 // Returns the number of characters parsed, space included and optionally 236 // advances adrs to first non-space character (MSC_SrcMov flag). 237 // Returns -1 on illegal or not full address (*adr unchanged, adrs not moved). 238 239 240 bool eq4Dadr (const ADR *adr1, const ADR *adr2); 241 242 // returns true if *adr1==*adr2 243 244 245 int GetLevKey (const char *&src, word *level, dword *keys = NULL, byte flags = 0); 246 247 // Gets a <level>[/<keys>] combination. 248 // src points to a string, with possible leading blanks. 249 // level will contain the found numerical level. 250 // keys, if !NULL, will contain the found keys (1..8,A..X), 251 // case is not significant, keys MUST be !NULL if /<keys> is present. 252 // Following space is skipped. 253 // Returns the number of characters parsed, space included and optionally 254 // advances src to first non-space character (MSC_SrcMov flag). 255 // If MSC_Allow_NoLevel, "/<keys>" is legal and level assumed USHRT_MAX. 256 // Returns -1 if no valid entry found (src not moved). 257 258 void PrintLevKey (char *buffer, word level, dword keys); 259 260 // Prints "<level>[/<keys>]" in buffer. 261 // Buffer must be MSC_AcsStrSize. 262 263 264 BOOL TagMatch (const char *Tag, const char *WildTag); 265 266 // Compares Tag with the WildTag (which can contain OS/2 wildcards). 267 // Special tags beginning with '<' must get an exact match (no wildcards). 268 269 270 char Ibm2Ascii (char c); 271 272 // Changes codes 0-255 to 0-127 273 274 275 // Implementation in AreaDat.Cpp 276 277 // class to handle Max 3.00 FAREA.DAT 278 279 #define FAD_OVR_MAX 100 // max number of command overrides per area 280 #define FAD_HEAP_SIZE 0x4000 // max size of string heap 281 // In case of excess, NextArea returns NULL 282 283 // For NextArea 284 #define FAD_Normal 0x0000 // Get all entries, BegDiv/EndDiv included 285 #define FAD_AreasOnly 0x0001 // Skip BegDiv/EndDiv entries 286 287 288 // WARNING: the returned fahp and filesbbs ptr points to "STATIC" areas ! 289 // When a new area is loaded, the previous fahp/filesbbs info is overwritten. 290 291 292 class FAREADAT { 293 private: 294 char *fareaname; 295 FILE *f; 296 FAH *fahp; 297 FAH *LoadArea (); 298 word arean; 299 char *filesbbsbuf, *filesbbsptr; 300 public: 301 FAREADAT (); 302 ~FAREADAT (); 303 int OpenFAreaDat (const char *FAreaDat); 304 // prepare to operate on FAreaDat 305 // return 0 on success 306 // -1: can't open, -2: short 307 // -3: ID mismatch 308 // FAreaDat: .DAT optional 309 FAH *NextArea (int act = FAD_Normal); 310 // return PFAH for next area, NULL if none 311 FAH *Area (word num); 312 // return PFAH for area #num, NULL if none or division 313 FAH *Area (const char *name); 314 // return PFAH for area tag "name", NULL if none or division 315 word AreaNum (); // return current areanum 316 char *filesbbs (); // return full name of filesbbs for current area 317 }; 318 319 320 // Implementation in MaxPrm.Cpp 321 322 #include <prm.h> 323 324 #define MaxPRM(p,s) (p->prmheap+(p->prm->s)) 325 326 class MAXPRM { 327 private: 328 byte *buffer; 329 public: 330 m_pointers *prm; 331 char *prmheap; 332 MAXPRM (); 333 ~MAXPRM (); 334 int Read (char *prmname); // returns 0 on success 335 // prmname can have or not .PRM ext 336 }; 337 338 339 // Implementation in MaxAcs.Cpp 340 341 class MAXACS { 342 private: 343 byte *buffer; // pointer to allocated array 344 char *heap; // pointer to string heap 345 word usn; // number of user classes 346 word ussize; // size of each class record 347 byte *uscl1; // pointer to first user class record 348 349 int GetGenAcs (char *lks, word *level, dword *keys1, dword *keys0 = NULL); 350 // Gets level and keys1/keys0 from lks. 351 // keys0 are the negated keys. 352 // lks is <level>[/<keys>] 353 // If keys0 is NULL, error is returned 354 // in the case of negated '!' keys. 355 // If keys1 is NULL, keys are not checked. 356 // Returns 0 on success. 357 BOOL TokAcs (char *TokAcs, word level, dword keys); 358 // TokAcs is a single access string 359 // (no & | operators). 360 // returns TRUE if level/keys grants 361 // access to TokAcs 362 BOOL ProdAccess (char *pac, word level, dword keys); 363 // pac is a series of access strings 364 // separated by the '&' operator. 365 // No '|' operator permitted. 366 int GetLevel (char *slevel, word *level); 367 // looks for slevel in access.dat 368 // and stores the numeric value in level 369 // returns 0 on success 370 public: 371 MAXACS (); 372 ~MAXACS (); 373 int Read (char *acsname); // returns 0 on success 374 // acsname can have or not .DAT ext 375 int GetAcs (char *ACS, word *level, dword *keys = NULL); 376 // Gets level and keys for a 377 // user access string. 378 // If keys is NULL, keys are not 379 // checked. 380 // returns 0 on success 381 char *LevName (word level); // returns pointer to class name 382 // or NULL if level is not equal 383 // to a defined class level. 384 char *LevStr (word level); // returns pointer to class name 385 // or to static string with numeric 386 // level value. 387 BOOL HaveAccess (char *ACS, word level, dword keys); 388 // returns TRUE if level and keys 389 // give access to an object of ACS. 390 // "name=<s>" and "alias=<s>" 391 // do not give access. 392 // | and & permitted 393 }; 394 395 396 // Implementation in ComprCfg.Cpp 397 398 399 class AH_Archiver { 400 private: 401 int identofs; // offset of identity string; -2 = last char 402 int identlen; // length of identity string 403 byte *identstr; // identity string (can contain 00) 404 char *addcmd; // command to add files (with %a %f) 405 char *extcmd; // command to extract files (with %a %f) 406 const class AH_Archiver *prev; // pointer to previous Archiver definition 407 public: 408 char *name; // name of archiver 409 char *ext; // typical extension 410 AH_Archiver (const class AH_Archiver *aptr); // constructor 411 412 friend class AH_ComprCfg; 413 }; 414 415 // for AH_VShow 416 #define AH_MT_Action 0 417 #define AH_MT_Info 1 418 #define AH_MT_Warning 2 419 #define AH_MT_Error 3 420 421 typedef void (*AH_VShow) (byte msgtype, char *strfmt, ...); 422 // function type to be used for output 423 424 425 class AH_ComprCfg { 426 private: 427 static AH_VShow outf; 428 static void RcShow (int code, ...); // for RunCmd 429 430 AH_Archiver *lastarc; // pointer to last Archiver definition 431 void ScanIdent (const char *tok); // Scans Ident string 432 BOOL ArcGood (const AH_Archiver *a); // is a good for sfx detection ? 433 const AH_Archiver *SfxNext (const AH_Archiver *a); // finds next arc good for sfx 434 const AH_Archiver *ChkSfx (const char *filename); // Checks if Sfx 435 436 public: 437 AH_ComprCfg (const char *cfgfile, // compress.cfg file 438 AH_VShow outf = NULL); // output function pointer 439 // is stored as static ! 440 int UnArc (const char *filename, // archive name 441 const char *extract); // extract template 442 // returns errorlevel 443 // -1 on error 444 // -2 unknown archiver 445 // -3 file not found 446 int Arc (const AH_Archiver *a, // archiver to be used 447 const char *filename, // archive name 448 const char *add); // template for add 449 // returns errorlevel or -1 on error 450 const AH_Archiver *AddDefined (const char *method); // is (compr) method defined in cfg ? 451 const AH_Archiver *ExtDefined (const char *ext); // is extension defined in compress.cfg ? 452 }; 453 454 455 // Implementation in Fbbs.Cpp 456 457 // The description is always null terminated and with no terminating '\n'. 458 // The '\n' character is used to separate multiple lines. 459 // It's possible that a '\n' is present at the end of the description if 460 // the description terminates with an empty line. 461 462 // Comment line if: 463 // - empty 464 // - starting ctrl characters 465 // - starting space 466 // - starting '-' and then a space or tab 467 // - starting high ascii (>127) 468 469 470 typedef BOOL (*SkipFile) (const char *file, void *ptr); 471 472 // Function type for function to be used by GetEntry/GetGenEntry to 473 // establish whether the file entry must be removed or not. 474 475 476 // FBBS.fbbsflags 477 478 #define FBBS_FLAG_NODATESIZE 0x8000 // date and size NOT used 479 #define FBBS_FLAG_NOCONTSPACE 0x4000 // no space after cont. char 480 481 #define FBBS_FLAG_DATEFORMAT 0x0003 // mask for date format 482 #define FBBS_FLAG_DATE_USA 0x0000 483 #define FBBS_FLAG_DATE_EURO 0x0001 484 #define FBBS_FLAG_DATE_JAPAN 0x0002 485 #define FBBS_FLAG_DATE_SCIENT 0x0003 486 487 488 // ATTENTION: when date&size is used, 489 // the functions that read the files.bbs use the first two tokens 490 // after the filename as date and size !!! 491 492 // When FBBS_FLAG_NODATESIZE -> date = 0, size = ULONG_MAX. 493 494 495 // for GetEntry first 496 497 #define FBBS_GE_FIRST TRUE 498 #define FBBS_GE_NEXT FALSE 499 500 // for GetDesc action (bitwise) 501 502 #define FBBS_REMOVE 0x01 503 504 // flag, besides FB.H 505 506 #define FF_SAFE 0x8000 // no Trojan check to be performed 507 // Input for PutGenEntry/SetDesc 508 509 510 class FBBS { 511 private: 512 char filesbbs[PATH_MAX]; // full name of file list 513 int filesize, // size of buffer for returned file 514 descsize, // size of buffer for returned description 515 linesize; // size of files.bbs line buffer 516 char cont; // continuation char 517 int cpos; // column for cont. char, zero based, -1 for disable 518 word fbbsflags; // flags 519 520 SkipFile sf; // Function pointer: if !NULL, Get(Gen)Entry 521 // removes entry if sf is TRUE. 522 void *ptr; // To be passed to ptr. 523 524 FILE *t; // Stream used by GetGenEntry when sf. 525 // NULL when closed. 526 FILE *f; // stream for filesbbs, NULL when closed. 527 int fileh; // write handle for filesbbs, -1 when closed. 528 529 char *line; // Pointer to line buffer. 530 531 BOOL repeatln; // True when line must be got by 532 // Fgetln again. 533 char *lastget; // result of last Fgetln 534 char *Fgetln (); // Loads line with next line of text (as fgets), 535 // returns line or NULL if EOF. 536 int descopy (const char *p = NULL, // points after filename 537 char *desc = NULL, // where to copy description 538 word *flag = NULL, // where to store flags 539 time_t *date = NULL, // optional date 540 dword *size = NULL, // optional size 541 FILE *t = NULL // where to copy the lines 542 ); 543 // copies description (even multi-line) for file 544 // present in current line. 545 // returns 0 on success 546 int descAddLine (const char *p, // pointer to begin of desc line 547 char *desc, // pointer to return desc buffer 548 int desclen); // current length of desc 549 // Appends a new line, preceded by '\n' 550 // Returns the new length of desc 551 // Does not exceed descsize 552 void RdClose (); // close f. 553 int WrOpen (); // prepare fileh for append. 0 on success. 554 555 556 public: 557 FBBS (const char *path, // path must terminate by '\' (files.bbs assumed) 558 // or contain the full filelist name. 559 int filesize, // size of buffer for returned file 560 int descsize, // size of buffer for returned description 561 // (maybe multi-line) or comment (1 line). 562 int linesize = 1024, // size of files.bbs line buffer 563 char cont = ' ', // continuation character 564 int cpos = 31, // Column where to put the cont char., 0..78, 565 // if cont == ' ' the range is 1..78 566 // If cpos == -1, the multi-line description 567 // handling is disabled. 568 // While reading, cpos is not used if cont != ' ', 569 // otherwise the continued description line MUST 570 // start at pos (possibly with heading space). 571 // While writing, if cont != ' ' the following is 572 // written starting at cpos: cont, ' ', desc; 573 // otherwise desc is written starting at cpos. 574 // While writing with cpos == -1, only the 575 // first line of a multi-line description 576 // is output, following ones are ignored. 577 word fbbsflags = FBBS_FLAG_NODATESIZE, // default flags 578 SkipFile sf = NULL, // optional function pointer to remove 579 // some entries from files.bbs with 580 // Get(Gen)Entry. 581 void *ptr = NULL // To be passed to sf. 582 ); 583 ~FBBS (); 584 int GetDesc (const char *file, // file to be searched for 585 char *desc = NULL, // destination buffer 586 word *flag = NULL, // optional flags (/t /b) 587 byte action = 0, // 588 const char *repl = NULL, // Optional additional file(s) 589 // which description must be removed 590 // *repl == '\0' is acceptable. 591 // If equal to file, it's ignored. 592 // In the case of multiple file names, 593 // they are separated by space. 594 time_t *date = NULL, // optional date 595 dword *size = NULL // optional size 596 ); 597 // the description is returned into desc, 598 // it's always zero terminated 599 // it can contain '\n' in case of multiple lines. 600 // if FBBS_REMOVE, the description for file is 601 // removed from the files.bbs 602 // Return: -2 file list not found 603 // -1 on error 604 // 0 All Ok 605 // 1 file entry not found 606 // 2 NO repl entry found 607 // 3 both entries not found 608 // 609 // If file not found: 610 // *flag = 0, *date = 0, *size = ULONG_MAX 611 612 int SetDesc (const char *file, // file to be appended to files.bbs 613 const char *desc, // description, null terminated 614 word flag = 0, // optional flags (/t /b) 615 const char *befdesc = NULL,// optional header 616 time_t date = 0, // optional date for FA_LISTDATE 617 dword size = 0 // optional size for FA_LISTDATE 618 ); // the desc is appended, no check for already 619 // existent entry (you must use GetDesc). 620 // desc can be multi-line ('\n' as separator). 621 // The continuation character and position 622 // specified in the constructor are used. 623 // The appended line does not exceed linesize. 624 // If file is empty or NULL, desc is output 625 // as a comment line. 626 // Returns 0 on success 627 // Trojan (control) characters are substituted with space 628 // (in the original desc buffer) 629 630 int PutGenEntry (const char *file, 631 const char *desc, 632 word flag = 0, 633 const char *befdesc = NULL, 634 time_t date = 0, 635 dword size = 0); 636 // as SetDesc, but file is not closed. 637 // Suitable for multiple appends. 638 639 int WrClose (); // close fileh. 0 on success. 640 // Not really necessary, but useful to check 641 // for write errors after PutGenEntry. 642 643 int RdOpen (); // prepare f for reading from begin. 0 on success. 644 // Usually not necessary, but useful to restart 645 // f from begin when you want to use Get(Gen)Entry 646 // with no FBBS_GE_FIRST and f is already open. 647 648 int GetEntry (char *file, // file name returned 649 char *desc, // description returned 650 word *flag = NULL, // optional flags returned 651 BOOL first = FBBS_GE_NEXT, // get first/next 652 // next is valid also after GetDesc with 653 // repl==NULL and no REMOVE action 654 time_t *date = NULL, // optional date for FA_LISTDATE 655 dword *size = NULL // optional size for FA_LISTDATE 656 ); // returns 657 // -1 error 658 // 0 while entry is available 659 // 1 no more entries 660 // 3 on entry removed 661 662 // If file not found: 663 // *flag = 0, *date = 0, *size = ULONG_MAX 664 665 // If sf is passed to FBBS, GetEntry must be invoked 666 // until no more entries are available, otherwise 667 // the files.bbs remains unchanged. 668 // If GetEntry restarts from first, the status 669 // is reset. 670 // If first = FBBS_GE_NEXT and f is not open, 671 // then a FBBS_GE_FIRST is assumed. 672 673 int GetGenEntry (char *file, // file name returned, empty if comment 674 char *desc, // description or comment line returned 675 word *flag = NULL, // optional flags returned 676 BOOL first = FBBS_GE_NEXT, // get first/next 677 // next is valid also after GetDesc with 678 // repl==NULL and no REMOVE action 679 time_t *date = NULL, // optional date for FA_LISTDATE 680 dword *size = NULL // optional size for FA_LISTDATE 681 ); // returns 682 // -1 error 683 // 0 on file entry 684 // 1 no more entries 685 // 2 on comment line 686 // 3 on entry removed 687 // same as GetEntry but also returns comment lines: 688 // 2 as return value, empty file and comment in desc. 689 690 int Trunc (); // Truncates f, 0 on success. 691 }; 692 693 694 word Max2FbbsDateStyle ( // converts date_style to FBBS_FLAG* 695 sword date_style // as in max.prm 696 ); 697 698 699 // Implementation in SqNetScn.Cpp 700 701 // Class to handle scan of a a netmail area via Squish MSGAPI. 702 // In the case of Squish base, if sav is given, a pointer to the last 703 // scanned message is saved in "area.<sav>" and used to scan new 704 // messages only. 705 // The area is Locked. 706 707 // It is assumed that the MsgApi are Opened and Closed externally. 708 709 #define SQNS_Get_SkipRead 0x01 // Skip msgs marked as read 710 711 712 class SqNetScan { 713 714 private: 715 char savfilename[PATH_MAX]; // name of the file for 716 // stored data (last msg ptr). 717 // Empty when none applicable 718 // (SDM or sav not given). 719 word areatype; // MSGTYPE_SDM or MSGTYPE_SQUISH 720 word areazone; // Primary (default) zone. 721 HAREA harea; // Handle of area, NULL when none. 722 UMSGID hwmID; // ID of last scanned message. 723 UMSGID highID; // ID of last message to be scanned. 724 HMSG hmsg; // current msg handle (NULL when none). 725 726 public: 727 728 SqNetScan (); // Constructor. 729 730 HAREA Open (const char *path, // path of netmail area. 731 // Backslash terminated when SDM. 732 word type, // MSGTYPE_SDM or MSGTYPE_SQUISH. 733 word defzone = 0, // Zone to be assumed. 734 const char *sav = NULL); // Extension (no .) for the 735 // file where the pointer to the last 736 // scanned message is stored. 737 // Return the area Handle, 738 // NULL on error. 739 740 UMSGID GetNextMsg (XMSG *xmsg, // Get UMSGID of next available 741 byte flags = 0); // message. 742 // Load the header into xmsg. 743 // Optional flags. 744 // Return 0 when no more. 745 746 void LoadMsgBody (char *body, // Load message body into body, 747 size_t size); // maximum size bytes, including 748 // terminating NULL, which is 749 // guaranteed. 750 751 int MarkMsgRead (); // Mark current msg as Read and 752 // leave it closed (no LoadMsgBody 753 // possible). 754 // Return 0 on success. 755 756 int KillMsg (); // Kill current msg. 757 // Return 0 on success. 758 759 int Close (); // Close the area, save the last 760 // pointer if necessary. 761 // Return 0 on success, 762 // 1 on "sav" save error, 763 // -1 on Api close error. 764 765 ~SqNetScan (); // Destructor. 766 }; 767 768 769 770 #endif 771