-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmtafile.pas
More file actions
1512 lines (1445 loc) · 47 KB
/
Copy pathmtafile.pas
File metadata and controls
1512 lines (1445 loc) · 47 KB
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 mtafile;
{ Myst Tic Announce Files
Copyright (C) 2018 Black Panther aka Dan Richter dan@castlerockbbs.com
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program 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 Library General Public License
for more details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA.
https://www.gnu.org/licenses/gpl-2.0.html
}
{ Version bump for initial open source release }
{ TODO : Insert command to generate report to show hatched files via Mystic log files }
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
SysUtils, strutils, DateUtils, vinfo, versiontypes;
{$R *.res}
const
O_FNAME = 'mtafile.rpt';
LogFile = 'mtafile.log';
prog = 'RCS Mys Tic File Announce';
author = 'DRPanther(RCS)';
ConfigFile = 'rcs.ini';
type
ticfiles = record
area : string;
areadesc : string;
filename : string;
size : integer;
desc : array [1..60] of string;
ldesc : array [1..60] of string;
origin : string;
magic : string;
replaces : string;
delete : boolean;
end;
datafile = record
datadate : string[13];
dcount : integer;
dsize : integer;
end;
var
tic : array [1..512] of ticfiles;
filedat : array [1..365] of datafile;
datfile : textfile;
tfIn : TextFile;
tfOut : TextFile;
tfLog : TextFile;
header : TextFile;
footer : TextFile;
final : TextFile;
cffile : TextFile;
tfRepOut : TextFile;
TicPath : string;
BBSName : string;
Sysop : string;
LogPath : string;
bbs : string;
info : TSearchRec;
Count : Int64;
repbool : boolean;
bool2 : boolean;
bool3 : boolean;
path : string;
path1 : string;
path2 : string;
received : string;
com1 : string;
com2 : string;
lastrec : integer;
s : ansistring;
i : LongInt;
d : integer;
p : integer;
x : Int64;
n : integer;
y : integer;
z : integer;
a : Longint;
e : integer;
v : integer;
b : integer;
c : integer;
f : integer;
sysos : string;
ver : string;
logbool : boolean=false; //debug logging toggle true=debug false=informational
function OSVersion: String;
//Determines the OS and bit on which the program in compiled
var
SizeofPointe: string;
begin
{$IFDEF LCLcarbon}
OSVersion := 'Mac OS X 10.';
{$ELSE}
{$IFDEF Linux}
OSVersion := 'Linux';
{$ELSE}
{$IFDEF UNIX}
OSVersion := 'Unix';
{$ELSE}
{$IFDEF WINDOWS}
OSVersion:= 'Windows';
{$ENDIF}
{$ENDIF}
{$ENDIF}
{$ENDIF}
{$ifdef CPU32}
SizeofPointe:='/32'; // 32-bit = 32
{$endif}
{$ifdef CPU64}
SizeofPointe:='/64'; // 64-bit = 64
{$endif}
sysos:=OSVersion+SizeofPointe;
end;
Function commainsert(com:string):string;
//Inserts a comma into numbers larger than 1000
var
len : integer;
begin
result:='';
len:=Length(com);
case(len) of
4:insert(',',com,2);
5:insert(',',com,3);
6:insert(',',com,4);
7:begin
insert(',',com,5);
insert(',',com,2);
end;
8:begin
insert(',',com,6);
insert(',',com,3);
end;
9:begin
insert(',',com,7);
insert(',',com,4);
end;
10:begin
insert(',',com,8);
insert(',',com,5);
insert(',',com,2);
end;
11:begin
insert(',',com,9);
insert(',',com,6);
insert(',',com,3);
end;
end;
com2:=com;
result:=com;
end;
Procedure mtahelp;
//Command line help file
begin
writeln;
writeln('-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-');
writeln;
writeln(prog+' '+ver);
writeln;
writeln('''-a'' - Run MTAFile in Announce mode - mtafile -a');
writeln('''-r'' - Run MTAFile in Reports mode - mtafile -r #');
writeln('''-h'' or ''?'' - Show help file - mtafile -h or mtafile ?');
writeln;
writeln('All commands must be run individually of each other');
writeln('You will get an error if you try ''-a -r 7''.');
writeln;
writeln('The number sign after the -r, is how many entries the program');
writeln('should generate the report for. If you use ''-r 7'', you will');
writeln('get the last 7 entries in the mtafile.dat file.');
writeln;
writeln('If the -r command is used, the program will NOT process any .tic');
writeln('files in that run. It must be run seperately as another command');
writeln;
writeln('Example...');
if OSVersion='Linux' then begin
writeln(sysos,':');
writeln('./mtafile -a');
writeln('./mtafile -r 7');
end;
if AnsiStartsStr('Windows',OSVersion) then begin
writeln(sysos,':');
writeln('mtafile -a');
writeln('mtafile -r 7');
end;
writeln;
writeln(author);
writeln;
writeln('-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-');
writeln;
halt;
end;
Procedure LogDate;
//Saves typing :)
begin
write(tfLog,FormatDateTime('yyyy mmm dd hh:nn:ss',(Now)));
end;
Procedure LogBreak;
//Ditto :)
begin
writeln(tfLog,' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ');
end;
Procedure ReadConfig;
//Reads the relevant information from the rcs.ini config file
begin
AssignFile(cffile, ConfigFile);
try
reset(cffile);
While not eof(cffile) do begin
s:='';
readln(cffile, s);
if AnsiStartsStr('TicPath=',s) then begin
Delete(s, 1, 8);
TicPath:=s;
end;
if AnsiStartsStr('BBS=',s) then begin
Delete(s, 1, 4);
BBSName:=s;
end;
if AnsiStartsStr('Sysop=',s) then begin
Delete(s, 1, 6);
Sysop:=s;
end;
if AnsiStartsStr('LogPath=',s) then begin
Delete(s, 1, 8);
LogPath:=s+LogFile;
end;
end;
except
on E: EInOutError do begin
writeln('File handling error occurred. Details: ',E.Message);
end;
end;
end;
function ProductVersionToString(PV: TFileProductVersion): String;
begin
Result := Format('%d.%d.%d.%d', [PV[0],PV[1],PV[2],PV[3]])
end;
procedure ProgVersion;
//Pulls the version information from Lazarus
var
Info: TVersionInfo;
begin
Info := TVersionInfo.Create;
Info.Load(HINSTANCE);
ver:=(ProductVersionToString(Info.FixedInfo.FileVersion));
Info.Free;
end;
Procedure startup;
begin
path:='';
ReadConfig;
AssignFile(tfOut, path+O_FNAME);
AssignFile(tfLog, LogPath);
path:=GetCurrentDir;
path1:=(path+PathDelim+O_FNAME);
AssignFile(datfile,path+PathDelim+'mtafile.dat'); //should change this to a data file
if fileexists(LogPath)=false then Rewrite(tfLog)
else append(tflog);
Count:=0;
com1:='';
com2:='';
bool2:=false;
d:=1;
x:=0;
n:=1;
y:=1;
i:=1;
c:=1;
repbool:=false;
Lastrec:=1;
LogBreak;
LogDate;
writeln(tfLog,' ',prog,' ',ver);
LogDate;
write(tfLog,' ');
for i:=0 to ParamCount do begin
write (tfLog,ParamStr (i));
write (tfLog,' ');
end;
writeln(tfLog);
end;
Procedure ProgramEnd;
//This should be changed to a function to take the exitcode as a parameter
begin
CloseFile(tfLog);
halt(1);
end;
Procedure TicSetup;
//This procedure adds '.tic' to any file that contains .TIC
//This is done, so that all tic files have the same extension in
//case sensative OS's, such as Linux
begin
chdir(TicPath);
If FindFirst ('*.TIC',faAnyFile, Info)=0 then
begin
Repeat
RenameFile(info.Name,info.Name+'.tic');
until FindNext(info)<>0;
end;
FindClose(Info);
If FindFirst('*.tic',faAnyFile, Info)<>0 then
begin
writeln('There are no .tic files in this directory!');
LogDate;
LogBreak;
LogDate;
writeln(tfLog,' MTAFile is unable to find any .tic files in the given directory');
ProgramEnd;
end;
end;
Procedure TicRead;
//There is probably a better way to run this procedure
begin
If FindFirst ('*.tic',faAnyFile, Info)=0 then
begin
Rewrite(tfOut);
Repeat
tic[d].area:='';
tic[d].areadesc:='';
tic[d].filename:='';
tic[d].size:=0;
tic[d].desc[d]:='';
tic[d].ldesc[d]:='';
tic[d].origin:='';
tic[d].magic:='';
tic[d].replaces:='';
tic[d].delete:=false;
if logbool=true then begin
LogDate;
LogBreak;
LogDate;
write(tfLog,' Reading TIC File Name - ');
writeln(tfLog,info.Name);
end;
AssignFile(tfIn,info.Name);
try
{$I-}
reset(tfIn);
{$I+}
if (IOResult<>0) then
begin
writeln('The file could not be opened!');
LogDate;
writeln(tfLog,' Error: The TIC file could not be opened');
break;
end;
While not eof(tfIn) do
begin
s:='';
readln(tfIn, s);
//Reads the Area from TIC file
if AnsiStartsStr('Area ',s) then begin
p:=6;
tic[d].area:=(ExtractSubstr(s, p, [' ']));
if logbool=true then begin
LogDate;
write(tfLog,' Area - ');
writeln(tfLog,tic[d].area);
end;
end;
//Reads the Area Description from TIC file
if AnsiStartsStr('Areadesc ',s) then begin
Delete(s,1,9);
tic[d].areadesc:=s;
end;
if tic[d].areadesc='' then begin
if AnsiStartsStr('AreaDesc ',s) then begin
Delete(s,1,9);
tic[d].areadesc:=s;
end;
end;
//Reads the Filename from TIC file
if AnsiStartsStr('File ',s) then begin
p:=6;
tic[d].filename:=(ExtractSubstr(s, p, [' ']));
if logbool=true then begin
LogDate;
Write(tfLog,' Filename - ');
writeln(tfLog,tic[d].filename);
end;
end;
//Reads the File Size from TIC file
if AnsiStartsStr('Size ',s) then begin
p:=6;
tic[d].size:=(StrToInt(ExtractSubstr(s,p,[' '])));
x:=x+tic[d].size;
end;
//Reads the Long Description from TIC file
if AnsiStartsStr('LDesc ',s) then begin
Delete(s,1,5);
tic[d].ldesc[n]:=s;
inc(n);
end;
//Reads the Description from TIC file
if (AnsiStartsStr('Desc ',s)) and (bool2=false) then begin
Delete(s,1,5);
tic[d].desc[y]:=s;
inc(y);
if y=41 then bool2:=true;
end;
//Reads the Origin from TIC file
if AnsiStartsStr('Origin ',s) then begin
Delete(s,1,7);
tic[d].origin:=s;
end;
//Reads the From, if Origin is absent from TIC file
if tic[d].origin='' then begin
if AnsiStartsStr('From ',s) then begin
Delete(s,1,5);
tic[d].origin:=s;
end;
end;
//Reads the Magic name from the TIC file
if AnsiStartsStr('Magic ',s) then begin
Delete(s,1,6);
tic[d].magic:=s;
end;
//Reads the Replaces from TIC file
if AnsiStartsStr('Replaces ',s) then begin
Delete(s,1,9);
tic[d].replaces:=s;
end;
end;
if tic[d].areadesc='' then tic[d].areadesc:=tic[d].area;
bool2:=false;
n:=1;
y:=1;
//Remove the processed TIC file
CloseFile(tfIn);
DeleteFile(info.Name);
except
on E: EInOutError do begin
writeln('File handling error occurred. Details: ',E.Message);
LogDate;
writeln(tfLog,' A File handling error occurred. Details: ',E.Message);
end;
end;
inc(d);
inc(lastrec);
inc(count);
until FindNext(info)<>0;
end;
FindClose(Info);
if FileExists(path1) then DeleteFile(path1);
RenameFile('mtafile.rpt',path1);
end;
Procedure DupeCheck;
//There's probably a better way to do the dupe checking as well
begin
z:=1;
d:=1;
if logbool=true then begin
LogDate;
LogBreak;
end;
LogDate;
writeln(tfLog,' Checking for duplicate file names');
for d:=1 to lastrec do begin
for z:=d+1 to lastrec do begin
if not (tic[d].delete)and not (tic[z].delete) then begin
if (upcase(tic[d].area))=(upcase(tic[z].area)) then begin
if (upcase(tic[d].filename))=(upcase(tic[z].filename)) then begin
if logbool=true then begin
LogDate;
LogBreak;
LogDate;
write(tfLog,' Found duplicate filename: ');
write(tfLog,tic[z].filename);
write(tfLog,' in ');
writeln(tfLog, tic[z].area);
end;
tic[z].filename:='';
tic[z].area:='';
tic[z].size:=0;
tic[z].delete:=true;
end;
end;
end;
end;
end;
end;
Procedure FindLowFile;
//This should be in a loop, so it not such a mess
var
temp:integer;
begin
z:=1;
d:=1;
i:=lastrec-1;
temp:=lastrec;
for d:=1 to i do begin
for z:=d+1 to i do begin
if (upcase(tic[d].filename)<>'')and(upcase(tic[z].filename)<>'') then begin
if (upcase(tic[d].area)=(upcase(tic[z].area))) then begin
if (upcase(tic[d].filename[1])>(upcase(tic[z].filename[1]))) then begin
tic[temp]:=tic[d];
tic[d]:=tic[z];
tic[z]:=tic[temp];
tic[temp].area:='';
tic[temp].filename:='';
end;
end;
if (upcase(tic[d].area)=(upcase(tic[z].area))) then begin
if (upcase(tic[d].filename[1])=(upcase(tic[z].filename[1]))) then begin
if (upcase(tic[d].filename[2])>(upcase(tic[z].filename[2]))) then begin
tic[lastrec]:=tic[d];
tic[d]:=tic[z];
tic[z]:=tic[lastrec];
end;
end;
end;
if (upcase(tic[d].area)=(upcase(tic[z].area))) then begin
if (upcase(tic[d].filename[1])=(upcase(tic[z].filename[1])))and(upcase(tic[d].filename[2])=(upcase(tic[z].filename[2]))) then begin
if (upcase(tic[d].filename[3])>(upcase(tic[z].filename[3]))) then begin
tic[lastrec]:=tic[d];
tic[d]:=tic[z];
tic[z]:=tic[lastrec];
end;
end;
end;
if (upcase(tic[d].area)=(upcase(tic[z].area))) then begin
if (upcase(tic[d].filename[1])=(upcase(tic[z].filename[1])))and(upcase(tic[d].filename[2])=(upcase(tic[z].filename[2])))and(upcase(tic[d].filename[3])=(upcase(tic[z].filename[3]))) then begin
if (upcase(tic[d].filename[4])>(upcase(tic[z].filename[4]))) then begin
tic[lastrec]:=tic[d];
tic[d]:=tic[z];
tic[z]:=tic[lastrec];
end;
end;
end;
if (upcase(tic[d].area)=(upcase(tic[z].area))) then begin
if (upcase(tic[d].filename[1])=(upcase(tic[z].filename[1])))and(upcase(tic[d].filename[2])=(upcase(tic[z].filename[2])))and(upcase(tic[d].filename[3])=(upcase(tic[z].filename[3])))and(upcase(tic[d].filename[4])=(upcase(tic[z].filename[4]))) then begin
if (upcase(tic[d].filename[5])>(upcase(tic[z].filename[5]))) then begin
tic[lastrec]:=tic[d];
tic[d]:=tic[z];
tic[z]:=tic[lastrec];
end;
end;
end;
if (upcase(tic[d].area)=(upcase(tic[z].area))) then begin
if (upcase(tic[d].filename[1])=(upcase(tic[z].filename[1])))and(upcase(tic[d].filename[2])=(upcase(tic[z].filename[2])))and(upcase(tic[d].filename[3])=(upcase(tic[z].filename[3])))and(upcase(tic[d].filename[4])=(upcase(tic[z].filename[4])))and(upcase(tic[d].filename[5])=(upcase(tic[z].filename[5]))) then begin
if (upcase(tic[d].filename[6])>(upcase(tic[z].filename[6]))) then begin
tic[lastrec]:=tic[d];
tic[d]:=tic[z];
tic[z]:=tic[lastrec];
end;
end;
end;
if (upcase(tic[d].area)=(upcase(tic[z].area))) then begin
if (upcase(tic[d].filename[1])=(upcase(tic[z].filename[1])))and(upcase(tic[d].filename[2])=(upcase(tic[z].filename[2])))and(upcase(tic[d].filename[3])=(upcase(tic[z].filename[3])))and(upcase(tic[d].filename[4])=(upcase(tic[z].filename[4])))and(upcase(tic[d].filename[5])=(upcase(tic[z].filename[5])))and(upcase(tic[d].filename[6])=(upcase(tic[z].filename[6]))) then begin
if (upcase(tic[d].filename[7])>(upcase(tic[z].filename[7]))) then begin
tic[lastrec]:=tic[d];
tic[d]:=tic[z];
tic[z]:=tic[lastrec];
end;
end;
end;
if (upcase(tic[d].area)=(upcase(tic[z].area))) then begin
if (upcase(tic[d].filename[1])=(upcase(tic[z].filename[1])))and(upcase(tic[d].filename[2])=(upcase(tic[z].filename[2])))and(upcase(tic[d].filename[3])=(upcase(tic[z].filename[3])))and(upcase(tic[d].filename[4])=(upcase(tic[z].filename[4])))and(upcase(tic[d].filename[5])=(upcase(tic[z].filename[5])))and(upcase(tic[d].filename[6])=(upcase(tic[z].filename[6])))and(upcase(tic[d].filename[7])=(upcase(tic[z].filename[7]))) then begin
if (upcase(tic[d].filename[8])>(upcase(tic[z].filename[8]))) then begin
tic[lastrec]:=tic[d];
tic[d]:=tic[z];
tic[z]:=tic[lastrec];
end;
end;
end;
if (upcase(tic[d].area)=(upcase(tic[z].area))) then begin
if (upcase(tic[d].filename[1])=(upcase(tic[z].filename[1])))and(upcase(tic[d].filename[2])=(upcase(tic[z].filename[2])))and(upcase(tic[d].filename[3])=(upcase(tic[z].filename[3])))and(upcase(tic[d].filename[4])=(upcase(tic[z].filename[4])))and(upcase(tic[d].filename[5])=(upcase(tic[z].filename[5])))and(upcase(tic[d].filename[6])=(upcase(tic[z].filename[6])))and(upcase(tic[d].filename[7])=(upcase(tic[z].filename[7])))and(upcase(tic[d].filename[8])=(upcase(tic[z].filename[8]))) then begin
if (upcase(tic[d].filename[9])>(upcase(tic[z].filename[9]))) then begin
tic[lastrec]:=tic[d];
tic[d]:=tic[z];
tic[z]:=tic[lastrec];
end;
end;
end;
if (upcase(tic[d].area)=(upcase(tic[z].area))) then begin
if (upcase(tic[d].filename[1])=(upcase(tic[z].filename[1])))and(upcase(tic[d].filename[2])=(upcase(tic[z].filename[2])))and(upcase(tic[d].filename[3])=(upcase(tic[z].filename[3])))and(upcase(tic[d].filename[4])=(upcase(tic[z].filename[4])))and(upcase(tic[d].filename[5])=(upcase(tic[z].filename[5])))and(upcase(tic[d].filename[6])=(upcase(tic[z].filename[6])))and(upcase(tic[d].filename[7])=(upcase(tic[z].filename[7])))and(upcase(tic[d].filename[8])=(upcase(tic[z].filename[8])))and(upcase(tic[d].filename[9])=(upcase(tic[z].filename[9]))) then begin
if (upcase(tic[d].filename[10])>(upcase(tic[z].filename[10]))) then begin
tic[lastrec]:=tic[d];
tic[d]:=tic[z];
tic[z]:=tic[lastrec];
end;
end;
end;
if (upcase(tic[d].area)=(upcase(tic[z].area))) then begin
if (upcase(tic[d].filename[1])=(upcase(tic[z].filename[1])))and(upcase(tic[d].filename[2])=(upcase(tic[z].filename[2])))and(upcase(tic[d].filename[3])=(upcase(tic[z].filename[3])))and(upcase(tic[d].filename[4])=(upcase(tic[z].filename[4])))and(upcase(tic[d].filename[5])=(upcase(tic[z].filename[5])))and(upcase(tic[d].filename[6])=(upcase(tic[z].filename[6])))and(upcase(tic[d].filename[7])=(upcase(tic[z].filename[7])))and(upcase(tic[d].filename[8])=(upcase(tic[z].filename[8])))and(upcase(tic[d].filename[9])=(upcase(tic[z].filename[9])))and(upcase(tic[d].filename[10])=(upcase(tic[z].filename[10]))) then begin
if (upcase(tic[d].filename[11])>(upcase(tic[z].filename[11]))) then begin
tic[lastrec]:=tic[d];
tic[d]:=tic[z];
tic[z]:=tic[lastrec];
end;
end;
end;
if (upcase(tic[d].area)=(upcase(tic[z].area))) then begin
if (upcase(tic[d].filename[1])=(upcase(tic[z].filename[1])))and(upcase(tic[d].filename[2])=(upcase(tic[z].filename[2])))and(upcase(tic[d].filename[3])=(upcase(tic[z].filename[3])))and(upcase(tic[d].filename[4])=(upcase(tic[z].filename[4])))and(upcase(tic[d].filename[5])=(upcase(tic[z].filename[5])))and(upcase(tic[d].filename[6])=(upcase(tic[z].filename[6])))and(upcase(tic[d].filename[7])=(upcase(tic[z].filename[7])))and(upcase(tic[d].filename[8])=(upcase(tic[z].filename[8])))and(upcase(tic[d].filename[9])=(upcase(tic[z].filename[9])))and(upcase(tic[d].filename[10])=(upcase(tic[z].filename[10])))and(upcase(tic[d].filename[11])=(upcase(tic[z].filename[11]))) then begin
if (upcase(tic[d].filename[12])>(upcase(tic[z].filename[12]))) then begin
tic[lastrec]:=tic[d];
tic[d]:=tic[z];
tic[z]:=tic[lastrec];
end;
end;
end;
end;
end;
end;
end;
Procedure FindLowArea;
//Finally got the sorting worked out. It's a long process, but it works. I'm sure there's better ways to do this
//This should also be in some type of loop
var
temp:integer;
begin
z:=1;
d:=1;
i:=lastrec-1;
temp:=lastrec;
for d:=1 to i do begin
for z:=d+1 to i do begin
if (upcase(tic[z].filename)<>'')and(upcase(tic[d].filename)<>'') then begin
if (upcase(tic[d].area[1]) > (upcase(tic[z].area[1]))) and (tic[d].area<>'') and (tic[z].area<>'') then begin
tic[temp]:=tic[d];
tic[d]:=tic[z];
tic[z]:=tic[temp];
tic[temp].area:='';
tic[temp].filename:='';
end;
if (upcase(tic[d].area[1]) = (upcase(tic[z].area[1]))) then begin
if ((upcase(tic[d].area[2])) > (upcase(tic[z].area[2]))) and (tic[d].area<>'') and (tic[z].area<>'') then begin
tic[lastrec]:=tic[d];
tic[d]:=tic[z];
tic[z]:=tic[lastrec];
end;
end;
if (upcase(tic[d].area[1]) = (upcase(tic[z].area[1]))) and (upcase(tic[d].area[2]) = (upcase(tic[z].area[2]))) then begin
if ((upcase(tic[d].area[3])) > (upcase(tic[z].area[3]))) and (tic[d].area<>'') and (tic[z].area<>'') then begin
tic[lastrec]:=tic[d];
tic[d]:=tic[z];
tic[z]:=tic[lastrec];
end;
end;
if (upcase(tic[d].area[1])=(upcase(tic[z].area[1])))and(upcase(tic[d].area[2])=(upcase(tic[z].area[2])))and(upcase(tic[d].area[3])=(upcase(tic[z].area[3]))) then begin
if ((upcase(tic[d].area[4])) > (upcase(tic[z].area[4]))) and (tic[d].area<>'') and (tic[z].area<>'') then begin
tic[lastrec]:=tic[d];
tic[d]:=tic[z];
tic[z]:=tic[lastrec];
end;
end;
if (upcase(tic[d].area[1])=(upcase(tic[z].area[1])))and(upcase(tic[d].area[2])=(upcase(tic[z].area[2])))and(upcase(tic[d].area[3])=(upcase(tic[z].area[3])))and(upcase(tic[d].area[4])=(upcase(tic[z].area[4]))) then begin
if ((upcase(tic[d].area[5])) > (upcase(tic[z].area[5]))) and (tic[d].area<>'') and (tic[z].area<>'') then begin
tic[lastrec]:=tic[d];
tic[d]:=tic[z];
tic[z]:=tic[lastrec];
end;
end;
if (upcase(tic[d].area[1])=(upcase(tic[z].area[1])))and(upcase(tic[d].area[2])=(upcase(tic[z].area[2])))and(upcase(tic[d].area[3])=(upcase(tic[z].area[3])))and(upcase(tic[d].area[4])=(upcase(tic[z].area[4])))and(upcase(tic[d].area[5])=(upcase(tic[z].area[5]))) then begin
if ((upcase(tic[d].area[6])) > (upcase(tic[z].area[6]))) and (tic[d].area<>'') and (tic[z].area<>'') then begin
tic[lastrec]:=tic[d];
tic[d]:=tic[z];
tic[z]:=tic[lastrec];
end;
end;
if (upcase(tic[d].area[1])=(upcase(tic[z].area[1])))and(upcase(tic[d].area[2])=(upcase(tic[z].area[2])))and(upcase(tic[d].area[3])=(upcase(tic[z].area[3])))and(upcase(tic[d].area[4])=(upcase(tic[z].area[4])))and(upcase(tic[d].area[5])=(upcase(tic[z].area[5])))and(upcase(tic[d].area[6])=(upcase(tic[z].area[6]))) then begin
if ((upcase(tic[d].area[7])) > (upcase(tic[z].area[7]))) and (tic[d].area<>'') and (tic[z].area<>'') then begin
tic[lastrec]:=tic[d];
tic[d]:=tic[z];
tic[z]:=tic[lastrec];
end;
end;
end;
end;
end;
end;
Procedure LineBreak;
//This should take the parameter of which filename to writeln to
//perhaps:
// Procedure LineBreak(filename:string);
// begin
// writeln(filename,' -=-=-=-=-=-=-=-=-=-=-=-=-=- ');
// end;
begin
writeln(tfOut,' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ');
end;
Procedure RepLineBreak;
//So it doesn't have to be duplicated for each output file
begin
writeln(tfRepOut,' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ');
end;
Procedure FileBreak;
//Yup. It's a bit redundant
begin
writeln(tfOut,' --------------------------------------------------------------------------- ');
end;
Procedure AreaBreak;
//Inserts a break between areas in the output file
begin
LineBreak;
write(tfOut,' ');
write(tfOut,PadRight(upcase(tic[c].area),14));
write(tfOut,' -=:=- ');
writeln(tfOut,PadRight(tic[c].areadesc,16));
LineBreak;
writeln(tfOut);
end;
Function AddLetter(y:longword):string;
//This function changes long numbers into short numbers followed by k, m, or g
var
s:string;
k:boolean;
m:boolean;
g:boolean;
begin
s:='';
k:=false;
m:=false;
g:=false;
if y >= 1024 then begin
y:=(y div 1024);
k:=true;
if y >= 1024 then begin
y:=(y div 1024);
m:=true;
k:=false;
if y >= 1024 then begin
y:=(y div 1024);
g:=true;
m:=false;
// s:=inttostr(y)+'g';
end;
// s:=IntToStr(y)+'m';
end;
// s:=IntToStr(y)+'k';
end
else s:=IntToStr(y)+' bytes';
if k = true then s:=IntToStr(y)+' Kb';
if m = true then s:=IntToStr(y)+' Mb';
if g = true then s:=IntToStr(y)+' Gb';
result:=s;
end;
Procedure InsertFooter;
//A bit messy, but inserts a footer in the daily output file
begin
b:=78;
bbs:='';
received:='';
writeln(tfOut);
LineBreak;
writeln(tfOut);
bbs:=BBSName;
write(tfOut,(PadCenter(bbs,b)));
//commainsert(IntToStr(x)); //removed when the Kb, Mb, etc was added
writeln(tfOut);
bbs:='';
Insert(' files',received,1);
str(Count,bbs);
Insert(bbs,received,1);
Insert(' in ',received,1);
Insert(AddLetter(x),received,1);
//Insert('Received ',received,1); //Removed the word 'Received', as a system is using to announce hatched files, not incoming
writeln(tfOut,PadCenter(Received,b));
writeln(tfOut);
LineBreak;
writeln(tfOut);
bbs:='';
Insert(sysos,bbs,1);
Insert(' ',bbs,1);
Insert(ver,bbs,1);
Insert(' v',bbs,1);
Insert(prog,bbs,1);
writeln(tfOut,PadCenter('Report generated by: ',b));
writeln(tfOut,PadCenter(bbs,b));
bbs:=FormatDateTime('dd mmm yyyy hh:nn:ss',(Now));
writeln(tfOut,PadCenter(bbs,b));
writeln(tfOut);
bbs:='';
Insert('CRBBS(RCS)(2017-2019)',bbs,1);
writeln(tfOut,PadCenter(bbs,b));
writeln(tfOut);
end;
Procedure GenericFooter;
//Generic footer for summary report. Does not contain specific information about inbound files
//The specific info from previous footer could conatin a bool to exclude information...
begin
b:=78;
bbs:='';
received:='';
writeln(tfRepOut);
RepLineBreak;
writeln(tfRepOut);
bbs:=BBSName;
write(tfRepOut,(PadCenter(bbs,b)));
writeln(tfRepOut);
write(tfRepOut,(PadCenter(sysop,b)));
writeln(tfRepOut);
bbs:='';
writeln(tfRepOut);
RepLineBreak;
writeln(tfRepOut);
bbs:='';
Insert(sysos,bbs,1);
Insert(' ',bbs,1);
Insert(ver,bbs,1);
Insert(' v',bbs,1);
Insert(prog,bbs,1);
writeln(tfRepOut,PadCenter('Report generated by: ',b));
writeln(tfRepOut,PadCenter(bbs,b));
bbs:=FormatDateTime('dd mmm yyyy hh:nn:ss',(Now));
writeln(tfRepOut,PadCenter(bbs,b));
writeln(tfRepOut);
bbs:='';
Insert('CRBBS(RCS)(2017-2019)',bbs,1);
writeln(tfRepOut,PadCenter(bbs,b));
writeln(tfRepOut);
end;
Procedure GenerateReport;
//This is also a mess. Had problems getting all the files into the proper areas in report
begin
x:=0;
a:=45;
p:=1;
i:=1;
Count:=0;
for c:= 1 to lastrec-1 do begin
if (tic[c].area<>'')and not(tic[c].delete) then begin
if c=1 then AreaBreak
else begin
if (upcase(tic[c-1].area)<>'') then begin
if ((upcase(tic[c].area))<>(upcase(tic[(c-1)].area)))and not(tic[c-1].delete) then begin
AreaBreak;
repbool:=true;
end;
end
else if (upcase(tic[c-1].area)='')and not(repbool) then begin
if ((upcase(tic[c].area))<>(upcase(tic[c-2].area)))and not(tic[c-2].delete) then begin
AreaBreak;
repbool:=true;
end;
end
else if (c>=3)and(upcase(tic[c-2].area)='')and not(repbool) then begin
if ((upcase(tic[c].area))<>(upcase(tic[c-3].area)))and not(tic[c-3].delete) then begin
AreaBreak;
repbool:=true;
end;
end
else if (c>=4)and(upcase(tic[c-3].area)='')and not(repbool) then begin
if ((upcase(tic[c].area))<>(upcase(tic[c-4].area)))and not(tic[c-4].delete) then begin
AreaBreak;
repbool:=true;
end;
end
else if (c>=5)and(upcase(tic[c-4].area)='')and not(repbool) then begin
if ((upcase(tic[c].area))<>(upcase(tic[c-5].area)))and not(tic[c-5].delete) then begin
AreaBreak;
repbool:=true;
end;
end
else if (c>=6)and(upcase(tic[c-5].area)='')and not(repbool) then begin
if ((upcase(tic[c].area))<>(upcase(tic[c-5].area)))and not(tic[c-6].delete) then begin
AreaBreak;
repbool:=true;
end;
end
else if (c>=7)and(upcase(tic[c-6].area)='')and not(repbool) then begin
if ((upcase(tic[c].area))<>(upcase(tic[c-6].area)))and not(tic[c-7].delete) then begin
AreaBreak;
repbool:=true;
end;
end
else if (c>=8)and(upcase(tic[c-7].area)='')and not(repbool) then begin
if ((upcase(tic[c].area))<>(upcase(tic[c-7].area)))and not(tic[c-7].delete) then begin
AreaBreak;
repbool:=true;
end;
end
else if (c>=9)and(upcase(tic[c-8].area)='')and not(repbool) then begin
if ((upcase(tic[c].area))<>(upcase(tic[c-8].area)))and not(tic[c-8].delete) then begin
AreaBreak;
repbool:=true;
end;
end
else if (c>=10)and(upcase(tic[c-9].area)='')and not(repbool) then begin
if ((upcase(tic[c].area))<>(upcase(tic[c-9].area)))and not(tic[c-9].delete) then begin
AreaBreak;
repbool:=true;
end;
end
else if (c>=11)and(upcase(tic[c-10].area)='')and not(repbool) then begin
if ((upcase(tic[c].area))<>(upcase(tic[c-10].area)))and not(tic[c-10].delete) then begin
AreaBreak;
repbool:=true;
end;
end
else if (c>=12)and(upcase(tic[c-11].area)='')and not(repbool) then begin
if ((upcase(tic[c].area))<>(upcase(tic[c-11].area)))and not(tic[c-11].delete) then begin
AreaBreak;
repbool:=true;
end;
end
else if (c>=13)and(upcase(tic[c-12].area)='')and not(repbool) then begin
if ((upcase(tic[c].area))<>(upcase(tic[c-12].area)))and not(tic[c-12].delete) then begin
AreaBreak;
repbool:=true;
end;
end;
end;
repbool:=false;
if logbool=true then begin
LogDate;
LogBreak;
LogDate;
write(tfLog,' Area: ');
writeln(tfLog,upcase(tic[c].area));
LogDate;
write(tfLog,' Filename ');
writeln(tfLog,UpCase(tic[c].filename));
end;
write(tfOut,' ');
write(tfOut,PadRight(UpCase(tic[c].filename),14));
inc(e);
write(tfOut,' -=:=- ');
com1:=commainsert(IntToStr(tic[c].size));
x:=x+tic[c].size;
write(tfOut,AddLetter(tic[c].size));
writeln(tfOut);
writeln(tfOut);
//This was pretty clever, as it performs a word wrap on long descriptions based on TIC specs
if (length(tic[c].desc[p])>45)and(tic[c].ldesc[1]='') then
begin
repeat
while tic[c].desc[p][a]<>' ' do begin
a:=a-1;
if (a=1)and(tic[c].desc[p][1]<> ' ')then begin
a:=45;
write(tfOut,' ');
writeln(tfOut,(LeftStr(tic[c].desc[p],a)));
delete(tic[c].desc[p],1,a);
break;