1 
2 //  ------------------------------------------------------------------
3 //  GoldED+
4 //  Copyright (C) 1998-1999 Odinn Sorensen
5 //  Copyright (C) 1999-2000 Alexander S. Aganichev
6 //  ------------------------------------------------------------------
7 //  This program is free software; you can redistribute it and/or
8 //  modify it under the terms of the GNU General Public License as
9 //  published by the Free Software Foundation; either version 2 of the
10 //  License, or (at your option) any later version.
11 //
12 //  This program is distributed in the hope that it will be useful,
13 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 //  General Public License for more details.
16 //
17 //  You should have received a copy of the GNU General Public License
18 //  along with this program; if not, write to the Free Software
19 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 //  MA 02111-1307 USA
21 //  ------------------------------------------------------------------
22 //  $Id: gccfgg0.cpp,v 1.57 2012/05/05 20:00:56 stas_degteff Exp $
23 //  ------------------------------------------------------------------
24 //  Configuration functions, part 0.
25 //  ------------------------------------------------------------------
26 
27 #include <golded.h>
28 #include <gccfgg.h>
29 #include <gcprot.h>
30 
31 
32 //  ------------------------------------------------------------------
33 
34 bool cfgingroup = false;
35 char* val;
36 
37 
38 //  ------------------------------------------------------------------
39 
40 struct tglobalbool {
41   word crc_token;
42 };
43 
44 //  globalbool[] array elements shoulds be complemented with
45 //  en_gswitches{} enumeration elements (see gecfgg.h).
46 //  globalbool[] array must be sorted by value
47 tglobalbool globalbool[gswitches_last] = {
48   { CRC_INTERNETLOOKUP           }, // 0x0E22;
49   { CRC_KLUDGECHRS               }, // 0x0EEF;
50   { CRC_MOUSE                    }, // 0x1B1B;
51   { CRC_DISPLOCALHIGH            }, // 0x1D8B;
52   { CRC_AREALISTGROUPID          }, // 0x1F75;
53   { CRC_ASKDELORIG               }, // 0x26DD;
54   { CRC_LOOKUPLOCAL              }, // 0x34E7;
55   { CRC_DISPSTATUSLINE           }, // 0x3FCF;
56   { CRC_SCREENUSEBIOS            }, // 0x43DE;
57   { CRC_HIGHLIGHTUNREAD          }, // 0x45DA;
58   { CRC_AKAMATCHLOCAL            }, // 0x4AC4;
59   { CRC_FIDONULLFIX              }, // 0x4F38;
60   { CRC_DISPAUTONEXT             }, // 0x52D9;
61   { CRC_LOOKUPUSERBASE           }, // 0x5852;
62   { CRC_AREAKEEPLAST             }, // 0x5876;
63   { CRC_FILELISTPAGEBAR          }, // 0x58AA;
64   { CRC_PRINTFORMFEED            }, // 0x59FB;
65   { CRC_AREALISTNOS              }, // 0x5FD7;
66   { CRC_DISPPAGEBAR              }, // 0x60A4;
67   { CRC_INTERNETREPLY            }, // 0x6253;
68   { CRC_AREALISTPAGEBAR          }, // 0x6C37;
69   { CRC_USEMSGID                 }, // 0x6FDB;
70   { CRC_LOOKUPNET                }, // 0x7359;
71   { CRC_JAMSMAPIHIGHWATER        }, // 0x74A4;
72   { CRC_SQUISHDIRECT             }, // 0x7C35;
73   { CRC_FIDOHWMARKS              }, // 0x7E07;
74   { CRC_MSGLISTPAGEBAR           }, // 0x8041;
75   { CRC_BEEPNOISES               }, // 0x84D5;
76   { CRC_SCREENSHADOWS            }, // 0x8543;
77   { CRC_EMPTYTEARLINE            }, // 0x8D0A;
78   { CRC_MENUDROPMSG              }, // 0x9645;
79   { CRC_BEEPLOCALMSG             }, // 0x984C;
80   { CRC_STATUSLINECLOCK          }, // 0x9C8A;
81   { CRC_TWITTO                   }, // 0x9DFE;
82   { CRC_KEYBDEFAULTS             }, // 0x9FAE;
83   { CRC_DISPLISTWRAP             }, // 0xB36D;
84   { CRC_QUOTESPACING             }, // 0xB403;
85   { CRC_LOOKUPECHO               }, // 0xB787;
86   { CRC_KEYBEXT                  }, // 0xC48A;
87   { CRC_BEEPCOMMENT              }, // 0xC49E;
88   { CRC_RCVDISABLESCFM           }, // 0xD3B2;
89   { CRC_QUOTEBLANK               }, // 0xD3BB;
90   { CRC_KEYBCLEAR                }, // 0xD407;
91   { CRC_DOSPROMPT                }, // 0xD983;
92   { CRC_AREACATCHUPREAD          }, // 0xDAFF;
93   { CRC_FORMFEEDSEPARATOR        }, // 0xDBD6;
94   { CRC_USEFLAGS                 }, // 0xE2B6;
95   { CRC_JAMHARDDELETE            }, // 0xE2D5;
96   { CRC_DISPREALMSGNO            }, // 0xE30F;
97   { CRC_FRQWAZOO                 }, // 0xE49C;
98   { CRC_MSGLISTVIEWSUBJ          }, // 0xED92;
99   { CRC_AKAMATCHECHO             }, // 0xF0C1;
100   { CRC_AREAFILEGROUPS           }, // 0xF0E7;
101   { CRC_AREAAUTONEXT             }, // 0xF589;
102   { CRC_TIMEOUTSAVEMSG           }, // 0xF644;
103   { CRC_NODELISTWARN             }, // 0xF818;
104   { CRC_AKAMATCHNET              }, // 0xFD6E;
105 };
106 
CfgJAMSMAPIHighwater(bool value)107 void CfgJAMSMAPIHighwater(bool value)
108 {
109   CFG->switches.handle(CRC_JAMSMAPIHIGHWATER, value ? "YES" : "NO");
110 }
111 
handle(word crc,const char * value)112 bool gswitches::handle(word crc, const char* value) {
113 
114   uint left,right,middle;
115   word cur;
116 
117   if (value == NULL) {
118     STD_PRINTNL("! Illegall call of function: gswitches::handle(" << crc << ",NULL). File " __FILE__ " line " << __LINE__);
119     LOG_NULL_POINTER;
120     LOG.printf("! Illegall call of function: gswitches::handle(%04X,NULL). File %s line %i ", crc, __FILE__, __LINE__);
121     PointerErrorExit();
122     return 0;
123   }
124 
125   left = 0;
126   right = gswitches_last - 1;
127 
128   if((crc < globalbool[left].crc_token) or (crc > globalbool[right].crc_token))
129     return false;
130 
131   do {
132     middle = (left + right)/2;
133 
134     cur = globalbool[middle].crc_token;
135 
136     if(crc < cur) {
137       right = middle - 1;
138     } else if(crc > cur) {
139       left  = middle + 1;
140     }
141     else {
142       cfg[middle] = make_bool(GetYesno(value));
143       return true;
144     }
145   } while(left <= right);
146 
147   return false;
148 }
149 
150 //  ------------------------------------------------------------------
151 
SwitchCfg(word crc,char k,char * v)152 int SwitchCfg(word crc, char k, char* v) {
153 
154   if (v == NULL) {
155     STD_PRINTNL("! Illegall call of function: SwitchCfg(" << crc << "," << k << "," << "NULL). File " __FILE__ " line " << __LINE__);
156     LOG_NULL_POINTER;
157     LOG.printf("! Illegall call of function: SwitchCfg(%04X,%c,NULL). File %s line %i ", crc, k, __FILE__, __LINE__);
158     PointerErrorExit();
159     return false;
160   }
161 
162   val = v;
163   bool found = true;
164 
165   if(CFG->switches.handle(crc, v))
166     return true;
167 
168   // Switch the first letter of the keyword
169   switch(g_toupper(k)) {
170     case 'A': goto SwitchA;
171     case 'B': goto SwitchB;
172     case 'C': goto SwitchC;
173     case 'D': goto SwitchD;
174     case 'E': goto SwitchE;
175     case 'F': goto SwitchF;
176     case 'G': goto SwitchG;
177     case 'H': goto SwitchH;
178     case 'I': goto SwitchI;
179     case 'J': goto SwitchJ;
180     case 'K': goto SwitchK;
181     case 'L': goto SwitchL;
182     case 'M': goto SwitchM;
183     case 'N': goto SwitchN;
184     case 'O': goto SwitchO;
185     case 'P': goto SwitchP;
186     case 'Q': goto SwitchQ;
187     case 'R': goto SwitchR;
188     case 'S': goto SwitchS;
189     case 'T': goto SwitchT;
190     case 'U': goto SwitchU;
191     case 'V': goto SwitchV;
192     case 'W': goto SwitchW;
193     case 'X': goto SwitchX;
194     case 'Y': goto SwitchY;
195     case 'Z': goto SwitchZ;
196     default:  found = false;
197   }
198   goto End;
199 
200 SwitchA:
201   switch(crc) {
202     case CRC_ADDRESS          :  CfgAddress          ();  break;
203     case CRC_ADDRESSBOOKADD   :  CfgAddressbookadd   ();  break;
204     case CRC_ADDRESSLOOKUPFIRST: CfgAddresslookupfirst(); break;
205     case CRC_ADDRESSMACRO     :  CfgAddressmacro     ();  break;
206     case CRC_ADEPTXBBSPATH    :  CfgAdeptxbbspath    ();  break;
207     case CRC_ADEPTXBBSUSERNO  :  CfgAdeptxbbsuserno  ();  break;
208     case CRC_AKA              :  CfgAddress          ();  break;
209     case CRC_AKAMATCH         :  CfgAkamatch         ();  break;
210     case CRC_AKAMATCHFROMTO   :  CfgAkamatchfromto   ();  break;
211     case CRC_AKAMATCHING      :  CfgAkamatching      ();  break;
212     case CRC_AKAMATCHMANUALLY :  CfgAkamatchmanually ();  break;
213     case CRC_AREAAUTOID       :  CfgAreaautoid       ();  break;
214     case CRC_AREACFMREPLYTO   :  CfgAreacfmreplyto   ();  break;
215     case CRC_AREACOPYADDID    :  CfgAreacopyaddid    ();  break;
216     case CRC_AREACOPYDIRECT   :  CfgAreacopydirect   ();  break;
217     case CRC_AREACOPYTO       :  CfgAreacopyto       ();  break;
218     case CRC_AREADEF          :  CfgAreadef          ();  break;
219     case CRC_AREADESC         :  CfgAreadesc         ();  break;
220     case CRC_AREAEXCL         :  CfgAreaexcl         ();  break;
221     case CRC_AREAFORWARDDIRECT:  CfgAreaforwarddirect();  break;
222     case CRC_AREAFREQDIRECT   :  CfgAreafreqdirect   ();  break;
223     case CRC_AREAFREQTO       :  CfgAreafreqto       ();  break;
224     case CRC_AREAINCL         :  CfgAreaincl         ();  break;
225     case CRC_AREAISEMAIL      :  CfgAreaisemail      ();  break;
226     case CRC_AREAISNEWS       :  CfgAreaisnews       ();  break;
227     case CRC_AREALISTECHOMAX  :  CfgArealistechomax  ();  break;
228     case CRC_AREALISTFORMAT   :  CfgArealistformat   ();  break;
229     case CRC_AREALISTGROUPORDER: CfgArealistgrouporder(); break;
230     case CRC_AREALISTSCAN     :  CfgArealistscan     ();  break;
231     case CRC_AREALISTSORT     :  CfgArealistsort     ();  break;
232     case CRC_AREALISTTYPE     :  CfgArealisttype     ();  break;
233     case CRC_AREAPATH         :  CfgAreapath         ();  break;
234     case CRC_AREAPMSCAN       :  CfgAreapmscan       ();  break;
235     case CRC_AREAPMSCANEXCL   :  CfgAreapmscanexcl   ();  break;
236     case CRC_AREAPMSCANINCL   :  CfgAreapmscanincl   ();  break;
237     case CRC_AREAREADONLY     :  CfgAreareadonly     ();  break;
238     case CRC_AREARECYCLEBIN   :  CfgArearecyclebin   ();  break;
239     case CRC_AREARENAME       :  CfgArearename       ();  break;
240     case CRC_AREAREPLYDIRECT  :  CfgAreareplydirect  ();  break;
241     case CRC_AREAREPLYTO      :  CfgAreareplyto      ();  break;
242     case CRC_AREASCAN         :  CfgAreascan         ();  break;
243     case CRC_AREASCANEXCL     :  CfgAreascanexcl     ();  break;
244     case CRC_AREASCANINCL     :  CfgAreascanincl     ();  break;
245     case CRC_AREASCANSORT     :  CfgAreascansort     ();  break;
246     case CRC_AREASEP          :  CfgAreasep          ();  break;
247     case CRC_AREASTART        :  CfgAreastart        ();  break;
248     case CRC_AREATYPEORDER    :  CfgAreatypeorder    ();  break;
249     case CRC_AREAYOUWROTETO   :  CfgAreayouwroteto   ();  break;
250     case CRC_ATTACHPATH       :  CfgAttachpath       ();  break;
251     case CRC_ATTRIBSATTACH    :  CfgAttribsattach    ();  break;
252     case CRC_ATTRIBSCC        :  CfgAttribscc        ();  break;
253     case CRC_ATTRIBSCFM       :  CfgAttribscfm       ();  break;
254     case CRC_ATTRIBSECHO      :  CfgAttribsecho      ();  break;
255     case CRC_ATTRIBSEMAIL     :  CfgAttribsemail     ();  break;
256     case CRC_ATTRIBSFRQ       :  CfgAttribsfrq       ();  break;
257     case CRC_ATTRIBSLOCAL     :  CfgAttribslocal     ();  break;
258     case CRC_ATTRIBSNET       :  CfgAttribsnet       ();  break;
259     case CRC_ATTRIBSNEWS      :  CfgAttribsnews      ();  break;
260     case CRC_ATTRIBUTES       :  CfgAttributes       ();  break;
261     default                   :  found = false;
262   }
263   goto End;
264 
265 SwitchB:
266   switch(crc) {
267     case CRC_BEEPFACTOR       :  CfgBeepfactor       ();  break;
268     case CRC_BEEPYOURMAIL     :  CfgBeepyourmail     ();  break;
269     default                   :  found = false;
270   }
271   goto End;
272 
273 SwitchC:
274   switch(crc) {
275     case CRC_CARBONCOPYLIST   :  CfgCarboncopylist   ();  break;
276     case CRC_COLOR            :  CfgColor            ();  break;
277     case CRC_COLORNAME        :  CfgColorname        ();  break;
278     case CRC_COLORSET         :  CfgColorset         ();  break;
279     case CRC_CONFIRMFILE      :  CfgConfirmfile      ();  break;
280     case CRC_CONFIRMRESPONSE  :  CfgConfirmresponse  ();  break;
281     case CRC_COOKIEPATH       :  CfgCookiepath       ();  break;
282     case CRC_CROSSPOST        :  CfgCrosspost        ();  break;
283     case CRC_CROSSPOSTLIST    :  CfgCrosspostlist    ();  break;
284     case CRC_CTRLINFO         :  CfgCtrlinfo         ();  break;
285     case CRC_CTRLINFOECHO     :  CfgCtrlinfoecho     ();  break;
286     case CRC_CTRLINFOEMAIL    :  CfgCtrlinfoemail    ();  break;
287     case CRC_CTRLINFOLOCAL    :  CfgCtrlinfolocal    ();  break;
288     case CRC_CTRLINFONET      :  CfgCtrlinfonet      ();  break;
289     case CRC_CTRLINFONEWS     :  CfgCtrlinfonews     ();  break;
290     default                   :  found = false;
291   }
292   goto End;
293 
294 SwitchD:
295   switch(crc) {
296     case CRC_DISPAREANO       :  CfgDispareano       ();  break;
297     case CRC_DISPATTACHSIZE   :  CfgDispattachsize   ();  break;
298     case CRC_DISPHDRDATESET   :  CfgDisphdrdateset   ();  break;
299     case CRC_DISPHDRLOCATION  :  CfgDisphdrlocation  ();  break;
300     case CRC_DISPHDRNAMESET   :  CfgDisphdrnameset   ();  break;
301     case CRC_DISPHDRNODESET   :  CfgDisphdrnodeset   ();  break;
302     case CRC_DISPLISTCURSOR   :  CfgDisplistcursor   ();  break;
303     case CRC_DISPMARGIN       :  CfgDispmargin       ();  break;
304     case CRC_DISPMSGSIZE      :  CfgDispmsgsize      ();  break;
305     case CRC_DISPPMFIRST      :  CfgDisppmfirst      ();  break;
306     case CRC_DISPSOFTCR       :  CfgDispsoftcr       ();  break;
307     case CRC_DISPTABSIZE      :  CfgDisptabsize      ();  break;
308     default                   :  found = false;
309   }
310   goto End;
311 
312 SwitchE:
313   switch(crc) {
314     case CRC_EDITAUTOATTACH   :  CfgEditautoattach   ();  break;
315     case CRC_EDITAUTOSAVE     :  CfgEditautosave     ();  break;
316     case CRC_EDITCHANGEDATE   :  CfgEditchangedate   ();  break;
317     case CRC_EDITCHARPARA     :  CfgEditcharpara     ();  break;
318     case CRC_EDITCHARSPACE    :  CfgEditcharspace    ();  break;
319     case CRC_EDITCOMMENT      :  CfgEditcomment      ();  break;
320     case CRC_EDITCOMPLETION   :  CfgEditcompletion   ();  break;
321     case CRC_EDITCRLFTERM     :  CfgEditcrlfterm     ();  break;
322     case CRC_EDITFIELDCLEAR   :  CfgEditfieldclear   ();  break;
323     case CRC_EDITHARDLINE     :  CfgEdithardline     ();  break;
324     case CRC_EDITHARDLINES    :  CfgEdithardlines    ();  break;
325     case CRC_EDITHARDTERM     :  CfgEdithardterm     ();  break;
326     case CRC_EDITHDRNAMESET   :  CfgEdithdrnameset   ();  break;
327     case CRC_EDITHDRNODESET   :  CfgEdithdrnodeset   ();  break;
328     case CRC_EDITHEADERATTRS  :  CfgEditheaderattrs  ();  break;
329     case CRC_EDITHEADERFIRST  :  CfgEditheaderfirst  ();  break;
330     case CRC_EDITINTERNAL     :  CfgEditinternal     ();  break;
331     case CRC_EDITMENU         :  CfgEditmenu         ();  break;
332     case CRC_EDITMIXCASE      :  CfgEditmixcase      ();  break;
333     case CRC_EDITOR           :  CfgEditor           ();  break;
334     case CRC_EDITORFILE       :  CfgEditorfile       ();  break;
335     case CRC_EDITQUOTEMARGIN  :  CfgEditquotemargin  ();  break;
336     case CRC_EDITREPLYRE      :  CfgEditreplyre      ();  break;
337     case CRC_EDITSAVEMENU     :  CfgEditsavemenu     ();  break;
338     case CRC_EDITSAVEUTIL     :  CfgEditsaveutil     ();  break;
339     case CRC_EDITSOFTCRXLAT   :  CfgEditsoftcrxlat   ();  break;
340     case CRC_EDITSPELLCHECK   :  CfgEditspellcheck   ();  break;
341     case CRC_EDITUNDELETE     :  CfgEditundelete     ();  break;
342     case CRC_ENDGROUP         :  CfgEndgroup         ();  break;
343     case CRC_ENCODEEMAILHEADERS: CfgEncodeemailheaders(); break;
344     case CRC_EVENT            :  CfgEvent            ();  break;
345     case CRC_EXCLUDENODES     :  CfgExcludenodes     ();  break;
346     case CRC_EXTERNOPTIONS    :  CfgExternoptions    ();  break;
347     case CRC_EXTERNUTIL       :  CfgExternutil       ();  break;
348     case CRC_EZYCOMMSGBASE    :  CfgEzycommsgbase    ();  break;
349     case CRC_EZYCOMUSERBASE   :  CfgEzycomuserbase   ();  break;
350     case CRC_EZYCOMUSERNO     :  CfgEzycomuserno     ();  break;
351     default                   :  found = false;
352   }
353   goto End;
354 
355 SwitchF:
356   switch(crc) {
357     case CRC_FIDOLASTREAD     :  CfgFidolastread     ();  break;
358     case CRC_FIDOMSGTYPE      :  CfgFidomsgtype      ();  break;
359     case CRC_FIDOUSERLIST     :  CfgFidouserlist     ();  break;
360     case CRC_FIDOUSERNO       :  CfgFidouserno       ();  break;
361     case CRC_FILEALIAS        :  CfgFilealias        ();  break;
362     case CRC_FORCETEMPLATE    :  CfgForcetemplate    ();  break;
363     case CRC_FRQEXT           :  CfgFrqext           ();  break;
364     case CRC_FRQNODEMAP       :  CfgFrqnodemap       ();  break;
365     case CRC_FRQOPTIONS       :  CfgFrqoptions       ();  break;
366     default                   :  found = false;
367   }
368   goto End;
369 
370 SwitchG:
371   switch(crc) {
372     case CRC_GEDHANDSHAKE     :  CfgGedhandshake     ();  break;
373     case CRC_GERMANKEYBOARD   :  CfgGermankeyboard   ();  break;
374     case CRC_GOLDBASEPATH     :  CfgGoldbasepath     ();  break;
375     case CRC_GOLDBASESYSPATH  :  CfgGoldbasesyspath  ();  break;
376     case CRC_GOLDBASEUSERNO   :  CfgGoldbaseuserno   ();  break;
377     case CRC_GOLDPATH         :  CfgGoldpath         ();  break;
378     case CRC_GROUP            :  CfgGroup            ();  break;
379     default                   :  found = false;
380   }
381   goto End;
382 
383 SwitchH:
384   switch(crc) {
385     case CRC_HUDSONPATH       :  CfgHudsonpath       ();  break;
386     case CRC_HUDSONSIZEWARN   :  CfgHudsonsizewarn   ();  break;
387     case CRC_HUDSONSYSPATH    :  CfgHudsonsyspath    ();  break;
388     case CRC_HUDSONUSERNO     :  CfgHudsonuserno     ();  break;
389     case CRC_HIGHLIGHTURLS    :  CfgHighlighturls    ();  break;
390     default                   :  found = false;
391   }
392   goto End;
393 
394 SwitchI:
395   switch(crc) {
396     case CRC_IGNORECHARSET    :  CfgIgnorecharset    ();  break;
397     case CRC_IMPORTBEGIN      :  CfgImportbegin      ();  break;
398     case CRC_IMPORTEND        :  CfgImportend        ();  break;
399     case CRC_INBOUNDPATH      :  CfgInboundpath      ();  break;
400     case CRC_INCLUDENODES     :  CfgIncludenodes     ();  break;
401     case CRC_INPUTFILE        :  CfgInputfile        ();  break;
402     case CRC_INTENSECOLORS    :  CfgIntensecolors    ();  break;
403     case CRC_INTERNETADDRESS  :  CfgInternetaddress  ();  break;
404     case CRC_INTERNETDOMAIN   :  CfgInternetdomain   ();  break;
405     case CRC_INTERNETGATE     :  CfgInternetgate     ();  break;
406     case CRC_INTERNETGATEEXP  :  CfgInternetgateexp  ();  break;
407     case CRC_INTERNETMSGID    :  CfgInternetmsgid    ();  break;
408     case CRC_INTERNETRFCBODY  :  CfgInternetrfcbody  ();  break;
409     case CRC_INTERNETVIAGATE  :  CfgInternetviagate  ();  break;
410     case CRC_INVALIDATE       :  CfgInvalidate       ();  break;
411     default                   :  found = false;
412   }
413   goto End;
414 
415 SwitchJ:
416   switch(crc) {
417     case CRC_JAMPATH          :  CfgJampath          ();  break;
418     default                   :  found = false;
419   }
420   goto End;
421 
422 SwitchK:
423   switch(crc) {
424     case CRC_KEYBMODE         :  CfgKeybmode         ();  break;
425     case CRC_KEYBSTACK        :  CfgKeybstack        ();  break;
426     case CRC_KLUDGE           :  CfgKludge           ();  break;
427     default                   :  found = false;
428   }
429   goto End;
430 
431 SwitchL:
432   switch(crc) {
433     case CRC_LATINTOLOCAL     :  CfgLatintolocal     ();  break;
434     case CRC_LOADLANGUAGE     :  CfgLoadlanguage     ();  break;
435     case CRC_LOCATIONALIAS    :  CfgLocationalias    ();  break;
436     case CRC_LOCATIONDELIMITER:  CfgLocationdelimiter();  break;
437     case CRC_LOGFILE          :  CfgLogfile          ();  break;
438     case CRC_LOGFORMAT        :  CfgLogformat        ();  break;
439     default                   :  found = false;
440   }
441   goto End;
442 
443 SwitchM:
444   switch(crc) {
445     case CRC_MAILINGLIST      :  CfgMailinglist      ();  break;
446     case CRC_MAILTOSS         :  CfgMailtoss         ();  break;
447     case CRC_MAPPATH          :  CfgMappath          ();  break;
448     case CRC_MEMBER           :  CfgMember           ();  break;
449     case CRC_MENUMARKED       :  CfgMenumarked       ();  break;
450     case CRC_MENUNEXTAREA     :  CfgMenunextarea     ();  break;
451     case CRC_MSGLISTDATE      :  CfgMsglistdate      ();  break;
452     case CRC_MSGLISTFAST      :  CfgMsglistfast      ();  break;
453     case CRC_MSGLISTFIRST     :  CfgMsglistfirst     ();  break;
454     case CRC_MSGLISTHEADER    :  CfgMsglistheader    ();  break;
455     case CRC_MSGLISTWIDESUBJ  :  CfgMsglistwidesubj  ();  break;
456     default                   :  found = false;
457   }
458   goto End;
459 
460 SwitchN:
461   switch(crc) {
462     case CRC_NAMESFILE        :  CfgNamesfile        ();  break;
463     case CRC_NICKNAME         :  CfgNickname         ();  break;
464     case CRC_NETNAME          :  CfgNetname          ();  break;
465     case CRC_NODELIST         :  CfgNodelist         ();  break;
466     case CRC_NODEPATH         :  CfgNodepath         ();  break;
467     case CRC_NODEPATHFD       :  CfgNodepathfd       ();  break;
468     case CRC_NODEPATHIM       :  CfgNodepathfd       ();  break;
469     case CRC_NODEPATHV7       :  CfgNodepathv7       ();  break;
470     case CRC_NODEV7FLAGS      :  CfgNodev7flags      ();  break;
471     case CRC_NODEV7MODEM      :  CfgNodev7modem      ();  break;
472     default                   :  found = false;
473   }
474   goto End;
475 
476 SwitchO:
477   switch(crc) {
478     case CRC_ORGANIZATION     :  CfgOrganization     ();  break;
479     case CRC_ORIGIN           :  CfgOrigin           ();  break;
480     case CRC_OUTBOUNDPATH     :  CfgOutboundpath     ();  break;
481     case CRC_OUTPUTFILE       :  CfgOutputfile       ();  break;
482     default                   :  found = false;
483   }
484   goto End;
485 
486 SwitchP:
487   switch(crc) {
488     case CRC_PATHREPORTFILE   :  CfgPathreportfile   ();  break;
489     case CRC_PCBOARDPATH      :  CfgPcboardpath      ();  break;
490     case CRC_PCBOARDUSERNO    :  CfgPcboarduserno    ();  break;
491     case CRC_PEEKURLOPTIONS   :  CfgPeekurloptions   ();  break;
492     case CRC_PERSONALMAIL     :  CfgPersonalmail     ();  break;
493     case CRC_PLAY             :  CfgPlay             ();  break;
494     case CRC_PRINTDEVICE      :  CfgPrintdevice      ();  break;
495     case CRC_PRINTINIT        :  CfgPrintinit        ();  break;
496     case CRC_PRINTLENGTH      :  CfgPrintlength      ();  break;
497     case CRC_PRINTMARGIN      :  CfgPrintmargin      ();  break;
498     case CRC_PRINTRESET       :  CfgPrintreset       ();  break;
499     default                   :  found = false;
500   }
501   goto End;
502 
503 SwitchQ:
504   switch(crc) {
505     case CRC_QUOTEBUFFILE     :  CfgQuotebuffile     ();  break;
506     case CRC_QUOTEBUFMODE     :  CfgQuotebufmode     ();  break;
507     case CRC_QUOTECHARS       :  CfgQuotechars       ();  break;
508     case CRC_QUOTECTRL        :  CfgQuotectrl        ();  break;
509     case CRC_QUOTEMARGIN      :  CfgQuotemargin      ();  break;
510     case CRC_QUOTESTRING      :  CfgQuotestring      ();  break;
511     case CRC_QUOTESTOPS       :  CfgQuotestops       ();  break;
512     case CRC_QUOTEWRAPHARD    :  CfgQuotewraphard    ();  break;
513     case CRC_QUOTEUSENEWAI    :  CfgQuoteusenewai    ();  break;
514     case CRC_QWKBADMSGS       :  CfgQwkbadmsgs       ();  break;
515     case CRC_QWKCONFMAP       :  CfgQwkconfmap       ();  break;
516     case CRC_QWKEXPORTPATH    :  CfgQwkexportpath    ();  break;
517     case CRC_QWKIMPORTPATH    :  CfgQwkimportpath    ();  break;
518     case CRC_QWKOPTIONS       :  CfgQwkoptions       ();  break;
519     case CRC_QWKREPLYLINKER   :  CfgQwkreplylinker   ();  break;
520     case CRC_QWKTOSSLOG       :  CfgQwktosslog       ();  break;
521     default                   :  found = false;
522   }
523   goto End;
524 
525 SwitchR:
526   switch(crc) {
527     case CRC_RA2USERSBBS      :  CfgRa2usersbbs      ();  break;
528     case CRC_REPLYLINK        :  CfgReplylink        ();  break;
529     case CRC_REPLYLINKFLOAT   :  CfgReplylinkfloat   ();  break;
530     case CRC_REPLYLINKLIST    :  CfgReplylinklist    ();  break;
531     case CRC_REPLYLINKSHOWALWAYS:CfgReplylinkshowalways();break;
532     case CRC_ROBOTNAME        :  CfgRobotname        ();  break;
533     default                   :  found = false;
534   }
535   goto End;
536 
537 SwitchS:
538   switch(crc)
539   {
540 #if defined(GCFG_SPELL_INCLUDED)
541     case CRC_SCHECKERENABLED  :  CfgScheckerenabled  ();  break;
542     case CRC_SCHECKERDEFLANG  :  CfgScheckerdeflang  ();  break;
543     case CRC_SCHECKERUSERDIC  :  CfgScheckeruserdic  ();  break;
544     case CRC_SCHECKERDICPATH  :  CfgScheckerdicpath  ();  break;
545 #endif
546     case CRC_SCREENBLANKER    :  CfgScreenblanker    ();  break;
547     case CRC_SCREENMAXCOL     :  CfgScreenmaxcol     ();  break;
548     case CRC_SCREENMAXROW     :  CfgScreenmaxrow     ();  break;
549     case CRC_SCREENPALETTE    :  CfgScreenpalette    ();  break;
550     case CRC_SCREENSIZE       :  CfgScreensize       ();  break;
551     case CRC_SEARCHFOR        :  CfgSearchfor        ();  break;
552     case CRC_SEMAPHORE        :  CfgSemaphore        ();  break;
553     case CRC_SEQDIR           :  CfgSeqDir           ();  break;
554     case CRC_SEQMSGID         :  CfgSeqMsgId         ();  break;
555     case CRC_SEQOUTRUN        :  CfgSeqOutRun        ();  break;
556     case CRC_SHAREMODE        :  CfgSharemode        ();  break;
557     case CRC_SHOWDELETED      :  CfgShowdeleted      ();  break;
558     case CRC_SOUNDPATH        :  CfgSoundpath        ();  break;
559     case CRC_SOUPBADMSGS      :  CfgSoupbadmsgs      ();  break;
560     case CRC_SOUPEMAIL        :  CfgSoupemail        ();  break;
561     case CRC_SOUPEXPORTMARGIN :  CfgSoupexportmargin ();  break;
562     case CRC_SOUPEXPORTPATH   :  CfgSoupexportpath   ();  break;
563     case CRC_SOUPIMPORTPATH   :  CfgSoupimportpath   ();  break;
564     case CRC_SOUPNEWSRCFILE   :  CfgSoupnewsrcfile   ();  break;
565     case CRC_SOUPREPLYLINKER  :  CfgSoupreplylinker  ();  break;
566     case CRC_SOUPREPLYTO      :  CfgSoupreplyto      ();  break;
567     case CRC_SOUPTOSSLOG      :  CfgSouptosslog      ();  break;
568     case CRC_SQUISHSCAN       :  CfgSquishscan       ();  break;
569     case CRC_SQUISHUSERNO     :  CfgSquishuserno     ();  break;
570     case CRC_SQUISHUSERPATH   :  CfgSquishuserpath   ();  break;
571     case CRC_STATUSLINEHELP   :  CfgStatuslinehelp   ();  break;
572     case CRC_STRIPHTML        :  CfgStripHTML        ();  break;
573     case CRC_STYLECODEPUNCT   :  CfgStylecodepunct   ();  break;
574     case CRC_STYLECODES       :  CfgStylecodes       ();  break;
575     case CRC_STYLECODESTOPS   :  CfgStylecodestops   ();  break;
576     default                   :  found = false;
577   }
578   goto End;
579 
580 SwitchT:
581   switch(crc) {
582     case CRC_TAGLINE          :  CfgTagline          ();  break;
583     case CRC_TAGLINECHAR      :  CfgTaglinechar      ();  break;
584     case CRC_TAGLINESUPPORT   :  CfgTaglinesupport   ();  break;
585     case CRC_TASKTITLE        :  CfgTasktitle        ();  break;
586     case CRC_TEARLINE         :  CfgTearline         ();  break;
587     case CRC_TEMPLATE         :  CfgTemplate         ();  break;
588     case CRC_TEMPLATEMATCH    :  CfgTemplatematch    ();  break;
589     case CRC_TEMPLATEPATH     :  CfgTemplatepath     ();  break;
590     case CRC_TEMPPATH         :  CfgTemppath         ();  break;
591     case CRC_TIMEOUT          :  CfgTimeout          ();  break;
592     case CRC_TITLESTATUS      :  CfgTitlestatus      ();  break;
593     case CRC_TRANSLATE        :  CfgTranslate        ();  break;
594     case CRC_TRANSPARENTCOLORS:  CfgTransparentcolors();  break;
595     case CRC_TWITMODE         :  CfgTwitmode         ();  break;
596     case CRC_TWITNAME         :  CfgTwitname         ();  break;
597     case CRC_TWITSUBJ         :  CfgTwitsubj         ();  break;
598     default                   :  found = false;
599   }
600   goto End;
601 
602 SwitchU:
603   switch(crc) {
604     case CRC_UNPACKER         :  CfgUnpacker         ();  break;
605     case CRC_URLHANDLER       :  CfgUrlhandler       ();  break;
606     case CRC_URLSCHEME        :  CfgUrlscheme        ();  break;
607     case CRC_USEAREA          :  CfgUsearea          ();  break;
608     case CRC_USECHARSET       :  CfgUsecharset       ();  break;
609     case CRC_USEFWD           :  CfgUsefwd           ();  break;
610     case CRC_USEINTL          :  CfgUseintl          ();  break;
611     case CRC_USEPID           :  CfgUsepid           ();  break;
612     case CRC_USERLIST         :  CfgUserlist         ();  break;
613     case CRC_USERLISTFILE     :  CfgUserlistfile     ();  break;
614     case CRC_USERNAME         :  CfgUsername         ();  break;
615     case CRC_USESOFTCRXLAT    :  CfgUsesoftcrxlat    ();  break;
616     case CRC_USETZUTC         :  CfgUsetzutc         ();  break;
617     case CRC_UUDECODEPATH     :  CfgUudecodepath     ();  break;
618     default                   :  found = false;
619   }
620   goto End;
621 
622 SwitchV:
623   switch(crc) {
624     case CRC_VIEWHIDDEN       :  CfgViewhidden       ();  break;
625     case CRC_VIEWKLUDGE       :  CfgViewkludge       ();  break;
626     case CRC_VIEWQUOTE        :  CfgViewquote        ();  break;
627     default                   :  found = false;
628   }
629   goto End;
630 
631 SwitchW:
632   switch(crc) {
633     case CRC_WHOTO            :  CfgWhoto            ();  break;
634     case CRC_WILDCATUSERNO    :  CfgWildcatuserno    ();  break;
635     case CRC_WRITEHEADER      :  CfgWriteheader      ();  break;
636     case CRC_WRITETEMPLATE    :  CfgWritetemplate    ();  break;
637     default                   :  found = false;
638   }
639   goto End;
640 
641 SwitchX:
642   switch(crc) {
643     case CRC_XLATCHARSET      :  CfgXlatcharset      ();  break;
644     case CRC_XLATCHARSETALIAS :  CfgXlatcharsetalias ();  break;
645     case CRC_XLATESCSET       :  CfgXlatescset       ();  break;
646     case CRC_XLATEXPORT       :  CfgXlatexport       ();  break;
647     case CRC_XLATIMPORT       :  CfgXlatimport       ();  break;
648     case CRC_XLATLOCALSET     :  CfgXlatlocalset     ();  break;
649     case CRC_XLATPATH         :  CfgXlatpath         ();  break;
650     default                   :  found = false;
651   }
652   goto End;
653 
654 SwitchY:
655   switch(crc) {
656     default                   :  found = false;
657   }
658   goto End;
659 
660 SwitchZ:
661   switch(crc) {
662     case CRC_ZONEGATING       :  CfgZonegating       ();  break;
663     default                   :  found = false;
664   }
665   goto End;
666 
667 End:
668   if(found)
669     return true;
670 
671   if(cmdlineoldkeyw == false)
672     return false;
673 
674   switch(crc) {
675     case CRC_AREA             :  CfgArea             ();  break;
676     case CRC_REGISTERKEY      :                           break;
677     case CRC_REGISTERNAME     :                           break;
678     case CRC_SERIALNO         :                           break;
679     default                   :  return false;
680   }
681 
682   return true;
683 }
684 
685 
686 //  ------------------------------------------------------------------
687 
do_if(char * val)688 static int do_if(char* val) {
689 
690   if (val == NULL) {
691     STD_PRINTNL("! Illegall call of function: do_if(NULL). File " __FILE__ " line " << __LINE__);
692     LOG_NULL_POINTER;
693     LOG.printf("! Illegall call of function: do_if(NULL). File %s line %i.", __FILE__, __LINE__);
694     PointerErrorExit();
695     return 0;
696   }
697   if(strieql(val, "OS/2") or strieql(val, "OS2")) {
698     #ifdef __OS2__
699     return true;
700     #else
701     return false;
702     #endif
703   }
704   else if(strieql(val, "NT") or strieql(val, "W32") or strieql(val, "WIN32")) {
705     #ifdef __WIN32__
706     return true;
707     #else
708     return false;
709     #endif
710   }
711   else if(strieql(val, "386") or strieql(val, "DOS") or strieql(val, "DPMI32")) {
712     #ifdef __MSDOS__
713     return true;
714     #else
715     return false;
716     #endif
717   }
718   else if(strieql(val, "LINUX") or strieql(val, "UNIX")) {
719     #ifdef __UNIX__
720     return true;
721     #else
722     return false;
723     #endif
724   }
725   else if (strieql(val, "SPELL"))
726   {
727     #ifdef GCFG_SPELL_INCLUDED
728     return true;
729     #else
730     return false;
731     #endif
732   }
733   else if(strieql(val, "FIREBIRD"))
734     return true;
735   else if(strieql(val, "ASA") or strieql(val, "PLUS"))
736     return true;
737   else if(strieql(val, "YES") or strieql(val, "TRUE") or strieql(val, "ON"))
738     return true;
739   return !!atoi(val);
740 }
741 
742 
743 //  ------------------------------------------------------------------
744 //  Compile a GoldED text config file
745 // Return 1 if success, return 0 if error
746 
ReadCfg(const char * cfgfile,int ignoreunknown)747 int ReadCfg(const char* cfgfile, int ignoreunknown)
748 {
749   const word CRC_APP      = 0x08B5;
750 
751   Path cfg;
752   char buf[1024];
753   static int inuse = 0;
754   static int in_if = false;
755   static int in_else = false;
756   static int if_status = false;
757   char* val;
758   char* key;
759   char* cfgname;
760   word crc;
761   int cfgignore=NO, line=0;
762 
763   if (cfgfile == NULL) {
764     STD_PRINTNL("! Illegall call of function: ReadCfg(NULL," << ignoreunknown << "). File " __FILE__ " line " << __LINE__);
765     LOG_NULL_POINTER;
766     LOG.printf("! Illegall call of function: ReadCfg(NULL,%i). File %s line %i ", ignoreunknown, __FILE__, __LINE__);
767     PointerErrorExit();
768     return 0;
769   }
770   // Open the file
771   if(strlen(cfgfile) >= GMAXPATH) {
772     STD_PRINTNL("* Filename '" << cfgfile << "' too long (max " << GMAXPATH-1 << " characters).");
773     LOG.ErrOpen();
774     LOG.printf("! Unable to use configuration file because filename too long (see next line):");
775     LOG.printf("%s",cfgfile);
776     cfgerrors++;
777     return 0; // Error: can't use too long file name
778   }
779   strxcpy(cfg, cfgfile, GMAXPATH);
780   MakePathname(cfg, CFG->goldpath, cfg);
781   if(cfg[0] == '\0') {
782     STD_PRINTNL("* Can't read '" << cfgfile << "': ca't construct full pathname, sorry");
783     LOG.ErrOpen();
784     LOG.printf("! Unable to use configuration file '%s' because unable to construct full pathname", cfgfile);
785     cfgerrors++;
786     return 0; // Error: can't use specified file name
787   }
788 
789   gfile fp(cfg, "rt", CFG->sharemode);
790   if (fp.isopen())
791   {
792     cfgname = strrchr(cfg, '\\');
793     cfgname = cfgname ? cfgname+1 : cfg;
794     inuse++;
795 
796     if (not quiet)
797       STD_PRINTNL("* Reading " << cfg);
798 
799     // Assign file buffer
800     fp.SetvBuf(NULL, _IOFBF, 8192);
801 
802     // Read each line
803     while (fp.Fgets((val=buf), sizeof(buf)))
804     {
805       line++;
806 
807       // Replace TABs with SPACEs
808       strchg(val, '\t', ' ');
809 
810       val = strskip_wht(val);
811 
812       if(g_isalpha(*val)) {
813 
814         // Extract key and val
815         crc = getkeyvalcrc(&key, &val);
816 
817         int _gotcond = true;
818         switch(crc) {
819           case CRC_IF:
820             if (in_if)
821             {
822               STD_PRINTNL("* " << cfgname << ": Misplaced IF at line " << line << ". IF's cannot be nested.");
823               cfgerrors++;
824             }
825             in_if = true;
826             if_status = do_if(val);
827             cfgignore = not if_status;
828             break;
829           case CRC_ELIF:
830           case CRC_ELSEIF:
831             if (not in_if or in_else)
832             {
833               STD_PRINTNL("* " << cfgname << ": Misplaced ELIF/ELSEIF at line " << line << ".");
834               cfgerrors++;
835             }
836             if(if_status)
837               cfgignore = true;
838             else {
839               if_status = do_if(val);
840               cfgignore = not if_status;
841             }
842             break;
843           case CRC_ELSE:
844             if (not in_if or in_else)
845             {
846               STD_PRINTNL("* " << cfgname << ": Misplaced ELSE at line " << line << ".");
847               cfgerrors++;
848             }
849             in_else = true;
850             if_status ^= true;
851             cfgignore = not if_status;
852             break;
853           case CRC_ENDIF:
854             if (not in_if)
855             {
856               STD_PRINTNL("* " << cfgname << ": Misplaced ENDIF at line " << line << ".");
857               cfgerrors++;
858             }
859             cfgignore = false;
860             in_if = in_else = false;
861             break;
862           case CRC_IGNORE:
863             cfgignore ^= true;
864             break;
865           default:
866             _gotcond = false;
867         }
868 
869         // Tell the world what we found
870         if (veryverbose)
871         {
872            char buff[256];
873            gsprintf(PRINTF_DECLARE_BUFFER(buff), " %c %04d: %s %s\n", cfgignore ? '-' : '+', line, key, val);
874            STD_PRINT(buff);
875         }
876 
877         // Call switch function to act on the key
878         if(not cfgignore) {
879           if(not _gotcond) {
880             switch(crc) {
881               case CRC_INCLUDE:
882                 strschg_environ(val, (buf+sizeof(buf))-val);
883                 MapPath(val);
884 
885                 if (not quiet)
886                   STD_PRINTNL("* Including " << val);
887 
888                 ReadCfg(val);          // NOTE! This is a recursive call!
889 
890                 if (not quiet)
891                   STD_PRINTNL("* Resuming " << cfg);
892 
893                 break;
894               case CRC_AREAFILE:
895                 strschg_environ(val, (buf+sizeof(buf))-val);
896                 MapPath(val);
897 
898                 if (not quiet)
899                   STD_PRINTNL("* Handling " << key << " " << val);
900 
901                 AL.GetAreafile(val);
902 
903                 if (not quiet)
904                   STD_PRINTNL("* Resuming " << cfg);
905 
906                 break;
907               case CRC_APP:
908                 // Ignore 3rd party application lines
909                 break;
910               case CRC_REM:
911                 // Ignore remark lines
912                 break;
913               default:
914                 if (not SwitchCfg(crc, *key, val))
915                 {
916                   if (not ignoreunknown)
917                   {
918                     STD_PRINTNL("* " << cfgname << ": Unknown keyword \"" << key << "\" at line " << line << ".");
919                     SayBibi();
920                     cfgerrors++;
921                   }
922                 }
923             }
924           }
925         }
926       }
927     }
928 
929     // Close and return all OK
930     fp.Fclose();
931     inuse--;
932 
933     // When the final cfg is compiled
934     if (inuse == 0)
935     {
936       // Mark all areas listed in the NEWSRC file as newsgroups
937       if (*CFG->soupnewsrcfile)
938       {
939         gfile gfp(CFG->soupnewsrcfile, "rt");
940         if (gfp.isopen())
941         {
942           char buf2[512];
943           while (gfp.Fgets(buf2, sizeof(buf2)))
944           {
945             char* ptr = strpbrk(buf2, ":! ");
946             if(ptr) {
947               *ptr = NUL;
948               Area* ap = AL.AreaEchoToPtr(buf2);
949               if(ap)
950                 ap->set_type(ap->isnet() ? GMB_SOUP|GMB_EMAIL|GMB_NET : GMB_SOUP|GMB_NEWSGROUP|GMB_ECHO);
951             }
952           }
953           gfp.Fclose();
954         }
955       }
956 
957       if(*CFG->soupemail) {
958         Area* ap = AL.AreaEchoToPtr(CFG->soupemail);
959         if(ap)
960           ap->set_type(GMB_SOUP|GMB_EMAIL|GMB_NET);
961       }
962 
963       std::vector<MailList>::iterator z;
964       for(z = CFG->mailinglist.begin(); z != CFG->mailinglist.end(); z++) {
965         Area* ap = AL.AreaEchoToPtr(z->echoid);
966         if(ap)
967           ap->set_type(GMB_SOUP|GMB_EMAIL|GMB_NET);
968       }
969 
970       // Mark all QWK areas
971       if(QWK->FirstBBS()) {
972         do {
973           if(QWK->FirstConf()) {
974             do {
975               Area* ap = AL.AreaEchoToPtr(QWK->ConfName());
976               if(ap)
977                 ap->set_type(ap->type() | GMB_QWK);
978             } while(QWK->NextConf());
979           }
980         } while(QWK->NextBBS());
981       }
982     }
983 
984     return 1;
985   }
986   else {
987 
988     LOG.ErrOpen();
989     LOG.printf("! Unable to open configuration file.");
990     LOG.printf(": %s", cfg);
991     LOG.ErrOSInfo();
992     OpenErrorExit();
993   }
994 
995   // Error opening file
996   return 0;
997 }
998 
999 
1000 //  ------------------------------------------------------------------
1001