1 /*****************************************************************************/
2 /*                                                                           */
3 /*                 (C) Copyright 1992-1997  Alberto Pasquale                 */
4 /*                 Portions (C) Copyright 1999 Per Lundberg                  */
5 /*                                                                           */
6 /*                   A L L   R I G H T S   R E S E R V E D                   */
7 /*                                                                           */
8 /*****************************************************************************/
9 /*                                                                           */
10 /* How to contact the author:  Alberto Pasquale of 2:332/504@fidonet         */
11 /*                             Viale Verdi 106                               */
12 /*                             41100 Modena                                  */
13 /*                             Italy                                         */
14 /*                                                                           */
15 /*****************************************************************************/
16 
17 #ifndef INPBLK_HPP
18 #define INPBLK_HPP
19 
20 #include "types.hpp"
21 #include "daydir.hpp"
22 #include "iocur.hpp"
23 #include <time.h>
24 
25 #define IB_NeededOnly TRUE     // for Prepare
26 
27 class DAYDIR;               // forward reference
28 class OUTBLK;
29 class OutncBlk;
30 class ARCMETHOD;
31 class OutSave;
32 class SEGEXPORT;
33 class SegAll;
34 
35 
36 class InpAll {  // can be anywhere (global section, outblk, inpblk, nocomp)
37   public:
38     BOOL        NeededBeforeKill;
39     char        *BeforeArcList;     // external commands
40     char        *AfterArcList;      //
41     char        *BeforeUnArcList;   //
42     char        *AfterUnArcList;    //
43     char        *BeforeArcDiff;     //
44     char        *AfterArcDiff;      //
45     char        *BeforeUnArcDiff;   //
46     char        *AfterUnArcDiff;    //
47     char        *BeforeEdit;        //
48     char        *AfterEdit;         //
49     ARCMETHOD   *ArcMethHead;   // list of ARC methods
50     ARCMETHOD   *ArcDiffMethHead;
51 
52     InpAll (InpAll *ia = NULL);
53     void Init (InpAll *ia = NULL);
54 };
55 
56 
57 #define MsgLogNullPhone     0x0001  // for MsgLog
58 #define MsgLogRedirected    0x0002
59 #define MsgLogPoints        0x0004
60 
61 
62                                 // bit-wise for InpNnc.flags
63 
64 #define GermanPointLst      0x01
65 #define NoPointLstPhone     0x02
66 
67 
68 class InpNnc {  // not acceptable in NoCompile block
69   public:
70     char        *MsgRem;         // when !NULL, selected comments go to MsgRemArea msg.
71     int         MsgLog;
72     char        *BeforeCompile;     //
73     char        *AfterCompile;      //
74     char        *FidoTxt;
75     char        *FidoPrn;
76     int         IncCoord;
77     byte        flags;
78 
79     InpNnc (InpNnc *in = NULL);
80 };
81 
82 
83 class InpOut { // can be in outblk or inpblk; lists that must NOT be inherited
84   public:
85     ADRLST      *IncAddr;
86     ADRLST      *ExcAddr;
87     ADRDATA     *Password;
88     ADRDATA     *Phone;
89     ADRDATA     *NodeFlags;
90     ADRDATA     *Flags;
91     ADRDATA     *Cost;
92     uint        pwn;
93     uint        phn;
94     uint        nfn;
95     uint        fln;
96     uint        csn;
97 
98     InpOut (void);
99 };
100 
101 
102 class InpLoc {   // Nodelist specific data, cannot be inherited
103   public:
104     char        *NodeList;
105     BOOL        VarNodeList;    // true when Nodelist.???
106     EXTADR      PartAddr;
107     char        *NodeDiff;
108     char        *ArcList;
109     int         ArcListKeep;
110     char        *ArcListDesc;   // description for ArcLists
111     char        *ArcDiff;
112     int         ArcDiffKeep;
113     char        *ArcDiffDesc;   // description for ArcDiffs
114 
115     InpLoc (void);
116 };
117 
118 
119 class InpVar {  // Locale variables
120   public:
121     BOOL        AlreadyPrepared;
122     BOOL        crcchk;
123 
124     InpVar (void);
125 };
126 
127 //#pragma pack (1)        // necessary for InpSave !
128 
129 class InpSave {        // to be saved in FastLst.Dat
130   public:
131     time_t      NodeTime;
132     time_t      ArcTime;
133     short       NodeDay;
134     short       FutDiff;        // day of oldest nodediff, future to NodeDay but not yet applicable; 0 if none.
135 
136     InpSave ();
137     void Init ();
138 };
139 
140 
141 class InpncBlk {
142   protected:
143     InpAll      *a;
144     InpLoc      *l;
145     InpVar      *v;
146     InpSave     *s;
147 
148     BOOL ChkNewList (int LatestList);
149     BOOL ChkNewDiff (int LatestList);
150     BOOL ChkNewArcList (int LatestList);
151     BOOL ChkNewArcDiff (int LatestList);
152     int  GetLatestList (void);
153     void DoArcDiff (int LatestList);
154     void DoArcList (int LatestList = -1);
155     int  ApplyNewDiffs (int LatestList);
156     int  ApplyDiff (int ListDay, int DiffDay); // return DiffDay, -1 on error
157     void ExecUnarcList (char *ArcFile);
158     void ExecUnarcDiff (char *ArcFile);
159     void ExecArcList ();
160     void ExecArcDiff (int day);
161 
162   public:
163     InpncBlk    *next;
164 
165     InpncBlk (InpAll *ia = NULL);
166     void savinit (void);
167     BOOL ChkNew (void);     // TRUE if something new
168     BOOL Prepare (BOOL NeededOnly = FALSE, BOOL *SomeNew = NULL); // TRUE when prepared a needed list
169         // NeededOnly = TRUE -> prepare only nodelists needed before KillAfter
170         // SomeNew is set to TRUE when the prepared nodelist is new.
171     void KillSource (void);
172 
173     friend class DAYDIR;
174     friend void read_cob (FILE *f, OutncBlk *cob, OutSave *os);
175     friend int save_cob (FILE *f, OutncBlk *cob, OutSave *os);
176     friend class Config;
177 };
178 
179 
180 class INPBLK : public InpncBlk {
181   private:
182     InpNnc      *n;
183     InpOut      *o;
184     SegAll      *sa;
185     SEGEXPORT   *SegExpHead;    // Head of segments to be exported
186 
187     void Open (INPCUR *icp);
188     void Close (INPCUR *icp);
189     BOOL InSegment (const EXTADR *adr, ADRLST *cobIncAddr, ADRLST *cobExcAddr, ADRLST *IncAddr, ADRLST *ExcAddr);
190     BOOL ProcessFile (char *fname, INPCUR *icp, OUTCUR *ocp, OUTBLK *cob, BOOL *SomeNeeded);
191 
192   public:
193     INPBLK (InpAll *ia = NULL, InpNnc *in = NULL, SegAll *isa = NULL);  // constructor initializer
194 
195     BOOL Process (OUTCUR *ocp, OUTBLK *cob, BOOL *SomeNeeded); // FALSE on error
196     void KillSource (void);
197 
198     friend class OUTBLK;
199     friend class Config;
200 };
201 
202 
203 #endif
204