forked from oe5hpm/openBCM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fwd.cpp
3801 lines (3655 loc) · 114 KB
/
fwd.cpp
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
/***************************************************************
BayCom(R) Packet-Radio fuer IBM PC
OpenBCM-Mailbox
-----------------------------------------------------------------
Allgemeine Forward-Ein- und Ausgabe sowie Adressierungsauswertung
-----------------------------------------------------------------
Copyright (C) Florian Radlherr et al
Taubenbergstr. 32
83627 Warngau
Alle Rechte vorbehalten / All Rights Reserved
***************************************************************/
//19980109 OE3DZW Added debug output isforwardpartner()
// Removed check for D-Box (bin-fwd)
// Added Call & BID in Errmsg "bin-mail could not be fwded"
// Added seperator for "d p"
//19980115 OE3DZW reduced priority of err-msges in delfwdlistentry
// Text "Info-mails" in "st f"
// Added comment
//19980118 OE3DZW Removed REJ from trace (for s52d)
//19880118 OE3DZW sec in timestr
//19980120 OE3DZW Removed Space in st f, added fix 80 Bytes per
// Mail (incl. E/M),
//19980124 OE3DZW fwdprop max. 127
// Added Fwd-Style to Fwd-Log
// Remove trace rx-sid, removed boxtypes
// Fixed sidrtt
// SID may be 119 chars long (was 79 before) - for Wingt-pw
// removed support for -S-flag in forwarding
//19980126 OE3DZW fixed fwd-machine (went from FBB into ASCII-Mode)
//19980128 OE3DZW Twice sid in fwd log, fixed
// added fbb-states to st-f command
//19980205 OE3DZW better alignment at st f
// fixed sid-rtt
//19980211 OE3DZW fixed lastconok, was not set
// added number of incoming/outgoing connects to st f
// removed err-msg in fpara()
//19980215 OE3DZW alignment st f
//19980216 OE3DZW removed old entries in fwd-triggerfile
// checked fwd-trigger before starting fwd for erased mail
//19980223 OE3DZW fwdget to 78 (was 119) due seg fault, will not accept wingt-pw
//19980225 OE3DZW fixed above bug, wingt-fwd should be ok now
//19980301 OE3DZW fixed fwdlog
// removed debug output in killfwded
// removed CTRLZ from log
// chkforward() entfernt alte eintraege, keine leeren vorschlaege im fbb-fwd
//19980302 OE3DZW added check for logincall when init fwd-list
// added return-mail to hold-function
// only mails type P/A are set to hold, not bulletins
//19980304 OE3DZW fixed bug, fwd bulletins were erased
//19980307 OE3DZW will not erase but hold if personal, also when o_r
//19980309 OE3DZW initfwdlist - output only when logincall
// add_hold with reason
//19980311 DG9MHZ changes for Linux-Kernel AX25
//19980311 OE3DZW removed unused variables
//19980318 OE3DZW more robust against invalid entries in fwd-triggerfile
// fixed bug in killfwded, added some debug-output
//19980329 OE3DZW E/M-lines will be put into the fwd-log (ascii-fwd)
//19980404 OE3DZW hold-msg only in fwd-standard,not in user-fwd
//19980404 hrx support tty-fwd
//19980408 OE3DZW fwd should be started when there is a mail to send
//19980418 DH3MB added space for diebox-pwd
//19980418 OE3DZW fwdlog shows taskid (was tnc-number)
//19980420 OE3DZW removed dashes after protests of flori,deti,chris an me
// Total only if at least on mail in queue
//19980421 OE3DZW no UNKNOWN mail for CP-Mails
//19980423 OE3DZW hold due to loop only if not held before
// included returnmailok()
//19980505 OE3DZW used rm_crlf instead of x[strlen(x)-1]=0..
//19980524 OE3DZW removed Fwd-Option -o in fwd.bcm
//19980609 OE3DZW killfwd will check for 0x00..0x00
// usermails will be erased when replied with "no" in userfwd
// sfhold - added parameter returnmail
//19980610 OE3DZW sfhold - not for "sysop" mails of type "p"
//19980614 OE3DZW killfwded will also remove entries longer 50 chars
//19980615 OE3DZW new fwdproc_reply - common for ascii and fbb-fwding
//19980830 OE3DZW text fwdreply no changed to "already rcvd", was
// not clear
//19980914 OE3DZW mails not twice in one proposal
//19980916 OE3DZW fwdlog will show taskid even on logout
//19981013 OE3DZW binary personal messages will be sent to fbb's
//19981015 OE3DZW users may totally disable active userforwarding
//19990201 OE3DZW commented out conat()
//19990211 OE3DZW added "W" to SID, added check for D2..D4 and B2..B4 in SID
//19990214 OE3DZW when fwd-times are incorrect, standard will be used
//19990215 OE3DZW generating sample fwd.bcm
//19990427 OE3DZW replaced E/M by WP in st f
//19990726 OE3DZW fixed security bug
//19990817 OE3DZW added JJ's code, added fwdoption -l
//19990918 OE3DZW added Jan's changes: filefwd
//19991028 Jan changes for telnetfwd
//20000101 OE3DZW fixed y2k-problem with DieBox-PW in S&F (100 -> 00)
// dk2ui (dzw) st f with em/wp
//20000111 OE3DZW activated fwd-by-size again, added sema-locks
//19991127 DF3VI added savefwdlist(), fwdlistedit(): edit fwd.bcm
//19991129 DF3VI reinvented E/M in "st f", summary also in Kb, Mb
//19991212 DF3VI changed structure of initfwdlist etc.
//19991221 DF3VI changed weiterleiten for new fwd-structure
//19991227 DF3VI if weiterleiten == unbekannt, take b->at from u.mybbs
//20000402 DF3VI added HOLD-features to add_fwdfile()
// needed changes in fwd-password-routines!
//20000518 DK2UI dest_idx array from stack to malloc
//20000520 DK2UI weiterleiten4() complete revised
//20000623 DK2UI hold with reject corrected
//20000818 DK2UI send file is closed in scanheader()
//20001113 DK2UI use of new function log_entry for fwdlog
//20010216 DF3VI fixed bugs in fwdlog and sidauswert
//20020110 DH8YMB RAUSCALL auf 15Zeichen statt 10, TRACE-Hinweise bei
// waitconnect() hinzu!
//20020723 JJ Unterdrueckung BIN/7+ Mails in Forward verfeinert
//20021031 hpk Sending Z-Sign in FWD-SID for a connection with the CB-BCMNET
//20030101 hpk if a mail is coming from a guest, the mail will be set on hold
// this action will be active if searchreject returns 'Z'.
//20030104 hpk fix: autorouter can now route with the full-destination, if
// neccesary.
//20030326 DH8YMB Funktion checkdouble_fwdfile hinzu
//20030416 DH8YMB fix: Autorouter may crashed if tempdest was uninitialized
//20030418 DH8YMB checkdouble_fwdfile deaktiviert (zu schlechte Performance),
// dafuer Funktion remove_oldentry hinzu
//20030809 hpk added CB-BCMNET gateway functions
//20030809 hpk some changes in HOLD for CB-BCMNET login-concept
#include "baycom.h"
//hadr.cpp
//extern void uclose (void);
//extern void hadr_tryopen (void);
//extern int loadhadr (char *hadrcall, hadr_t *u, int anlegen);
/*---------------------------------------------------------------------------*/
#define DUMMY "DUMMY"
#define MIN_TRIG_LEN 11 // fwd file
unsigned fwdpartners = 0;
unsigned fwddestlen = 0;
unsigned fwddest = 0;
#ifdef __FLAT__
#ifdef __LINUX__
static unsigned long long *dest_idx = NULL;
#define LONG_ZERO 0LL
#define LONG_ONE 1LL
#else // Win32
static __int64 *dest_idx = NULL;
#define LONG_ZERO 0I64
#define LONG_ONE 1I64
#endif
#else
static unsigned long *dest_idx = NULL;
#define LONG_ZERO 0L
#define LONG_ONE 1L
#endif
static fwdpara_t *fp = NULL; // dynamisch bei "new" allocieren,
static char *boxdest = NULL; // kein Datensegmentplatz verschwenden!
// boxdest = Liste mit allen Zielbezeichnern, in der Reihenfolge des
// Forwardfiles, jeweils durch ein Blank von einander getrennt. Durch
// dest_idx[] kann festgestellt werden, zu welchen Boxen das jeweilige Ziel
// gehoert.
/*---------------------------------------------------------------------------*/
int waitfwdprompt (char *buf)
//*************************************************************************
//
// Wartet auf ein Forward-Prompt (Wird benutzt beim SID-Austausch
// und beim RLI-Forwarding)
//
// Rueckgabe:
// 0..Linkfehler
// 1..Prompt > (Normales Prompt)
// 2..CRC-Fehler-BIN-Prompt
//
//*************************************************************************
{
lastfunc("waitfwdprompt");
#ifdef _FILEFWD
if (b->forwarding == fwd_file) return 1;
#endif
do
{
fwdget(buf, 118);
if (stristr(buf, "RECONNECT")) return 0;
if (stristr(buf, "FAILURE")) return 0;
if (strstr(buf, "|>")) return 2;
}
while (buf[strlen(buf) - 1] != '>');
return 1;
}
/*---------------------------------------------------------------------------*/
int isforwardpartner (char *call)
//*************************************************************************
//
// Gibt zurueck, ob das uebergebene Call ein eingetragener
// Forwardpartner ist.
//
//*************************************************************************
{
unsigned int i = 0;
if (! strcmp(call, DUMMY)) return NOTFOUND;
while (i < fwdpartners)
{
if (! strcmp(fp[i].call, call)) return i;
else i++;
}
return NOTFOUND;
}
/*---------------------------------------------------------------------------*/
char another_fwd_sender (char *call)
//*************************************************************************
//
// Checks, if we are sending files in another forward-session
//
//*************************************************************************
{ // eingelogt ignores own (running) task
return ( eingelogt(call, j_fwdsend, 0)
|| eingelogt(call, j_fwdsendf, 0)
|| eingelogt(call, j_fwdlink, 0)
|| eingelogt(call, j_fbb_recv_propose, 0)
|| eingelogt(call, j_fbb_recv_mail, 0) // bei 5er-wechsel kein
// Doppel-fwd noetig!
|| eingelogt(call, j_fbb_send_propose, 0)
|| eingelogt(call, j_fbb_send_mail, 0)
|| eingelogt(call, j_fbb_send_delay, 0)
|| eingelogt(call, 0, 1) > 1);
}
/*---------------------------------------------------------------------------*/
fwdpara_t *fpara (void)
//*************************************************************************
//
// Gibt einen Zeiger auf die forward-Parameterstruktur zurueck
// Beim User-Forwarding wird online ein Dummy befuellt
//
//*************************************************************************
{
lastfunc("fpara");
int box = isforwardpartner(b->logincall);
fwdpara_t *ff;
if (box != NOTFOUND) return &fp[box];
if (b->forwarding == fwd_none)
return fp; //df3vi: wird in mbdir fuer dir_outstanding_all-ersatz benutzt
if (! b->fwd_parameter)
b->fwd_parameter = t_malloc(sizeof(fwdpara_t), "fwdp");
ff = (fwdpara_t *) b->fwd_parameter;
memset(ff, 0, sizeof(fwdpara_t));
strcpy(ff->call, b->logincall);
strcpy(ff->concall, get_ufwd(ff->call));
if (*ff->concall == 1) *ff->concall = 0; //user has disabled userfwding
strcpy(ff->times, "AAAAAAAAAAAAAAAAAAAAAAAA");
ff->connectbar = 1;
ff->nolink = 0;
ff->n_conok = 0;
ff->n_login = 0;
ff->lastwp = 0;
ff->txf = 0;
ff->rxf = 0;
ff->wprot_r_partner = 0;
ff->current_routing_quality = 0;
ff->routing_quality = 0;
ff->routing_txf = 0;
ff->lastmeasure = 0;
ff->lastwpr = 0;
ff->sidrtt = 0;
ff->timeout_cnt = 0;
ff->ssid = m.fwdssid;
if (b->forwarding == fwd_standard)
trace(fatal, "fpara", "%s unknown fwd params", b->logincall);
return ff;
}
/*---------------------------------------------------------------------------*/
void fwdlog (char *s1, char *s2, char dir)
//*************************************************************************
//
// Schreibt ggf (nur wenn konfiguriert) jede FWD-Zeile in ein
// zum Loginrufzeichen passendes Logfile
//
//*************************************************************************
{
char buf[120];
char filename[13];
if (m.fwdtrace)
{
if (m.fwdtrace == 2 && ! (fpara()->options & o_t)) return;
sprintf(filename, "t_%s.bcm", b->logincall);
strlwr(filename);
sprintf(buf, "%2d%c %-.80s", t->taskid, dir, s1);
subst1(buf, CTRLZ, 0);
strcat(buf, s2);
subst1(buf, CTRLZ, 0);
log_entry(filename, buf);
}
}
/*---------------------------------------------------------------------------*/
void fwdput (char *s1, char *s2)
//*******************************************************************
//
//
//*******************************************************************
{
putf("%s%s\n", s1, s2);
fwdlog(s1, s2, 'S');
}
/*---------------------------------------------------------------------------*/
void fwdget (char *s, int maxlen)
//*******************************************************************
//
//
//*******************************************************************
{
getline(s, maxlen, 1);
timeout(m.fwdtimeout);
fwdlog(s, "", 'R');
}
/*---------------------------------------------------------------------------*/
static int scanforwardoption (char *opt, int boxindex)
//*******************************************************************
//
//
//*******************************************************************
{
lastfunc("scanforwardoption");
if (*opt == '-' && isalpha(opt[1]))
{
fp[boxindex].options |= (1L << (toupper(opt[1]) - 'A'));
switch (opt[1])
{
case 'B': fp[boxindex].maxbytes = atol(opt + 2); break;
#ifdef _LCF
case 'C': fp[boxindex].fwdcallformat = atoi(opt + 2); break; // JJ
#endif
}
return 1;
}
else return 0;
}
/*---------------------------------------------------------------------------*/
#ifndef _AUTOFWD
static
#endif
void strip_hadr (char *header)
//*******************************************************************
//
//
//*******************************************************************
{
lastfunc("strip_hadr");
int i = strlen(header) - 1;
int j = strlen(m.boxadress) - 1;
while (i >= 0 && j >= 0 && m.boxadress[j] == header[i])
{
i--;j--;
}
i++;
while (header[i] != '.' && header[i]) i++;
header[i] = 0;
}
/*---------------------------------------------------------------------------*/
static void erase_igate (char *connectpfad)
//*******************************************************************
//
// loescht "IGATE" aus dem Connectpfad-String
//
//*******************************************************************
{
int i = 0;
int startpos, endpos = 0;
int pos = strpos(connectpfad, "IGATE");
if (pos != -1)
{
int laenge = strlen(connectpfad);
while (connectpfad[pos+i] != ' ' && ((pos+i) <= laenge))
{
endpos = pos + i;
i++;
}
if (pos > 3
&& connectpfad[pos-3] == ' '
&& connectpfad[pos-2] == '/'
&& connectpfad[pos-1] == ' ')
startpos = pos - 3;
else
{
if (pos > 1
&& connectpfad[pos-1] == ' ') startpos = pos - 1;
else startpos = pos;
}
for (i = 0 ; i <= (laenge-(endpos-startpos)) ; i++)
{
if (i >= startpos)
connectpfad[i] = connectpfad[i+(endpos-startpos)+1];
else
connectpfad[i] = connectpfad[i];
}
connectpfad[i] = 0;
}
}
/*---------------------------------------------------------------------------*/
void initfwdlist (void)
//*************************************************************************
//
// Legt die Forwardliste an. Die Liste wird aus einem File eingelesen
// und bleibt dann staendig im Speicher liegen.
//
//*************************************************************************
{
char name[20];
FILE *f;
char s[BLEN];
char word[MAXPARSE];
char eintrag[HADRESSLEN+1];
char *dest;
int boxindex = 0, destindex = 0, anzdest = 0, line = 0, i;
fwdpara_t *ff;
strcpy(name, "initfwdlist");
lastfunc(name);
#ifdef __FLAT__
#ifdef __LINUX__
if (! dest_idx)
dest_idx =
(unsigned long long *) t_malloc(MAXDEST * sizeof(unsigned long long),
"*fid");
#else //Win32
if (! dest_idx)
dest_idx =
(__int64 *) t_malloc(MAXDEST * sizeof(_int64), "*fid");
#endif
#else
if (! dest_idx)
dest_idx =
(unsigned long *) t_malloc(MAXDEST * sizeof(unsigned long), "*fid");
#endif
if (! fp)
fp = (fwdpara_t *) t_malloc(MAXFWD * sizeof(fwdpara_t), "*fwd");
if (! boxdest)
boxdest = (char *) t_malloc(MAXDESTLEN, "*fds");
if (! dest_idx || ! fp || ! boxdest)
{
if (! dest_idx) trace(tr_abbruch, name, "no dest_idx");
if (! fp) trace(tr_abbruch, name, "no fp");
if (! boxdest) trace(tr_abbruch, name, "no boxdest");
}
for (i = 0; i < MAXDEST; i++) dest_idx[i] = LONG_ZERO;
memset(fp, 0, MAXFWD * sizeof(fwdpara_t));
*boxdest = 0;
ff = &fp[0];
fwdpartners = 0;
fwddestlen = 0;
fwddest = 0;
if ((f = s_fopen(FWDLISTNAME, "srt")) != NULL)
{
while (fgets(s, sizeof(s) - 1, f))
{
line++;
subst1(s, ';', 0);
if (strlen(s) > 2)
{
i = (*s == ' ');
strupr(s);
parseline(s, word);
if (i)
{
if (! boxindex) goto error; // erster Eintrag: Boxcall fehlt
else
{
i = 0;
while (word[i])
{
waitfor(e_ticsfull);
char dstb[HADRESSLEN+1];
strncpy(dstb, s + word[i], HADRESSLEN);
dstb[HADRESSLEN] = 0;
strip_hadr(dstb);
if (*dstb && ! scanforwardoption(dstb, boxindex - 1))
{
dest = boxdest;
for (destindex = 0; destindex < anzdest; destindex++)
{
dest = nextword(dest, eintrag, HADRESSLEN);
if (! stricmp(eintrag, dstb))
{ //Eintrag existiert schon -> Index setzen
dest_idx[destindex] |= (LONG_ONE << (boxindex - 1));
break;
}
}
if (destindex >= (MAXDEST - 1))
{
trace(serious, name, ms(m_fwd_toomanydest));
if (*b->logincall) putf(ms(m_fwd_toomanydest));
break;
}
if (destindex >= anzdest)
{ //neuer Eintrag
if ((fwddestlen + strlen(dstb) + 1) >= MAXDESTLEN)
{
trace(serious, name, ms(m_fwd_toomanydest));
if (*b->logincall) putf(ms(m_fwd_toomanydest));
break;
}
strcat(boxdest, dstb);
strcat(boxdest, " ");
dest_idx[anzdest] = (LONG_ONE << (boxindex - 1));
anzdest++;
fwddestlen = strlen(boxdest);
}
}
i++;
}
}
}
else
{
*ff->call = 0;
*ff->concall = 0;
ff->sidrtt = 0;
*ff->times = 0;
ff->n_conok = 0;
ff->lastwp = 0;
ff->n_login = 0;
ff->txf = 0;
ff->rxf = 0;
ff->wprot_r_partner = 0;
ff->current_routing_quality = 0;
ff->routing_quality = 0;
ff->routing_txf = 0;
ff->lastmeasure = 0;
ff->lastwpr = 0;
ff->timeout_cnt = 0;
ff->connectbar = 0;
ff->nolink = 0;
if ( strlen(s + word[0]) <= CALLEN
&& (mbcallok(s + word[0]) || ! stricmp(s + word[0], DUMMY)))
strcpy(ff->call, s + word[0]);
else goto error; // Boxcall ungueltig
if (word[1])
{
if (strlen (s + word[1]) == 24) strcpy(ff->times, s + word[1]);
else if (*(s + word[1]) == '-')
strcpy(ff->times, "APAAAAAAAAAAAAAAAAAAAAAA");
else goto error;
}
i = 2;
while (word[i])
{
if ( (strlen(s + word[i]) <= 14
|| (! strncasecmp("=", s + word[i], 1)
&& strlen(s + word[i]) <= 40)
#ifdef _AX25K
|| (! strncasecmp("ax", s + word[i], 2)
&& strlen(s + word[i]) <= 15)
#endif
#ifdef _TELNETFWD
|| ! strncasecmp("telnet:", s + word[i], 7)
#endif
#ifdef _FILEFWD
|| ! strncasecmp("file:", s + word[i], 5)
#endif
#ifdef _TELEPHONE
|| (! strncasecmp("tty:", s + word[i], 3)
&& strlen(s + word[i]) <= 20)
#endif
)
&& (strlen(ff->concall) + strlen(s+word[i])+1)
< sizeof(ff->concall))
{
strcat(ff->concall, s + word[i]);
strcat(ff->concall, " ");
}
else goto error; // Connectcall zu lang
i++;
}
if (*ff->concall)
{
ff->connectbar = 1;
ff->ssid = m.fwdssid;
}
if (strcmp(ff->call, m.boxname) && strcmp(ff->call, DUMMY))
{
dest = boxdest;
for (destindex = 0; destindex < anzdest; destindex++)
{
dest = nextword(dest, eintrag, HADRESSLEN);
if (! stricmp(eintrag, ff->call))
{ //Eintrag existiert schon -> Index setzen
dest_idx[destindex] |= (LONG_ONE << (boxindex));
break;
}
}
if (destindex >= MAXDEST - 1)
{
trace(serious, name, ms(m_fwd_toomanydest));
if (*b->logincall) putf(ms(m_fwd_toomanydest));
break;
}
if (destindex >= anzdest)
{ //neuer Eintrag
if ((fwddestlen + CALLEN + 1) >= MAXDESTLEN)
{
trace(serious, name, ms(m_fwd_toomanydest));
if (*b->logincall) putf(ms(m_fwd_toomanydest));
break;
}
strcat(boxdest, ff->call);
strcat(boxdest, " ");
dest_idx[anzdest] = (LONG_ONE << boxindex);
anzdest++;
fwddestlen = strlen(boxdest);
}
}
if (++boxindex >= MAXFWD)
{
trace(serious, name, ms(m_fwd_toomanycalls));
if (*b->logincall) putf(ms(m_fwd_toomanycalls));
break;
}
ff = &fp[boxindex];
}
}
}
*ff->call = 0;
s_fclose(f);
trace(report, name, "%d partners, %d destinations", boxindex, anzdest);
if (*b->logincall)
putf("%s: %d partners, %d destinations.\n", name, boxindex, anzdest);
fwdpartners = boxindex;
fwddest = anzdest;
fwddestlen = strlen(boxdest);
return;
}
else
{
if (! (f = s_fopen(FWDLISTNAME, "swt")))
{ // file is not accessible (why ever...)
trace(serious, name, "open "FWDLISTNAME);
if (*b->logincall) putf(ms(m_filenotopen), FWDLISTNAME);
return;
}
char fwd_init[] =
";sample fwd file\n"
";\n"
";db0aab - db0aab-8 hb9ra-2\n"
"; db0aab $wp\n"
";\n";
fwrite(fwd_init, sizeof(fwd_init) - 1, 1, f);
s_fclose(f);
trace(replog, name, "sample "FWDLISTNAME" generated");
return;
}
error:
#ifdef __DOS16__
sound(1000);
wdelay(106);
nosound();
#endif
trace(serious, name, "line %d error", line);
if (*b->logincall) putf(ms(m_fwd_lineerr), name, line);
s_fclose(f);
}
/*---------------------------------------------------------------------------*/
void dirfwdlist (char * dest)
//*************************************************************************
//
// Gibt die Forwardeintraege aus
//
//*************************************************************************
{
lastfunc("dirfwdlist");
unsigned int boxindex = 0;
unsigned int di, tab;
char *dst = boxdest;
char wort[HADRESSLEN+1];
if (! *dest)
{
di = 1;
for (tab = 0; tab < fwddest; tab++)
{
dst = nextword(dst, wort, HADRESSLEN);
if (dest_idx[tab])
{
putf("%-19s", wort);
if (di == 4)
{
putv(LF);
di = 0;
if (testabbruch()) break;
}
else putf(" ");
di++;
waitfor(e_ticsfull);
}
}
putv (LF);
return;
}
if (! strcmp(dest, "+")) *dest = 0;
for (tab = 0; tab < fwddest; tab++)
{
dst = nextword(dst, wort, HADRESSLEN);
if (! *dest || strstr(wort, dest))
{
di = 0;
putv(LF);
if (testabbruch()) break;
putf("%19s : ", wort);
#if TEST_FWD
strcpy(b->at, wort);
weiterleiten(0, "");
putf("%s ", b->destboxlist);
#else
for (boxindex = 0; boxindex < fwdpartners; boxindex++)
{
if ((dest_idx[tab] >> boxindex) & LONG_ONE)
{
if (di == 8)
{
putv(LF);
if (testabbruch()) break;
putf(" ");
di = 0;
}
putf("%-6s ", fp[boxindex].call);
di++;
}
waitfor(e_ticsfull);
}
#endif
}
}
putv(LF);
}
/*---------------------------------------------------------------------------*/
void printfwdlist (char *box)
//*************************************************************************
//
// Gibt die Forwardliste aus. Die Ausgabe erfolgt im gleichen
// Format wie die Eingabe ueber das Initialisierungsfile
//
//*************************************************************************
{
lastfunc("printfwdlist");
int boxindex = 0;
unsigned int di = 0, tab = 0;
char *dest;
char eintrag[HADRESSLEN+1];
char cc[FSPATHLEN];
fwdpara_t *ff;
ff = &fp[boxindex];
while (*ff->call)
{
if (testabbruch()) break;
if (! *box || stristr(ff->call, box))
{
putv(LF);
if (testabbruch()) break;
putf("; BBS 012345678901234567890123 Path\n");
if (testabbruch()) break;
putf("%-6s %s %s", ff->call, ff->times, ff->concall);
if (ff->nolink == 0 && strpos(ff->concall, "IGATE") != -1)
{
strcpy(cc, ff->concall);
erase_igate(cc);
putv(LF);
putf(" currently used: %s", cc);
}
if (ff->options)
{
int i;
putv(LF);
if (testabbruch()) break;
for (i = 0; i < 26; i++)
{
if ((ff->options >> i) & 1)
{
int ch = i + 'A';
putf(" -%c", ch);
switch (ch)
{
case 'B': putf("%ld", ff->maxbytes); break;
#ifdef _LCF
case 'C': putf("%ld", ff->fwdcallformat); break;
#endif
}
}
}
}
di = 80;
dest = boxdest;
for (tab = 0; tab < fwddest; tab++)
{
dest = nextword(dest, eintrag, HADRESSLEN);
if ((dest_idx[tab] >> boxindex) & LONG_ONE)
{
di += strlen(eintrag) + 1;
if (di > 78)
{
putv(LF);
if (testabbruch()) break;
di = strlen(eintrag) + 1;
}
putf(" %s", eintrag);
}
waitfor(e_ticsfull);
}
}
boxindex++;
ff = &fp[boxindex];
}
putv(LF);
}
/*---------------------------------------------------------------------------*/
#ifdef DF3VI_FWD_EDIT
void savefwdlist (void)
//*************************************************************************
//
// Schreibt die Forwardliste in FWD.BCM. Die Ausgabe erfolgt im gleichen
// Format wie die Eingabe ueber das Initialisierungsfile
//
//*************************************************************************
{
lastfunc("savefwdlist");
int boxindex = 0;
unsigned int di = 0, tab = 0;
FILE *f;
char eintrag[HADRESSLEN+1];
fwdpara_t *ff;
char buf[LINELEN+1];
char *dest;
xunlink(FWDLISTNAMEBAK);
xrename(FWDLISTNAME, FWDLISTNAMEBAK);
if ((f = s_fopen(FWDLISTNAME, "swt")) != NULL)
{
ff = &fp[boxindex];
sprintf(buf, "; Forwardfile " STD_BOXHEADER " %s-%i\n;",
m.boxname, m.fwdssid);
fputs(buf, f);
while (*ff->call)
{
sprintf(buf, "\n; BBS 012345678901234567890123 Path");
fputs(buf, f);
sprintf(buf, "\n%-6s %s %s", ff->call, ff->times, ff->concall);
fputs(buf, f);
if (ff->options)
{
char i;
fputs("\n ", f);
for (i = 0; i < 26; i++)
{
if ((ff->options >> i) & 1L)
{
char ch = i + 'A';
sprintf(buf, " -%c", ch);
fputs(buf, f);
switch (ch)
{
case 'B': sprintf(buf, "%ld", ff->maxbytes);
fputs(buf, f);
break;
#ifdef _LCF // JJ
case 'C': sprintf(buf, "%ld", ff->fwdcallformat);
fputs(buf, f);
break;
#endif
}
}
}
}
di = LINELEN + 1;
dest = boxdest;
for (tab = 0; tab < fwddest; tab++)
{
dest = nextword(dest, eintrag, HADRESSLEN);
if ((dest_idx[tab] >> boxindex) & LONG_ONE)
{
di += strlen(eintrag) + 1;
if (di >= (LINELEN - 1))
{
fputs("\n ", f);
di = strlen(eintrag) + 1;
}
sprintf(buf, " %s", eintrag);
fputs(buf, f);
}
}
boxindex++;
ff = &fp[boxindex];
}
fputs("\n;\n;End\n", f);
s_fclose(f);
putf(ms(m_filestored), FWDLISTNAME);
}
else
trace(serious, "savefwdlist", ms(m_filenotopen), FWDLISTNAME);
}
/*---------------------------------------------------------------------------*/
void fwdlistedit (char *befbuf)
//*************************************************************************
//
// df3vi: remote-editor fuer FWD.BCM
//
//*************************************************************************
{
lastfunc("fwdlistedit");
char cmd[5], box[CALLEN+1], call[CALLEN+1], timesf[25], path[FSPATHLEN+1],
worte[MAXPARSE], vgl[HADRESSLEN+1], eintrag[HADRESSLEN+1];
char *entry, *s_ptr, *dst;
char syntax1[80];
char syntax2[80];
unsigned int indexf, boxindex = 0, i, anz;
fwdpara_t *ff;
strcpy(syntax1, "Syntax: FWDEDIT <cmd> [[entries] boxcall]\n");
strcpy(syntax2, "<cmd>: CALL, TIME, PATH, ADD, DEL, NEW, REMOVE, BACKUP\n");
if (! *befbuf) //keine Parameter
{
putf(syntax1);
putf(syntax2);
return;
}
strupr(befbuf);
entry = nextword(befbuf, cmd, 4); //Kommando suchen, danach sind Eintraege
s_ptr = befbuf + strlen(befbuf); //Vom Stringende her Leerzeichen suchen
while (s_ptr > befbuf && *s_ptr != ' ') s_ptr--;
strncpy(box, ++s_ptr, CALLEN); //dahinter steht das Box-Call
box[CALLEN] = 0; //max. 6 Zeichen
*s_ptr = 0; //das kann nun weg, uebrig bleiben Eintraege
switch (*cmd) // Befehle, die sich nicht auf einen Eintrag beziehen
{
/* case 'S': //save changes - nur vorlaeufig
savefwdlist();
return;
*/
case 'B': //backup old changes
if (file_isreg(FWDLISTNAMEBAK))
{
xunlink(FWDLISTNAME);
filecopy(FWDLISTNAMEBAK, FWDLISTNAME);
initfwdlist();
}
else putf(ms(m_filenotfound), FWDLISTNAMEBAK);
return;
case 'N': //new entry
if (! strcmp(box, m.boxname))
{
putf(ms(m_nofwdmycall));
return;
}
if (mbcallok(box) || ! strcmp(box, DUMMY))
{ //Boxcall sieht sinnvoll aus
boxindex = 0;
ff = &fp[boxindex];
//Suche leeren Eintrag
while (*ff->call && boxindex < MAXFWD)
{ //Existiert Eintrag schon?
if (! stricmp(ff->call, box))
{
putf(ms(m_fwd_boxexist), box);
return;