forked from MarkHofmann11/WWIVTOSS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
4DMATRIX.C
3696 lines (3390 loc) · 138 KB
/
4DMATRIX.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
/* ------------------------------------------------------------------------ */
#include <alloc.h>
/* conio.h used for testing lines */
#include <conio.h>
#include <ctype.h>
#include <dos.h>
#include <dir.h>
#include <errno.h>
#include <fcntl.h>
#include <io.h>
#include <process.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys\\stat.h>
#define my_version "4DMatrix v1.17"
/* maximum # bytes in a single message */
#define MAX_MSG_SIZE 32000
/* table size for echo areas */
#define MAX_AREAS 150
/* table size for equates of areas to BBS's (50 x 50 = 2500) */
#define MAX_FIX 2500
/* table size for the SEEN-BY's */
#define MAX_SEEN 250
/* table size for the PATH's */
#define MAX_PATH 100
/* table size for disposition info */
#define MAX_DISPOSITION 40
/* table size for routing info */
#define MAX_ROUTES 50
/* table size for ARCmail info */
#define MAX_ARCS 50
#define MAX_ARC_TYPES 5
/* table size for passwords */
#define MAX_PASSWORDS 50
/* table size for message-limit info */
#define MAX_LIMITS 20
/* default outgoing message type if none specified
'H' - hold.... 'C' - Crash.... 'O' - Normal */
#define DEFAULT_DISPOSITION 'H'
struct ffblk ffblk;
char *BINKpath = "";
int outbound_file;
int incoming_file;
FILE *log_file;
int i;
int testing;
int verbose;
int logging;
int my_net;
int my_node;
int point_net;
int netmail_net;
int netmail_node;
int exit_status;
char origin_handling;
struct date work_date;
struct time work_time;
struct ffblk ff;
long work_long_secs;
/* ----------------------------
* Misc global string variables
* ---------------------------- */
char fido_title[255], /* limited to 72 chars */
fido_to_user[255], /* limited to 36 chars */
fido_from_user[255], /* limited to 36 chars */
fido_area_name[81], /* area name for echomail */
fido_origin[255], /* Origin line for echomail */
fido_EID_info[81], /* Opus dupe-killer info */
my_origin[81], /* the " * Origin:" line text */
my_tear[81], /* the "---" tear-line text */
via_line[81], /* message for forwarded mail */
arcmail_path[64], /* the destination directory for ARCmail files */
outbound_path[64], /* the directory for outgoing packets */
inbound_path[64], /* the directory for incoming packets */
frontdoor_path[64]; /* the directory for MSG file-attach messages */
int fido_from_point; /* point # the message is from */
int fido_to_point; /* point # the message is to */
/* --------------------------------
* definition of net/node structure
* -------------------------------- */
typedef struct {
int net;
int node;
} netnode;
netnode curr_out_netnode; /* net/node of currently opened .PKT file */
netnode true_origin;
char curr_out_disposition; /* file-type "H"=.HUT "C"=.CUT, etc. */
/* ----------------------------------------------
* definition of beginning of message packet file
* ---------------------------------------------- */
typedef struct {
int orig_node;
int dest_node;
int year;
int month;
int day;
int hour;
int minute;
int second;
int baud;
int packet_type;
int orig_net;
int dest_net;
char product_code;
char fill[33];
} packet_header_struct;
packet_header_struct packet_header;
/* ----------------------------
* definition of message header
* ---------------------------- */
typedef struct {
int id;
int orig_node;
int dest_node;
int orig_net;
int dest_net;
int attribute;
int cost;
char datetime[20];
} message_header_struct;
message_header_struct message_header;
/* -----------------------------------------------------------------
* definition of configuration structure for other nodes in echo-net
* ----------------------------------------------------------------- */
typedef struct {
netnode disposition_netnode;
char disposition_filetype; /* C=.CUT N=.OUT O=.OUT, H=.HUT, D=.DUT, etc. */
} disposition_node_struct;
int curr_disposition_node;
int num_disposition_nodes;
disposition_node_struct disposition[MAX_DISPOSITION];
/* -------------------------------------------------------------------------- */
/* Echomail control structures diagram. Shows a sample AREA which is */
/* distributed to two other systems. */
/* */
/* area[n] */
/* ----------------- */
/* | type (E/G) | */
/* ----------------- */
/* | flags | areafix[x] areafix[y] */
/* ----------------- --------------------- --------------------- */
/* | pointer |-----> | net/node | pointer|-----> | net/node | pointer| */
/* ----------------- --------------------- --------------------- */
/* | ECHO_NAME | | */
/* ----------------- | */
/* NULL */
/* -------------------------------------------------------------------------- */
/* ----------------------------
* echomail distribution matrix
* ---------------------------- */
typedef struct areafix_type {
netnode fixnode;
struct areafix_type * fixnext;
} areafix_struct;
areafix_struct areafix[MAX_FIX];
int num_fixes;
/* ----------------------------------------
* definition of configuration structure
* associating AREAs with the list of nodes
* who receive those areas.
* ---------------------------------------- */
typedef struct {
char areatype;
int areaflags;
areafix_struct *arealist;
char areaname[81];
} area_struct;
int curr_area;
int num_areas;
area_struct area[MAX_AREAS];
#define areaflag_strip_SEEN 0x0001
#define areaflag_strip_ORIGIN 0x0002
#define areaflag_zonegate 0x0004
#define areaflag_keep_pointnet 0x0008
#define areaflag_manual_add 0x0010
#define areaflag_manual_del 0x0020
/* -----------------------
* echomail seen-by matrix
* ----------------------- */
netnode seen_by[MAX_SEEN];
netnode saw_by[MAX_SEEN];
int num_seens;
int num_saws;
/* --------------------
* echomail PATH matrix
* -------------------- */
netnode path[MAX_PATH];
int num_paths;
/* -------------------
* Mail routing matrix
* ------------------- */
typedef struct {
netnode route_from;
netnode route_to;
} route_struct;
route_struct route[MAX_ROUTES];
int num_routes;
/* ------------------
* ARCmail specifiers
* ------------------ */
typedef struct {
netnode arc_to;
char arc_type;
char arc_flag;
} arcmail_struct;
arcmail_struct arcmail[MAX_ARCS];
int num_arcs;
int num_arc_types;
char arc_text[MAX_ARC_TYPES][80];
/* ------------------------------
* message-count limit specifiers
* ------------------------------ */
typedef struct {
netnode who;
int count;
int max;
char name;
} limit_struct;
limit_struct limit[MAX_LIMITS];
int num_limits;
int curr_limit; /* -1 if no match */
/* ----------------
* Password storage
* ---------------- */
typedef struct {
netnode pass_who;
unsigned char pass_AR;
char pass_word[13];
} password_struct;
password_struct password[MAX_PASSWORDS];
int num_passes;
void invent_pkt_name (char * string)
{
struct tm *tp;
time_t ltime;
time (<ime);
tp = localtime (<ime);
sprintf (string, "%02d%02d%02d%02d.pkt",
tp->tm_mday, tp->tm_hour, tp->tm_min, tp->tm_sec);
}
static char *suffixes[8] = {
"SU", "MO", "TU", "WE", "TH", "FR", "SA", NULL
};
int is_arcmail (p, n)
char *p;
int n;
{
int i;
char c[128];
if (!isdigit (p[n]))
{
return (0);
}
strcpy (c, p);
strupr (c);
for (i = n - 11; i < n - 3; i++)
{
if ((!isdigit (c[i])) && ((c[i] > 'F') || (c[i] < 'A')))
return (0);
}
for (i = 0; i < 7; i++)
{
if (strnicmp (&c[n - 2], suffixes[i], 2) == 0)
break;
}
if (i >= 7)
{
return (0);
}
return (1);
}
char upcase(char ch)
/* This converts a character to uppercase */
{
if ((ch>96) && (ch<123))
ch=ch-32;
return(ch);
}
void outchr(unsigned char ch)
{
write(outbound_file,(void *)&ch,1);
if (testing) {
_AL=ch;
_AH=0x0e;
_BL=0x07;
geninterrupt(0x10);
}
}
/* -------------------------------------------------------------
* Process the configuration files.
* These files should reside in the main BBS subdirectory (the
* same subdirectory from which BBS.EXE is executed.)
* This is a plain ASCII file, and contains various lines which
* specify various options for program operation. Each line must
* be terminated by a carriage-return character, and optionally
* a linefeed. Note that this departs from UNIX/XENIX standards
* but follows MSDOS standards. It is expected that other ports
* of this program will follow the conventions used on those
* systems.
* ------------------------------------------------------------- */
void get_areafix_config(void)
{
unsigned char s[255];
unsigned char wkstr[25];
int areafix_config_file;
int p,i;
char area_type;
int area_flags;
int init_area;
int config_linecount;
unsigned char area_name[81];
unsigned char * sline;
unsigned char * wksp;
unsigned char * temp_sp;
char ch;
netnode user_netnode;
int curr_net;
areafix_struct * last_fix;
areafix_struct * first_fix;
config_linecount=0;
num_fixes=0;
my_net = -1;
my_node = -1;
strcpy(s,"AREAFIX.CFG");
areafix_config_file=-1;
if ((areafix_config_file=open(&s[0],O_RDONLY | O_BINARY))==NULL) {
printf("error opening areafix_config_file file: %s. errno=%d\n",s,errno);
exit_status=1;
return;
}
p=0;
sline=&s[0];
while (read(areafix_config_file,(void *)&ch,1)) {
if (ch!=0x0a){
if (ch!=0x0d) {
if (p < 255) {
s[p++]=ch;
} else {
s[p]=0;
printf("Line %d too long in AREAFIX.CFG at %s\n",config_linecount,s);
exit_status=1;
return;
}
} else {
++config_linecount;
s[p]=0;
p=0;
sline=&s[0];
/* ---------------------------
* Skip any leading whitespace
* --------------------------- */
while ((*sline == ' ')
|| (*sline == 0x09) )
++sline;
/* -------------------------
* get the name of this AREA
* ------------------------- */
if ((temp_sp=strchr(sline,' ')) == NULL) {
printf("error in format of areafix config file: Line %d\n", config_linecount);
exit_status=1;
return;
}
*temp_sp++=0; /* make a terminator on the string */
strcpy(area_name,sline);
/* ------------------------------------------------
* check if it's a new area, or a continuation line
* ------------------------------------------------ */
init_area = -1;
for (curr_area=0 ; curr_area < num_areas ; curr_area++) {
if (!strcmp(area[curr_area].areaname,area_name)) {
init_area = curr_area;
break;
}
}
/* ---------------------------------------------------
* if it's a new area, begin a fresh area[] entry
* if it's an existing echo, initialize linkage info
* to point to the last entry already present.
* --------------------------------------------------- */
first_fix=NULL;
if (init_area == -1) {
init_area = num_areas;
last_fix = NULL;
} else {
first_fix = area[init_area].arealist;
last_fix = first_fix;
while ((last_fix -> fixnext) != NULL) {
last_fix = last_fix -> fixnext;
}
}
sline=temp_sp; /* point to next char on line */
while ((*sline == ' ')
|| (*sline == 0x09) )
++sline;
area_type=upcase(*sline++);
if ((area_type != 'G')
&& (area_type != 'E')) {
printf("bad Echomail/Groupmail flag in AREAFIX.CFG Line %d at '%s'\n", config_linecount,sline);
exit_status=1;
return;
}
while ((*sline == ' ')
|| (*sline == 0x09) )
++sline;
/* ---------------------------------
* check for optional echomail flags
* --------------------------------- */
area_flags=0;
if (*sline == '^') {
sscanf(++sline,"%x",&area_flags);
if (testing) {
printf("Found area_flags = %x\n",area_flags);
}
while ((*sline != ' ')
&& (*sline != 0x09))
++sline;
}
while ((*sline == ' ')
|| (*sline == 0x09))
++sline;
/* ----------------------------------------------------
* build the linked list of nodes who receive this echo
* ---------------------------------------------------- */
curr_net=0;
for(;;) {
/* -----------------------
* skip any leading blanks
* ----------------------- */
while ((*sline == ' ')
|| (*sline == 0x09))
++sline;
/* ------------------------
* exit when at end of line
* ------------------------ */
if ((*sline == 0)
|| (*sline == 0x8d)
|| (*sline == 0x0d)
|| (*sline == 0x0a)) {
break; /* goes to comment "sline_exit" */
}
/* -----------------------------------------------
* copy next blank-delimited string into work-area
* ----------------------------------------------- */
wksp=&wkstr[0];
i=0;
while ((*sline != ' ')
&& (*sline != 0)
&& (*sline != 0x8d)
&& (*sline != 0x0d)
&& (*sline != 0x0a)) {
*wksp++ = *sline++;
if ((++i) >= 20) /* enforce string length limit */
--wksp;
}
*wksp=0;
if (testing) {
printf("Area %s, node: %s\n",area_name,wkstr);
}
/* -------------------------------------------------
* determine if this is a net/node, or just a node #
* ------------------------------------------------- */
if ((wksp=strchr(&wkstr[0],'/')) != NULL) {
user_netnode.net=atoi(&wkstr[0]);
++wksp;
if (!strnicmp(wksp,"ALL",3)) {
user_netnode.node=-1;
} else {
user_netnode.node=atoi(wksp);
}
curr_net=user_netnode.net;
} else {
user_netnode.net=curr_net;
user_netnode.node=atoi(&wkstr[0]);
}
/* --------------------------------------
* add it into the echo distribution list
* -------------------------------------- */
if (num_fixes >= MAX_FIX){
printf("Too many area::net/node associations in AREAFIX.CFG - need to recompile\n");
exit_status=4;
return;
}
/* -------------------------------------------------------------------------------------- *\
| if this is the first echo in the list, save the pointer to put in the "area" structure |
\* -------------------------------------------------------------------------------------- */
if (first_fix == NULL) {
first_fix = &areafix[num_fixes];
if (testing) {
printf("First node this area\n");
}
}
/* --------------------------------------------------------------------------- *\
| if there was a previous node in this list, go patch it to point to this one |
\* --------------------------------------------------------------------------- */
if (last_fix != NULL) {
last_fix -> fixnext = &areafix[num_fixes];
}
areafix[num_fixes].fixnext = NULL;
areafix[num_fixes].fixnode = user_netnode;
last_fix=&areafix[num_fixes];
++num_fixes;
}
/* break above exits to here "sline_exit" */
if (num_areas >= MAX_AREAS){
printf("Too many AREA lines in AREAFIX.CFG - need to recompile\n");
exit_status=4;
return;
}
if (first_fix == NULL){
printf("Warning - area %s is not sent anywhere - line %d\n",
area_name,
config_linecount);
}
area[init_area].areatype = area_type;
area[init_area].areaflags = area_flags;
strcpy(area[init_area].areaname,area_name);
area[init_area].arealist = first_fix;
if (init_area == num_areas) {
num_areas++;
}
}
}
}
close(areafix_config_file);
if (testing) {
printf("%d areas.\n",num_areas);
for (i=0 ; i<num_areas ; i++) {
printf("Area: %s type %c flags %04x sent to :", area[i].areaname, area[i].areatype, area[i].areaflags);
if (area[i].arealist == NULL) {
printf("*NOBODY*");
} else {
last_fix = area[i].arealist;
while (last_fix != NULL) {
printf("%d/%d ",(last_fix -> fixnode.net), (last_fix -> fixnode.node));
last_fix = last_fix -> fixnext;
}
}
printf("\n");
}
}
}
void get_routing(unsigned char * sline)
{
netnode curr_to;
int curr_net;
int net;
int node;
int i;
char wkstr[20];
unsigned char * wksp;
/* ------------------------
* Get the node to route TO
* ------------------------ */
while ((*sline == ' ')
|| (*sline == 0x09) )
++sline;
curr_to.net=atoi(sline);
if ((sline=strchr(sline,'/')) != NULL) {
curr_to.node=atoi(++sline);
} else {
printf("Expecting slash at line %s\n",sline);
}
sline=strchr(sline,' ');
if (testing) {
printf("Routing to node %d/%d\n",curr_to.net,curr_to.node);
}
/* -----------------------------------
* get the list of nodes to route FROM
* ----------------------------------- */
curr_net=0;
for(;;) {
/* -----------------------
* skip any leading blanks
* ----------------------- */
while ((*sline == ' ')
|| (*sline == 0x09))
++sline;
/* ------------------------
* exit when at end of line
* ------------------------ */
if ((*sline == 0)
|| (*sline == 0x8d)
|| (*sline == 0x0d)
|| (*sline == 0x0a))
return;
/* -----------------------------------------------
* copy next blank-delimited string into work-area
* ----------------------------------------------- */
wksp=&wkstr[0];
i=0;
while ((*sline != ' ')
&& (*sline != 0)
&& (*sline != 0x8d)
&& (*sline != 0x0d)
&& (*sline != 0x0a)) {
*wksp++ = *sline++;
if ((++i) >= 20) /* enforce string length limit */
--wksp;
}
*wksp=0;
/* -------------------------------------------------
* determine if this is a net/node, or just a node #
* ------------------------------------------------- */
if ((wksp=strchr(&wkstr[0],'/')) != NULL) {
net=atoi(&wkstr[0]);
++wksp;
if (!strnicmp(wksp,"ALL",3)) {
node=-1;
} else {
node=atoi(wksp);
}
curr_net=net;
} else {
net=curr_net;
node=atoi(&wkstr[0]);
}
/* --------------------------
* add it into the route list
* -------------------------- */
if (num_routes > MAX_ROUTES) {
printf("Too many routing entries - must recompile\n");
--num_routes;
}
route[num_routes].route_from.net = net;
route[num_routes].route_from.node = node;
route[num_routes].route_to.net = curr_to.net;
route[num_routes].route_to.node = curr_to.node;
++num_routes;
}
}
void add_disposition_list(char disp_type,unsigned char * sline)
{
int curr_net;
int net;
int node;
int i;
char wkstr[20];
unsigned char * wksp;
curr_net=0;
for(;;) {
/* -----------------------
* skip any leading blanks
* ----------------------- */
while ((*sline == ' ')
|| (*sline == 0x09))
++sline;
/* ------------------------
* exit when at end of line
* ------------------------ */
if ((*sline == 0)
|| (*sline == 0x8d)
|| (*sline == 0x0d)
|| (*sline == 0x0a))
return;
/* -----------------------------------------------
* copy next blank-delimited string into work-area
* ----------------------------------------------- */
wksp=&wkstr[0];
i=0;
while ((*sline != ' ')
&& (*sline != 0)
&& (*sline != 0x8d)
&& (*sline != 0x0d)
&& (*sline != 0x0a)) {
*wksp++ = *sline++;
if ((++i) >= 20) /* enforce string length limit */
--wksp;
}
*wksp=0;
/* -------------------------------------------------
* determine if this is a net/node, or just a node #
* ------------------------------------------------- */
if ((wksp=strchr(&wkstr[0],'/')) != NULL) {
net=atoi(&wkstr[0]);
++wksp;
if (!strnicmp(wksp,"ALL",3)) {
node=-1;
} else {
node=atoi(wksp);
}
curr_net=net;
} else {
net=curr_net;
node=atoi(&wkstr[0]);
}
/* --------------------------------
* add it into the disposition list
* -------------------------------- */
if (num_disposition_nodes > MAX_DISPOSITION) {
printf("Too many disposition entries - must recompile\n");
--num_disposition_nodes;
}
disposition[num_disposition_nodes].disposition_netnode.net=net;
disposition[num_disposition_nodes].disposition_netnode.node=node;
disposition[num_disposition_nodes].disposition_filetype=disp_type;
++num_disposition_nodes;
}
}
void add_arcmail_list(unsigned char * sline)
{
int curr_net;
int net;
int node;
int i;
char curr_type;
char wkstr[20];
unsigned char * wksp;
unsigned char * save_sline;
save_sline = sline;
curr_net=0;
curr_type=0;
for(;;) {
/* -----------------------
* skip any leading blanks
* ----------------------- */
while ((*sline == ' ')
|| (*sline == 0x09))
++sline;
/* ------------------------
* exit when at end of line
* ------------------------ */
if ((*sline == 0)
|| (*sline == 0x8d)
|| (*sline == 0x0d)
|| (*sline == 0x0a))
return;
/* -----------------------------------------------
* copy next blank-delimited string into work-area
* ----------------------------------------------- */
wksp=&wkstr[0];
i=0;
while ((*sline != ' ')
&& (*sline != 0)
&& (*sline != 0x8d)
&& (*sline != 0x0d)
&& (*sline != 0x0a)) {
*wksp++ = *sline++;
if ((++i) >= 20) /* enforce string length limit */
--wksp;
}
*wksp=0;
/* -------------------------------------------------------------
* if this item begins with "^", then it's an ARC-type indicator
* ------------------------------------------------------------- */
if (wkstr[0] == '^') {
i = atoi(&wkstr[1]);
if (i >= num_arc_types) {
printf("Invalid arctype at line %s\n",save_sline);
} else {
if (testing)
printf("type %d\n",i);
curr_type = i;
}
} else {
/* -------------------------------------------------
* determine if this is a net/node, or just a node #
* ------------------------------------------------- */
if ((wksp=strchr(&wkstr[0],'/')) != NULL) {
net=atoi(&wkstr[0]);
++wksp;
node=atoi(wksp);
curr_net=net;
} else {
net=curr_net;
node=atoi(&wkstr[0]);
}
/* --------------------------------
* add it into the disposition list
* -------------------------------- */
if (num_arcs > MAX_ARCS) {
printf("Too many ARCmail entries - must recompile\n");
--num_arcs;
}
arcmail[num_arcs].arc_to.net = net;
arcmail[num_arcs].arc_to.node = node;
arcmail[num_arcs].arc_type = curr_type;
arcmail[num_arcs].arc_flag = 0;
++num_arcs;
}
}
}
/* -------------------------------------------------------------
* Process the configuration files.
* These files should reside in the main BBS subdirectory (the
* same subdirectory from which BBS.EXE is executed.)
* This is a plain ASCII file, and contains various lines which
* specify various options for program operation. Each line must
* be terminated by a carriage-return character, and optionally
* a linefeed. Note that this departs from UNIX/XENIX standards
* but follows MSDOS standards. It is expected that other ports
* of this program will follow the conventions used on those
* systems.
* ------------------------------------------------------------- */
void get_system_config(void)
{
char s[255];
int system_config_file;
int p;
int config_linecount;
unsigned int wk_word;
char * wksp;
char ch;
config_linecount=0;
my_net = -1;
my_node = -1;
point_net = -1;
num_routes = 0;
num_arcs = 0;
num_arc_types = 0;
netmail_net = 0;
num_passes = 0;
num_limits = 0;
curr_limit = -1;
strcpy(s,"4DMATRIX.CFG");
system_config_file=-1;
if ((system_config_file=open(&s[0],O_RDONLY | O_BINARY))==NULL) {
printf("error opening system_config_file file: %s. errno=%d\n",s,errno);
exit_status=1;
return;
}
p=0;
while (read(system_config_file,(void *)&ch,1)) {
if (ch!=0x0a){
if (ch!=0x0d) {
if (p < 255) {
s[p++]=ch;
} else {
s[p]=0;
printf("Line %d too long in 4DMATRIX.CFG at %s\n",config_linecount,s);
exit_status=1;
return;
}
} else {
++config_linecount;
s[p]=0;
p=0;
wksp=&s[0];
/* ---------------------------
* Skip any leading whitespace
* --------------------------- */
while ((*wksp == ' ')
|| (*wksp == 0x09) )
++wksp;
/* ----------------------------------
* get the node number of this system
* ---------------------------------- */
if (!strnicmp(wksp,"MYNODE",6)) {
wksp=&s[6];
while ((*wksp == ' ')
|| (*wksp == 0x09) )
++wksp;
my_net=atoi(wksp);
if ((wksp=strchr(wksp,'/')) != NULL) {
my_node=atoi(++wksp);
} else {
printf("Expecting slash at line %s\n",s);
}
if (testing) {
printf("Mynode is %d/%d\n",my_net,my_node);
}
}
/* ----------------------------------
* get the password for another node
* ---------------------------------- */
if (!strnicmp(wksp,"PASSWORD",8)) {
wksp=&s[8];
while ((*wksp == ' ')
|| (*wksp == 0x09) )
++wksp;
password[num_passes].pass_who.net=atoi(wksp);
if ((wksp=strchr(wksp,'/')) != NULL) {
password[num_passes].pass_who.node=atoi(++wksp);
} else {
printf("Expecting slash at line %s\n",s);
}
wksp=strchr(wksp,' ');
while ((*wksp == ' ')
|| (*wksp == 0x09) )
++wksp;