home *** CD-ROM | disk | FTP | other *** search
- {*****************************************************************************
- * *
- * AvaiList.Pas By Andrew Farmer *
- * Main Source Code Module for AvaiList Revision 1.10 *
- * *
- * Copyright 1989 by Andrew D. Farmer, All Rights Reserved. *
- * *
- * *
- * Compiled using Turbo Pascal Version 5.0 By Borland International *
- * *
- *****************************************************************************}
-
- Program AvaiList_By_Andrew_Farmer;
-
- {$R-} {Range checking off}
- {$B+} {Boolean complete evaluation on}
- {$S+} {Stack checking on}
- {$I+} {I/O checking on}
- {$N-} {No floating point coprocessor}
- {$E-} {No emulation coprocessor}
- {$M 48000,0,0} {Allocate 48000 bytes on the Stack, No Heap}
-
- Uses Dos, Crt;
-
- const
- version : String[5] = '1.10';
- copyright : String[47] = ' - Copyright 1989 by Andrew Farmer of 1:163/115';
-
- Type
- Opus = Record
- Junk1 : Word;
- Junk2 : Word;
- Message : Array[1..40] of Char ;
- System : Array[1..40] of Char ;
- Help : Array[1..40] of Char ;
- Upload : Array[1..40] of Char ;
- DownLoad : Array[1..40] of Char ;
- End;
-
- Var { ----------------------- Variable Deffinitions ------------------------- }
- Buf : Array[1..8192] of Char;
- Paths : Array[1..300] of String[79];
- Debug, DoArc, DoNewList, DoOpus, FlagNew, KillOrphan, MoveIt : Boolean;
- NoDate, Ok, Quiet, StripCom, TotArea : Boolean;
- OutPath, NewPath : DirStr;
- OutExt, NewExt : ExtStr;
- SortL : File of Opus;
- SearchTime : DateTime;
- Syst : Opus;
- CountOpus, ck1, ck2, ck3, ck5, n, count, count2, count3 : Integer;
- Fcount, TotalFile, TotalNFile, FlagDays, NowJD, FileJD, Ve : Integer;
- NewTot, Code, CountParamStr, AreaTotal, PathCount, PathInc : Integer;
- FileInc, FileCount, TotalAdd, JD, DiffJD : Integer;
- TotalSize, TotalNSize, AreaSize : LongInt;
- OutName, NewName : NameStr;
- OutList, OutArc, ThePath, FlagCheck, NewArc, ConfigFile : PathStr;
- HeadFile, ExiFile, OpusPath : PathStr;
- ck4 : Real;
- SearchData : SearchRec;
- BoxType, Pchk, Pcheck, FC1, PR1, Versions ,Sarea, FlagChar : String[1];
- TL, TR, BL, BR, LR, TB, Slash, GP, GP1, Ch : String[1];
- minu, secu, houru, dayu, num, Fmonth, Fday, FlagIt,FlagString : String[2];
- mh, DoIt, CountOp : String[3];
- Vers, Fyear : String[4];
- GrandChk, check2, check3, dayn, yearn, hourn, ArcCmd, FSize : String[7];
- Fdate : String[8];
- month2, dow, VerString : string[9];
- TheFile, FileCheck, PR2, Parm1 : String[12];
- FC2, Fspace : String[13];
- FC3, TheDesc, PR3 : String[60];
- Dirbbs : String[73];
- GraphLine, Filesbbs, parm2, TheTop, GetFiles : String[79];
- DateCh1, DateCh2, Ch1, Ch2,TotCount,SortDir,ListLine,OpusFile : String[80];
- Pstr, Ps, Pr, SortFiles, SortArea, HelloDos, CallArc,GetPaths : String[80];
- Tf, f1, SortList, ListIn, ListOut, StErr, DirCopy : Text;
- FileCopy, KillIt, ReadCfg, NewIn, NewOut : Text;
- sec, smallsec, hour, min, Year, Month, day, dofweek : Word;
-
- Label 1, 2, 102, 103, 104, 105; { Jump Labels }
-
- {$I AL_TIME.PAS} {Include The Time Routines}
- {$I AL_READ.PAS} {Include the Read/Write Routines}
-
- Procedure LogFile (Code, LogEntry : String);
- Begin
- Time;
- Date;
- Writeln(Code,' ',dayu,' ',mh,' ',Houru,':',Minu,':',Secu,' ALST ',LogEntry);
- End;
-
- Procedure Banner;
- Begin
- VerString := '';
- Versions := copy(version,4,1);
- If Versions <> '0' then VerString := 'a Beta';
- Versions := copy(version,5,1);
- If Versions <> '' then VerString := 'an Alpha';
- Assign(StErr,'CON');
- ReWrite(StErr);
- Writeln(StErr,'');
- Writeln(StErr,'AvaiList, Revision: ',version,copyright,'.');
- If VerString <> '' then Writeln(StErr,'This Revision is ',VerString,' Test Copy only. Please do not distribute.');
- Writeln(StErr,'');
- Close(StErr);
- End; {Procedure Banner}
-
- Procedure Run_Time;
- Begin
- Assign(StErr,'CON');
- ReWrite(StErr);
- If Quiet = True then Writeln(StErr,'Quiet Mode engaged...');
- If Quiet = False then
- Begin
- Writeln(StErr,'RunTime Configuration...');
- Writeln(StErr,'');
- Writeln(StErr,'Header File: ',HeadFile);
- Writeln(StErr,'Extra Info File: ',ExiFile);
- Writeln(StErr,'Master List: ',OutList);
- If DoArc = True then Writeln(StErr,'Master Archive: ',OutArc);
- If DoNewList = True then Writeln(StErr,'NewFile List: ',FlagCheck);
- If (DoNewList = True) AND (DoArc = True) then Writeln(StErr,'NewFile Archive: ',NewArc);
- Writeln(StErr,'');
- Writeln(StErr,'AvaiList will create header blocks using BoxType ',BoxType);
- If DoOpus = True then Writeln(StErr,'AvaiList will use Opus System.Bbs files for Path Information');
- If DoNewList = False then Writeln(StErr,'AvaiList will not create a NewFile list');
- If DoArc = True then Writeln(StErr,'AvaiList will use ',ArcCmd,' for archiving');
- If (DoArc = False) AND (DoNewList = True) then Writeln(StErr,'AvaiList will not archive the finished lists');
- If (DoArc = False) AND (DoNewList = False) then Writeln(StErr,'AvaiList will not archive the finished list');
- If (MoveIt = True) AND (DoArc = True) then Writeln(StErr,'AvaiList will delete the original after archiving');
- If (MoveIt = False) AND (DoArc = True) then Writeln(StErr,'AvaiList will not delete the original after archiving');
- If StripCom = True then Writeln(StErr,'AvaiList will not include files.bbs comments in master list');
- If StripCom = False then Writeln(StErr,'AvaiList will include files.bbs comments in master list');
- If NoDate = True then Writeln(StErr,'AvaiList will not include file dates in master list');
- If NoDate = False then Writeln(StErr,'AvaiList will include file dates in master list');
- If FlagNew = True then
- Begin
- Writeln(StErr,'AvaiList will flag files less than ',FlagDays,' days old');
- Writeln(StErr,'AvaiList will use the ''',flagchar,''' character to mark New Files');
- End;
- If FlagNew = False then Writeln(StErr,'AvaiList will not flag new files');
- If KillOrphan = True then Writeln(StErr,'AvaiList will not include missing or offline files in master list');
- If KillOrphan = False then Writeln(StErr,'AvaiList will include missing or offline files in master list');
- If TotArea = True then Writeln(StErr,'AvaiList will report files/bytes totals for each area');
- If TotArea = False then Writeln(StErr,'AvaiList will not report files/bytes totals for each area');
- End;
- Writeln(StErr,'');
- Close(StErr);
- End;
-
- Procedure Report_Error (Line : String ; Code : Integer);
- Begin
- Assign(StErr,'CON');
- Rewrite(StErr);
- Writeln(StErr,'');
- Writeln(StErr,Line);
- Close(StErr);
- Halt(code);
- End;
-
- {$I AL_CFG.PAS}
-
- Begin
- Assign(Input,''); Reset(Input); Assign(Output,''); Rewrite(Output);
- CheckBreak := False;
- HelloDOS := GetEnv('ComSpec');
- Vers := Copy(Version,1,4);
- TotalSize := 0;
- TotalFile := 0;
- TotalNSize := 0;
- TotalNFile := 0;
- ck1 := 0;
- ck2 := 0;
- ck3 := 0;
- ck4 := 0;
- ck5 := 0;
- Quiet := False;
- DoArc := False;
- DoOpus := False;
- NoDate := False;
- MoveIt := False;
- FlagNew := False;
- DoNewList := False;
- KillOrphan := False;
- Debug := False;
- TotArea := True;
- ArcCmd := 'ZOO';
- FlagChar := '*';
- PathInc := 0;
- PathCount := 0;
- FileInc := 0;
- FileCount := 0;
- ConfigFile := 'AvaiList.Cfg';
- HeadFile := 'AvaiList.Hdr';
- ExiFile := 'AvaiList.Exi';
- OpusPath := '\';
- StripCom := False;
- OutList := '';
- OutArc := '';
- FlagCheck := '';
- NewArc := '';
- FlagDays := 7;
- BoxType := '4';
- Banner;
- If ParamCount <> 0 then Pre_Cmd_Check;
- ConfigFile := FExpand(ConfigFile);
- If ParamCount <> 0 then Config_Read;
- Command_Line;
- HeadFile := FExpand(HeadFile);
- ExiFile := FExpand(ExiFile);
- If BoxType = '0' then
- Begin
- TL := '-'; TR := '-';
- BL := '-'; BR := '-';
- LR := '-'; TB := ' ';
- End;
- If BoxType = '1' then
- Begin
- TL := '┌'; TR := '┐';
- BL := '└'; BR := '┘';
- LR := '─'; TB := '│';
- End;
- If BoxType = '2' then
- Begin
- TL := '╔'; TR := '╗';
- BL := '╚'; BR := '╝';
- LR := '═'; TB := '║';
- End;
- If BoxType = '3' then
- Begin
- TL := '╓'; TR := '╖';
- BL := '╙'; BR := '╜';
- LR := '─'; TB := '║';
- End;
- If BoxType = '4' then
- Begin
- TL := '╒'; TR := '╕';
- BL := '╘'; BR := '╛';
- LR := '═'; TB := '│';
- End;
- TheTop := LR;
- For N := 1 to 76 do
- TheTop := TheTop + LR;
- If (DoOpus = False) and (PathCount = 0) then Goto 102;
- If DoOpus = True then
- Begin
- Slash := Copy(OpusPath,Length(OpusPath),1);
- If Slash <> '\' then OpusPath := OpusPath + '\';
- OpusFile := Concat(OpusPath,'System.Bbs');
- Assign(SortL,OpusFile);
- {$I-} Reset(SortL); {$I+}
- If IOResult <> 0 then goto 105;
- Close(SortL);
- End;
- OutList := FExpand(OutList);
- Assign(ListOut,OutList);
- {$I-} ReWrite(ListOut); {$I+}
- OK := (IOResult = 0);
- If NOT OK then goto 103;
- Close(ListOut);
- If DoNewList = TRUE then
- Begin
- Assign(NewOut,FlagCheck);
- {$I-} ReWrite(NewOut); {$I+}
- OK := (IOResult = 0);
- If Not OK then goto 104;
- Close(NewOut);
- End;
- If ArcCmd = '' then ArcCmd := 'ZOO';
- FSplit(OutList,OutPath,OutName,OutExt);
- OutArc := OutPath + OutName + '.' + ArcCmd;
- If ArcCmd = 'PKARC' then OutArc := OutPath + OutName + '.ARC';
- If ArcCmd = 'PKPAK' then OutArc := OutPath + OutName + '.ARC';
- If DoNewList = TRUE then
- Begin
- FlagCheck := FExpand(FlagCheck);
- FSplit(FlagCheck,NewPath,NewName,NewExt);
- NewArc := NewPath + NewName + '.' + ArcCmd;
- If ArcCmd = 'PKARC' then NewArc := NewPath + NewName + '.ARC';
- If ArcCmd = 'PKPAK' then NewArc := NewPath + NewName + '.ARC';
- End;
- Run_Time;
- LogFile('+','Begin, AvaiList ' + version);
- LogFile('#','Un-linking Old Master Files');
- Assign(f1,OutList);
- {$I-} Reset(f1) {$I+};
- OK := (IOResult = 0);
- If Ok then begin Close(f1); Erase(f1); End;
- If DoNewList = TRUE then
- Begin
- Assign(f1,FlagCheck);
- {$I-} Reset(f1) {$I+};
- OK := (IOResult = 0);
- If Ok then begin Close(f1); Erase(f1); End;
- End;
- If DoArc = TRUE then
- Begin
- Assign(f1,OutArc);
- {$I-} Reset(f1) {$I+};
- OK := (IOResult = 0);
- If Ok then begin Close(f1); Erase(f1); End;
- If DoNewList = TRUE then
- Begin
- Assign(f1,NewArc);
- {$I-} Reset(f1) {$I+};
- OK := (IOResult = 0);
- If Ok then begin Close(f1); Erase(f1); End;
- End;
- End;
- LogFile(' ','Calculating Date/Time Stamp');
- Time;
- Date;
- Str(Day,Dayn);
- Str(Year,Yearn);
- Ch1 := ConCat('Master List of ALL files in system on ',dow,', ',month2,' ',dayn,', ',yearn,' at ',houru,':',minu);
- Ch2 := ConCat('Master List of NEW files in system on ',dow,', ',month2,' ',dayn,', ',yearn,' at ',houru,':',minu);
- For n := 1 to length(ch1) do
- ck1 := ck1 + 1;
- ck2 := 77 - ck1;
- ck4 := ck2 / 2;
- ck3 := round(ck4);
- ck5 := ck2 - ck3;
- if ck3 = 0 then check2 := '';
- if ck3 = 1 then check2 := ' ';
- if ck3 = 2 then check2 := ' ';
- if ck3 = 3 then check2 := ' ';
- if ck3 = 4 then check2 := ' ';
- if ck3 = 5 then check2 := ' ';
- if ck5 = 0 then check3 := '';
- if ck5 = 1 then check3 := ' ';
- if ck5 = 2 then check3 := ' ';
- if ck5 = 3 then check3 := ' ';
- if ck5 = 4 then check3 := ' ';
- if ck5 = 5 then check3 := ' ';
- Assign(ListOut,OutList);
- {$I-} ReWrite(ListOut); {$I+}
- OK := (IOResult = 0);
- If Not OK then goto 103;
- Assign(ListIn,HeadFile);
- SetTextBuf(ListIn,Buf);
- {$I-} Reset(ListIn); {$I+}
- OK := (IOResult = 0);
- If OK then
- Begin
- Repeat
- Readln(ListIn,ListLine);
- Writeln(ListOut,ListLine);
- Until EOF(ListIn);
- Close(ListIn);
- End;
- Writeln(ListOut,TL,TheTop,TR);
- Writeln(ListOut,TB,check2,ch1,check3,TB);
- If FlagNew = True then
- Begin
- Writeln(ListOut,TB,' ',TB);
- If NoDate = False then Write(ListOut,TB,' Files marked with ',FlagChar,' following the FileDate ');
- If NoDate = True then Write(ListOut,TB,' Files marked with ',FlagChar,' following the FileSize ');
- Writeln(ListOut,'are less than ',flagdays:2,' days old. ',TB);
- end;
- Writeln(ListOut,BL,TheTop,BR);
- Assign(ListIn,ExiFile);
- SetTextBuf(ListIn,Buf);
- {$I-} Reset(ListIn); {$I+}
- OK := (IOResult = 0);
- If OK then
- Begin
- Repeat
- Readln(ListIn,ListLine);
- Writeln(ListOut,ListLine);
- Until EOF(ListIn);
- Close(ListIn);
- End;
- If DoNewList = True then
- Begin
- Assign(NewOut,FlagCheck);
- {$I-} ReWrite(NewOut); {$I+}
- OK := (IOResult = 0);
- If Not OK then goto 104;
- Assign(NewIn,HeadFile);
- SetTextBuf(NewIn,Buf);
- {$I-} Reset(NewIn); {$I+}
- OK := (IOResult = 0);
- If OK then
- Begin
- Repeat
- Readln(NewIn,ListLine);
- Writeln(NewOut,ListLine);
- Until EOF(NewIn);
- Close(NewIn);
- End;
- Writeln(NewOut,TL,TheTop,TR);
- Writeln(NewOut,TB,check2,ch2,check3,TB);
- Writeln(NewOut,TB,' ',TB);
- Writeln(NewOut,TB,' This listing only contains the files that are less than ',Flagdays:2,' days old. ',TB);
- Writeln(NewOut,BL,TheTop,BR);
- End;
- If DoOpus = True then
- Begin
- LogFile('#','Reading Opus System Files');
- CountOpus := 0;
- Repeat
- CountOpus := CountOpus + 1;
- Str(CountOpus,CountOp);
- OpusFile := Concat(OpusPath,'System',CountOp,'.Bbs');
- Assign(SortL,OpusFile);
- {$I-} Reset(SortL); {$I+}
- If IOResult <> 0 then begin CountOpus := 99; goto 2; End;
- Read(SortL,Syst);
- GetPaths := Copy(Syst.Download,1,Length(Syst.Download));
- GP := Copy(GetPaths,1,1); GP1:= Copy(GetPaths,2,1);
- If (GP1 = ':') and (GP <> #0) then
- Begin
- Inc(PathInc);
- Paths[PathInc] := GetPaths;
- End;
- Close(SortL);
- 2:
- Until CountOpus = 99;
- PathCount := PathInc;
- PathInc := 0;
- End;
- Repeat
- If PathCount = 0 then goto 102;
- NewTot := 0;
- AreaTotal := 0;
- AreaSize := 0;
- Inc(PathInc);
- SortArea := Paths[PathInc];
- Sarea := Copy(SortArea,1,1);
- If (SortArea = '') or (Sarea = '') or (Sarea = ' ') or (Sarea = ';') then goto 1;
- SortArea := FExpand(SortArea);
- Slash := Copy(SortArea,Length(SortArea),1);
- If Slash <> '\' then SortArea := SortArea + '\';
- SortFiles := SortArea + 'Files.Bbs';
- SortDir := SortArea + 'Dir.Bbs';
- LogFile(':','Processing ' + SortArea);
- ReadDirBbs;
- ReadFilesbbs;
- If (DoNewList = True) AND (NewTot = 0) then Writeln(NewOut,'No Files');
- If (TotArea = True) AND (AreaTotal <> 0) then
- Begin
- Writeln(ListOut,'');
- Writeln(ListOut,'> Total of ',AreaTotal,' files (',AreaSize,' bytes) in this Area');
- End;
- 1:
- Until PathInc = PathCount;
- Writeln(ListOut,'');
- Writeln(ListOut,TL,TheTop,TR);
- Writeln(ListOut,TB,' Total number of files = ',TotalFile:5,' Total number of bytes = ',TotalSize:9,' ',TB);
- Writeln(ListOut,TB,' ',TB);
- Writeln(ListOut,TB,' Compiled using AvaiList ',vers,copyright,' ',TB);
- Writeln(ListOut,BL,TheTop,BR);
- Close(ListOut);
- If DoNewList = True then
- Begin
- Writeln(NewOut,'');
- Writeln(NewOut,TL,TheTop,TR);
- Writeln(NewOut,TB,' Total number of files = ',TotalNFile:5,' Total number of bytes = ',TotalNSize:9,' ',TB);
- Writeln(NewOut,TB,' ',TB);
- Writeln(NewOut,TB,' Compiled using AvaiList ',vers,copyright,' ',TB);
- Writeln(NewOut,BL,TheTop,BR);
- Close(NewOut);
- End;
- If DoArc = TRUE then
- Begin
- LogFile('#','Creating "Master" File Archive');
- If ArcCmd <> 'ZOO' then
- Begin
- If MoveIt = True then DoIt := 'm';
- If MoveIt = False then DoIt := 'a';
- End;
- If ArcCmd = 'ZOO' then
- Begin
- If MoveIt = True then DoIt := 'aM:';
- If MoveIt = False then DoIt := 'a:';
- End;
- If Debug then
- Begin
- CallArc := Concat('/c ',ArcCmd,' ',DoIt,' ',OutArc,' ',OutList);
- Writeln;
- Writeln('> ',HelloDOS,' ',CallArc);
- Writeln;
- Exec(HelloDOS,CallArc);
- Writeln;
- End;
- If Not Debug then
- Begin
- CallArc := Concat('/c ',ArcCmd,' ',DoIt,' ',OutArc,' ',OutList,' >Nul');
- Exec(HelloDOS,CallArc);
- End;
- If DoNewList = True then
- Begin
- LogFile('#','Creating "New" File Archive');
- If Debug then
- Begin
- CallArc := Concat('/c ',ArcCmd,' ',DoIt,' ',NewArc,' ',FlagCheck);
- Writeln;
- Writeln('> ',HelloDOS,' ',CallArc);
- Writeln;
- Exec(HelloDOS,CallArc);
- Writeln;
- End;
- If Not Debug then
- Begin
- CallArc := Concat('/c ',ArcCmd,' ',DoIt,' ',NewArc,' ',FlagCheck,' >Nul');
- Exec(HelloDOS,CallArc);
- End;
- End;
- End;
- LogFile('+','End, AvaiList ' + version);
- Writeln;
- Halt(0);
- 102:
- Report_Error('No File Area Directories were specified, aborting.',2);
- 103:
- Report_Error('Unable to Write to selected Master File List ''' + outlist + ''', aborting.',3);
- 104:
- Report_Error('Unable to Write to selected New File List ''' + FlagCheck + ''', aborting.',4);
- 105:
- Report_Error('Unable to Find or Read from Opus System.Bbs files, aborting.',5);
- End.