home *** CD-ROM | disk | FTP | other *** search
- {*****************************************************************************
- * *
- * AL_Cfg.Pas By Andrew Farmer *
- * Config File and Command Line Parseing 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 *
- * *
- *****************************************************************************}
-
- Procedure Bad_Keyword (CLO : String);
- Begin
- Report_Error('''' + CLO + ''' is an invalid Configuration File keyword, aborting.',1);
- End;
-
- Procedure Bad_Option (CLO : String);
- Begin
- Report_Error('''-' + CLO + ''' is an invalid Command Line Option, aborting.',1);
- End;
-
- Procedure CONFIG_READ;
- Label 1, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, Translate;
- Begin
- Assign(ReadCfg,ConfigFile);
- SetTextBuf(ReadCfg,Buf);
- {$I-} Reset(ReadCfg) {$I+} ;
- OK := (IOResult = 0);
- If Not OK then Exit;
- Assign(StErr,'CON');
- ReWrite(StErr);
- Writeln(StErr,'Reading Configuration File ''',ConfigFile,'''...');
- Writeln(StErr,'');
- Close(StErr);
- PathInc := 0;
- PathCount := 0;
- Repeat
- Readln(ReadCfg,pr);
- For n := 1 to length(pr) do
- pr[n] := Upcase(pr[n]);
- PR1 := Copy(Pr,1,1);
- PR2 := Copy(Pr,1,15);
- if (pr = '') or (PR1 = ' ') or (PR1 = ';') then Goto 1;
- count := 0;
- repeat
- Count := Count + 1;
- Ch := Copy(PR2,Count,1);
- until (Ch = ' ') or (Count = Length(Pr));
- If Count = Length(Pr) then
- Begin
- Count := Length(Pr);
- Parm1 := Copy(Pr,1,count);
- Parm2 := '';
- Goto Translate;
- End;
- count := count - 1;
- Parm1 := Copy(Pr,1,count);
- count2 := count + 2;
- PR3 := Copy(Pr,count2,Length(Pr));
- If PR3 = '' then Parm2 := '';
- If PR3 <> '' then
- Begin
- Count3 := 0;
- repeat
- Count3 := Count3 + 1;
- Ch := Copy(PR3,Count3,1);
- until Ch <> ' ';
- count3 := count3 + count2;
- count3 := count3 - 1;
- Parm2 := Copy(Pr,count3,Length(Pr));
- End;
- Translate:
- If Parm1 = 'AREA' then Begin Inc(PathInc); Paths[PathInc] := Parm2; Goto 1; End;
- If Parm1 = 'ARCHIVE' then Begin DoArc := TRUE; ArcCmd := Parm2; Goto 1; End;
- If Parm1 = 'BOXTYPE' then Begin BoxType := Parm2; Goto 1; End;
- If Parm1 = 'NOCOMMENTS' then Begin StripCom := True; Goto 1; End;
- If Parm1 = 'NODATE' then Begin NoDate := TRUE; Goto 1; End;
- If Parm1 = 'EXTRA' then Begin ExiFile := Parm2; Goto 1; End;
- If Parm1 = 'FLAGNEW' then Begin FlagNew := True; FlagString := Parm2; Goto 1; End;
- If Parm1 = 'HEADER' then Begin HeadFile := Parm2; Goto 1; End;
- If Parm1 = 'KILLORPHAN' then Begin KillOrphan := True; Goto 1; End;
- If Parm1 = 'MOVE' then Begin MoveIt := TRUE; Goto 1; End;
- If Parm1 = 'NEWFILE' then Begin DoNewList := True; FlagCheck := Parm2; Goto 1; End;
- If Parm1 = 'OUTFILE' then Begin OutList := Parm2; Goto 1; End;
- If Parm1 = 'QUIET' then Begin Quiet := True; Goto 1; End;
- If Parm1 = 'SYSTEMBBS' then Begin DoOpus := True; OpusPath := Parm2; Goto 1; End;
- If Parm1 = 'NOTOTAL' then Begin TotArea := False; Goto 1; End;
- If Parm1 = 'FLAGCHAR' then Begin FlagChar := Parm2; Goto 1; End;
- If Parm1 = 'DEBUG' then Begin Debug := True; Goto 1; End;
- Bad_keyword(Parm1);
- 1:
- Until Eof(ReadCfg);
- Close(ReadCfg);
- PathCount := PathInc;
- PathInc := 0;
- If ConfigFile = '' then goto 100;
- If ExiFile = '' then goto 105;
- If HeadFile = '' then goto 106;
- If (ArcCmd <> '') AND (ArcCmd <> 'ARC') AND (ArcCmd <> 'DWC') AND (ArcCmd <> 'PKARC') AND
- (ArcCmd <> 'PKPAK') AND (ArcCmd <> 'PAK') AND (ArcCmd <> 'ZOO') then Goto 101;
- If (FlagNew = FALSE) AND (DoNewList = TRUE) then goto 102;
- If (DoNewList = TRUE) AND (FlagCheck = '') then goto 103;
- If (FlagNew = True) AND (FlagString <> '') then
- Begin
- Val(FlagString,FlagDays,Code);
- If Code <> 0 then Goto 104;
- End;
- If (BoxType <> '0') and (BoxType <> '1') and (BoxType <> '2') and (BoxType <> '3') and (BoxType <> '4') then goto 107;
- If FlagChar = '' then goto 108;
- If OpusPath = '' then goto 109;
- OpusPath := FExpand(OpusPath);
- Exit;
- 100:
- Report_Error('You MUST Provide a FileName following the INFOFILE keyword, aborting',1);
- 101:
- Report_Error('The ARCHIVE keyword modifier ''' + ArcCmd + ''' is invalid, aborting',1);
- 102:
- Report_Error('The NEWFILE keyword was selected without the the FLAGNEW keyword, aborting',1);
- 103:
- Report_Error('You MUST Provide an Output FileName following the NEWFILE keyword, aborting',1);
- 104:
- Report_Error('The FLAGNEW keyword was modified, but not with a valid interger, aborting',1);
- 105:
- Report_Error('You MUST Provide an Input FileName following the EXTRA keyword, aborting',1);
- 106:
- Report_Error('You MUST Provide an Input FileName following the HEADER keyword, aborting',1);
- 107:
- Report_Error('The BOXTYPE keyword modifier ''' + BoxType + ''' is out of range, aborting',1);
- 108:
- Report_Error('The FLAGCHAR keyword MUST be modified with a vaild ASCII character, aborting',1);
- 109:
- Report_Error('The SYSTEMBBS keyword MUST be modified with a Drive\Directory\Path, aborting',1);
- End; {Procedure CONFIG_READ}
-
- Procedure PRE_CMD_CHECK;
- Begin
- ps := ParamStr(1);
- For n := 1 to length(ps) do
- ps[n] := Upcase(ps[n]);
- pcheck := copy(ps,1,1);
- pchk := Copy(ps,2,1);
- Pstr := Copy(ps,3,length(ps));
- if (pcheck <> '/') and (pcheck <> '-') then Exit;
- If (Pchk = 'R') then If Pstr <> '' then ConfigFile := Pstr;
- End; {Procedure Pre_Cmd_Check}
-
- Procedure COMMAND_LINE;
- Label 1, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113;
- Begin
- If ParamCount > 15 then Goto 103;
- If ParamCount = 0 then Goto 105;
- ps := ParamStr(1);
- For n := 1 to length(ps) do
- ps[n] := Upcase(ps[n]);
- pcheck := copy(ps,1,1);
- pchk := Copy(ps,2,1);
- if (pcheck <> '/') and (pcheck <> '-') then Goto 101;
- If Pchk = 'R' then Exit;
- CountParamStr := 0;
- Repeat
- CountParamStr := CountParamStr + 1;
- ps := ParamStr(CountParamStr);
- For n := 1 to length(ps) do
- ps[n] := Upcase(ps[n]);
- pcheck := copy(ps,1,1);
- pchk := Copy(ps,2,1);
- Pstr := Copy(ps,3,length(ps));
- if (pcheck <> '/') and (pcheck <> '-') then Goto 101;
- If Pchk = 'A' then Begin DoArc := TRUE; ArcCmd := Pstr; Goto 1; End;
- If Pchk = 'B' then Begin BoxType := Pstr; Goto 1; End;
- If Pchk = 'C' then Begin StripCom := True; Goto 1; End;
- If Pchk = 'D' then Begin NoDate := TRUE; Goto 1; End;
- If Pchk = 'E' then Begin ExiFile := Pstr; Goto 1; End;
- If Pchk = 'F' then Begin FlagNew := True; FlagString := Pstr; Goto 1; End;
- If Pchk = 'H' then Begin HeadFile := Pstr; Goto 1; End;
- If Pchk = 'K' then Begin KillOrphan := True; Goto 1; End;
- If Pchk = 'M' then Begin MoveIt := TRUE; Goto 1; End;
- If Pchk = 'N' then Begin DoNewList := True; FlagCheck := Pstr; Goto 1; End;
- If Pchk = 'O' then Begin OutList := Pstr; Goto 1; End;
- If Pchk = 'Q' then Begin Quiet := True; Goto 1; End;
- If Pchk = 'S' then Begin DoOpus := True; OpusPath := Pstr; Goto 1; End;
- If Pchk = 'T' then Begin TotArea := False; Goto 1; End;
- If Pchk = 'Z' then Begin FlagChar := Pstr; Goto 1; End;
- Bad_Option(Pchk);
- 1:
- Until CountParamStr = ParamCount;
- If OutList = '' then goto 102;
- If ConfigFile = '' then goto 108;
- If ExiFile = '' then goto 109;
- If HeadFile = '' then goto 110;
- If (ArcCmd <> '') AND (ArcCmd <> 'ARC') AND (ArcCmd <> 'DWC') AND (ArcCmd <> 'PKARC') AND
- (ArcCmd <> 'PKPAK') AND (ArcCmd <> 'PAK') AND (ArcCmd <> 'ZOO') then Goto 104;
- If (FlagNew = FALSE) AND (DoNewList = TRUE) then goto 106;
- If (DoNewList = TRUE) AND (FlagCheck = '') then goto 107;
- If (FlagNew = True) AND (FlagString <> '') then
- Begin
- Val(FlagString,FlagDays,Code);
- If Code <> 0 then Goto 100;
- End;
- If (BoxType <> '0') and (BoxType <> '1') and (BoxType <> '2') and (BoxType <> '3') and (BoxType <> '4') then goto 111;
- If FlagChar = '' then goto 112;
- If OpusPath = '' then goto 113;
- OpusPath := FExpand(OpusPath);
- Exit;
- 100:
- Report_Error('The F Parameter was modified, but not with a valid integer, aborting',1);
- 101:
- Report_Error('ALL Command Line Options MUST be preceded with / or -, aborting',1);
- 102:
- Report_Error('The -O Parameter MUST be present, and MUST be followed by a FileName, aborting',1);
- 103:
- Report_Error('Too Many Command Line Options were used, aborting',1);
- 104:
- Report_Error('The A Parameter value of ''' + ArcCmd + ''' is invalid, aborting',1);
- 105:
- Assign(StErr,'CON');
- ReWrite(StErr);
- Writeln(StErr,'Usage: AvaiList <-R> or <-Ooutfile + your choice of optional switches>');
- Writeln(StErr,'');
- Writeln(StErr,' -A<arccmd> Causes Master/NewFile list to be Archived. See Docs re: ''arccmd''');
- Writeln(StErr,' -B<boxtyp> Selects which BoxType to use in the lists. See Docs re: ''boxtyp''');
- Writeln(StErr,' -C Causes Files.Bbs comment lines to be striped from the Master List.');
- Writeln(StErr,' -D Causes each file''s Date Stamp NOT to be put into the List.');
- Writeln(StErr,' -Efilespec Replace the default ''Extra Info'' file with one of your choice.');
- Writeln(StErr,' -F<days> Flag files that are new in past <days> days. Default is 7 days.');
- Writeln(StErr,' -Hfilespec Replace the default ''Header'' file with one of your choice.');
- Writeln(StErr,' -K Kill Orphans. Do NOT show Missing/Offline files in the Master List.');
- Writeln(StErr,' -M When used with the -A command, causes File to be Moved to Archive.');
- Writeln(StErr,' -Noutfile With -F, causes a NewFile list to be created with the Master List.');
- Writeln(StErr,' -Ooutfile File for Master Output, outfile is a filename or a path + filename.');
- Writeln(StErr,' -Q Causes AvaiList to run Quietly, will not display Runtime settings.');
- Writeln(StErr,' -R<config> Run from pre-set configfile settings only. Must be the First switch');
- Writeln(StErr,' -Spath Use Opus System.Bbs Files in directory <path> for the Path Info.');
- Writeln(StErr,' -T DO NOT total up files/bytes in EACH Area & report in Master List.');
- Writeln(StErr,' -Z<char> Use <char> to flag new files instead of using an asterix (*).');
- Writeln(StErr,'');
- Writeln(StErr,'Switches may be set in the Config File. Redirect output to produce Log Report.');
- Close(StErr);
- Halt(0);
- 106:
- Report_Error('The N Parameter was selected without the presence of the F Parameter, aborting',1);
- 107:
- Report_Error('You MUST Provide an Output FileName following the N Parameter, aborting',1);
- 108:
- Report_Error('You MUST Provide an Input FileName following the P Parameter, aborting',1);
- 109:
- Report_Error('You MUST Provide an Input FileName following the E Parameter, aborting',1);
- 110:
- Report_Error('You MUST Provide an Input FileName following the H Parameter, aborting',1);
- 111:
- Report_Error('The B Parameter value of ''' + BoxType + ''' is out of range, aborting',1);
- 112:
- Report_Error('The Z Parameter MUST be modified with a vaild ASCII character, aborting',1);
- 113:
- Report_Error('The S Parameter MUST be modified with a Drive\Directory\Path, aborting',1);
- End; {Procedure COMMAND_LINE}