home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / lora299s.zip / CONFIG.CPP < prev    next >
C/C++ Source or Header  |  1998-05-12  |  25KB  |  744 lines

  1.  
  2. // LoraBBS Version 2.99 Free Edition
  3. // Copyright (C) 1987-98 Marco Maccaferri
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation; either version 2 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. // GNU General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program; if not, write to the Free Software
  17. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19. #include "_ldefs.h"
  20. #include "lora_api.h"
  21.  
  22. TConfig::TConfig (void)
  23. {
  24.    strcpy (ConfigFile, "config.dat");
  25.    strcpy (ChannelFile, "channel.dat");
  26.    TaskNumber = 1;
  27. }
  28.  
  29. TConfig::~TConfig (void)
  30. {
  31. }
  32.  
  33. VOID TConfig::Default (VOID)
  34. {
  35.    strcpy (Device, "COM2");
  36.    Speed = 19200L;
  37.    strcpy (Initialize[0], "ATZ");
  38.    Initialize[1][0] = Initialize[2][0] = '\0';
  39.    strcpy (Answer, "ATA");
  40.    strcpy (Dial, "ATDT%s");
  41.    strcpy (Hangup, "v~^~+++~~ATH");
  42.    strcpy (OffHook, "ATM0H1");
  43.    LockSpeed = TRUE;
  44.    StripDashes = FALSE;
  45.    ManualAnswer = TRUE;
  46.    strcpy (FaxMessage, "FAX");
  47.    strcpy (FaxCommand, "");
  48.    strcpy (SystemName, "LoraBBS Test System");
  49.    strcpy (SysopName, "LoraBBS Tester");
  50.    strcpy (Location, "Nowhere");
  51.    strcpy (Phone, "-Unpublished-");
  52.    strcpy (NodelistFlags, "CM,XA");
  53.    DialTimeout = 45;
  54.    CarrierDropTimeout = 1;
  55.    LoginType = 0;
  56.    NewUserLevel = 10;
  57.    NewUserFlags = 0L;
  58.    NewUserDenyFlags = 0L;
  59.    NewUserLimits[0] = '\0';
  60.    UseAnsi = YES;
  61.    AskAlias = REQUIRED;
  62.    AskCompanyName = YES;
  63.    AskAddress = YES;
  64.    AskCity = REQUIRED;
  65.    AskPhoneNumber = YES;
  66.    AskGender = REQUIRED;
  67. #if defined(__LINUX__)
  68.    strcpy (SystemPath, "./");
  69.    strcpy (UserFile, "users");
  70.    strcpy (NormalInbound, "inbound/");
  71.    strcpy (KnownInbound, "inbound/");
  72.    strcpy (ProtectedInbound, "inbound/");
  73.    strcpy (Outbound, "./outbound/");
  74.    strcpy (SchedulerFile, "events");
  75.    strcpy (NodelistPath, "nodes/");
  76.    strcpy (UsersHomePath, "home/");
  77.    strcpy (MenuPath, "menu/");
  78.    strcpy (LanguageFile, "language");
  79.    strcpy (TextFiles, "misc/");
  80.    strcpy (NewAreasPath, "./");
  81.    strcpy (TempPath, "temp/");
  82. #else
  83.    strcpy (SystemPath, ".\\");
  84.    strcpy (UserFile, "users");
  85.    strcpy (NormalInbound, "inbound\\");
  86.    strcpy (KnownInbound, "inbound\\");
  87.    strcpy (ProtectedInbound, "inbound\\");
  88.    strcpy (Outbound, ".\\outbound\\");
  89.    strcpy (SchedulerFile, "events");
  90.    strcpy (NodelistPath, "nodes\\");
  91.    strcpy (UsersHomePath, "home\\");
  92.    strcpy (MenuPath, "menu\\");
  93.    strcpy (LanguageFile, "language");
  94.    strcpy (TextFiles, "misc\\");
  95.    strcpy (NewAreasPath, ".\\");
  96.    strcpy (TempPath, "temp\\");
  97. #endif
  98.    strcpy (MainMenu, "MAIN");
  99.    strcpy (HostName, "unknown.host");
  100.    strcpy (NewsServer, "news");
  101.    strcpy (MailServer, "mail");
  102.    strcpy (PopServer, "mail");
  103.    strcpy (LogFile, "lora%u.log");
  104.    FakeNet = 0;
  105.    MailStorage = ST_SQUISH;
  106.    NetMailStorage = BadStorage = DupeStorage = ST_SQUISH;
  107.    strcpy (MailPath, "email");
  108.    strcpy (NetMailPath, "netmail");
  109.    strcpy (BadPath, "bad_msgs");
  110.    strcpy (DupePath, "dupes");
  111.    TelnetPort = 23;
  112.    FtpPort = 21;
  113.    WebPort = 80;
  114.    SMTPPort = 25;
  115.    POP3Port = 109;
  116.    NNTPPort = 119;
  117.    WaZoo = EMSI = TRUE;
  118.    Janus = FALSE;
  119.    NewAreasStorage = ST_SQUISH;
  120.    Ansi = IEMSI = TRUE;
  121.    UseSinglePass = FALSE;
  122.    SeparateNetMail = TRUE;
  123.    ZModemTelnet = FALSE;
  124.    strcpy (OLRPacketName, "offline");
  125.    TextPasswords = TRUE;
  126.  
  127.    MailAddress.Load (SystemPath);
  128. }
  129.  
  130. /*
  131. USHORT TConfig::Compile (PSZ pszConfig, PSZ pszChannel, CONFIG *Cfg)
  132. {
  133.    FILE *fp;
  134.    CHAR Temp[128], *p;
  135.  
  136.    strcpy (Temp, strlwr (pszConfig));
  137.    if ((p = strstr (Temp, ".dat")) != NULL)
  138.       strcpy (p, ".cfg");
  139.  
  140.    if ((fp = fopen (Temp, "rt")) != NULL) {
  141.       while (fgets (Temp, sizeof (Temp) - 1, fp) != NULL) {
  142.          Temp[strlen (Temp) - 1] = '\0';
  143.          if ((p = strtok (Temp, " ")) != NULL) {
  144.             if (!stricmp (p, "System")) {
  145.                if ((p = strtok (NULL, " ")) != NULL) {
  146.                   if (!stricmp (p, "Name")) {
  147.                      p = strtok (NULL, "");
  148.                      while (*p == ' ')
  149.                         *p++;
  150.                      strcpy (Cfg->SystemName, p);
  151.                   }
  152.                }
  153.             }
  154.             else if (!stricmp (p, "Sysop")) {
  155.                if ((p = strtok (NULL, " ")) != NULL) {
  156.                   if (!stricmp (p, "Name")) {
  157.                      p = strtok (NULL, "");
  158.                      while (*p == ' ')
  159.                         *p++;
  160.                      strcpy (Cfg->SysopName, p);
  161.                   }
  162.                }
  163.             }
  164.             else if (!stricmp (p, "Janus"))
  165.                Cfg->Janus = TRUE;
  166.             else if (!stricmp (p, "NoJanus"))
  167.                Cfg->Janus = FALSE;
  168.          }
  169.       }
  170.       fclose (fp);
  171.    }
  172. }
  173. */
  174.  
  175. USHORT TConfig::Load (PSZ pszConfig, PSZ pszChannel)
  176. {
  177.    if (pszConfig != NULL)
  178.       strcpy (ConfigFile, pszConfig);
  179.    if (pszChannel != NULL)
  180.       strcpy (ChannelFile, pszChannel);
  181.  
  182.    return (Reload ());
  183. }
  184.  
  185. VOID TConfig::NewChannel (VOID)
  186. {
  187.    Speed = 19200L;
  188. //   strcpy (Initialize[0], "ATZ");
  189.    Initialize[1][0] = Initialize[1][0] = Initialize[2][0] = '\0';
  190.    strcpy (Answer, "ATA");
  191.    strcpy (Dial, "ATDT%s");
  192.    strcpy (Hangup, "v~^~+++~~ATH");
  193.    strcpy (OffHook, "ATM0H1");
  194.    LockSpeed = FALSE;
  195.    StripDashes = FALSE;
  196.    FaxMessage[0] = FaxCommand[0] = '\0';
  197.    strcpy (Ring, "RING");
  198.    ManualAnswer = TRUE;
  199.    LimitedHours = FALSE;
  200.    StartTime = EndTime = 0;
  201.    CallIf[0] = DontCallIf[0] = '\0';
  202. }
  203.  
  204. VOID TConfig::New (VOID)
  205. {
  206.    CONFIG *Cfg;
  207.  
  208.    if ((Cfg = (CONFIG *)malloc (sizeof (CONFIG))) != NULL) {
  209.       memset (Cfg, 0, sizeof (CONFIG));
  210.       Struct2Class (Cfg);
  211.       free (Cfg);
  212.    }
  213. }
  214.  
  215. USHORT TConfig::Reload (VOID)
  216. {
  217.    int fd;
  218.    USHORT RetVal = FALSE;
  219.    CONFIG *Cfg;
  220.    CHANNEL *Ch;
  221.  
  222.    if ((Cfg = (CONFIG *)malloc (sizeof (CONFIG))) != NULL)
  223.       memset (Cfg, 0, sizeof (CONFIG));
  224.    fd = sopen (ConfigFile, O_RDONLY|O_BINARY, SH_DENYNO, S_IREAD|S_IWRITE);
  225.  
  226.    if (fd != -1 && Cfg != NULL) {
  227.       RetVal = TRUE;
  228.       read (fd, Cfg, sizeof (CONFIG));
  229.       Struct2Class (Cfg);
  230.    }
  231.  
  232.    if (fd != -1)
  233.       close (fd);
  234.    if (Cfg != NULL)
  235.       free (Cfg);
  236.  
  237.    if ((Ch = (CHANNEL *)malloc (sizeof (CHANNEL))) != NULL) {
  238.       if ((fd = sopen (ChannelFile, O_RDONLY|O_BINARY, SH_DENYNO, S_IREAD|S_IWRITE)) != -1) {
  239.          while (read (fd, Ch, sizeof (CHANNEL)) == sizeof (CHANNEL)) {
  240.             if (Ch->TaskNumber == TaskNumber) {
  241.                strcpy (Device, Ch->Device);
  242.                Speed = Ch->Speed;
  243.                strcpy (Initialize[0], Ch->Initialize[0]);
  244.                strcpy (Initialize[1], Ch->Initialize[1]);
  245.                strcpy (Initialize[2], Ch->Initialize[2]);
  246.                strcpy (Answer, Ch->Answer);
  247.                strcpy (Dial, Ch->Dial);
  248.                strcpy (Hangup, Ch->Hangup);
  249.                strcpy (OffHook, Ch->OffHook);
  250.                LockSpeed = Ch->LockSpeed;
  251.                StripDashes = Ch->StripDashes;
  252.                strcpy (FaxMessage, Ch->FaxMessage);
  253.                strcpy (FaxCommand, Ch->FaxCommand);
  254.                DialTimeout = Ch->DialTimeout;
  255.                CarrierDropTimeout = Ch->CarrierDropTimeout;
  256.                strcpy (SchedulerFile, Ch->SchedulerFile);
  257.                strcpy (MainMenu, Ch->MainMenu);
  258.                strcpy (Ring, Ch->Ring);
  259.                ManualAnswer = Ch->ManualAnswer;
  260.                LimitedHours = Ch->LimitedHours;
  261.                StartTime = Ch->StartTime;
  262.                EndTime = Ch->EndTime;
  263.                strcpy (CallIf, Ch->CallIf);
  264.                strcpy (DontCallIf, Ch->DontCallIf);
  265.                break;
  266.             }
  267.          }
  268.          close (fd);
  269.       }
  270.       free (Ch);
  271.    }
  272.  
  273.    MailAddress.Load (SystemPath);
  274.  
  275.    return (RetVal);
  276. }
  277.  
  278. VOID TConfig::Struct2Class (CONFIG *Cfg)
  279. {
  280.    strcpy (Device, Cfg->Device);
  281.    Speed = Cfg->Speed;
  282.    strcpy (Initialize[0], Cfg->Initialize[0]);
  283.    strcpy (Initialize[1], Cfg->Initialize[1]);
  284.    strcpy (Initialize[2], Cfg->Initialize[2]);
  285.    strcpy (Answer, Cfg->Answer);
  286.    strcpy (Dial, Cfg->Dial);
  287.    strcpy (Hangup, Cfg->Hangup);
  288.    strcpy (OffHook, Cfg->OffHook);
  289.    LockSpeed = Cfg->LockSpeed;
  290.    StripDashes = Cfg->StripDashes;
  291.    strcpy (FaxMessage, Cfg->FaxMessage);
  292.    strcpy (FaxCommand, Cfg->FaxCommand);
  293.    DialTimeout = Cfg->DialTimeout;
  294.    CarrierDropTimeout = Cfg->CarrierDropTimeout;
  295.    strcpy (SystemName, Cfg->SystemName);
  296.    strcpy (SysopName, Cfg->SysopName);
  297.    strcpy (Location, Cfg->Location);
  298.    strcpy (Phone, Cfg->Phone);
  299.    strcpy (NodelistFlags, Cfg->NodelistFlags);
  300.    LoginType = Cfg->LoginType;
  301.    NewUserLevel = Cfg->NewUserLevel;
  302.    NewUserFlags = Cfg->NewUserFlags;
  303.    NewUserDenyFlags = Cfg->NewUserDenyFlags;
  304.    strcpy (NewUserLimits, Cfg->NewUserLimits);
  305.    UseAnsi = Cfg->UseAnsi;
  306.    AskAlias = Cfg->AskAlias;
  307.    AskCompanyName = Cfg->AskCompanyName;
  308.    AskAddress = Cfg->AskAddress;
  309.    AskCity = Cfg->AskCity;
  310.    AskPhoneNumber = Cfg->AskPhoneNumber;
  311.    AskGender = Cfg->AskGender;
  312.    strcpy (SystemPath, FixPath (Cfg->SystemPath));
  313.    strcpy (UserFile, AdjustPath (Cfg->UserFile));
  314.    strcpy (NormalInbound, FixPath (Cfg->NormalInbound));
  315.    strcpy (KnownInbound, FixPath (Cfg->KnownInbound));
  316.    strcpy (ProtectedInbound, FixPath (Cfg->ProtectedInbound));
  317.    strcpy (Outbound, FixPath (Cfg->Outbound));
  318.    strcpy (SchedulerFile, AdjustPath (Cfg->SchedulerFile));
  319.    strcpy (NodelistPath, FixPath (Cfg->NodelistPath));
  320.    strcpy (UsersHomePath, FixPath (Cfg->UsersHomePath));
  321.    strcpy (MenuPath, FixPath (Cfg->MenuPath));
  322.    strcpy (LanguageFile, AdjustPath (Cfg->LanguageFile));
  323.    strcpy (TextFiles, FixPath (Cfg->TextFiles));
  324.    strcpy (MainMenu, Cfg->MainMenu);
  325.    strcpy (HostName, Cfg->HostName);
  326.    strcpy (NewsServer, Cfg->NewsServer);
  327.    strcpy (MailServer, Cfg->MailServer);
  328.    strcpy (PopServer, Cfg->PopServer);
  329.    strcpy (LogFile, AdjustPath (Cfg->LogFile));
  330.    FakeNet = Cfg->FakeNet;
  331.    MailStorage = Cfg->MailStorage;
  332.    NetMailStorage = Cfg->NetMailStorage;
  333.    BadStorage = Cfg->BadStorage;
  334.    DupeStorage = Cfg->DupeStorage;
  335.    if (MailStorage == ST_FIDO)
  336.       strcpy (MailPath, FixPath (Cfg->MailPath));
  337.    else
  338.       strcpy (MailPath, AdjustPath (Cfg->MailPath));
  339.    if (NetMailStorage == ST_FIDO)
  340.       strcpy (NetMailPath, FixPath (Cfg->NetMailPath));
  341.    else
  342.       strcpy (NetMailPath, AdjustPath (Cfg->NetMailPath));
  343.    if (BadStorage == ST_FIDO)
  344.       strcpy (BadPath, FixPath (Cfg->BadPath));
  345.    else
  346.       strcpy (BadPath, AdjustPath (Cfg->BadPath));
  347.    if (DupeStorage == ST_FIDO)
  348.       strcpy (DupePath, FixPath (Cfg->DupePath));
  349.    else
  350.       strcpy (DupePath, AdjustPath (Cfg->DupePath));
  351.    TelnetServer = Cfg->TelnetServer;
  352.    TelnetPort = Cfg->TelnetPort;
  353.    FtpServer = Cfg->FtpServer;
  354.    FtpPort = Cfg->FtpPort;
  355.    WebServer = Cfg->WebServer;
  356.    WebPort = Cfg->WebPort;
  357.    SMTPServer = Cfg->SMTPServer;
  358.    SMTPPort = Cfg->SMTPPort;
  359.    POP3Server = Cfg->POP3Server;
  360.    POP3Port = Cfg->POP3Port;
  361.    NNTPServer = Cfg->NNTPServer;
  362.    NNTPPort = Cfg->NNTPPort;
  363.    WaZoo = Cfg->WaZoo;
  364.    EMSI = Cfg->EMSI;
  365.    Janus = Cfg->Janus;
  366.    NewAreasStorage = Cfg->NewAreasStorage;
  367.    strcpy (NewAreasPath, FixPath (Cfg->NewAreasPath));
  368.    NewAreasLevel = Cfg->NewAreasLevel;
  369.    NewAreasFlags = Cfg->NewAreasFlags;
  370.    NewAreasDenyFlags = Cfg->NewAreasDenyFlags;
  371.    NewAreasWriteLevel = Cfg->NewAreasWriteLevel;
  372.    NewAreasWriteFlags = Cfg->NewAreasWriteFlags;
  373.    NewAreasDenyWriteFlags = Cfg->NewAreasDenyWriteFlags;
  374.    Ansi = Cfg->Ansi;
  375.    IEMSI = Cfg->IEMSI;
  376.    ImportEmpty = Cfg->ImportEmpty;
  377.    ReplaceTear = Cfg->ReplaceTear;
  378.    strcpy (TearLine, Cfg->TearLine);
  379.    ForceIntl = Cfg->ForceIntl;
  380.    Secure = Cfg->Secure;
  381.    KeepNetMail = Cfg->KeepNetMail;
  382.    TrackNetMail = Cfg->TrackNetMail;
  383.    strcpy (MailOnly, Cfg->MailOnly);
  384.    strcpy (EnterBBS, Cfg->EnterBBS);
  385.    strcpy (ImportCmd, Cfg->ImportCmd);
  386.    strcpy (ExportCmd, Cfg->ExportCmd);
  387.    strcpy (PackCmd, Cfg->PackCmd);
  388.    strcpy (SinglePassCmd, Cfg->SinglePassCmd);
  389.    UseSinglePass = Cfg->UseSinglePass;
  390.    SeparateNetMail = Cfg->SeparateNetMail;
  391.    strcpy (AreasBBS, AdjustPath (Cfg->AreasBBS));
  392.    UseAreasBBS = Cfg->UseAreasBBS;
  393.    UpdateAreasBBS = Cfg->UpdateAreasBBS;
  394.    strcpy (AfterCallerCmd, Cfg->AfterCallerCmd);
  395.    strcpy (AfterMailCmd, Cfg->AfterMailCmd);
  396.    ZModemTelnet = Cfg->ZModemTelnet;
  397.    EnablePPP = Cfg->EnablePPP;
  398.    PPPTimeLimit = Cfg->PPPTimeLimit;
  399.    strcpy (PPPCmd, Cfg->PPPCmd);
  400.    strcpy (TempPath, FixPath (Cfg->TempPath));
  401.    strcpy (OLRPacketName, Cfg->OLRPacketName);
  402.    OLRMaxMessages = Cfg->OLRMaxMessages;
  403.    ExternalFax = Cfg->ExternalFax;
  404.    FaxFormat = Cfg->FaxFormat;
  405.    strcpy (FaxPath, FixPath (Cfg->FaxPath));
  406.    strcpy (AfterFaxCmd, Cfg->AfterFaxCmd);
  407.    strcpy (FaxAlertNodes, Cfg->FaxAlertNodes);
  408.    strcpy (FaxAlertUser, Cfg->FaxAlertUser);
  409.    ReloadLog = Cfg->ReloadLog;
  410.    MakeProcessLog = Cfg->MakeProcessLog;
  411.    RetriveMaxMessages = Cfg->RetriveMaxMessages;
  412.    UseAvatar = Cfg->UseAvatar;
  413.    UseColor = Cfg->UseColor;
  414.    UseFullScreenEditor = Cfg->UseFullScreenEditor;
  415.    UseHotKey = Cfg->UseHotKey;
  416.    UseIBMChars = Cfg->UseIBMChars;
  417.    AskLines = Cfg->AskLines;
  418.    UsePause = Cfg->UsePause;
  419.    UseScreenClear = Cfg->UseScreenClear;
  420.    AskBirthDate = Cfg->AskBirthDate;
  421.    AskMailCheck = Cfg->AskMailCheck;
  422.    AskFileCheck = Cfg->AskFileCheck;
  423.    ExternalEditor = Cfg->ExternalEditor;
  424.    strcpy (EditorCmd, Cfg->EditorCmd);
  425.    strcpy (HudsonPath, Cfg->HudsonPath);
  426.    strcpy (GoldPath, Cfg->GoldPath);
  427.    BadBoard = Cfg->BadBoard;
  428.    DupeBoard = Cfg->DupeBoard;
  429.    MailBoard = Cfg->MailBoard;
  430.    NetMailBoard = Cfg->NetMailBoard;
  431.    UseFullScreenReader = Cfg->UseFullScreenReader;
  432.    UseFullScreenLists = Cfg->UseFullScreenLists;
  433.    UseFullScreenAreaLists = Cfg->UseFullScreenAreaLists;
  434.    AreafixActive = Cfg->AreafixActive;
  435.    AllowRescan = Cfg->AllowRescan;
  436.    CheckZones = Cfg->CheckZones;
  437.    RaidActive = Cfg->RaidActive;
  438.    strcpy (AreafixNames, Cfg->AreafixNames);
  439.    strcpy (AreafixHelp, Cfg->AreafixHelp);
  440.    strcpy (RaidNames, Cfg->RaidNames);
  441.    strcpy (RaidHelp, Cfg->RaidHelp);
  442.    strcpy (NewTicPath, FixPath (Cfg->NewTicPath));
  443.    TextPasswords = Cfg->TextPasswords;
  444. }
  445.  
  446. PSZ TConfig::FixPath (PSZ path)
  447. {
  448.    PSZ p;
  449.  
  450.    if (path[0] != '\0') {
  451.       if (path[strlen (path) - 1] != '\\' && path[strlen (path) - 1] != '/')
  452.          strcat (path, "\\");
  453.    }
  454.  
  455. #if defined(__LINUX__)
  456.    while ((p = strchr (path, '\\')) != NULL)
  457.       *p = '/';
  458. #else
  459.    while ((p = strchr (path, '/')) != NULL)
  460.       *p = '\\';
  461. #endif
  462.  
  463.    return (path);
  464. }
  465.  
  466. PSZ TConfig::AdjustPath (PSZ path)
  467. {
  468.    PSZ p;
  469.  
  470.    if (path[strlen (path) - 1] == '\\' || path[strlen (path) - 1] == '/')
  471.       path[strlen (path) - 1] = '\0';
  472.  
  473. #if defined(__LINUX__)
  474.    while ((p = strchr (path, '\\')) != NULL)
  475.       *p = '/';
  476. #else
  477.    while ((p = strchr (path, '/')) != NULL)
  478.       *p = '\\';
  479. #endif
  480.  
  481.    return (path);
  482. }
  483.  
  484. USHORT TConfig::Save (PSZ pszConfig, PSZ pszChannel)
  485. {
  486.    int fd;
  487.    USHORT RetVal = FALSE, Found;
  488.    CONFIG *Cfg;
  489.    CHANNEL *Ch;
  490.  
  491.    if (pszConfig == NULL)
  492.       pszConfig = ConfigFile;
  493.    if (pszChannel == NULL)
  494.       pszChannel = ChannelFile;
  495.  
  496.    Cfg = (CONFIG *)malloc (sizeof (CONFIG));
  497.    fd = sopen (pszConfig, O_WRONLY|O_BINARY|O_CREAT|O_TRUNC, SH_DENYNO, S_IREAD|S_IWRITE);
  498.  
  499.    if (fd != -1 && Cfg != NULL) {
  500.       memset (Cfg, 0, sizeof (CONFIG));
  501.       RetVal = TRUE;
  502.  
  503.       Cfg->Version = CONFIG_VERSION;
  504.       Cfg->Speed = Speed;
  505.       sprintf (Cfg->Device, Device);
  506.       strcpy (Cfg->Initialize[0], Initialize[0]);
  507.       strcpy (Cfg->Initialize[1], Initialize[1]);
  508.       strcpy (Cfg->Initialize[2], Initialize[2]);
  509.       strcpy (Cfg->Answer, Answer);
  510.       strcpy (Cfg->Dial, Dial);
  511.       strcpy (Cfg->Hangup, Hangup);
  512.       strcpy (Cfg->OffHook, OffHook);
  513.       Cfg->LockSpeed = LockSpeed;
  514.       Cfg->StripDashes = StripDashes;
  515.       strcpy (Cfg->FaxMessage, FaxMessage);
  516.       strcpy (Cfg->FaxCommand, FaxCommand);
  517.       Cfg->DialTimeout = DialTimeout;
  518.       Cfg->CarrierDropTimeout = CarrierDropTimeout;
  519.       strcpy (Cfg->SystemName, SystemName);
  520.       strcpy (Cfg->SysopName, SysopName);
  521.       strcpy (Cfg->Location, Location);
  522.       strcpy (Cfg->Phone, Phone);
  523.       strcpy (Cfg->NodelistFlags, NodelistFlags);
  524.       Cfg->LoginType = LoginType;
  525.       Cfg->NewUserLevel = NewUserLevel;
  526.       Cfg->NewUserFlags = NewUserFlags;
  527.       Cfg->NewUserDenyFlags = NewUserDenyFlags;
  528.       strcpy (Cfg->NewUserLimits, NewUserLimits);
  529.       Cfg->UseAnsi = UseAnsi;
  530.       Cfg->AskAlias = AskAlias;
  531.       Cfg->AskCompanyName = AskCompanyName;
  532.       Cfg->AskAddress = AskAddress;
  533.       Cfg->AskCity = AskCity;
  534.       Cfg->AskPhoneNumber = AskPhoneNumber;
  535.       Cfg->AskGender = AskGender;
  536.       strcpy (Cfg->SystemPath, SystemPath);
  537.       strcpy (Cfg->UserFile, UserFile);
  538.       strcpy (Cfg->NormalInbound, NormalInbound);
  539.       strcpy (Cfg->KnownInbound, KnownInbound);
  540.       strcpy (Cfg->ProtectedInbound, ProtectedInbound);
  541.       strcpy (Cfg->Outbound, Outbound);
  542.       strcpy (Cfg->SchedulerFile, SchedulerFile);
  543.       strcpy (Cfg->NodelistPath, NodelistPath);
  544.       strcpy (Cfg->UsersHomePath, UsersHomePath);
  545.       strcpy (Cfg->MenuPath, MenuPath);
  546.       strcpy (Cfg->LanguageFile, LanguageFile);
  547.       strcpy (Cfg->TextFiles, TextFiles);
  548.       strcpy (Cfg->MainMenu, MainMenu);
  549.       strcpy (Cfg->HostName, HostName);
  550.       strcpy (Cfg->NewsServer, NewsServer);
  551.       strcpy (Cfg->MailServer, MailServer);
  552.       strcpy (Cfg->PopServer, PopServer);
  553.       strcpy (Cfg->LogFile, LogFile);
  554.       Cfg->FakeNet = FakeNet;
  555.       Cfg->MailStorage = MailStorage;
  556.       Cfg->NetMailStorage = NetMailStorage;
  557.       Cfg->BadStorage = BadStorage;
  558.       Cfg->DupeStorage = DupeStorage;
  559.       strcpy (Cfg->MailPath, MailPath);
  560.       strcpy (Cfg->NetMailPath, NetMailPath);
  561.       strcpy (Cfg->BadPath, BadPath);
  562.       strcpy (Cfg->DupePath, DupePath);
  563.       Cfg->TelnetServer = TelnetServer;
  564.       Cfg->TelnetPort = TelnetPort;
  565.       Cfg->FtpServer = FtpServer;
  566.       Cfg->FtpPort = FtpPort;
  567.       Cfg->WebServer = WebServer;
  568.       Cfg->WebPort = WebPort;
  569.       Cfg->SMTPServer = SMTPServer;
  570.       Cfg->SMTPPort = SMTPPort;
  571.       Cfg->POP3Server = POP3Server;
  572.       Cfg->POP3Port = POP3Port;
  573.       Cfg->NNTPServer = NNTPServer;
  574.       Cfg->NNTPPort = NNTPPort;
  575.       Cfg->WaZoo = WaZoo;
  576.       Cfg->EMSI = EMSI;
  577.       Cfg->Janus = Janus;
  578.       Cfg->NewAreasStorage = NewAreasStorage;
  579.       strcpy (Cfg->NewAreasPath, NewAreasPath);
  580.       Cfg->NewAreasLevel = NewAreasLevel;
  581.       Cfg->NewAreasFlags = NewAreasFlags;
  582.       Cfg->NewAreasDenyFlags = NewAreasDenyFlags;
  583.       Cfg->NewAreasWriteLevel = NewAreasWriteLevel;
  584.       Cfg->NewAreasWriteFlags = NewAreasWriteFlags;
  585.       Cfg->NewAreasDenyWriteFlags = NewAreasDenyWriteFlags;
  586.       Cfg->Ansi = Ansi;
  587.       Cfg->IEMSI = IEMSI;
  588.       Cfg->ImportEmpty = ImportEmpty;
  589.       Cfg->ReplaceTear = ReplaceTear;
  590.       strcpy (Cfg->TearLine, TearLine);
  591.       Cfg->ForceIntl = ForceIntl;
  592.       Cfg->Secure = Secure;
  593.       Cfg->KeepNetMail = KeepNetMail;
  594.       Cfg->TrackNetMail = TrackNetMail;
  595.       strcpy (Cfg->MailOnly, MailOnly);
  596.       strcpy (Cfg->EnterBBS, EnterBBS);
  597.       strcpy (Cfg->ImportCmd, ImportCmd);
  598.       strcpy (Cfg->ExportCmd, ExportCmd);
  599.       strcpy (Cfg->PackCmd, PackCmd);
  600.       strcpy (Cfg->SinglePassCmd, SinglePassCmd);
  601.       Cfg->UseSinglePass = UseSinglePass;
  602.       Cfg->SeparateNetMail = SeparateNetMail;
  603.       strcpy (Cfg->AreasBBS, AreasBBS);
  604.       Cfg->UseAreasBBS = UseAreasBBS;
  605.       Cfg->UpdateAreasBBS = UpdateAreasBBS;
  606.       strcpy (Cfg->AfterCallerCmd, AfterCallerCmd);
  607.       strcpy (Cfg->AfterMailCmd, AfterMailCmd);
  608.       Cfg->ZModemTelnet = ZModemTelnet;
  609.       Cfg->EnablePPP = EnablePPP;
  610.       Cfg->PPPTimeLimit = PPPTimeLimit;
  611.       strcpy (Cfg->PPPCmd, PPPCmd);
  612.       strcpy (Cfg->TempPath, TempPath);
  613.       strcpy (Cfg->OLRPacketName, OLRPacketName);
  614.       Cfg->OLRMaxMessages = OLRMaxMessages;
  615.       Cfg->ExternalFax = ExternalFax;
  616.       Cfg->FaxFormat = FaxFormat;
  617.       strcpy (Cfg->FaxPath, FaxPath);
  618.       strcpy (Cfg->AfterFaxCmd, AfterFaxCmd);
  619.       strcpy (Cfg->FaxAlertNodes, FaxAlertNodes);
  620.       strcpy (Cfg->FaxAlertUser, FaxAlertUser);
  621.       Cfg->ReloadLog = ReloadLog;
  622.       Cfg->MakeProcessLog = MakeProcessLog;
  623.       Cfg->RetriveMaxMessages = RetriveMaxMessages;
  624.       Cfg->UseAvatar = UseAvatar;
  625.       Cfg->UseColor = UseColor;
  626.       Cfg->UseFullScreenEditor = UseFullScreenEditor;
  627.       Cfg->UseHotKey = UseHotKey;
  628.       Cfg->UseIBMChars = UseIBMChars;
  629.       Cfg->AskLines = AskLines;
  630.       Cfg->UsePause = UsePause;
  631.       Cfg->UseScreenClear = UseScreenClear;
  632.       Cfg->AskBirthDate = AskBirthDate;
  633.       Cfg->AskMailCheck = AskMailCheck;
  634.       Cfg->AskFileCheck = AskFileCheck;
  635.       Cfg->ExternalEditor = ExternalEditor;
  636.       strcpy (Cfg->EditorCmd, EditorCmd);
  637.       strcpy (Cfg->HudsonPath, HudsonPath);
  638.       strcpy (Cfg->GoldPath, GoldPath);
  639.       Cfg->BadBoard = BadBoard;
  640.       Cfg->DupeBoard = DupeBoard;
  641.       Cfg->MailBoard = MailBoard;
  642.       Cfg->NetMailBoard = NetMailBoard;
  643.       Cfg->UseFullScreenReader = UseFullScreenReader;
  644.       Cfg->UseFullScreenLists = UseFullScreenLists;
  645.       Cfg->UseFullScreenAreaLists = UseFullScreenAreaLists;
  646.       Cfg->AreafixActive = AreafixActive;
  647.       Cfg->AllowRescan = AllowRescan;
  648.       Cfg->CheckZones = CheckZones;
  649.       Cfg->RaidActive = RaidActive;
  650.       strcpy (Cfg->AreafixNames, AreafixNames);
  651.       strcpy (Cfg->AreafixHelp, AreafixHelp);
  652.       strcpy (Cfg->RaidNames, RaidNames);
  653.       strcpy (Cfg->RaidHelp, RaidHelp);
  654.       strcpy (Cfg->NewTicPath, Cfg->NewTicPath);
  655.       Cfg->TextPasswords = TextPasswords;
  656.  
  657.       write (fd, Cfg, sizeof (CONFIG));
  658.       close (fd);
  659.    }
  660.  
  661.    if (fd != -1)
  662.       close (fd);
  663.    if (Cfg != NULL)
  664.       free (Cfg);
  665.  
  666.    if ((Ch = (CHANNEL *)malloc (sizeof (CHANNEL))) != NULL) {
  667.       if ((fd = sopen (pszChannel, O_RDWR|O_BINARY|O_CREAT, SH_DENYNO, S_IREAD|S_IWRITE)) != -1) {
  668.          Found = FALSE;
  669.          while (read (fd, Ch, sizeof (CHANNEL)) == sizeof (CHANNEL)) {
  670.             if (Ch->TaskNumber == TaskNumber) {
  671.                memset (Ch, 0, sizeof (CHANNEL));
  672.                Found = TRUE;
  673.  
  674.                Ch->TaskNumber = TaskNumber;
  675.                strcpy (Ch->Device, Device);
  676.                Ch->Speed = Speed;
  677.                strcpy (Ch->Initialize[0], Initialize[0]);
  678.                strcpy (Ch->Initialize[1], Initialize[1]);
  679.                strcpy (Ch->Initialize[2], Initialize[2]);
  680.                strcpy (Ch->Answer, Answer);
  681.                strcpy (Ch->Dial, Dial);
  682.                strcpy (Ch->Hangup, Hangup);
  683.                strcpy (Ch->OffHook, OffHook);
  684.                Ch->LockSpeed = LockSpeed;
  685.                Ch->StripDashes = StripDashes;
  686.                strcpy (Ch->FaxMessage, FaxMessage);
  687.                strcpy (Ch->FaxCommand, FaxCommand);
  688.                Ch->DialTimeout = DialTimeout;
  689.                Ch->CarrierDropTimeout = CarrierDropTimeout;
  690.                strcpy (Ch->SchedulerFile, SchedulerFile);
  691.                strcpy (Ch->MainMenu, MainMenu);
  692.                strcpy (Ch->Ring, Ring);
  693.                Ch->ManualAnswer = ManualAnswer;
  694.                Ch->LimitedHours = LimitedHours;
  695.                Ch->StartTime = StartTime;
  696.                Ch->EndTime = EndTime;
  697.                strcpy (Ch->CallIf, CallIf);
  698.                strcpy (Ch->DontCallIf, DontCallIf);
  699.  
  700.                lseek (fd, tell (fd) - sizeof (CHANNEL), SEEK_SET);
  701.                write (fd, Ch, sizeof (CHANNEL));
  702.                break;
  703.             }
  704.          }
  705.          if (Found == FALSE) {
  706.             memset (Ch, 0, sizeof (CHANNEL));
  707.  
  708.             Ch->TaskNumber = TaskNumber;
  709.             strcpy (Ch->Device, Device);
  710.             Ch->Speed = Speed;
  711.             strcpy (Ch->Initialize[0], Initialize[0]);
  712.             strcpy (Ch->Initialize[1], Initialize[1]);
  713.             strcpy (Ch->Initialize[2], Initialize[2]);
  714.             strcpy (Ch->Answer, Answer);
  715.             strcpy (Ch->Dial, Dial);
  716.             strcpy (Ch->Hangup, Hangup);
  717.             strcpy (Ch->OffHook, OffHook);
  718.             Ch->LockSpeed = LockSpeed;
  719.             Ch->StripDashes = StripDashes;
  720.             strcpy (Ch->FaxMessage, FaxMessage);
  721.             strcpy (Ch->FaxCommand, FaxCommand);
  722.             Ch->DialTimeout = DialTimeout;
  723.             Ch->CarrierDropTimeout = CarrierDropTimeout;
  724.             strcpy (Ch->SchedulerFile, SchedulerFile);
  725.             strcpy (Ch->MainMenu, MainMenu);
  726.             strcpy (Ch->Ring, Ring);
  727.             strcpy (Ch->CallIf, CallIf);
  728.             strcpy (Ch->DontCallIf, DontCallIf);
  729.  
  730.             write (fd, Ch, sizeof (CHANNEL));
  731.          }
  732.          close (fd);
  733.       }
  734.       free (Ch);
  735.    }
  736.  
  737.    if (SystemPath[0] != '\0')
  738.       MailAddress.Save (SystemPath);
  739.  
  740.    return (RetVal);
  741. }
  742.  
  743.  
  744.