-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.c
3100 lines (2371 loc) · 61.3 KB
/
config.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Copyright 2001-2018 John Wiseman G8BPQ
This file is part of LinBPQ/BPQ32.
LinBPQ/BPQ32 is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
LinBPQ/BPQ32 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
*/
// July 2010
// BPQ32 now reads bpqcfg.txt. This module converts it to the original binary format.
// Based on the standalonw bpqcfg.c
/************************************************************************/
/* CONFIG.C Jonathan Naylor G4KLX, 19th November 1988 */
/* */
/* Program to produce configuration file for G8BPQ Network Switch */
/* based on the original written in BASIC by G8BPQ. */
/* */
/* Subsequently extended by G8BPQ */
/* */
/************************************************************************/
//
// 22/11/95 - Add second port alias for digipeating (for APRS)
// - Add PORTMAXDIGIS param
// 1999 - Win32 Version (but should also compile in 16 bit
// 5/12/99 - Add DLLNAME Param for ext driver
// 26/11/02 - Added AUTOSAVE
// Jan 2006
// Add params for input and output names
// Wait before exiting if error detected
// March 2006
// Accept # as comment delimiter
// Display input and output filenames
// Wait before exit, even if ok
// March 2006
// Add L4APPL param
// Jan 2007
// Remove UNPROTO
// Add BTEXT
// Add BCALL
// Nov 2007
// Convert calls and APPLICATIONS string to upper case
// Jan 2008
// Remove trailing space from UNPROTO
// Don't warn BBSCALL etc missing if APPL1CALL etc present
// August 2008
// Add IPGATEWAY Parameter
// Add Port DIGIMASK Parameter
// December 2008
// Add C_IS_CHAT Parameter
// March 2009
// Add C style COmments (/* */ at start of line)
// August 2009
// Add INP3 flag to locked routes
// November 2009
// Add PROTOCOL=PACTOR or WINMOR option
// December 2009
// Add INP3 MAXRTT and MAXHOPS Commands
// March 2010
// Add SIMPLE mode
// March 2010
// Change SIMPLE mode default of Full_CTEXT to 1
// April 2010
// Add NoKeepAlive ROUTE option
// Converted to intenal bpq32 process
// Spetember 2010
// Add option of embedded port configuration
#define _CRT_SECURE_NO_DEPRECATE
#include "CHeaders.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
// KISS Options Equates
#define CHECKSUM 1
#define POLLINGKISS 2 // KISSFLAGS BITS
#define ACKMODE 4 // CAN USE ACK REQURED FRAMES
#define POLLEDKISS 8 // OTHER END IS POLLING US
#define D700 16 // D700 Mode (Escape "C" chars
#define TNCX 32 // TNC-X Mode (Checksum of ACKMODE frames includes ACK bytes
#define PITNC 64 // PITNC Mode - can reset TNC with FEND 15 2
#define NOPARAMS 128 // Don't send SETPARAMS frame
#define FLDIGI 256 // Support FLDIGI COmmand Frames
#define TRACKER 512 // SCS Tracker. Need to set KISS Mode
#define FASTI2C 1024 // Use BLocked I2C Reads (like ARDOP)
struct WL2KInfo * DecodeWL2KReportLine(char * buf);
// Dummy file routines - write to buffer instead
char * ConfigBuffer;
char * PortConfig[36];
char * RigConfigMsg[36];
char * WL2KReportLine[36];
BOOL PortDefined[36];
extern BOOL IncludesMail;
extern BOOL IncludesChat;
extern int AGWPort;
extern int AGWSessions;
extern int AGWMask;
extern BOOL LoopMonFlag;
extern BOOL Loopflag;
char * fp2;
short * fp2s;
VOID bputc(int Ch, char * ptr)
{
*fp2++ = Ch;
}
VOID bputi(int Ch, char * ptr);
VOID bputs(char * Val, char * ptr)
{
int Len = strlen(Val);
memcpy(fp2, Val, Len);
fp2 += Len;
}
VOID bseek(char * ptr, int offset, int dummy)
{
fp2 = ConfigBuffer + offset;
}
int btell(char * ptr)
{
return fp2 - ConfigBuffer;
}
VOID * zalloc(int len);
int WritetoConsoleLocal(char * buff);
VOID Consoleprintf(const char * format, ...)
{
char Mess[255];
va_list(arglist);
va_start(arglist, format);
vsprintf(Mess, format, arglist);
strcat(Mess, "\n");
WritetoConsoleLocal(Mess);
return;
}
#include "configstructs.h"
struct PORTCONFIG * PortRec;
#pragma pack()
int tnctypes(int i, char value[],char rec[]);
int do_kiss (char value[],char rec[]);
int dec_byte(int i, char * value, char * rec);
struct TNCDATA * TNCCONFIGTABLE = NULL; // malloc'ed
int NUMBEROFTNCPORTS = 0;
struct TNCDATA * TNC2ENTRY;
extern char PWTEXT[];
extern char HFCTEXT[];
extern int HFCTEXTLEN;
extern char LOCATOR[];
extern char MAPCOMMENT[];
extern char LOC[];
extern int RFOnly;
extern int main(int argc,char **argv,char **envp);
extern int decode_rec(char *rec);
extern int applcallsign(int i,char *value,char *rec);
extern int appl_qual(int i,char *value,char *rec);
extern int callsign(int i,char *value,char *rec);
extern int int_value(int i,char *value,char *rec);
extern int hex_value(int i,char *value,char *rec);
extern int bin_switch(int i,char *value,char *rec);
extern int dec_switch(int i,char *value,char *rec);
extern int numbers(int i,char *value,char *rec);
extern int applstrings(int i,char *value,char *rec);
extern int dotext(int i,char *key_word, int max);
extern int doBText(int i,char *key_word);
int routes(int i);
int ports(int i);
extern int tncports(int i);
extern int dedports(int i);
extern int xindex(char *s,char *t);
extern int verify(char *s,char c);
int GetNextLine(char * rec);
int call_check(char *callsign);
int call_check_internal(char * callsign);
extern int callstring(int i,char *value,char *rec);
int decode_port_rec(char *rec);
extern int doid(int i,char *value,char *rec);
extern int dodll(int i,char *value,char *rec);
extern int doDriver(int i,char *value,char *rec);
extern int hwtypes(int i,char *value,char *rec);
extern int protocols(int i,char *value,char *rec);
extern int bbsflag(int i,char *value,char *rec);
extern int channel(int i,char *value,char *rec);
extern int validcalls(int i,char *value,char *rec);
extern int kissoptions(int i,char *value,char *rec);
extern int decode_tnc_rec(char *rec);
extern int tnctypes(int i,char *value,char *rec);
extern int dec_byte(int i,char *value,char *rec);
extern int do_kiss(char *value,char *rec);
extern int decode_ded_rec(char *rec);
extern int simple(int i);
int C_Q_ADD_NP(VOID *PQ, VOID *PBUFF);
int doSerialPortName(int i, char * value, char * rec);
BOOL ProcessAPPLDef(char * rec);
BOOL ToLOC(double Lat, double Lon , char * Locator);
//int i;
//char value[];
//char rec[];
int FIRSTAPPL=1;
BOOL Comment = FALSE;
int CommentLine = 0;
#define MAXLINE 512
#define FILEVERSION 22
extern UCHAR BPQDirectory[];
char inputname[250]="bpqcfg.txt";
char option[250];
/************************************************************************/
/* STATIC VARIABLES */
/************************************************************************/
static char *keywords[] =
{
"OBSINIT", "OBSMIN", "NODESINTERVAL", "L3TIMETOLIVE", "L4RETRIES", "L4TIMEOUT",
"BUFFERS", "PACLEN", "TRANSDELAY", "T3", "IDLETIME", "BBS",
"NODE", "NODEALIAS", "BBSALIAS", "NODECALL", "BBSCALL",
"TNCPORT", "IDMSG:", "INFOMSG:", "ROUTES:", "PORT", "MAXLINKS",
"MAXNODES", "MAXROUTES", "MAXCIRCUITS", "IDINTERVAL", "MINQUAL",
"HIDENODES", "L4DELAY", "L4WINDOW", "BTINTERVAL", "UNPROTO", "BBSQUAL",
"APPLICATIONS", "EMS", "CTEXT:", "DESQVIEW", "HOSTINTERRUPT", "ENABLE_LINKED",
"DEDHOST", "FULL_CTEXT", "SIMPLE", "AUTOSAVE" , "L4APPL",
"APPL1CALL", "APPL2CALL", "APPL3CALL", "APPL4CALL",
"APPL5CALL", "APPL6CALL", "APPL7CALL", "APPL8CALL",
"APPL1ALIAS", "APPL2ALIAS", "APPL3ALIAS", "APPL4ALIAS",
"APPL5ALIAS", "APPL6ALIAS", "APPL7ALIAS", "APPL8ALIAS",
"APPL1QUAL", "APPL2QUAL", "APPL3QUAL", "APPL4QUAL",
"APPL5QUAL", "APPL6QUAL", "APPL7QUAL", "APPL8QUAL",
"BTEXT:", "NETROMCALL", "C_IS_CHAT", "MAXRTT", "MAXHOPS", // IPGATEWAY= no longer allowed
"LogL4Connects"
}; /* parameter keywords */
static int offset[] =
{
40, 42, 44, 46, 48, 50,
52, 54, 56, 58, 64, 68,
69, 10, 30, 0, 20,
384, 512, InfoOffset, C_ROUTES, 2560, 72,
74, 76, 78, 96, 100,
102, 104, 106, 108, 120, 118,
ApplOffset, 66, 2048, 71, 70, 67,
3000, 98, 0, 103, 110,
0,10,20,30,
40,50,60,70,
80,90,100,110,
120,130,140,150,
160,162,164,166,
168,170,172,174,
121, 256, 111, 113, 114, // BTEXT was UNPROTO+1
116}; /* offset for corresponding data in config file */
static int routine[] =
{
1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 2,
2, 0, 0, 0, 0,
3, 4, 20, 5, 6, 1,
1, 1, 1, 1, 1,
2, 1, 1, 1, 7, 1,
8, 2, 4, 2, 9, 10,
11, 1, 12, 2 , 1,
13, 13, 13, 13,
13, 13 ,13, 13,
13, 13, 13, 13,
13, 13 ,13, 13,
14, 14, 14, 14,
14, 14 ,14, 14,
15, 0, 2, 9, 9,
2} ; // Routine to process param
int PARAMLIM = sizeof(routine)/sizeof(int);
//int NUMBEROFKEYWORDS = sizeof(routine)/sizeof(int);
//#define PARAMLIM 74
static char eof_message[] = "Unexpected end of file on input\n";
static char *pkeywords[] =
{
"ID", "TYPE", "PROTOCOL", "IOADDR", "INTLEVEL", "SPEED", "CHANNEL",
"BBSFLAG", "QUALITY", "MAXFRAME", "TXDELAY", "SLOTTIME", "PERSIST",
"FULLDUP", "SOFTDCD", "FRACK", "RESPTIME", "RETRIES",
"PACLEN", "CWID", "PORTCALL", "PORTALIAS", "ENDPORT", "VALIDCALLS",
"QUALADJUST", "DIGIFLAG", "DIGIPORT", "USERS" ,"UNPROTO", "PORTNUM",
"TXTAIL", "ALIAS_IS_BBS", "L3ONLY", "KISSOPTIONS", "INTERLOCK", "NODESPACLEN",
"TXPORT", "MHEARD", "CWIDTYPE", "MINQUAL", "MAXDIGIS", "PORTALIAS2", "DLLNAME",
"BCALL", "DIGIMASK", "NOKEEPALIVES", "COMPORT", "DRIVER", "WL2KREPORT", "UIONLY",
"UDPPORT", "IPADDR", "I2CBUS", "I2CDEVICE", "UDPTXPORT", "UDPRXPORT", "NONORMALIZE",
"IGNOREUNLOCKEDROUTES", "INP3ONLY", "TCPPORT"}; /* parameter keywords */
static int poffset[] =
{
2, 32, 34, 36, 38, 40, 42,
44, 46, 48, 50, 52, 54,
56, 58, 60, 62, 64,
66, 80, 90, 100, 127, 256,
68, 70, 71 ,74, 128, 0,
76, 78, 110, 112, 114, 116,
118, 120, 121, 122, 123, 200, 210,
226, 72, 124, 516, 210, 512, 125,
36, 236, 38, 36, 36, 126, 243,
111, 242, 244}; /* offset for corresponding data in config file */
static int proutine[] =
{
4, 5, 8, 3, 1, 1, 7,
6, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1,
1, 0, 0, 0, 9, 10,
1, 13, 13, 1, 11, 1,
1, 2, 2, 12, 1, 1,
1, 7, 7, 13, 13, 0, 14,
0, 1, 2, 18, 15, 16, 2,
1, 17, 1, 1, 1, 1, 2,
2, 2, 1}; /* routine to process parameter */
int PPARAMLIM = sizeof(proutine)/sizeof(int);
static int fileoffset = 0;
static int portoffset = 2560;
static int tncportoffset = 384;
static int endport = 0;
static int portnum = 1;
static int porterror = 0;
static int tncporterror = 0;
static int dedporterror = 0;
static int kissflags = 0;
static int NextAppl = 0;
/************************************************************************/
/* Global variables */
/************************************************************************/
int paramok[100]; /* PARAMETER OK FLAG */
FILE *fp1; /* TEXT INPUT FILE */
static char s1[80];
static char s2[80];
static char s3[80];
static char s4[80];
static char s5[80];
static char s6[80];
static char s7[80];
static char s8[80];
char commas[]=",,,,,,,,,,,,,,,,";
char bbscall[11];
char bbsalias[11];
int bbsqual;
BOOL LocSpecified = FALSE;
/************************************************************************/
/* MAIN PROGRAM */
/************************************************************************/
VOID WarnThread();
int LineNo = 0;
int heading = 0;
struct CONFIGTABLE * xxcfg;
UCHAR CfgBridgeMap[33][33];
BOOL ProcessConfig()
{
int i;
char rec[MAXLINE];
int Cfglen = sizeof(struct CONFIGTABLE);
struct APPLCONFIG * App;
heading = 0;
fileoffset = 0;
portoffset = 2560;
tncportoffset = 384;
portnum = 1;
NextAppl = 0;
LOCATOR[0] = 0;
MAPCOMMENT[0] = 0;
for (i = 0; i < 35; i++)
{
if (PortConfig[i])
{
free(PortConfig[i]);
PortConfig[i] = NULL;
}
if (RigConfigMsg[i])
{
free(RigConfigMsg[i]);
RigConfigMsg[i] = NULL;
}
PortDefined[i] = FALSE;
}
TNCCONFIGTABLE = NULL;
NUMBEROFTNCPORTS = 0;
Consoleprintf("Configuration file Preprocessor.");
if (BPQDirectory[0] == 0)
{
strcpy(inputname, "bpq32.cfg");
}
else
{
strcpy(inputname,BPQDirectory);
strcat(inputname,"/");
strcat(inputname, "bpq32.cfg");
}
if ((fp1 = fopen(inputname,"r")) == NULL)
{
Consoleprintf("Could not open file %s",inputname);
return FALSE;
}
Consoleprintf("Using Configuration file %s",inputname);
ConfigBuffer = malloc(100000);
memset(ConfigBuffer, 0, 100000);
xxcfg = (struct CONFIGTABLE * )ConfigBuffer;
App = (struct APPLCONFIG *)&ConfigBuffer[ApplOffset];
memset(CfgBridgeMap, 0, sizeof(CfgBridgeMap));
for (i=0; i < NumberofAppls; i++)
{
memset(App->Command, ' ', 12);
memset(App->CommandAlias, ' ', 48);
memset(App->ApplCall, ' ', 10);
memset(App->ApplAlias, ' ', 10);
App++;
}
fp2 = ConfigBuffer;
GetNextLine(rec);
while (rec[0])
{
decode_rec(rec);
GetNextLine(rec);
}
paramok[6]=1; /* dont need BUFFERS */
paramok[8]=1; /* dont need TRANSDELAY */
paramok[17]=1; /* dont need TNCPORTS */
paramok[20]=1; // Or ROUTES
paramok[32]=1; /* dont need UNPROTO */
paramok[35]=1; /* dont need EMS */
paramok[37]=1; /* dont need DESQVIEW */
paramok[38]=1; /* dont need HOSTINTERRUPT */
paramok[40]=1; /* or DEDHOST */
paramok[42]=1; /* or SIMPLE */
paramok[43]=1; /* or AUTOSAVE */
paramok[44]=1; /* or L4APPL */
paramok[16]=1; // BBSCALL
paramok[14]=1; // BBSALIAS
paramok[33]=1; // BBSQUAL
paramok[34]=1; // APPLICATIONS
if (paramok[45]==1)
{
paramok[16]=1; // APPL1CALL overrides BBSCALL
bseek(fp2,(long) 20,SEEK_SET);
for (i=0; i<10; i++)
{
if (bbscall[i] == 0)
bputc(32,fp2);
else
bputc(bbscall[i],fp2);
}
}
if (paramok[53]==1)
{
paramok[14]=1; // APPL1ALIAS overrides BBSALIAS
bseek(fp2,(long) 30,SEEK_SET);
for (i=0; i<10; i++)
{
if (bbsalias[i] == 0)
bputc(32,fp2);
else
bputc(bbsalias[i],fp2);
}
}
if (paramok[61]==1)
{
paramok[33]=1; // APPL1QUAL overrides BBSQUAL
bseek(fp2,(long) 118,SEEK_SET);
bputi(bbsqual,fp2);
}
for (i=0;i<24;i++)
paramok[45+i]=1; /* or APPLCALLS, APPLALIASS APPLQUAL */
paramok[69]=1; // BText optional
paramok[70]=1; // IPGateway optional
paramok[71]=1; // C_IS_CHAT optional
paramok[72]=1; // MAXRTT optional
paramok[73]=1; // MAXHOPS optional
paramok[74]=1; // LogL4Connects optional
for (i=0; i < PARAMLIM; i++)
{
if (paramok[i] == 0)
{
if (heading == 0)
{
Consoleprintf(" ");
Consoleprintf("The following parameters were not correctly specified");
heading = 1;
}
Consoleprintf(keywords[i]);
}
}
if (portnum == 1)
{
Consoleprintf("No valid radio ports defined");
heading = 1;
}
bseek(fp2,(long) 255,SEEK_SET);
bputc(FILEVERSION,fp2);
if (Comment)
{
Consoleprintf("Unterminated Comment (Missing */) at line %d", CommentLine);
heading = 1;
}
fclose(fp1);
if (LOCATOR[0] == 0 && LocSpecified == 0 && RFOnly == 0)
{
Consoleprintf("");
Consoleprintf("Please enter a LOCATOR statment in your BPQ32.cfg");
Consoleprintf("If you really don't want to be on the Node Map you can enter LOCATOR=NONE");
Consoleprintf("");
// _beginthread(WarnThread, 0, 0);
}
memcpy(&ConfigBuffer[BridgeMapOffset], CfgBridgeMap, sizeof(CfgBridgeMap));
if (heading == 0)
{
Consoleprintf("Conversion (probably) successful");
Consoleprintf("");
}
else
{
Consoleprintf("Conversion failed");
return FALSE;
}
/*
// Dump to file for debugging
sprintf_s(inputname, sizeof(inputname), "CFG%d", time(NULL));
fp1 = fopen(inputname, "wb");
if (fp1)
{
fwrite(ConfigBuffer, 1, 100000, fp1);
fclose(fp1);
}
*/
return TRUE;
}
/************************************************************************/
/* Decode PARAM= */
/************************************************************************/
int decode_rec(char * rec)
{
int i;
int cn = 1; /* RETURN CODE FROM ROUTINES */
char key_word[300] = "";
char value[300] = "";
if (_memicmp(rec, "IPGATEWAY", 9) == 0 && rec[9] != '=') // IPGATEWAY, not IPGATEWAY=
{
// Create Embedded IPGateway Config
// Copy all subsequent lines up to **** to a memory buffer
char * ptr;
struct CONFIGTABLE * cfg = (struct CONFIGTABLE *)ConfigBuffer;
PortConfig[33] = ptr = malloc(50000);
*ptr = 0;
GetNextLine(rec);
while (!feof(fp1))
{
if (_memicmp(rec, "****", 3) == 0)
{
PortConfig[33] = realloc(PortConfig[33], (strlen(ptr) + 1));
cfg->C_IP = 1;
return 0;
}
strcat(ptr, rec);
strcat(ptr, "\r\n");
GetNextLine(rec);
}
Consoleprintf("Missing **** for IPGateway Config %d", portnum);
heading = 1;
return 0;
}
if (_memicmp(rec, "PORTMAPPER", 10) == 0)
{
// Create Embedded portmapper Config
// Copy all subsequent lines up to **** to a memory buffer
char * ptr;
struct CONFIGTABLE * cfg = (struct CONFIGTABLE *)ConfigBuffer;
PortConfig[35] = ptr = malloc(50000);
*ptr = 0;
GetNextLine(rec);
while (!feof(fp1))
{
if (_memicmp(rec, "****", 3) == 0)
{
PortConfig[35] = realloc(PortConfig[35], (strlen(ptr) + 1));
cfg->C_PM = 1;
return 0;
}
strcat(ptr, rec);
strcat(ptr, "\r\n");
GetNextLine(rec);
}
Consoleprintf("Missing **** for Portmapper Config %d", portnum);
heading = 1;
return 0;
}
if (_memicmp(rec, "APRSDIGI", 8) == 0)
{
// Create Embedded APRS Config
// Copy all subsequent lines up to **** to a memory buffer
char * ptr;
struct CONFIGTABLE * cfg = (struct CONFIGTABLE * )ConfigBuffer;
PortConfig[34] = ptr = malloc(50000);
*ptr = 0;
// Don't use GetNextLine - we need to keep ; in messages
fgets(rec,MAXLINE,fp1);
LineNo++;
while (!feof(fp1))
{
if (_memicmp(rec, "****", 3) == 0)
{
PortConfig[34] = realloc(PortConfig[34], (strlen(ptr) + 1));
return 0;
}
if (strlen(rec) > 1)
{
if (memcmp(rec, "/*", 2) == 0)
{
Comment = TRUE;
CommentLine = LineNo;
goto NextAPRS;
}
else if (memcmp(rec, "*/", 2) == 0)
{
Comment = FALSE;
goto NextAPRS;
}
}
if (Comment)
goto NextAPRS;
strcat(ptr, rec);
strcat(ptr, "\r\n");
NextAPRS:
fgets(rec,MAXLINE,fp1);
LineNo++;
}
if (_memicmp(rec, "****", 3) == 0)
return 0; // No Newline after ***
Consoleprintf("Missing **** for APRS Config %d", portnum);
heading = 1;
return 0;
}
if (_memicmp(rec, "PASSWORD", 8) == 0)
{
// SYSOP Password
if (strlen(rec) > 88) rec[88] = 0;
_strupr(rec);
strcpy(PWTEXT, &rec[9]);
return 0;
}
#ifdef LINBPQ
if (_memicmp(rec, "LINMAIL", 7) == 0)
{
// Enable Mail on Linux Verdion
IncludesMail = TRUE;
return 0;
}
if (_memicmp(rec, "LINCHAT", 7) == 0)
{
// Enable Chat on Linux Verdion
IncludesChat = TRUE;
return 0;
}
#endif
if (_memicmp(rec, "HFCTEXT", 7) == 0)
{
// HF only CTEXT (normlly short to reduce traffic)
if (strlen(rec) > 87) rec[87] = 0;
strcpy(HFCTEXT, &rec[8]);
HFCTEXTLEN = strlen(HFCTEXT);
HFCTEXT[HFCTEXTLEN - 1] = '\r';
return 0;
}
if (_memicmp(rec, "LOCATOR", 7) == 0)
{
// Station Maidenhead Locator or Lat/Long
char * Context;
char * ptr1 = strtok_s(&rec[7], " ,=\t\n\r:", &Context);
char * ptr2 = strtok_s(NULL, " ,=\t\n\r:", &Context);
LocSpecified = TRUE;
if (_memicmp(&rec[8], "NONE", 4) == 0)
return 0;
if (_memicmp(&rec[8], "XXnnXX", 6) == 0)
return 0;
if (ptr1)
{
strcpy(LOCATOR, ptr1);
if (ptr2)
{
strcat(LOCATOR, ":");
strcat(LOCATOR, ptr2);
ToLOC(atof(ptr1), atof(ptr2), LOC);
}
else
{
if (strlen(ptr1) == 6)
strcpy(LOC, ptr1);
}
}
return 0;
}
if (_memicmp(rec, "MAPCOMMENT", 10) == 0)
{
// Additional Info for Node Map
char * ptr1 = &rec[11];
char * ptr2 = MAPCOMMENT;
while (*ptr1)
{
if (*ptr1 == ',')
{
*ptr2++ = '&';
*ptr2++ = '#';
*ptr2++ = '4';
*ptr2++ = '4';
*ptr2++ = ';';
}
else
*(ptr2++) = *ptr1;
ptr1++;
if ((ptr2 - MAPCOMMENT) > 248)
break;
}
*ptr2 = 0;
return 0;
}
// Process BRIDGE statement
if (_memicmp(rec, "BRIDGE", 6) == 0)
{
int DigiTo;
int Port;
char * Context;
char * p_value;
char * ptr;
p_value = strtok_s(&rec[7], ",=\t\n\r", &Context);
Port = atoi(p_value);
if (Port > 32)
return FALSE;
if (Context == NULL)
return FALSE;
ptr = strtok_s(NULL, ",\t\n\r", &Context);
while (ptr)
{
DigiTo = atoi(ptr);
if (DigiTo > 32)
return 0;
if (Port != DigiTo) // Not to our port!
CfgBridgeMap[Port][DigiTo] = TRUE;
ptr = strtok_s(NULL, " ,\t\n\r", &Context);
}
return 0;
}
// AGW Emulator Params
if (_memicmp(rec, "AGWPORT", 7) == 0)
{
AGWPort = atoi(&rec[8]);
return 0;
}
if (_memicmp(rec, "AGWSESSIONS", 11) == 0)
{
AGWSessions = atoi(&rec[12]);
return 0;
}
if (_memicmp(rec, "AGWMASK", 7) == 0)
{
AGWMask = strtol(&rec[8], 0, 0);
return 0;