-
Notifications
You must be signed in to change notification settings - Fork 0
/
pm-tv.pas
2267 lines (2139 loc) · 67.6 KB
/
pm-tv.pas
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
Program Point_Master;
{$I VERSION.INC}
Uses App,Objects,Views,Dialogs,Drivers,Menus,
{ ********* begin skMHLB *********}
{skMHL, skMHLjam, skMHLmsg, skComnTV, skCommon,skOpen,}
{ ********* end skMHLB *********}
Use32,
SysUtils,
PM_Obj,Dos,Face,StrUnit,FidoMsg,Incl,Address,PointLst,Report,Logger,Strings,
Statist,Parser,Config,Crt,Memory,MCommon,Language,Check,Script,
Os_Type,FileIO,Dates,Segments,PntL_Obj;
Type
TPointMaster=Object(TMyApplication)
MainInfoWindow:PInfoWindow;
MainLogWindow:PLogWindow;
Constructor Init;
Procedure Run;virtual;
Destructor Done;virtual;
Procedure HandleEvent(var Event: TEvent); virtual;
Procedure InitStatusLine;Virtual;
{ Procedure InitMenuBar;Virtual;}
{ Procedure SetInfoWindowRect(Var R:Trect);
Procedure SetLogWindowRect(Var R:TRect);}
End;
{Var}
{ C_LikeMasterName:Z36;}
{ DirInfo:SearchRec;}
{ CommentsInMessage:PCommentsCollection;}
{ Msg:File;
MsgRec:TFidoMsgHeader;}
Procedure ForEachMasterName(Pnt,MsgRecord:Pointer);
Var
AsciizMasterName:Z36;
Begin
If MessageForPntMaster Then
Exit;
If StrTrim(PString(Pnt)^)='' Then
Exit;
FillStr(StrUp(PString(Pnt)^),AsciizMasterName,36);
If StrUp(AsciizMasterName)=StrUp(PFidoMsgHeader(MsgRecord)^._To) Then
MessageForPntMaster:=True;
End;
Function MsgForPntMaster(MsgRecord:TFidoMsgHeader):Boolean;
Begin
MessageForPntMaster:=False;
ForEachVarWithData(MasterNameTag.Tag,Addr(MsgRecord),ForEachMasterName);
MsgForPntMaster:=MessageForPntMaster=True;
If (MsgRecord._DestNet<>PntMasterAddress.Net) or
(MsgRecord._DestNode<>PntMasterAddress.Node) Then
MsgForPntMaster:=False;
End;
Function SecCheckMsgForPntMaster(MsgRecord:TFidoMsgHeader):Boolean;
Begin
SecCheckMsgForPntMaster:=True;
If (MsgRecord._DestZone<>PntMasterAddress.Zone) or
(MsgRecord._DestNet<>PntMasterAddress.Net) or
(MsgRecord._DestNode<>PntMasterAddress.Node) or
(MsgRecord._DestPoint<>PntMasterAddress.Point) Then
SecCheckMsgForPntMaster:=False;
End;
Function MsgFromPoint(MsgRecord:TFidoMsgHeader):Boolean;
Begin
MsgFromPoint:=BossAddress.Point<>0;
If BossAddress.Point<>0 Then
Begin
SetVar(FromAddressTag,GetStringWithPointFromAddress(BossAddress));
LogWriteLn(GetExpandedString(_logMessageFromPoint));
CreateReport(BossAddress,PntMasterAddress,
MsgRecord._From,GetVar(MasterNameTag.Tag,_varNONE),_repNotAllowForPoint,
-1,GetVar(_tplNotAllowForPoint.Tag,_varNONE),'',_whoNotAllowedToPoint);
Exit;
End;
End;
Procedure ReportPasswordMismatch(MsgRecord:TFidoMsgHeader);
Begin
LogWriteLn(GetExpandedString(_logPasswordMismatch));
CreateReport(BossAddress,PntMasterAddress,
MsgRecord._From,GetVar(MasterNameTag.Tag,_varNONE),_repPasswordMisMatch,
-1,GetVar(_tplBadPassword.Tag,_varNONE),'',_whoPasswordMismatch);
End;
Procedure ReportInBounceList(MsgRecord:TFidoMsgHeader);
Begin
LogWriteLn(GetExpandedString(_logInBounceList));
CreateReport(BossAddress,PntMasterAddress,
MsgRecord._From,GetVar(MasterNameTag.Tag,_varNONE),_repInBounceList,
-1,GetVar(_tplInBounceList.Tag,_varNONE),'',_whoInBounceList);
End;
Procedure ReportInExcludeList(MsgRecord:TFidoMsgHeader);
Begin
LogWriteLn(GetExpandedString(_logInExcludeList)+GetStringFromAddress(ExcludeAddr));
CreateReport(BossAddress,PntMasterAddress,
MsgRecord._From,GetVar(MasterNameTag.Tag,_varNONE),_repInExcludeList,
-1,GetVar(_tplInExcludeList.Tag,_varNONE),'',_whoInExcludeList);
End;
Procedure ForEachAutoUpdateSegment(Pnt:Pointer);
Var
Mask: String;
Begin
Mask:=PString(Pnt)^;
ExpandString(Mask);
Mask:=StrTrim(Mask);
If Mask<>'' Then
ConditionalAutoCreateSegmentsFromMask(Mask);
End;
Procedure ForEachAutoCreateSegment(Pnt:Pointer);
Var
Mask: String;
Begin
Mask:=PString(Pnt)^;
ExpandString(Mask);
Mask:=StrTrim(Mask);
If Mask<>'' Then
ConditionalAutoCreateSegmentsFromMask(Mask);
End;
Procedure ForEachForceAutoCreateSegment(Pnt:Pointer);
Var
Mask: String;
Begin
Mask:=PString(Pnt)^;
ExpandString(Mask);
Mask:=StrTrim(Mask);
If Mask<>'' Then
ForcedAutoCreateSegmentsFromMask(Mask);
End;
Procedure ForEachAutoUpdate(Pnt:Pointer);
Var
{PStr:PString absolute Pnt;}
PStr:String;
Begin
If _AutoUpdateFound Then
Exit;
PStr:=PString(Pnt)^;
ExpandString(PStr);
If IsAddressMatch(StrTrim(PStr),BossAddress) Then
Begin
_IsInAutoUpdateList:=True;
_AutoUpdateFound:=True;
End;
End;
Procedure ForEachPassword(Pnt:Pointer);
Var
{PStr:PString absolute Pnt;}
PStr:String;
Mask,Password:String;
BeginPos:Word;
Begin
If _PasswordFound Then
Exit;
PStr:=PString(Pnt)^;
ExpandString(PStr);
if PStr='' Then
Exit;
BeginPos:=Pos(' ',StrTrim(PStr));
If BeginPos>0 Then
Begin
Mask:=Copy(PStr,1,Pos(' ',StrTrim(PStr))-1);
Mask:=StrTrim(Mask);
Password:=Copy(PStr,Pos(' ',StrTrim(PStr)),Length(StrTrim(PStr)));
Password:=StrTrim(Password);
SetVar(MustBePasswordTag,Password);
If IsAddressMatch(Mask,BossAddress) Then
Begin
If StrUp(Password)<>StrUp(GetVar(FromPasswordTag.Tag,_varNONE)) Then
_IsPasswordValid:=False;
_PasswordFound:=True;
End;
End;
End;
Procedure ForEachIgnore(Pnt,MsgRecordPtr:Pointer);
Var
{PStr:PString absolutes Pnt;}
PStr:String;
Begin
If _IgnoreFound Then
Exit;
PStr:=PString(Pnt)^;
ExpandString(PStr);
If PStr='' Then
Exit;
If CharsMaskMatch(StrUp(PStr),StrUp(TruncStr(PFidoMsgHeader(MsgRecordPtr)^._From))) Then
Begin
_IgnoreFound:=True;
_IsInIgnoreList:=True;
End;
End;
Procedure ForEachReRoute(Pnt:Pointer);
Var
{PStr:PString absolute Pnt;}
PStr:String;
Mask,RouteAddress:String;
BeginPos:Word;
Begin
If _ReRouteFound Then
Exit;
PStr:=PString(Pnt)^;
ExpandString(PStr);
If PStr='' Then
Exit;
BeginPos:=Pos(' ',StrTrim(PStr));
If BeginPos>0 Then
Begin
Mask:=Copy(PStr,1,Pos(' ',StrTrim(PStr))-1);
Mask:=StrTrim(Mask);
RouteAddress:=Copy(PStr,Pos(' ',StrTrim(PStr)),Length(StrTrim(PStr)));
RouteAddress:=StrTrim(RouteAddress);
If IsAddressMatch(Mask,BossAddress) Then
Begin
_ReRouteFound:=True;
SetAddressFromString(RouteAddress,ReRouteAddress);
_IsInReRouteList:=True;
End;
End;
End;
Procedure ForEachBounce(Pnt:Pointer);
Var
{PStr:PString absolute Pnt;}
PStr:String;
IsReverse:Boolean;
Begin
If _BounceFound Then
Exit;
IsReverse:=False;
PStr:=PString(Pnt)^;
ExpandString(PStr);
If PStr='' Then
Exit;
If Copy(PadLeft(PStr),1,1)='!' Then
Begin
Delete(PStr,Pos('!',PStr),1);
IsReverse:=True;
End;
If IsReverse Then
Begin
If Not (IsAddressMatch(StrTrim(PStr),BossAddress)) Then
Begin
_IsInBounceList:=True;
_BounceFound:=True;
End;
End
Else
Begin
If IsAddressMatch(StrTrim(PStr),BossAddress) Then
Begin
_IsInBounceList:=True;
_BounceFound:=True;
End;
End;
End;
Function IsPasswordValid(MsgRecord:TFidoMsgHeader):Boolean;
Begin
_IsPasswordValid:=True;
IsPasswordValid:=True;
_PasswordFound:=False;
{If StrUp(GetVar(UsePasswordsTag.Tag,_varNONE))=Yes Then}
Begin
ForEachVar(PasswordTag.Tag,ForEachPassword);
If Not (_IsPasswordValid) Then
Begin
IsPasswordValid:=False;
ReportPasswordMisMatch(MsgRecord);
End;
End;
End;
Function IsInReRouteList:Boolean;
Begin
IsInReRouteList:=False;
_IsInReRouteList:=False;
_ReRouteFound:=False;
{If StrUp(GetVar(UseReRouteTag.Tag,_varNONE))=Yes Then}
Begin
ForEachVar(ReRouteTag.Tag,ForEachReRoute);
If _IsInReRouteList Then
Begin
IsInReRouteList:=True;
End;
End;
End;
Function IsInBounceList(MsgRecord:TFidoMsgHeader):Boolean;
Begin
_IsInBounceList:=False;
IsInBounceList:=False;
_BounceFound:=False;
{If StrUp(GetVar(UseBounceTag.Tag,_varNONE))=Yes Then}
Begin
ForEachVar(BounceTag.Tag,ForEachBounce);
If _IsInBounceList Then
Begin
IsInBounceList:=True;
ReportInBounceList(MsgRecord);
End;
End;
End;
Function IsInAutoUpdateList:Boolean;
Begin
_IsInAutoUpdateList:=False;
IsInAutoUpdateList:=False;
_AutoUpdateFound:=False;
ForEachVar(AutoUpdateSegmentTag.Tag,ForEachAutoUpdate);
If _IsInAutoUpdateList Then
Begin
IsInAutoUpdateList:=True;
End;
End;
Function IsInIgnoreList(MsgRecord:TFidoMsgHeader):Boolean;
Begin
_IsInIgnoreList:=False;
IsInIgnoreList:=False;
_IgnoreFound:=False;
{If StrUp(GetVar(UseBounceTag.Tag,_varNONE))=Yes Then}
Begin
ForEachVarWithData(IgnoreFromNameTag.Tag,Addr(MsgRecord),ForEachIgnore);
If _IsInIgnoreList Then
Begin
IsInIgnoreList:=True;
{ ReportInBounceList;}
LogWriteLn(GetExpandedString(_logMessageFromIgnoreName));
End;
End;
End;
Function BossFoundInPntList(Var BossIndex:Integer;BossString:String):Boolean;
Begin
BossIndex:=SearchForBoss(BossAddress);
BossFoundInPntList:=BossIndex<>-1;
If (BossIndex=-1) and (BossString<>'') Then
Begin
BossRecArray^.Insert(New(
PBossRecord,Init(
BossString,Nil,Nil)));
BossIndex:=SearchForBoss(BossAddress);
BossFoundInPntList:=BossIndex<>-1;
If BossIndex<>-1 Then
Begin
AddedBosses:=AddedBosses+1;
SetVar(AddedBossesTag,IntToStr(AddedBosses));
End;
End;
End;
Function ReportBossesNotEqual(Boss1,Boss2:TAddress;MsgRecord:TFidoMsgHeader):Boolean;
Begin
{Case (IsAddressesEqual(Boss1,Boss2)) Of
False:
Begin}
ReportBossesNotEqual:=True;
CreateReport(BossAddress,PntMasterAddress,
MsgRecord._From,GetVar(MasterNameTag.Tag,_varNONE),_repCantChangeAnotherBoss,
-1,GetVar(_tplCantChangeAnotherBoss.Tag,_varNONE),'',_whoCantChangeAnotherBoss);
Exit;
{ End;
True:BossesEqual:=True;
End;}
End;
Procedure ReportWellDone(MsgRecord:TFidoMsgHeader);
Begin
CreateReport(BossAddress,PntMasterAddress,
MsgRecord._From,GetVar(MasterNameTag.Tag,_varNONE),_repAllDone,
-1,GetVar(_tplAllDone.Tag,_varNONE),'',_whoBoss);
End;
Procedure ReportErrorsInMessage(MsgRecord:TFidoMsgHeader);
Begin
If (PMessageErrorsMap<>Nil) And (PMessageErrorsMap^.Count>0) Then
CreateReport(BossAddress,PntMasterAddress,
MsgRecord._From,GetVar(MasterNameTag.Tag,_varNONE),_repErrorsInMessage,
-1,GetVar(_tplErrorsInMessage.Tag,_varNONE),'',_whoBoss);
End;
Procedure ReportErrorsInPointList;
Const
_BOTH=1;
_SYSOP=2;
_BOSS=3;
Var
Counter:Integer;
NotifyMask:Byte;
Begin
If (PSegmentErrorsMap<>Nil) And (PSegmentErrorsMap^.Count>0) Then
CreateReport(SysOpAddress,PntMasterAddress,
GetVar(SysOpNameTag.Tag,_varNONE),GetVar(MasterNameTag.Tag,_varNONE),
_repErrorsInPointList,-1,GetVar(_tplErrorsInPointList.Tag,_varNONE),'',_whoSysOp);
If (BossWithSegmentErrorsArray<>Nil) And (BossWithSegmentErrorsArray^.Count>0) Then
Begin
NotifyMask:=0;
If StrTrim(GetVar(NotifyOnErrorsTag.Tag,_varNONE))='' Then
Begin
Dispose(BossWithSegmentErrorsArray,Done);
BossWithSegmentErrorsArray:=Nil;
Exit;
End
Else
If StrUp(GetVar(NotifyOnErrorsTag.Tag,_varNONE))=BothTag Then
Begin
NotifyMask:=_BOTH;
End
Else
If StrUp(GetVar(NotifyOnErrorsTag.Tag,_varNONE))=BossTag Then
Begin
NotifyMask:=_BOSS;
End
Else
If StrUp(GetVar(NotifyOnErrorsTag.Tag,_varNONE))=SysopTag Then
Begin
NotifyMask:=_SYSOP;
End
Else
Begin
Dispose(BossWithSegmentErrorsArray,Done);
BossWithSegmentErrorsArray:=Nil;
Exit;
End;
For Counter:=0 To Pred(BossWithSegmentErrorsArray^.Count) Do
Begin
PersonalErrors:=BossWithSegmentErrorsArray^.At(Counter);
Case NotifyMask Of
_BOTH:
Begin
CreateReport(SysOpAddress,PntMasterAddress,
GetVar(SysOpNameTag.Tag,_varNONE),GetVar(MasterNameTag.Tag,_varNONE),
_repErrorsInSegment,-1,GetVar(_tplErrorsInSegment.Tag,_varNONE),'',_whoSysOp);
CreateReport(PBossWithSegmentErrors(BossWithSegmentErrorsArray^.At(Counter))^.TBossAddress
,PntMasterAddress,'SysOp',GetVar(MasterNameTag.Tag,_varNONE),
_repErrorsInSegment,-1,GetVar(_tplErrorsInSegment.Tag,_varNONE),'',_whoBoss);
End;
_BOSS:
Begin
CreateReport(PBossWithSegmentErrors(BossWithSegmentErrorsArray^.At(Counter))^.TBossAddress
,PntMasterAddress,'SysOp',GetVar(MasterNameTag.Tag,_varNONE),
_repErrorsInSegment,-1,GetVar(_tplErrorsInSegment.Tag,_varNONE),'',_whoBoss);
End;
_SYSOP:
Begin
CreateReport(SysOpAddress,PntMasterAddress,
GetVar(SysOpNameTag.Tag,_varNONE),GetVar(MasterNameTag.Tag,_varNONE),
_repErrorsInSegment,-1,GetVar(_tplErrorsInSegment.Tag,_varNONE),'',_whoSysOp);
End;
End;
End;
Dispose(BossWithSegmentErrorsArray,Done);
BossWithSegmentErrorsArray:=Nil;
End;
End;
Function ProcessSegmentRequest(BossIndex:Integer;MsgRecord:TFidoMsgHeader):Boolean;
Begin
SetVar(RequestTag,SegmentRequestTag.Tag);
LogWriteLn(GetExpandedString(_logFoundRequest));
CreateReport(BossAddress,PntMasterAddress,
MsgRecord._From,GetVar(MasterNameTag.Tag,_varNONE),_repSegmentRequest,
BossIndex,GetVar(_tplDoneSegRequest.Tag,_varNONE),'',_whoBoss);
End;
Function ProcessStatisticRequest(BossIndex:Integer;MsgRecord:TFidoMsgHeader):Boolean;
Begin
SetVar(RequestTag,StatisticRequestTag.Tag);
LogWriteLn(GetExpandedString(_logFoundRequest));
CreateReport(BossAddress,PntMasterAddress,
MsgRecord._From,GetVar(MasterNameTag.Tag,_varNONE),_repStatisticRequest,
BossIndex,GetVar(_tplStatisticRequest.Tag,_varNONE),'',_whoBoss);
End;
Function ProcessHelpRequest(BossIndex:Integer;MsgRecord:TFidoMsgHeader):Boolean;
Begin
SetVar(RequestTag,HelpRequestTag.Tag);
LogWriteLn(GetExpandedString(_logFoundRequest));
CreateReport(BossAddress,PntMasterAddress,
MsgRecord._From,GetVar(MasterNameTag.Tag,_varNONE),_repHelpRequest,
BossIndex,GetVar(_tplDoneHelpRequest.Tag,_varNONE),'',_whoBoss);
End;
Function ProcessFileAttach(MsgRecord:TFidoMsgHeader):Boolean;
Var
FileAttachPath:String;
Old:Byte;
Begin
Old:=StringsToSkipAtBegin;
StringsToSkipAtBegin:=0;
If StrTrim(GetVar(FileAttachPathTag.Tag,_varNONE))<>'' Then
Begin
FileAttachPath:=GetVar(FileAttachPathTag.Tag,_varNONE);
If FileAttachPath[Length(FileAttachPath)]<>'\' Then
FileAttachPath:=FileAttachPath+'\';
If Not IsFileExist(FileAttachPath+MsgRecord._Subj) Then
LogWriteLn(GetExpandedString(_logCantOpenFile)+StrTrim(FileAttachPath+MsgRecord._Subj));
InitPointList(FileAttachPath+MsgRecord._Subj);
End
Else
Begin
If Not IsFileExist(MsgRecord._Subj) Then
LogWriteLn(GetExpandedString(_logCantOpenFile)+StrTrim(MsgRecord._Subj));
InitPointList(FExpand(MsgRecord._Subj));
End;
StringsToSkipAtBegin:=Old;
End;
Function ReRouteMessage(MsgRecord:TFidoMsgHeader):Boolean;
Begin
ReRouteMessage:=True;
If IsAddressesEqual(PntMasterAddress,ReRouteAddress) Then
Begin
LogWriteLn(GetExpandedString(_logTryToReRouteToOurSelf));
ReRouteMessage:=False;
Exit;
End;
CurrentOperation:=GetOperationString(_logInReRouteList)+GetStringFromAddress(ReRouteAddress);
LogWriteLn(GetExpandedString(_logInReRouteList)+GetStringFromAddress(ReRouteAddress));
{MsgMaskToSet:=MsgRecord._Attr;}
CreateReport(ReRouteAddress,BossAddress,
MsgRecord._To,MsgRecord._From,_repInReRouteList,
-1,GetVar(_tplReRoute.Tag,_varNONE),MsgRecord._Subj,_whoNone);
WriteToMessage(#1'Re-routed by '+PntMasterVersion+' ('+
GetStringFromAddress(PntMasterAddress)+') to '+
GetStringFromAddress(ReRouteAddress));
CloseMessage;
End;
Function GetMsgBody(Var Msg:File;MsgRecord:TFidoMsgHeader):Boolean;
Var
S,S2:String;
Begin
While Not Eof(Msg) Do
Begin
{ ReadMsgLn(Msg,S);}
ReadLnFromMsg(Msg,S);
ReadedBytes:=ReadedBytes+Length(S);
{WritePerCent;}
{ ScreenHandler;}
RefreshScreen;
If S[1]=#01 Then
Begin
{ FindKludge(S);}
ExtractKludge(S,MsgRecord);
End;
If S[Length(S)]=GetVar(SplitCharTag.Tag,_varNONE) Then
Begin
{ ReadMsgLn(Msg,S2);}
ReadLnFromMsg(Msg,S2);
StrTrim(S2);
Delete(S,Length(S),1);
S:=S+S2;
If S[Length(S)]=GetVar(SplitCharTag.Tag,_varNONE) Then
Begin
{ ReadMsgLn(Msg,S2);}
ReadLnFromMsg(Msg,S2);
StrTrim(S2);
Delete(S,Length(S),1);
S:=S+S2;
End;
End;
If S='' Then
S:=' ';
MessageBody^.Insert(MCommon.NewStr(S));
End;
End;
Procedure ForEachOnListUpdateScript(Pnt:Pointer);
{Var
ScriptName:PString Absolute Pnt;}
Begin
If StrTrim(PString(Pnt)^)<>'' Then
If Load_Script(PString(Pnt)^) Then
Begin
Exec_Script;
Done_Script;
End;
End;
Procedure ForEachOnMessagesScript(Pnt:Pointer);
{Var
ScriptName:PString Absolute Pnt;}
Begin
If StrTrim(PString(Pnt)^)<>'' Then
If Load_Script(PString(Pnt)^) Then
Begin
Exec_Script;
Done_Script;
End;
End;
Procedure ForEachPntList(Point:Pointer);
Begin
InitPointList(PString(Point)^);
End;
Function CheckMessage(Var Msg:File;MsgRecord:TFidoMsgHeader):Boolean;
Var
S,SS:String;
BossAddrInMsg:TAddress;
Count:Integer;
CommaPos:Byte;
CommentsInMessage:PCommentsCollection;
Begin
CheckMessage:=True;
CommentsInMessage:=Nil;
BossFound:=False;
GetMsgBody(Msg,MsgRecord);
SetVar(FromAddressTag,GetStringFromAddress(BossAddress));
If (Not SecCheckMsgForPntMaster(MsgRecord)) Then
Begin
CheckMessage:=False;
LogWriteLn(GetExpandedString(_logMessageNotForMaster)+
IntToStr(MsgRecord._DestZone)+':'+
IntToStr(MsgRecord._DestNet)+'/'+
IntToStr(MsgRecord._DestNode)+'.'+
IntToStr(MsgRecord._DestPoint));
Exit;
End;
If MsgFromPoint(MsgRecord) Then
Begin
CheckMessage:=False;
Exit;
End;
If IsInBounceList(MsgRecord) Then
Begin
CheckMessage:=False;
Exit;
End;
If IsInIgnoreList(MsgRecord) Then
Begin
CheckMessage:=False;
Exit;
End;
If IsInReRouteList Then
Begin
ReRouteMessage(MsgRecord);
CheckMessage:=False;
Exit;
End;
If (Not IsPasswordValid(MsgRecord)) Then
Begin
CheckMessage:=False;
Exit;
End;
If IsInExcludeList(GetStringFromAddress(BossAddress)) Then
{потом это пеpенести ниже, после нахождения boostag -для той веpсии,
где можно бyдет изменять дpyгих боссов}
Begin
CheckMessage:=False;
ReportInExcludeList(MsgRecord);
Exit;
End;
ForEachVar(OnEachMessageBeforeScriptTag.Tag,ForEachOnMessagesScript);
If (Not _IsPointListInMemory) Then
Begin
ForEachVar(PointListNameTag.Tag,ForEachPntList);
_IsPointListInMemory:=True;
End;
{ If (Not MsgFromPoint) And (Not IsInBounceList) And (IsPasswordValid) Then}
For Count:=0 To Pred(MessageBody^.Count) Do
Begin
S:=PString(MessageBody^.At(Count))^;
S:=StrTrim(S);
If Pos(BossTag,StrUp(Copy(S,1,7)))=1 Then
Begin
SS:=S;
Delete(SS,1,Length(BossTag)+1);
SetAddressFromString(SS,BossAddrInMsg);
If Not (IsAddressesEqual(BossAddress,BossAddrInMsg)) Then
Begin
LogWriteLn(GetExpandedString(_logTryChangeAnotherBoss)+GetStringFromAddress(BossAddrInMsg));
ReportBossesNotEqual(BossAddress,BossAddrInMsg,MsgRecord);
{ Exit;}
End
Else
Begin
BossFound:=BossFoundInPntList(CurrentBossIndex,S);
LogWriteLn(GetExpandedString(_logBossAddress));
End;
End
Else
If (Pos(PointTag,StrUp(Copy(S,1,7)))=1) Then
Begin
DeleteSpacesInString(S);
If (Not BossFound) Then
Begin
BossFound:=BossFoundInPntList(CurrentBossIndex,'');
If CurrentBossIndex=-1 Then
Begin
BossFound:=BossFoundInPntList(CurrentBossIndex,
'Boss,'+GetStringFromAddress(BossAddress));
End;
End;
If CurrentBossIndex<>-1 Then
Begin
If StrUp(GetVar(UseValidatetag.Tag,_varNONE))=Yes Then
Begin
If IsValidPointString(GetStringFromAddress(BossAddress),S,PMessageErrorsMap) Then
ProcessPoint(CurrentBossIndex,S,_varNONE)
Else
Begin
Inc(ErrorPoints);
SetVar(ErrorPointsTag,IntToStr(ErrorPoints));
End;
End
Else
ProcessPoint(CurrentBossIndex,S,_varNONE);
End;
End
Else
If Pos((GetVar(DeleteCharsTag.Tag,_varNONE)),S)=1 Then
Begin
If (Not BossFound) Then
Begin
BossFound:=BossFoundInPntList(CurrentBossIndex,'');
End;
If CurrentBossIndex<>-1 Then
Begin
Delete(S,1,Length(GetVar(DeleteCharsTag.Tag,_varNONE)));
CommaPos:=Pos(',',S);
If CommaPos>0 Then
Begin
While CommaPos>0 Do
Begin
ProcessPoint(CurrentBossIndex,
StrTrim(Copy(S,1,CommaPos-1)),_flgDeletePoint);
Delete(S,1,CommaPos);
CommaPos:=Pos(',',S);
End;
ProcessPoint(CurrentBossIndex,
StrTrim(S),_flgDeletePoint);
End
Else
Begin
ProcessPoint(CurrentBossIndex,
StrTrim(S),_flgDeletePoint);
End;
End
End
Else
If Pos(SegmentRequestTag.Tag,StrUp(S))=1 Then
Begin
If (Not BossFound) Then
Begin
BossFound:=BossFoundInPntList(CurrentBossIndex,'');
End;
If CurrentBossIndex<>-1 Then
ProcessSegmentRequest(CurrentBossIndex,MsgRecord);
End
Else
If Pos(StatisticRequestTag.Tag,StrUp(S))=1 Then
Begin
If (Not BossFound) Then
Begin
BossFound:=BossFoundInPntList(CurrentBossIndex,'');
End;
ProcessStatisticRequest(CurrentBossIndex,MsgRecord);
End
Else
If Pos(HelpRequestTag.Tag,StrUp(S))=1 Then
Begin
If (Not BossFound) Then
Begin
BossFound:=BossFoundInPntList(CurrentBossIndex,'');
End;
ProcessHelpRequest(CurrentBossIndex,MsgRecord);
End
Else
If Pos(GetVar(AddCommentCharsTag.Tag,_varNONE),StrUp(S))=1 Then
Begin
If (Not BossFound) Then
Begin
BossFound:=BossFoundInPntList(CurrentBossIndex,'');
End;
If CurrentBossIndex<>-1 Then
Begin
If CommentsInMessage=Nil Then
CommentsInMessage:=New(PCommentsCollection,Init(5,1));
Delete(S,1,1);
CommentsInMessage^.Insert(MCommon.NewStr(S));
End;
End
Else
If Pos(ScriptTag,StrUp(S))=1 Then
Begin
If _IsMsgWithMainPassword Then
Begin
ExpandString(S);
If Load_Script(S) Then
Begin
Exec_Script;
Done_Script;
End;
End
Else
LogWriteLn(GetExpandedString(
_logTryToExecProtectedCommand)+S);
End
Else
If Pos(DefineTag,StrUp(S))=1 Then
Begin
If _IsMsgWithMainPassword Then
Begin
ExpandString(S);
End
Else
LogWriteLn(GetExpandedString(
_logTryToExecProtectedCommand)+S);
End
Else
If Pos(IncludeTag,StrUp(S))=1 Then
Begin
If _IsMsgWithMainPassword Then
Begin
ExpandString(S);
ReadConfig(S);
End
Else
LogWriteLn(GetExpandedString(
_logTryToExecProtectedCommand)+S);
End;
End;
{Else
Begin
Exit;
End;}
If CommentsInMessage<>Nil Then
Begin
LogWriteLn(GetExpandedString(_logReplacingBossComments)+
GetBossAddressByIndex(CurrentBossIndex));
ReplaceBossComments(CurrentBossIndex,CommentsInMessage);
Dispose(CommentsInMessage);
CommentsInMessage:=Nil;
End;
ReportErrorsInMessage(MsgRecord);
ReportWellDone(MsgRecord);
WriteStatistic(MsgRecord._From,BossAddress);
LogWriteLn(GetExpandedString(_logAddedBosses));
LogWriteLn(GetExpandedString(_logDeletedBosses));
LogWriteLn(GetExpandedString(_logDuplicateBosses));
LogWriteLn(GetExpandedString(_logFalseDeletedPoints));
LogWriteLn(GetExpandedString(_logAddedPoints));
LogWriteLn(GetExpandedString(_logDeletedPoints));
LogWriteLn(GetExpandedString(_logChangedPoints));
LogWriteLn(GetExpandedString(_logFalseDeletedPoints));
LogWriteLn(GetExpandedString(_logFalseChangedPoints));
LogWriteLn(GetExpandedString(_logErrorPoints));
_IsPointListUpdated:=
(AddedPoints<>0) or
(DeletedPoints<>0) or
(ChangedPoints<>0) or
(AddedBosses<>0) or
(DeletedBosses<>0);
If _IsPointListUpdated Then
Begin
If IsInAutoUpdateList Then
ForcedAutoUpdateSegmentFromAddress(BossAddress);
End;
End;
Procedure SetToDefaultVariables;
Begin
SetVar(DeletedPointsTag,'0');
SetVar(FalseDeletedPointsTag,'0');
SetVar(AddedPointsTag,'0');
SetVar(ChangedPointsTag,'0');
SetVar(FalseChangedPointsTag,'0');
SetVar(ErrorPointsTag,'0');
SetVar(DeletedBossesTag,'0');
SetVar(FalseDeletedBossesTag,'0');
SetVar(AddedBossesTag,'0');
SetVar(DuplicateBossesTag,'0');
DeletedPoints:=0;
AddedPoints:=0;
ChangedPoints:=0;
FalseChangedPoints:=0;
FalseDeletedPoints:=0;
ErrorPoints:=0;
AddedBosses:=0;
DeletedBosses:=0;
FalseDeletedBosses:=0;
DuplicateBosses:=0;
{ MsgMaskToSet:=_attrPrivate+_attrLocal;}
{ MsgMaskToSet:=GetAttributesFromString(GetVar(MsgAttributesTag.Tag,_varNONE));}
_IsMsgWithMainPassword:=False;
_IsInReRouteList:=False;
_IsInAutoUpdateList:=False;
MsgFromGate:=False;
ToEmailName:='';
If MessageBody<> Nil Then
MessageBody^.FreeAll;
If PSegmentErrorsMap<>Nil Then
Begin
PSegmentErrorsMap^.Done;
PSegmentErrorsMap:=Nil;
End;
If PMessageErrorsMap<>Nil Then
Begin
PMessageErrorsMap^.Done;
PMessageErrorsMap:=Nil;
End;
{ If CommentsInMessage<>Nil Then
Begin
CommentsInMessage^.Done;
CommentsInMessage:=Nil;
End;}
End;
Procedure InitAllVariables;
Begin
VarRecArray:=Nil;
PMessageErrorsMap:=Nil;
PSegmentErrorsMap:=Nil;
{ CommentsInMessage:=Nil;}
PersonalErrors:=Nil;
ModeString:='';
SetToDefaultVariables;
_IsPointListUpdated:=False;
_IsWasMessages:=False;
SetVar(ProcessMessagesTag,Yes);
SetVar(BuildPointListTag,No);
_flgCheckPointList:=False;
SetVar(ConfigNameTag,'pm.ctl');
SetVar(LanguageTag,'ENG');
SetVar(MasterLogNameTag,'pm.log');
SetVar(CurDateStrTag,GetDateString);
SetVar(CurTimeStrTag,GetTimeString);
SetVar(DayOfWeekTag,GetDoWString);
SetVar(DayOfYearTag,GetDoYString);
SetVar(YearTag,GetYearString);
SetVar(MonthTag,GetMonthString);
SetVar(DayTag,GetDayString);
SetVar(MonthNameTag,GetMonthNameString);
SetVar(MasterVerTag,PntMasterVersion);
SetVar(MasterNameTag,PntMasterName);
MSG_PID:=PntMasterVersion;
SetVar(NetMailPathTag,'C:\');
SetVar(MasterAddressTag,'-1:-1/-1.-1@net');
SetVar(DomainTag,'net');
SetVar(LogSizeTag,'100');
SetVar(StatFileNameTag,'pm.pbs');
SetVar(SafeMsgModeTag,No);
SetVar(PointSegmentNameTag,'');
SetVar(PointListNameTag,'');
SetVar(SplitCharTag,'&');
SetVar(AddCommentCharsTag,';;');
SetVar(CommentsBeforeBossTag,Yes);
SetVar(AddSemicolonAfterEachBossTag,Yes);
SetVar(TaskNumberTag,'1');
SetVar(ProcessFileAttachTag,Yes);
SetVar(FileAttachPathTag,'');
SetVar(BusyFlagNameTag,'pm.bsy');
SetVar(AllowedCharsTag,'33..126');
SetVar(UseValidateTag,Yes);
SetVar(DeleteListAfterProcessTag,No);
SetVar(StatisticDateTag,'');
SetVar(PasswordTag,'');
SetVar(BounceTag,'');
SetVar(IgnoreFromNameTag,'');
SetVar(ExcludeTag,'');
SetVar(OnStartScriptTag,'');
SetVar(OnExitScriptTag,'');
SetVar(OnMessagesScriptTag,'');
SetVar(OnEachMessageBeforeScriptTag,'');
SetVar(OnEachMessageAfterScriptTag,'');
SetVar(CrcTag,'0');
SetVar(MessageSizeTag,'16');