home *** CD-ROM | disk | FTP | other *** search
/ PC-Online 1998 February / PCOnline_02_1998.iso / filesbbs / dos / listz21s.exe / LZSET10S.RAR / LZS_ARCH.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-25  |  4.0 KB  |  156 lines

  1. /*
  2.  * This file is part of LZSETUP (Configuration program for Listerz)
  3.  *
  4.  * Copyright (c) 1997 Branislav L. Slantchev (gargoyle)
  5.  * A fine product of Silicon Creations, Inc.
  6.  *
  7.  * This file is released under the terms and conditions of the GNU
  8.  * General Public License Version 2. The full text of the license is
  9.  * supplied in the Copying.Doc file included with this archive. This
  10.  * free software comes with absolutely no warranty, as outlined in the
  11.  * licensing text. You are not allowed to remove this copyright notice.
  12.  *
  13.  * Contact: Branislav L. Slantchev at 73023.262@compuserve.com
  14. */
  15. #include <opdefine.h>
  16. #include <string.h>
  17. #include <opentry.h>
  18. #include <opstring.h>
  19. #include "lzs_cmds.h"
  20. #include "../lzconfig.h"
  21.  
  22. extern boolean    lz_Dirty;
  23. extern FrameArray lz_FrameType;
  24. extern ColorSet   lz_Colors;
  25.  
  26. typedef struct
  27. {
  28.     char    path[80];
  29.     char    options[36];
  30.     boolean enabled;
  31.     boolean swap;
  32.     char    header[30];
  33. } ArchiveRecord;
  34.  
  35. static word
  36. InitArchiveScreen(EntryScreen &ES, ColorSet &EsColors, ArchiveRecord &UR)
  37. {
  38.     char Pic[255];
  39.     long WinOptions = wBordered | wClear | wUserContents;
  40.  
  41.     if( !ES.InitCustom(14, 8, 69, 14, EsColors, WinOptions) )
  42.         return ES.InitStatus;
  43.  
  44.     ES.wFrame.SetFrameType(lz_FrameType);
  45.     ES.EnableExplosions(15);
  46.     ES.wFrame.AddShadow(shBR, shSeeThru);
  47.     ES.wFrame.AddHeader(UR.header, heTR);
  48.     ES.esOptionsOff(esMousePage);
  49.     ES.esFieldOptionsOn(efCursorToEnd | efClearFirstChar);
  50.     ES.esFieldOptionsOff(efInsertPushes | efAllowEscape |
  51.         efShowReadChar | efDefaultAccepted);
  52.     ES.SetWrapMode(WrapAtEdges);
  53.  
  54.     CharStr('!', 79, Pic);
  55.     ES.AddStringField("Archiver path   ", 2, 3, Pic, 2, 20, 35,
  56.         hi_ArchPath, UR.path);
  57.     CharStr('X', 35, Pic);
  58.     ES.AddStringField("└ Options       ", 3, 3, Pic, 3, 20, 35,
  59.         hi_Options, UR.options);
  60.     ES.AddYesNoField("Enabled         ", 5, 3, "Y", 5, 20,
  61.         hi_Enabled, UR.enabled);
  62.     ES.AddYesNoField("Swap to EMS/XMS ", 6, 3, "Y", 6, 20,
  63.         hi_Swap, UR.swap);
  64.  
  65.     if( ES.RawError() ) ES.Done();
  66.     return ES.RawError();
  67. }
  68.  
  69. void
  70. ArchiverSetup( int which )
  71. {
  72.     char          *path, *options;
  73.     Boolean       *enabled, *swap;
  74.     char          *header;
  75.     EntryScreen    dlg;
  76.     ArchiveRecord  rec;
  77.  
  78.     // get pointers to the correct info in lz_Config
  79.     switch( which )
  80.     {
  81.         case ARCHIVER_ZIP:
  82.             path    = lz_Config.zip.path;
  83.             options = lz_Config.zip.options;
  84.             enabled = &lz_Config.zip.enabled;
  85.             swap    = &lz_Config.zip.swap;
  86.             header  = " ZIP Archiver Setup ";
  87.             break;
  88.         case ARCHIVER_RAR:
  89.             path    = lz_Config.rar.path;
  90.             options = lz_Config.rar.options;
  91.             enabled = &lz_Config.rar.enabled;
  92.             swap    = &lz_Config.rar.swap;
  93.             header  = " RAR Archiver Setup ";
  94.             break;
  95.         case ARCHIVER_ARJ:
  96.             path    = lz_Config.arj.path;
  97.             options = lz_Config.arj.options;
  98.             enabled = &lz_Config.arj.enabled;
  99.             swap    = &lz_Config.arj.swap;
  100.             header  = " ARJ Archiver Setup ";
  101.             break;
  102.         case ARCHIVER_LHA:
  103.             path    = lz_Config.lha.path;
  104.             options = lz_Config.lha.options;
  105.             enabled = &lz_Config.lha.enabled;
  106.             swap    = &lz_Config.lha.swap;
  107.             header  = " LHA Archiver Setup ";
  108.             break;
  109.         case ARCHIVER_ZOO:
  110.             path    = lz_Config.zoo.path;
  111.             options = lz_Config.zoo.options;
  112.             enabled = &lz_Config.zoo.enabled;
  113.             swap    = &lz_Config.zoo.swap;
  114.             header  = " ZOO Archiver Setup ";
  115.             break;
  116.         default:
  117.             return;
  118.     }
  119.  
  120.     // setup the record
  121.     strcpy(rec.path, path);
  122.     strcpy(rec.options, options);
  123.     strcpy(rec.header, header);
  124.     rec.enabled = *enabled;
  125.     rec.swap    = *swap;
  126.  
  127.     if( 0 == InitArchiveScreen(dlg, lz_Colors, rec) )
  128.     {
  129.         dlg.Draw();
  130.         dlg.Process();
  131.         dlg.Erase();
  132.         dlg.Done();
  133.  
  134.         if( strcmp(rec.path, path) )
  135.         {
  136.             strcpy(path, rec.path);
  137.             lz_Dirty = TRUE;
  138.         }
  139.         if( strcmp(rec.options, options) )
  140.         {
  141.             strcpy(options, rec.options);
  142.             lz_Dirty = TRUE;
  143.         }
  144.         if( rec.enabled != *enabled )
  145.         {
  146.             *enabled = Boolean(rec.enabled);
  147.             lz_Dirty = TRUE;
  148.         }
  149.         if( rec.swap != *swap )
  150.         {
  151.             *swap = Boolean(rec.swap);
  152.             lz_Dirty = TRUE;
  153.         }
  154.     }
  155. }
  156.