home *** CD-ROM | disk | FTP | other *** search
/ PC-Online 1998 February / PCOnline_02_1998.iso / filesbbs / dos / listz21s.exe / LZSET10S.RAR / LZS_CONF.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-25  |  6.1 KB  |  206 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 <stdio.h>
  16. #include <string.h>
  17. #include <opcrt.h>
  18. #include <dir.h>
  19. #include "file.h"
  20. #include "proboard.h"
  21. #include "../lzconfig.h"
  22.  
  23. extern void     MsgBox(char *header, char *text, ColorSet &colors);
  24. extern ColorSet lz_Colors;
  25. extern boolean  lz_Dirty;
  26. extern char     lz_ConfigPath[];
  27.  
  28. void
  29. LoadConfig()
  30. {
  31.     FILE    *fp;
  32.     char    *name = "LISTERZ.CNF";
  33.     char    *msg = "Configuration file not found.\r"
  34.                    "lzSetup will use the built-in default values";
  35.  
  36.     strcpy(lz_ConfigPath, name);
  37.     if( !file_exist(lz_ConfigPath) )
  38.     {
  39.         strcpy(lz_ConfigPath, pb_getpath(name, PBDIR_PEX));
  40.     }
  41.  
  42.     memset(&lz_Config, 0x00, sizeof(lz_Config));
  43.  
  44.     if( 0 != (fp = fopen(lz_ConfigPath, "rb")) )
  45.     {
  46.         fread(&lz_Config, sizeof(lz_Config), 1, fp);
  47.         fclose(fp);
  48.     }
  49.     else
  50.     {
  51.         char *p;
  52.  
  53.         // display message box with info (defaults loaded)
  54.         MsgBox(" Info ", msg, lz_Colors);
  55.  
  56.         getcwd(lz_Config.sys_Path, sizeof(lz_Config.sys_Path));
  57.         file_appchr(lz_Config.sys_Path, NULL);
  58.         strcpy(lz_Config.sys_MainFile, "LSZ_MAIN.ANS");
  59.         strcpy(lz_Config.sys_ProcFile, "LSZ_PROC.ANS");
  60.         strcpy(lz_Config.text_HeaderAll, "LSZ_MSTR.HDR");
  61.         strcpy(lz_Config.text_FooterAll, "LSZ_MSTR.FTR");
  62.         strcpy(lz_Config.text_Header, "LSZ_AREA.HDR");
  63.         strcpy(lz_Config.text_Footer, "LSZ_AREA.FTR");
  64.  
  65.         lz_Config.lbox_Bounds.a.x    = 12;
  66.         lz_Config.lbox_Bounds.a.y    = 7;
  67.         lz_Config.lbox_Bounds.b.x    = 63;
  68.         lz_Config.lbox_Bounds.b.y    = 18;
  69.         lz_Config.lbox_Color         = 0x0C;
  70.         lz_Config.lbox_Hilite        = 0x4A;
  71.         lz_Config.lbox_TagChar       = '√';
  72.         lz_Config.lbox_TagColor      = 0x0F;
  73.         lz_Config.lbox_TagHilite     = 0x4A;
  74.  
  75.         lz_Config.cbar_Bounds.a.x    = 12;
  76.         lz_Config.cbar_Bounds.a.y    = 22;
  77.         lz_Config.cbar_Bounds.b.x    = 63;
  78.         lz_Config.cbar_Bounds.b.y    = 22;
  79.         lz_Config.cbar_Color         = 0x04;
  80.         lz_Config.cbar_Background    = 0x00;
  81.         lz_Config.cbar_HotkeyColor   = 0x0C;
  82.         lz_Config.cbar_HiliteColor   = 0x0E;
  83.         lz_Config.cbar_OffColor      = 0x08;
  84.         lz_Config.cbar_OffBackground = 0x00;
  85.  
  86.         lz_Config.proc_Bounds.a.x    = 14;
  87.         lz_Config.proc_Bounds.a.y    = 7;
  88.         lz_Config.proc_Bounds.b.x    = 66;
  89.         lz_Config.proc_Bounds.b.y    = 15;
  90.         lz_Config.proc_Color         = 0x03;
  91.  
  92.         lz_Config.area_Bounds.a.x    = 3;
  93.         lz_Config.area_Bounds.a.y    = 19;
  94.         lz_Config.area_Bounds.b.x    = 38;
  95.         lz_Config.area_Bounds.b.y    = 19;
  96.         lz_Config.area_Color         = 0x0F;
  97.         lz_Config.area_Percent.a.x   = 39;
  98.         lz_Config.area_Percent.a.y   = 19;
  99.         lz_Config.area_Percent.b.x   = 43;
  100.         lz_Config.area_Percent.b.y   = 19;
  101.  
  102.         lz_Config.area_Progbar.bounds.a.x = 3;
  103.         lz_Config.area_Progbar.bounds.a.y = 20;
  104.         lz_Config.area_Progbar.bounds.b.x = 43;
  105.         lz_Config.area_Progbar.bounds.b.y = 20;
  106.         lz_Config.area_Progbar.fgColor    = 0x4C;
  107.         lz_Config.area_Progbar.bgColor    = 0x04;
  108.         lz_Config.area_Progbar.fgChar     = '▒';
  109.         lz_Config.area_Progbar.bgChar     = '■';
  110.  
  111.         lz_Config.total_Percent.a.x        = 39;
  112.         lz_Config.total_Percent.a.y        = 21;
  113.         lz_Config.total_Percent.b.x        = 43;
  114.         lz_Config.total_Percent.b.y        = 21;
  115.         lz_Config.total_Progbar.bounds.a.x = 3;
  116.         lz_Config.total_Progbar.bounds.a.y = 22;
  117.         lz_Config.total_Progbar.bounds.b.x = 43;
  118.         lz_Config.total_Progbar.bounds.b.y = 22;
  119.         lz_Config.total_Progbar.fgColor    = 0x4C;
  120.         lz_Config.total_Progbar.bgColor    = 0x04;
  121.         lz_Config.total_Progbar.fgChar     = '▒';
  122.         lz_Config.total_Progbar.bgChar     = '■';
  123.  
  124.         lz_Config.total_Areas.a.x    = 62;
  125.         lz_Config.total_Areas.a.y    = 19;
  126.         lz_Config.total_Areas.b.x    = 77;
  127.         lz_Config.total_Areas.b.y    = 19;
  128.         lz_Config.total_Files.a.x    = 62;
  129.         lz_Config.total_Files.a.y    = 20;
  130.         lz_Config.total_Files.b.x    = 77;
  131.         lz_Config.total_Files.b.y    = 20;
  132.         lz_Config.total_Size.a.x     = 62;
  133.         lz_Config.total_Size.a.y     = 21;
  134.         lz_Config.total_Size.b.x     = 77;
  135.         lz_Config.total_Size.b.y     = 21;
  136.         lz_Config.total_ListSize.a.x = 62;
  137.         lz_Config.total_ListSize.a.y = 22;
  138.         lz_Config.total_ListSize.b.x = 77;
  139.         lz_Config.total_ListSize.b.y = 22;
  140.         lz_Config.total_DigitColor   = 0x0B;
  141.  
  142.         lz_Config.drop_UserDoes = False;
  143.         lz_Config.drop_Doing    = False;
  144.         strcpy(lz_Config.drop_Text, "Using Listerz (The Best)");
  145.  
  146.         if( 0 != (p = file_scan(NULL, "PKZIP.EXE")) )
  147.         {
  148.             strcpy(lz_Config.zip.path, p);
  149.             strcpy(lz_Config.zip.options, "-ex -m");
  150.             lz_Config.zip.enabled = True;
  151.             lz_Config.zip.swap = True;
  152.         }
  153.         if( 0 != (p = file_scan(NULL, "RAR.EXE")) )
  154.         {
  155.             strcpy(lz_Config.rar.path, p);
  156.             strcpy(lz_Config.rar.options, "m -ep -m5");
  157.             lz_Config.rar.enabled = True;
  158.             lz_Config.rar.swap = True;
  159.         }
  160.         if( 0 != (p = file_scan(NULL, "ARJ.EXE")) )
  161.         {
  162.             strcpy(lz_Config.arj.path, p);
  163.             strcpy(lz_Config.arj.options, "m -e -m1");
  164.             lz_Config.arj.enabled = True;
  165.             lz_Config.arj.swap = True;
  166.         }
  167.         if( 0 != (p = file_scan(NULL, "LHA.EXE")) )
  168.         {
  169.             strcpy(lz_Config.lha.path, p);
  170.             strcpy(lz_Config.lha.options, "m");
  171.             lz_Config.lha.enabled = True;
  172.             lz_Config.lha.swap = True;
  173.         }
  174.         if( 0 != (p = file_scan(NULL, "ZOO.EXE")) )
  175.         {
  176.             strcpy(lz_Config.zoo.path, p);
  177.             strcpy(lz_Config.zoo.options, "ahM:");
  178.             lz_Config.zoo.enabled = True;
  179.             lz_Config.zoo.swap = True;
  180.         }
  181.  
  182.         lz_Dirty = TRUE;
  183.     }
  184. }
  185.  
  186.  
  187. void
  188. SaveConfig()
  189. {
  190.     FILE *fp = fopen(lz_ConfigPath, "wb");
  191.  
  192.     if( fp )
  193.     {
  194.         fwrite(&lz_Config, sizeof(lz_Config), 1, fp);
  195.         fclose(fp);
  196.     }
  197.     else
  198.     {
  199.         char msg[255];
  200.  
  201.         sprintf(msg, "Unable to update configuration file\r%s", lz_ConfigPath);
  202.         MsgBox(" Error ", msg, lz_Colors);
  203.     }
  204. }
  205.  
  206.