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