home *** CD-ROM | disk | FTP | other *** search
/ synchro.net / synchro.net.tar / synchro.net / main / BBS / ODOORS62.ZIP / ODCFile.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-08-07  |  32.8 KB  |  924 lines

  1. /* OpenDoors Online Software Programming Toolkit
  2.  * (C) Copyright 1991 - 1999 by Brian Pirie.
  3.  *
  4.  * This library is free software; you can redistribute it and/or
  5.  * modify it under the terms of the GNU Lesser General Public
  6.  * License as published by the Free Software Foundation; either
  7.  * version 2 of the License, or (at your option) any later version.
  8.  *
  9.  * This library is distributed in the hope that it will be useful,
  10.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.  * Lesser General Public License for more details.
  13.  *
  14.  * You should have received a copy of the GNU Lesser General Public
  15.  * License along with this library; if not, write to the Free Software
  16.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  17.  *
  18.  *
  19.  *        File: ODCFile.c
  20.  *
  21.  * Description: Implements the configuration file sub-system.
  22.  *
  23.  *   Revisions: Date          Ver   Who  Change
  24.  *              ---------------------------------------------------------------
  25.  *              Oct 13, 1994  6.00  BP   New file header format.
  26.  *              Dec 09, 1994  6.00  BP   Standardized coding style.
  27.  *              Nov 11, 1995  6.00  BP   32-bit portability.
  28.  *              Nov 11, 1995  6.00  BP   Removed register keyword.
  29.  *              Nov 16, 1995  6.00  BP   Removed oddoor.h, added odcore.h.
  30.  *              Dec 30, 1995  6.00  BP   Added ODCALL for calling convention.
  31.  *              Jan 01, 1996  6.00  BP   Added DisableDTR and NoDTRDisable.
  32.  *              Jan 19, 1996  6.00  BP   Display error if config file not found
  33.  *              Feb 19, 1996  6.00  BP   Changed version number to 6.00.
  34.  *              Mar 03, 1996  6.10  BP   Begin version 6.10.
  35.  *              Mar 19, 1996  6.10  BP   MSVC15 source-level compatibility.
  36.  */
  37.  
  38. #define BUILDING_OPENDOORS
  39.  
  40. #include <stdio.h>
  41. #include <stdlib.h>
  42. #include <string.h>
  43. #include <ctype.h>
  44. #include <time.h>
  45.  
  46. #include "OpenDoor.h"
  47. #include "ODCore.h"
  48. #include "ODGen.h"
  49. #include "ODInEx.h"
  50. #include "ODUtil.h"
  51.  
  52.  
  53. /* Internal private variables */
  54. static WORD awTimeVal[3];
  55. static BYTE btTimeNumVals;
  56.  
  57.  
  58. /* Local functions. */
  59. static WORD ODCfgGetWordDecimal(char *pszConfigText);
  60. static DWORD ODCfgGetDWordDecimal(char *pszConfigText);
  61. static WORD ODCfgGetWordHex(char *pszConfigText);
  62. static void ODCfgGetNextTime(char **ppchConfigText);
  63. static BOOL ODCfgIsTrue(char *pszConfigText);
  64.  
  65.  
  66. /* ----------------------------------------------------------------------------
  67.  * ODConfigInit()
  68.  *
  69.  * Called to perform OpenDoors initialization when the configuration file
  70.  * system is being used. This function is called from the normal od_init(),
  71.  * and also uses the normal od_init() to perform base initialization after
  72.  * the configuration file has been read, but before certain configuration
  73.  * settings are set in od_control.
  74.  *
  75.  * Parameters: none
  76.  *
  77.  *     Return: void
  78.  */
  79. ODAPIDEF void ODCALL ODConfigInit(void)
  80. {
  81.    void (*custom_line_function)(char *keyword, char *options)
  82.       = od_control.config_function;
  83.    char *pchConfigText;
  84.    WORD wCurrent;
  85.    INT nConfigOption;
  86.    BOOL bConfigFileRequired = TRUE;
  87.    static FILE *pfConfigFile;
  88.    static FILE *pfCustomDropFile = NULL;
  89.    static char szConfigLine[257];
  90.    static char szToken[33];
  91.    static char szTempString[256];
  92.    static char szWorkDir[80];
  93.    static BOOL bWorkDirSet = FALSE;
  94.    static time_t nUnixTime;
  95.    static struct tm *TimeBlock;
  96.    static INT16 nPageStart;
  97.    static INT16 nPageEnd;
  98.    static BOOL bPageSet = FALSE;
  99.    static BOOL bInactivitySet = FALSE;
  100.    static INT16 nInactivity;
  101.    static char *pszWork;
  102.    static BOOL bPageLengthSet = FALSE;
  103.    static BYTE btPageLength;
  104.    static char *apszFileNames[1];
  105.  
  106.    bIsCallbackActive = TRUE;
  107.  
  108.    nUnixTime = time(NULL);
  109.    TimeBlock = localtime(&nUnixTime);
  110.  
  111.    /* Use default configuration file filename if none has been specified. */
  112.    if(od_control.od_config_filename == NULL)
  113.    {
  114.       od_control.od_config_filename = "door.cfg";
  115.       bConfigFileRequired = FALSE;
  116.    }
  117.  
  118.    if((pfConfigFile = fopen(od_control.od_config_filename, "rt")) == NULL)
  119.    {
  120.       if(strchr(od_control.od_config_filename, '\\') != NULL
  121.          || strchr(od_control.od_config_filename, ':') != NULL)
  122.       {
  123.          wCurrent = strlen(od_control.od_config_filename);
  124.          pchConfigText = (char *)od_control.od_config_filename + (wCurrent - 1);
  125.          while(wCurrent > 0)
  126.          {
  127.             if(*pchConfigText == '\\' || *pchConfigText == ':')
  128.             {
  129.                strcpy(szConfigLine, (char *)pchConfigText + 1);
  130.                pfConfigFile = fopen(szConfigLine, "rt");
  131.                break;
  132.             }
  133.  
  134.             --pchConfigText;
  135.             --wCurrent;
  136.          }
  137.       }
  138.       else
  139.       {
  140.          strcpy(szConfigLine, od_control.od_config_filename);
  141.       }
  142.    }
  143.  
  144.    /* If we were able to open the configuration file. */
  145.    if(pfConfigFile != NULL)
  146.    {
  147.       /* Get configuration file strings in upper case. */
  148.       for(wCurrent = 0; wCurrent < TEXT_SIZE; ++wCurrent)
  149.       {
  150.          strupr(od_config_text[wCurrent]);
  151.       }
  152.       for(wCurrent = 0; wCurrent < LINES_SIZE; ++wCurrent)
  153.       {
  154.          strupr(od_config_lines[wCurrent]);
  155.       }
  156.  
  157.       for(;;)
  158.       {
  159.          /* Read the next line from the configuration file. */
  160.          if(fgets(szConfigLine, 257, pfConfigFile) == NULL) break;
  161.  
  162.          /* Ignore all of line after comments or CR/LF char. */
  163.          pchConfigText = (char *)szConfigLine;
  164.          while(*pchConfigText)
  165.          {
  166.             if(*pchConfigText == '\n' || *pchConfigText == '\r'
  167.                || *pchConfigText == ';')
  168.             {
  169.                *pchConfigText = '\0';
  170.                break;
  171.             }
  172.             ++pchConfigText;
  173.          }
  174.  
  175.          /* Search for beginning of first token on line. */
  176.          pchConfigText = (char *)szConfigLine;
  177.          while(*pchConfigText
  178.             && (*pchConfigText == ' ' || *pchConfigText == '\t'))
  179.          {
  180.             ++pchConfigText;
  181.          }
  182.          if(!*pchConfigText) continue;
  183.  
  184.          /* Get first token from line. */
  185.          wCurrent = 0;
  186.          while(*pchConfigText
  187.             && !(*pchConfigText == ' ' || *pchConfigText == '\t'))
  188.          {
  189.             if(wCurrent < 32) szToken[wCurrent++] = *pchConfigText;
  190.             ++pchConfigText;
  191.          }
  192.          if(wCurrent <= 32)
  193.          {
  194.             szToken[wCurrent] = '\0';
  195.          }
  196.          else
  197.          {
  198.             szToken[32] = '\0';
  199.          }
  200.          strupr(szToken);
  201.  
  202.          /* Find beginning of configuration option parameters */
  203.          while(*pchConfigText && (*pchConfigText == ' '
  204.             || *pchConfigText == '\t'))
  205.          {
  206.             ++pchConfigText;
  207.          }
  208.  
  209.          /* Trim trailing spaces from setting string. */
  210.          for(wCurrent = strlen(pchConfigText) - 1; wCurrent > 0; --wCurrent)
  211.          {
  212.             if(pchConfigText[wCurrent] == ' '
  213.                || pchConfigText[wCurrent] == '\t')
  214.             {
  215.                pchConfigText[wCurrent] = '\0';
  216.             }
  217.             else
  218.             {
  219.                break;
  220.             }
  221.          }
  222.  
  223.  
  224.          for(wCurrent = 0; wCurrent < TEXT_SIZE; ++wCurrent)
  225.          {
  226.             if(strcmp(szToken, od_config_text[wCurrent]) == 0)
  227.             {
  228.                switch(wCurrent)
  229.                {
  230.                   case 0:
  231.                      wODNodeNumber = ODCfgGetWordDecimal(pchConfigText);
  232.                      break;
  233.  
  234.                   case 1:
  235.                      strcpy(od_control.info_path,pchConfigText);
  236.                      break;
  237.  
  238.                   case 2:
  239.                      if(pchConfigText[strlen(pchConfigText) - 1] == '\\'
  240.                         && pchConfigText[strlen(pchConfigText) - 2] != ':'
  241.                         && strlen(pchConfigText) > 1)
  242.                      {
  243.                         pchConfigText[strlen(pchConfigText) - 1] = '\0';
  244.                      }
  245.  
  246.                      szOriginalDir = (char *)malloc(256);
  247.                      if(szOriginalDir != NULL)
  248.                      {
  249.                         ODDirGetCurrent(szOriginalDir, 256);
  250.                      }
  251.  
  252.                      strcpy(szWorkDir, pchConfigText);
  253.                      bWorkDirSet = TRUE;
  254.                      break;
  255.  
  256.                   case 3:
  257.                      strcpy(od_control.od_logfile_name, pchConfigText);
  258.                      break;
  259.  
  260.                   case 4:
  261.                      od_control.od_logfile_disable = TRUE;
  262.                      break;
  263.  
  264.                   case 5:
  265.                   case 6:
  266.                   case 7:
  267.                   case 8:
  268.                   case 9:
  269.                   case 10:
  270.                   case 11:
  271.                       if((wCurrent - 5) == (WORD)TimeBlock->tm_wday)
  272.                       {
  273.                          ODCfgGetNextTime((char **)&pchConfigText);
  274.                          nPageStart = awTimeVal[0] * 60 + awTimeVal[1];
  275.                          ODCfgGetNextTime((char **)&pchConfigText);
  276.                          nPageEnd = awTimeVal[0] * 60 + awTimeVal[1];
  277.                          bPageSet = TRUE;
  278.                       }
  279.                      break;
  280.  
  281.                   case 12:
  282.                      od_control.od_maxtime = ODCfgGetWordDecimal(pchConfigText);
  283.                      break;
  284.  
  285.                   case 13:
  286.                      bSysopNameSet = TRUE;
  287.                      strncpy((char *)&szForcedSysopName, pchConfigText, 39);
  288.                      szForcedSysopName[39] = '\0';
  289.                      break;
  290.  
  291.                   case 14:
  292.                      bSystemNameSet = TRUE;
  293.                      strncpy((char *)&szForcedSystemName, pchConfigText, 39);
  294.                      szForcedSystemName[39] = '\0';
  295.                      break;
  296.  
  297.                   case 15:
  298.                      od_control.od_swapping_disable = TRUE;
  299.                      break;
  300.  
  301.                   case 16:
  302.                      strncpy(od_control.od_swapping_path, pchConfigText, 79);
  303.                      od_control.od_swapping_path[79] = '\0';
  304.                      break;
  305.  
  306.                   case 17:
  307.                      od_control.od_swapping_noems = TRUE;
  308.                      break;
  309.  
  310.                   case 18:
  311.                      dwForcedBPS = ODCfgGetDWordDecimal(pchConfigText);
  312.                      break;
  313.  
  314.                   case 19:
  315.                      nForcedPort = ODCfgGetWordDecimal(pchConfigText);
  316.                      break;
  317.  
  318.                   case 20:
  319.                      if(pfCustomDropFile == NULL && !od_control.od_force_local)
  320.                      {
  321.                         apszFileNames[0] = (char *)pchConfigText;
  322.                         if(ODSearchForDropFile(apszFileNames, 1, szTempString,
  323.                            NULL) != -1)
  324.                         {
  325.                            if((pfCustomDropFile = fopen(szTempString, "rt"))
  326.                               != NULL)
  327.                            {
  328.                               od_control.od_info_type = CUSTOM;
  329.                               od_control.user_attribute = 0x06;
  330.                               od_control.user_screen_length = 23;
  331.                               od_control.user_ansi = TRUE;
  332.                               od_control.user_rip = FALSE;
  333.                               od_control.user_avatar = FALSE;
  334.                               od_control.od_page_pausing = TRUE;
  335.                               od_control.od_page_len = 15;
  336.                               od_control.user_timelimit = 0;
  337.                               strcpy(od_control.user_name, "Unknown User");
  338.                               strcpy(od_control.user_location,
  339.                                  "Unknown Location");
  340.                               od_control.user_security = 1;
  341.                            }
  342.                         }
  343.                      }
  344.                      break;
  345.  
  346.                   case 21:
  347.                      if(pfCustomDropFile != NULL)
  348.                      {
  349.                         if(fgets(szTempString, 255, pfCustomDropFile)!=NULL)
  350.                         {
  351.                            if(szTempString[strlen(szTempString) - 1] == '\n')
  352.                            {
  353.                               szTempString[strlen(szTempString) - 1] = '\0';
  354.                            }
  355.                            else
  356.                            {
  357.                               INT ch;
  358.                               do
  359.                               {
  360.                                  ch = fgetc(pfCustomDropFile);
  361.                               } while(ch != '\n' && ch != EOF);
  362.                            }
  363.  
  364.                            strupr(pchConfigText);
  365.  
  366.                            for(nConfigOption = 0; nConfigOption < LINES_SIZE;
  367.                               ++nConfigOption)
  368.                            {
  369.                               if(strcmp(pchConfigText,
  370.                                  od_config_lines[nConfigOption]) == 0)
  371.                               {
  372.                                  switch(nConfigOption)
  373.                                  {
  374.                                     case 1:
  375.                                        od_control.port =
  376.                                           ODCfgGetWordDecimal(szTempString) - 1;
  377.                                        break;
  378.  
  379.                                     case 2:
  380.                                        od_control.port =
  381.                                           ODCfgGetWordDecimal(szTempString);
  382.                                        break;
  383.  
  384.                                     case 3:
  385.                                        od_control.baud =
  386.                                           ODCfgGetWordDecimal(szTempString);
  387.                                        break;
  388.  
  389.                                     case 4:
  390.                                        if(ODCfgIsTrue(szTempString))
  391.                                        {
  392.                                           od_control.baud = 0;
  393.                                        }
  394.                                        break;
  395.  
  396.                                     case 5:
  397.                                     case 6:
  398.                                        ODStringToName(szTempString);
  399.                                        strncpy(od_control.user_name,
  400.                                           szTempString, 34);
  401.                                        od_control.user_name[34] = '\0';
  402.                                        break;
  403.  
  404.                                     case 7:
  405.                                        strcat(od_control.user_name, " ");
  406.                                        ODStringToName(szTempString);
  407.                                        strncat(od_control.user_name,
  408.                                           szTempString,
  409.                                           35 - strlen(od_control.user_name));
  410.                                        od_control.user_name[35] = '\0';
  411.                                        break;
  412.  
  413.                                     case 8:
  414.                                        ODStringToName(szTempString);
  415.                                        strncpy(od_control.user_handle,
  416.                                           szTempString, 35);
  417.                                        od_control.user_handle[35] = '\0';
  418.                                        break;
  419.  
  420.                                     case 9:
  421.                                        pszWork = (char *)szTempString;
  422.                                        ODCfgGetNextTime((char **)&pszWork);
  423.                                        od_control.user_timelimit += 
  424.                                           (awTimeVal[0] * 60);
  425.                                        break;
  426.  
  427.                                     case 10:
  428.                                        pszWork = (char *)szTempString;
  429.                                        ODCfgGetNextTime((char **)&pszWork);
  430.                                        if(btTimeNumVals <= 1)
  431.                                        {
  432.                                           od_control.user_timelimit +=
  433.                                              awTimeVal[0];
  434.                                        }
  435.                                        else
  436.                                        {
  437.                                           od_control.user_timelimit +=
  438.                                              awTimeVal[1] + (awTimeVal[0] * 60);
  439.                                        }
  440.                                        break;
  441.  
  442.                                     case 11:
  443.                                        pszWork = (char *)szTempString;
  444.                                        ODCfgGetNextTime((char **)&pszWork);
  445.                                        if(btTimeNumVals <= 1)
  446.                                        {
  447.                                           od_control.user_timelimit +=
  448.                                              awTimeVal[0] / 60;
  449.                                        }
  450.                                        else if(btTimeNumVals == 2)
  451.                                        {
  452.                                           od_control.user_timelimit +=
  453.                                              (awTimeVal[1] / 60) + awTimeVal[0];
  454.                                        }
  455.                                        else
  456.                                        {
  457.                                           od_control.user_timelimit +=
  458.                                              (awTimeVal[2] / 60) + awTimeVal[1]
  459.                                              + (awTimeVal[0] * 60);
  460.                                        }
  461.                                        break;
  462.  
  463.                                     case 12:
  464.                                        od_control.user_ansi =
  465.                                           ODCfgIsTrue(szTempString);
  466.                                        break;
  467.  
  468.                                     case 13:
  469.                                        od_control.user_avatar =
  470.                                           ODCfgIsTrue(szTempString);
  471.                                        break;
  472.  
  473.                                     case 14:
  474.                                        od_control.od_page_pausing =
  475.                                           ODCfgIsTrue(szTempString);
  476.                                        break;
  477.  
  478.                                     case 15:
  479.                                        od_control.user_screen_length =
  480.                                           ODCfgGetWordDecimal(szTempString);
  481.                                        break;
  482.  
  483.                                     case 16:
  484.                                        if(ODCfgIsTrue(szTempString))
  485.                                         {
  486.                                            od_control.user_attribute |= 0x02;
  487.                                         }
  488.                                        else
  489.                                         {
  490.                                            od_control.user_attribute &=~ 0x02;
  491.                                         }
  492.                                        break;
  493.  
  494.                                     case 17:
  495.                                        od_control.user_security =
  496.                                           ODCfgGetWordDecimal(szTempString);
  497.                                        break;
  498.  
  499.                                     case 18:
  500.                                        ODStringToName(szTempString);
  501.                                        strncpy(od_control.user_location,
  502.                                           szTempString, 25);
  503.                                        od_control.user_location[25] = '\0';
  504.                                        break;
  505.  
  506.                                     case 19:
  507.                                        wODNodeNumber =
  508.                                           ODCfgGetWordDecimal(szTempString);
  509.                                        break;
  510.  
  511.                                     case 20:
  512.                                     case 21:
  513.                                        ODStringToName(szTempString);
  514.                                        strncpy(od_control.sysop_name,
  515.                                           szTempString, 38);
  516.                                        od_control.sysop_name[38] = '\0';
  517.                                        break;
  518.  
  519.                                     case 22:
  520.                                        strcat(od_control.sysop_name, " ");
  521.                                        ODStringToName(szTempString);
  522.                                        strncat(od_control.sysop_name,
  523.                                           szTempString,
  524.                                           39 - strlen(od_control.system_name));
  525.                                        od_control.sysop_name[39] = '\0';
  526.                                        break;
  527.  
  528.                                     case 23:
  529.                                        strncpy(od_control.system_name,
  530.                                           szTempString, 39);
  531.                                        od_control.system_name[39] = '\0';
  532.                                        break;
  533.  
  534.                                     case 24:
  535.                                        od_control.user_rip =
  536.                                           ODCfgIsTrue(szTempString);
  537.                                  }
  538.                               }
  539.                            }
  540.                         }
  541.                      }
  542.                      break;
  543.  
  544.                   case 22:
  545.                      bInactivitySet = TRUE;
  546.                      nInactivity = ODCfgGetWordDecimal(pchConfigText);
  547.                      if(nInactivity < 0) nInactivity = 0;
  548.                      break;
  549.  
  550.                   case 23:
  551.                      btPageLength = (BYTE)ODCfgGetWordDecimal(pchConfigText);
  552.                      bPageLengthSet = TRUE;
  553.                      break;
  554.  
  555.                   case 24:
  556.                      od_control.od_chat_color2 = 
  557.                         od_color_config(pchConfigText);
  558.                      break;
  559.  
  560.                   case 25:
  561.                      od_control.od_chat_color1 =
  562.                         od_color_config(pchConfigText);
  563.                      break;
  564.  
  565.                   case 26:
  566.                      od_control.od_list_title_col =
  567.                         od_color_config(pchConfigText);
  568.                      break;
  569.  
  570.                   case 27:
  571.                      od_control.od_list_name_col =
  572.                         od_color_config(pchConfigText);
  573.                      break;
  574.  
  575.                   case 28:
  576.                      od_control.od_list_size_col = 
  577.                         od_color_config(pchConfigText);
  578.                      break;
  579.  
  580.                   case 29:
  581.                      od_control.od_list_comment_col =
  582.                         od_color_config(pchConfigText);
  583.                      break;
  584.  
  585.                   case 30:
  586.                      od_control.od_list_offline_col =
  587.                         od_color_config(pchConfigText);
  588.                      break;
  589.  
  590.                   case 31:
  591.                      strncpy(szDesiredPersonality, pchConfigText, 32);
  592.                      szDesiredPersonality[32] = '\0';
  593.                      break;
  594.  
  595.                   case 32:
  596.                      /* "NoFossil" */
  597.                      od_control.od_no_fossil = TRUE;
  598.                      break;
  599.  
  600.                   case 33:
  601.                      /* "PortAddress" */
  602.                      od_control.od_com_address = ODCfgGetWordHex(pchConfigText);
  603.                      break;
  604.  
  605.                   case 34:
  606.                      /* "PortIRQ" */
  607.                      od_control.od_com_irq =
  608.                         (char)ODCfgGetWordDecimal(pchConfigText);
  609.                      break;
  610.  
  611.                   case 35:
  612.                      /* "ReceiveBuffer" */
  613.                      od_control.od_com_rx_buf =
  614.                         ODCfgGetWordDecimal(pchConfigText);
  615.                      break;
  616.  
  617.                   case 36:
  618.                      /* "TransmitBuffer" */
  619.                      od_control.od_com_tx_buf =
  620.                         ODCfgGetWordDecimal(pchConfigText);
  621.                      break;
  622.  
  623.                   case 37:
  624.                      /* "PagePromptColour" */
  625.                      od_control.od_continue_col =
  626.                         od_color_config(pchConfigText);
  627.                      break;
  628.  
  629.                   case 38:
  630.                      /* "LocalMode" */
  631.                      od_control.od_force_local = TRUE;
  632.                      break;
  633.  
  634.                   case 39:
  635.                      /* "PopupMenuTitleColour" */
  636.                      od_control.od_menu_title_col =
  637.                         od_color_config(pchConfigText);
  638.                      break;
  639.  
  640.                   case 40:
  641.                      /* "PopupMenuBorderColour" */
  642.                      od_control.od_menu_border_col =
  643.                         od_color_config(pchConfigText);
  644.                      break;
  645.  
  646.                   case 41:
  647.                      /* "PopupMenuTextColour" */
  648.                      od_control.od_menu_text_col =
  649.                         od_color_config(pchConfigText);
  650.                      break;
  651.  
  652.                   case 42:
  653.                      /* "PopupMenuKeyColour" */
  654.                      od_control.od_menu_key_col =
  655.                         od_color_config(pchConfigText);
  656.                      break;
  657.  
  658.                   case 43:
  659.                      /* "PopupMenuHighlightColour" */
  660.                      od_control.od_menu_highlight_col =
  661.                         od_color_config(pchConfigText);
  662.                      break;
  663.  
  664.                   case 44:
  665.                      /* "PopupMenuHighKeyColour" */
  666.                      od_control.od_menu_highkey_col = 
  667.                         od_color_config(pchConfigText);
  668.                      break;
  669.  
  670.                   case 45:
  671.                      /* "NoFIFO" */
  672.                      od_control.od_com_no_fifo = TRUE;
  673.                      break;
  674.  
  675.                   case 46:
  676.                      /* "FIFOTriggerSize" */
  677.                      od_control.od_com_fifo_trigger =
  678.                         (BYTE)ODCfgGetWordDecimal(pchConfigText);
  679.                      break;
  680.  
  681.                   case 47:
  682.                      /* "DisableDTR" */
  683.                      ODStringCopy(od_control.od_disable_dtr, pchConfigText,
  684.                         sizeof(od_control.od_disable_dtr));
  685.                      break;
  686.  
  687.                   case 48:
  688.                      /* "NoDTRDisable" */
  689.                      od_control.od_disable |= DIS_DTR_DISABLE;
  690.                      break;
  691.                }
  692.             }
  693.          }
  694.  
  695.          /* Check if command is a programmer customized option. */
  696.          if(wCurrent >= TEXT_SIZE && custom_line_function != NULL)
  697.          {
  698.             (*custom_line_function)((char *)&szToken, pchConfigText);
  699.          }
  700.       }
  701.  
  702.       /* Close the configuration file. */
  703.       fclose(pfConfigFile);}
  704.    else
  705.    {
  706.       if(bConfigFileRequired)
  707.       {
  708.          od_control.od_error = ERR_FILEOPEN;
  709.          ODInitError("Unable to access configuration file.");
  710.          exit(od_control.od_errorlevel[1]);
  711.       }
  712.    }
  713.  
  714.    /* Close custom door info file */
  715.    if(pfCustomDropFile != NULL)
  716.    {
  717.       fclose(pfCustomDropFile);
  718.    }
  719.  
  720.    bIsCallbackActive = FALSE;
  721.  
  722.    /* Carry out normal OpenDoors initialization. */
  723.    bCalledFromConfig = TRUE;
  724.    od_init();
  725.    bCalledFromConfig = FALSE;
  726.  
  727.    /* Update any settings that need to be updated. */
  728.    if(bPageSet)
  729.    {
  730.       od_control.od_pagestartmin = nPageStart;
  731.       od_control.od_pageendmin = nPageEnd;
  732.    }
  733.  
  734.    if(bInactivitySet && nInactivity != 0)
  735.    {
  736.       od_control.od_inactivity = nInactivity;
  737.    }
  738.  
  739.    if(bSysopNameSet)
  740.    {
  741.       strcpy((char *)&od_control.sysop_name, (char *)&szForcedSysopName);
  742.    }
  743.  
  744.    if(bSystemNameSet)
  745.    {
  746.       strcpy((char *)&od_control.system_name, (char *)&szForcedSystemName);
  747.    }
  748.  
  749.    if(bPageLengthSet)
  750.    {
  751.       od_control.od_page_len = btPageLength;
  752.    }
  753.  
  754.    if(bWorkDirSet)
  755.    {
  756.       ODDirChangeCurrent(szWorkDir);
  757.    }
  758. }
  759.  
  760.  
  761. /* ----------------------------------------------------------------------------
  762.  * ODCfgGetWordDecimal()                               *** PRIVATE FUNCTION ***
  763.  *
  764.  * Obtains the value of the next decimal number in the provided string, in the
  765.  * form of a WORD (16 bit value).
  766.  *
  767.  * Parameters: pszConfigText - String to examine.
  768.  *
  769.  *     Return: The first number obtained from the string.
  770.  */
  771. static WORD ODCfgGetWordDecimal(char *pszConfigText)
  772. {
  773.    ASSERT(pszConfigText != NULL);
  774.  
  775.    /* Skip any initial non-numerical characters. */
  776.    while(*pszConfigText && (*pszConfigText < '0' || *pszConfigText > '9'))
  777.    {
  778.       ++pszConfigText;
  779.    }
  780.  
  781.    /* Return value of number. */
  782.    return(atoi(pszConfigText));
  783. }
  784.  
  785.  
  786. /* ----------------------------------------------------------------------------
  787.  * ODCfgGetDWordDecimal()                              *** PRIVATE FUNCTION ***
  788.  *
  789.  * Obtains the value of the next decimal number in the provided string, in the
  790.  * form of a DWORD (32 bit value).
  791.  *
  792.  * Parameters: pszConfigText - String to examine.
  793.  *
  794.  *     Return: The first number obtained from the string.
  795.  */
  796. static DWORD ODCfgGetDWordDecimal(char *pszConfigText)
  797. {                                
  798.    ASSERT(pszConfigText != NULL);
  799.  
  800.    /* Skip any initial non-numerical characters. */
  801.    while(*pszConfigText && (*pszConfigText < '0' || *pszConfigText > '9'))
  802.    {
  803.       ++pszConfigText;
  804.    }
  805.  
  806.    /* Return value of number. */
  807.    return(atol(pszConfigText));
  808. }
  809.  
  810.  
  811. /* ----------------------------------------------------------------------------
  812.  * ODCfgGetWordHex()                                   *** PRIVATE FUNCTION ***
  813.  *
  814.  * Obtains the value of the next hexidecimal number in the provided string, in
  815.  * the form of a WORD (16 bit value).
  816.  *
  817.  * Parameters: pszConfigText - String to examine.
  818.  *
  819.  *     Return: The first number obtained from the string.
  820.  */
  821. static WORD ODCfgGetWordHex(char *pszConfigText)
  822. {
  823.    WORD wToReturn;
  824.  
  825.    ASSERT(pszConfigText != NULL);
  826.  
  827.    /* Skip any initial non-hexidecimal characters. */
  828.    while(*pszConfigText && (*pszConfigText < '0' || *pszConfigText > '9')
  829.       && (toupper(*pszConfigText) < 'A' || toupper(*pszConfigText) > 'F'))
  830.    {
  831.       ++pszConfigText;
  832.    }
  833.  
  834.    sscanf(pszConfigText, "%x", &wToReturn);
  835.  
  836.    return(wToReturn);
  837. }
  838.  
  839.  
  840. /* ----------------------------------------------------------------------------
  841.  * ODCfgGetNextTime()                                  *** PRIVATE FUNCTION ***
  842.  *
  843.  * Obtains the next time from a string, updating the string pointer to point to
  844.  * the position in the string after the end of the time. The time information
  845.  * is stored in the btTimeNumVals and awTimeVal private global variables.
  846.  *
  847.  * Parameters: ppchConfigText - Pointer to character pointer to the string,
  848.  *                              which is to be updated.
  849.  *
  850.  *     Return: void
  851.  */
  852. static void ODCfgGetNextTime(char **ppchConfigText)
  853. {
  854.    char *pchConfigText = (char *)(*ppchConfigText);
  855.  
  856.    ASSERT(ppchConfigText != NULL);
  857.    ASSERT(*ppchConfigText != NULL);
  858.  
  859.    btTimeNumVals = 0;
  860.    awTimeVal[0] = 0;
  861.    awTimeVal[1] = 0;
  862.    awTimeVal[2] = 0;
  863.  
  864.  
  865.    while(*pchConfigText && (*pchConfigText == ' ' || *pchConfigText == '\t'))
  866.    {
  867.       ++pchConfigText;
  868.    }
  869.  
  870.  
  871.    while(*pchConfigText && btTimeNumVals < 3)
  872.    {
  873.       if(*pchConfigText < '0' || *pchConfigText > '9') break;
  874.       awTimeVal[btTimeNumVals++] = atoi(pchConfigText);
  875.       while(*pchConfigText && *pchConfigText >= '0' && *pchConfigText <= '9')
  876.       {
  877.          ++pchConfigText;
  878.       }
  879.       if(*pchConfigText == ':' || *pchConfigText == '.' || *pchConfigText == ','
  880.          || *pchConfigText == ';')
  881.       {
  882.          ++pchConfigText;
  883.       }
  884.    }
  885.  
  886.    *ppchConfigText = (char *)pchConfigText;
  887. }
  888.  
  889.  
  890. /* ----------------------------------------------------------------------------
  891.  * ODCfgIsTrue()                                       *** PRIVATE FUNCTION ***
  892.  *
  893.  * Determines whether the specified string represents a TRUE or FALSE value.
  894.  * For example "Yes", "TRUE", "Y" and "1" all represent TRUE values, while
  895.  * "No", "FALSE", "N" and "0" all represent FALSE values.
  896.  *
  897.  * Parameters: pszConfigText - String to examine.
  898.  *
  899.  *     Return: The Boolean value represented by the string.
  900.  */
  901. static BOOL ODCfgIsTrue(char *pszConfigText)
  902. {
  903.    ASSERT(pszConfigText != NULL);
  904.  
  905.    while(*pszConfigText && (*pszConfigText == ' ' || *pszConfigText == '\t'))
  906.    {
  907.       ++pszConfigText;
  908.    }
  909.  
  910.    switch(*pszConfigText)
  911.    {
  912.       case '1':
  913.       case 't':
  914.       case 'T':
  915.       case 'y':
  916.       case 'Y':
  917.       case 'g':
  918.       case 'G':
  919.          return(TRUE);
  920.    }
  921.  
  922.    return(FALSE);
  923. }
  924.