home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 15 / CD_ASCQ_15_070894.iso / vrac / gus_180.zip / GUS_WCFG.PAS < prev    next >
Pascal/Delphi Source File  |  1994-02-05  |  6KB  |  146 lines

  1. {$A+,B-,D-,E-,F-,I+,L-,N-,O-,R+,S+,V-}
  2. {$IFDEF VER60}
  3.   {$G-,X-}
  4. {$ENDIF}
  5. {$IFDEF VER70}
  6.   {$G-,P-,Q-,T-,X-,Y-}
  7. {$ENDIF}
  8. {$M 1024, 0, 0}
  9.  
  10. program GUS_WriteConfig;    { Append or update configuration }
  11.                             { information to or in GUS.EXE    for v1.80 !!!  }
  12. uses DOS;
  13.  
  14. type
  15.     FNameStr = string[12];
  16.  
  17.     ArcType = (ARC, ARp, ARJ, DWC, HA, HAP, HPK, HYP, LZH, PAK, SQZ, UC2, ZIP, ZOO);
  18.     ArcCmds = (Extract, Replace, Display, Test, Contents);
  19.  
  20.     ArcData = record
  21.                 Ext : string[3];
  22.                 Prog: FNameStr;
  23.                 Cmd : array [ArcCmds] of string[10];
  24.                 Pth,
  25.                 Pwd : string[5];
  26.               end;
  27.  
  28.     ArcCfg  = record
  29.                 Marker  : longint;
  30.                 ArcTable: array [ArcType] of ArcData;
  31.               end;
  32.  
  33. const
  34.     GUSname     = 'GUS.EXE';
  35.     CfgMarker   = $B4535547;       {'GUS'+chr(180)}
  36.     Unsupported = '**********';
  37.     ArcInfo     : ArcCfg
  38.     = (Marker   : CfgMarker;
  39.        ArcTable :                         {     Extract       Replace       Display       Test          Contents    }
  40.        ((Ext: 'ARC'; Prog: 'PKUNPAK .EXE'; Cmd:('-n        ', '-r        ', '-c        ', '-t        ', '-v        ');
  41.                                            Pth: Unsupported;
  42.                                            Pwd: 'g    '     ),
  43.         (Ext: 'A7+'; Prog: 'XARC    .EXE'; Cmd:('          ', '/o        ', Unsupported , Unsupported , Unsupported );
  44.                                            Pth: Unsupported;
  45.                                            Pwd: '/g   '     ),
  46.         (Ext: 'ARJ'; Prog: 'ARJ     .EXE'; Cmd:('e -uy     ', 'e -y      ', 'p         ', 't         ', 'l         ');
  47.                                            Pth: '<x   '    ;
  48.                                            Pwd: ' -g  '     ),
  49.         (Ext: 'DWC'; Prog: 'DWC     .EXE'; Cmd:('xow       ', 'xw        ', 'p         ', 't         ', 'v         ');
  50.                                            Pth: 'r    '    ;
  51.                                            Pwd: 'g    '     ),
  52.         (Ext: 'HA '; Prog: 'HA      .EXE'; Cmd:('et        ', 'ety       ', Unsupported , 't         ', 'l         ');
  53.                                            Pth: '<x   '    ;
  54.                                            Pwd: Unsupported ),
  55.         (Ext: 'HAP'; Prog: 'PAH     .EXE'; Cmd:('e         ', 'e         ', Unsupported , Unsupported , 'l         ');
  56.                                            Pth: Unsupported;
  57.                                            Pwd: Unsupported ),
  58.         (Ext: 'HPK'; Prog: 'HPACK   .EXE'; Cmd:('x -on     ', 'x -oa     ', 'p         ', 't         ', 'v         ');
  59.                                            Pth: ' -da '    ;
  60.                                            Pwd: ' -c  '     ),
  61.         (Ext: 'HYP'; Prog: 'HYPER   .EXE'; Cmd:('-x        ', '-xo       ', Unsupported , Unsupported , '-v        ');
  62.                                            Pth: 'p    '    ;
  63.                                            Pwd: Unsupported ),
  64.         (Ext: 'LZH'; Prog: 'LHA     .EXE'; Cmd:('e /m+     ', 'e /m+c+   ', 'p /m+     ', 't /m+     ', 'l         ');
  65.                                            Pth: 'x+   '    ;
  66.                                            Pwd: Unsupported ),
  67.         (Ext: 'PAK'; Prog: 'PAK     .EXE'; Cmd:('e/WO      ', 'e/WA      ', 'p         ', 't         ', 'l         ');
  68.                                            Pth: '/PATH'    ;
  69.                                            Pwd: '/g=  '     ),
  70.         (Ext: 'SQZ'; Prog: 'SQZ     .EXE'; Cmd:('e /o0     ', 'e /o1     ', 'p         ', 't         ', 'l         ');
  71.                                            Pth: '<x   '    ;
  72.                                            Pwd: Unsupported ),
  73.         (Ext: 'UC2'; Prog: 'UC      .EXE'; Cmd:('E         ', 'E -F      ', Unsupported , 'T         ', 'V         ');
  74.                                            Pth: ' -S  '    ;
  75.                                            Pwd: Unsupported ),
  76.         (Ext: 'ZIP'; Prog: 'PKUNZIP .EXE'; Cmd:('-n        ', '-o        ', '-c        ', '-t        ', '-v        ');
  77.                                            Pth: ' -d  '    ;
  78.                                            Pwd: ' -s  '     ),
  79.         (Ext: 'ZOO'; Prog: 'ZOO     .EXE'; Cmd:('e:O       ', 'e:OS      ', 'e:p       ', 'e:N       ', 'lC        ');
  80.                                            Pth: '//   '    ;
  81.                                            Pwd: Unsupported )
  82.        )
  83.       );  {NOTE: if the first character of an option string is a '<', then it means that the following letter
  84.            should REPLACE the first letter of the command string and not be added to it like the other options.}
  85. var
  86.     CfgData : ArcCfg;
  87.     GUSfile : file;
  88.  
  89.  
  90. procedure ReadData (var F   : file;
  91.                     var Data: ArcCfg);
  92.  begin
  93.   {$I-} reset(F, 1); {$I+}
  94.   if IOresult <> 0
  95.    then begin
  96.          writeln('Can''t open ', GUSname);
  97.          Halt(1);
  98.         end;
  99.   {$I-} seek(F, filesize(F)-sizeof(ArcCfg)); {$I+}
  100.   if IOresult <> 0
  101.    then begin
  102.          writeln('Problem: cannot seek to byte location ', filesize(F), ' - ', sizeof(ArcCfg));
  103.          Halt(1);
  104.         end;
  105.   {$I-} BlockRead(F, Data, sizeof(ArcCfg)); {$I+}
  106.   if IOresult <> 0
  107.    then begin
  108.          writeln('Problem: cannot read ', sizeof(ArcCfg), ' bytes in ', GUSname, ' at offset ', filepos(F));
  109.          Halt(1);
  110.         end;
  111.   close(F);
  112.   writeln('Reading configuration information from ', GUSname)
  113.  end; {ReadData}
  114.  
  115.  
  116. procedure AppendData (var F   : file;
  117.                       var Data: ArcCfg);
  118.  begin
  119.   Data.Marker:=CfgMarker;
  120.   reset(F, 1);
  121.   seek(F, filesize(F));
  122.   BlockWrite(F, Data, sizeof(ArcCfg));
  123.   close(F);
  124.   writeln('Appending configuration information to ', GUSname)
  125.  end; {AppendData}
  126.  
  127.  
  128. procedure UpdateData (var F   : file;
  129.                       var Data: ArcCfg);
  130.  begin
  131.   Data.Marker:=CfgMarker;
  132.   reset(F, 1);
  133.   seek(F, filesize(F)-sizeof(ArcCfg));
  134.   BlockWrite(F, Data, sizeof(ArcCfg));
  135.   close(F);
  136.   writeln('Updating configuration information in ', GUSname)
  137.  end; {UpdateData}
  138.  
  139. begin {=MAIN=}
  140.  assign(GUSfile, GUSname);
  141.  ReadData(GUSfile, CfgData);
  142.  if CfgData.Marker = CfgMarker
  143.   then UpdateData(GUSfile, ArcInfo)
  144.   else AppendData(GUSfile, ArcInfo)
  145. end.
  146.