1 /*
2  * MultiMail offline mail reader
3  * QWK
4 
5  Copyright 1997 John Zero <john@graphisoft.hu>
6  Copyright 1997-2019 William McBrine <wmcbrine@gmail.com>
7  Distributed under the GNU General Public License, version 3 or later. */
8 
9 #ifndef QWK_H
10 #define QWK_H
11 
12 #include "pktbase.h"
13 
14 #define ndxRecLen 5
15 
16 // Offset of the "chunks" field, so it can be written separately
17 #define CHUNK_OFFSET 116
18 
19 #define getQfield(d, s, l) { memcpy(d, s, l); d[l] = '\0'; }
20 
21 class qheader {
22     struct qwkmsg_header {
23         char status;
24         char msgnum[7];         // in ASCII
25         char date[8];           // ASCII MM-DD-YY date
26         char time[5];           // time in HH:MM ASCII
27         char to[25];            // TO
28         char from[25];          // FROM
29         char subject[25];       // subject of message
30         char password[12];      // message passw.
31         char refnum[8];         // in ASCII
32         char chunks[6];         // number of 128 byte chunks
33         char alive;             // msg is alive/killed
34         unsigned char confLSB;
35         unsigned char confMSB;
36         char res[3];
37     };
38 
39  public:
40     char from[72], to[72], subject[72], date[15];
41     long msglen;
42     int origArea;
43     long msgnum, refnum;
44     bool privat, netblock;
45 
46     bool init(FILE *);
47     bool init_short(FILE *);
48     void output(FILE *);
49     void set_length(FILE *, long, long);
50 };
51 
52 class qwkpack : public pktbase
53 {
54     char newsfile[1][13];
55     char controlname[26];
56     bool qwke, greekqwk;
57 
58     unsigned long MSBINtolong(unsigned const char *);
59     void readControlDat();
60     void readDoorId();
61     void readToReader();
62     bool externalIndex();
63     void readIndices();
64 
65     void getblk(int, long &, long, unsigned char *&, unsigned char *&);
66     void postfirstblk(unsigned char *&, letter_header &);
67     void endproc(letter_header &);
68  public:
69     qwkpack(mmail *);
70     ~qwkpack();
71     area_header *getNextArea();
72     letter_header *getNextLetter();
73     bool isQWKE();
74     bool isGreekQWK();
75     const char *ctrlName();
76 };
77 
78 class qwkreply : public pktreply
79 {
80     class upl_qwk : public upl_base {
81      public:
82         qheader qHead;
83 
84         upl_qwk(const char * = 0);
85     };
86 
87     bool qwke, greekqwk;
88 
89     bool getRep1(FILE *, upl_qwk *);
90     void getReplies(FILE *);
91     void addRep1(FILE *, upl_base *, int);
92     void addHeader(FILE *);
93     void repFileName();
94     const char *repTemplate(bool);
95  public:
96     qwkreply(mmail *, specific_driver *);
97     ~qwkreply();
98     area_header *getNextArea();
99     letter_header *getNextLetter();
100     void enterLetter(letter_header &, const char *, long);
101     bool getOffConfig();
102     bool makeOffConfig();
103 };
104 
105 #endif
106