home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / UUPC11XS.ZIP / LIB / CONFIGUR.C < prev    next >
C/C++ Source or Header  |  1992-11-30  |  26KB  |  682 lines

  1. /*--------------------------------------------------------------------*/
  2. /*    c o n f i g u r . c                                             */
  3. /*                                                                    */
  4. /*    Support routines for UUPC/extended                              */
  5. /*                                                                    */
  6. /*    Changes Copyright 1990, 1991 (c) Andrew H. Derbyshire           */
  7. /*                                                                    */
  8. /*    History:                                                        */
  9. /*       21Nov1991 Break out of lib.c                          ahd    */
  10. /*--------------------------------------------------------------------*/
  11.  
  12. /*--------------------------------------------------------------------*/
  13. /*    Changes Copyright (c) 1989 by Andrew H. Derbyshire.             */
  14. /*                                                                    */
  15. /*    Changes Copyright (c) 1990-1992 by Kendra Electronic            */
  16. /*    Wonderworks.                                                    */
  17. /*                                                                    */
  18. /*    All rights reserved except those explicitly granted by the      */
  19. /*    UUPC/extended license agreement.                                */
  20. /*--------------------------------------------------------------------*/
  21.  
  22. /*--------------------------------------------------------------------*/
  23. /*                          RCS Information                           */
  24. /*--------------------------------------------------------------------*/
  25.  
  26. /*
  27.  *    $Header: E:\src\uupc\LIB\RCS\CONFIGUR.C 1.4 1992/12/01 04:37:03 ahd Exp $
  28.  *
  29.  *    Revision history:
  30.  *    $Log: CONFIGUR.C $
  31.  * Revision 1.4  1992/12/01  04:37:03  ahd
  32.  * Add SpeedOverMemory
  33.  *
  34.  * Revision 1.3  1992/11/22  20:58:55  ahd
  35.  * Normalize directories as read
  36.  * Use strpool to allocate const strings
  37.  *
  38.  * Revision 1.2  1992/11/19  02:56:47  ahd
  39.  * drop rcsid
  40.  *
  41.  * Revision 1.1  1992/11/16  05:00:26  ahd
  42.  * Initial revision
  43.  *
  44.  */
  45.  
  46.  
  47. #include <stdio.h>
  48. #include <stdlib.h>
  49. #include <string.h>
  50. #include <time.h>
  51. #include <ctype.h>
  52.  
  53. #ifndef __GNUC__
  54. #include <io.h>
  55. #endif
  56.  
  57. /*--------------------------------------------------------------------*/
  58. /*                    UUPC/extended include files                     */
  59. /*--------------------------------------------------------------------*/
  60.  
  61. #include "lib.h"
  62. #include "hlib.h"
  63. #include "timestmp.h"
  64.  
  65. /*--------------------------------------------------------------------*/
  66. /*                          Global variables                          */
  67. /*--------------------------------------------------------------------*/
  68.  
  69. currentfile();
  70.  
  71. boolean bflag[F_LAST];        /* Initialized to zero by compiler     */
  72.  
  73. char *E_aliases = NULL;
  74. char *E_anonymous = NULL;
  75. char *E_archivedir = NULL;
  76. char *E_confdir = NULL;
  77. char *E_domain = NULL;
  78. char *E_altsignature = NULL;
  79. char *E_backup = NULL;
  80. char *E_charset = NULL;
  81. char *E_editor = NULL;
  82. char *E_filesent = NULL;
  83. char *E_inmodem = NULL;
  84. char *E_mailext = NULL;
  85. char *E_pager = NULL;
  86. char *E_signature = NULL;
  87. char *E_uuxqtpath = NULL;
  88. char *E_fdomain = NULL;
  89. char *E_homedir = NULL;
  90. char *E_localdomain = NULL;
  91. char *E_mailbox = NULL;
  92. char *E_maildir = NULL;
  93. char *E_mailserv = NULL;
  94. char *E_name = NULL;
  95. char **E_internal = NULL;
  96. char *E_newsdir = NULL;
  97. char *E_newsserv = NULL;
  98. char *E_nodename = NULL;
  99. char *E_organization = NULL;
  100. char *E_postmaster = NULL;
  101. char *E_pubdir = NULL;
  102. char *E_replyto = NULL;
  103. char *E_spooldir = NULL;
  104. char *E_tempdir = NULL;
  105. char *E_version = NULL;
  106. char *E_uncompress = NULL;
  107. static char *dummy = NULL;
  108.  
  109. INTEGER E_maxhops = 20;                                     /* ahd */
  110.  
  111. /*--------------------------------------------------------------------*/
  112. /*                       Local emumerated types                       */
  113. /*--------------------------------------------------------------------*/
  114.  
  115. typedef enum {
  116.       OS2_ENV,
  117.       DOS_ENV,
  118.       UNKNOWN_ENV
  119.       } ENV_TYPE;
  120.  
  121. #ifdef __GNUC__
  122. static ENV_TYPE active_env = OS2_ENV;
  123. #else
  124. static ENV_TYPE active_env = DOS_ENV;
  125. #endif
  126.  
  127. static boolean getrcnames(char **sysp,char **usrp);
  128.  
  129. /*--------------------------------------------------------------------*/
  130. /*  The following table controls the configuration files processing   */
  131. /*--------------------------------------------------------------------*/
  132.  
  133. static CONFIGTABLE envtable[] = {
  134.    {"aliases",      &E_aliases,      B_TOKEN|B_MUA},
  135.    {"altsignature", &E_altsignature, B_TOKEN|B_MUA},
  136.    {"anonymouslogin",
  137.                     &E_anonymous,   B_GLOBAL|B_TOKEN|(B_ALL & ~ B_MAIL)},
  138.    {"archivedir",   &E_archivedir,   B_REQUIRED|B_GLOBAL|B_PATH|B_NEWS},
  139.    {"backupext",    &E_backup,       B_TOKEN|B_MUA},
  140.    {"confdir",      &E_confdir,      B_REQUIRED|B_GLOBAL|B_PATH|B_ALL},
  141.    {"charset",      &E_charset,      B_TOKEN|B_GLOBAL|B_SPOOL},
  142.    {"domain",       &E_domain,       B_REQUIRED|B_GLOBAL|B_TOKEN|B_ALL},
  143.    {"editor",       &E_editor,       B_STRING|B_MUA|B_NEWS},
  144.    {"filesent",     &E_filesent,     B_TOKEN|B_MUA|B_NEWS},
  145.    {"folders",      &dummy,          B_PATH|B_MUSH },
  146.    {"fromdomain",   &E_fdomain,      B_GLOBAL|B_MAIL|B_NEWS|B_TOKEN},
  147.    {"home",         &E_homedir,      B_PATH|B_REQUIRED|B_ALL},
  148.    {"inmodem",      &E_inmodem,      B_GLOBAL|B_TOKEN|B_UUCICO},
  149.    {"internalcommands", (char **)   &E_internal,
  150.                                      B_GLOBAL|B_LIST|B_UUXQT},
  151.    {"localdomain",  &E_localdomain,  B_GLOBAL|B_TOKEN|B_MAIL},
  152.    {"mailbox",      &E_mailbox,      B_REQUIRED|B_TOKEN|B_ALL},
  153.    {"mailext",      &E_mailext,      B_TOKEN|B_MAIL},
  154.    {"maildir",      &E_maildir,      B_REQUIRED|B_GLOBAL|B_PATH|B_MAIL},
  155.    {"mailserv",     &E_mailserv,     B_REQUIRED|B_GLOBAL|B_TOKEN|B_ALL},
  156.    {"maximumhops",  (char **) &E_maxhops,
  157.                                      B_MTA | B_INTEGER | B_GLOBAL},
  158.    {"mushdir",      &dummy,          B_GLOBAL|B_PATH|B_MUSH},
  159.    {"name",         &E_name,         B_REQUIRED|B_MAIL|B_NEWS|B_STRING},
  160.    {"newsdir",      &E_newsdir,      B_REQUIRED|B_GLOBAL|B_PATH|B_NEWS},
  161.    {"newsserv",     &E_newsserv,     B_GLOBAL|B_PATH|B_NEWS},
  162.    {"nodename",     &E_nodename,     B_REQUIRED|B_GLOBAL|B_TOKEN|B_ALL},
  163.    {"options",      (char **) bflag, B_ALL|B_BOOLEAN},
  164.    {"organization", &E_organization, B_STRING|B_MAIL|B_NEWS},
  165.    {"pager",        &E_pager,        B_STRING|B_MUA|B_NEWS},
  166.    {"path",         &E_uuxqtpath,    B_STRING|B_UUXQT|B_GLOBAL},
  167.    {"postmaster",   &E_postmaster,   B_REQUIRED|B_GLOBAL|B_TOKEN|B_MTA},
  168.    {"pubdir",       &E_pubdir,       B_REQUIRED|B_GLOBAL|B_PATH|B_SPOOL},
  169.    {"replyto",      &E_replyto,      B_TOKEN|B_MAIL|B_NEWS},
  170.    {"signature",    &E_signature,    B_TOKEN|B_MUA|B_NEWS},
  171.    {"spooldir",     &E_spooldir,     B_REQUIRED|B_GLOBAL|B_PATH|B_SPOOL|B_NEWS},
  172.    {"tempdir",      &E_tempdir,      B_REQUIRED|B_GLOBAL|B_PATH|B_ALL},
  173.    {"uncompress",   &E_uncompress,   B_GLOBAL|B_STRING|B_NEWS },
  174.    {"version",      &E_version,      B_TOKEN|B_INSTALL},
  175.    {"rmail",        &dummy,          B_OBSOLETE },
  176.    {"rnews",        &dummy,          B_OBSOLETE },
  177.    { nil(char) }
  178. }; /* table */
  179.  
  180. /*--------------------------------------------------------------------*/
  181. /*               Boolean options shared by all programs               */
  182. /*--------------------------------------------------------------------*/
  183.  
  184. FLAGTABLE configFlags[] = {
  185.  { "askcc",       F_ASKCC,       B_LOCAL},
  186.  { "autoedit",    F_AUTOEDIT,    B_LOCAL},
  187.  { "autoinclude", F_AUTOINCLUDE, B_LOCAL},
  188.  { "autoprint",   F_AUTOPRINT,   B_LOCAL},
  189.  { "autosign",    F_AUTOSIGN,    B_LOCAL},
  190.  { "backup",      F_BACKUP,      B_LOCAL},
  191.  { "doskey",      F_DOSKEY,      B_LOCAL},
  192.  { "dot",         F_DOT,         B_LOCAL},
  193.  { "expert",      F_EXPERT,      B_LOCAL},
  194.  { "forwardsave", F_SAVERESENT,  B_LOCAL},
  195.  { "fromsep",     F_FROMSEP,     B_LOCAL},
  196.  { "pager",       F_PAGER,       B_LOCAL},
  197.  { "purge",       F_PURGE,       B_LOCAL},
  198.  { "save",        F_SAVE,        B_LOCAL},
  199.  { "suppresscopyright",
  200.                   F_SUPPRESSCOPYRIGHT,
  201.                                  B_LOCAL},
  202.  { "speedovermemory",
  203.                   F_SPEEDOVERMEMORY,
  204.                                  B_LOCAL},
  205.  { "verbose",     F_VERBOSE,     B_LOCAL},
  206.  { "undelete",    F_UNDELETE,    B_LOCAL},
  207.  
  208.  { "bang",        F_BANG,        B_GLOBAL},
  209.  { "collect",     F_COLLECTSTATS,B_GLOBAL},
  210.  { "directory",   F_DIRECT,      B_GLOBAL},
  211.  { "escape",      F_ESCAPE,      B_GLOBAL},
  212.  { "hpfs",        F_HPFS,        B_GLOBAL},
  213.  { "history",     F_HISTORY,     B_GLOBAL},
  214.  { "kanji",       F_KANJI,       B_GLOBAL},
  215.  { "monocase",    F_ONECASE,     B_GLOBAL},
  216.  { "multiqueue",  F_MULTI,       B_GLOBAL},
  217.  { "multitask",   F_MULTITASK,   B_GLOBAL},
  218.  { "snews",       F_SNEWS,       B_GLOBAL},
  219.  { "syslog",      F_SYSLOG,      B_GLOBAL},
  220.  { "symmetricgrades",
  221.                   F_SYMMETRICGRADES,
  222.                                  B_GLOBAL},
  223.  
  224.  { nil(char) }
  225. }           ;
  226.  
  227. /*--------------------------------------------------------------------*/
  228. /*    p r o c e s s c o n f i g                                       */
  229. /*                                                                    */
  230. /*    Handle a single line of a configuration file                    */
  231. /*--------------------------------------------------------------------*/
  232.  
  233. boolean processconfig(char *buff,
  234.                   SYSMODE sysmode,
  235.                   CONFIGBITS program,
  236.                   CONFIGTABLE *table,
  237.                   FLAGTABLE *btable)
  238. {
  239.    CONFIGTABLE *tptr;
  240.    char *cp;
  241.    char *keyword;
  242.    ENV_TYPE target_env;
  243.  
  244. /*--------------------------------------------------------------------*/
  245. /*                break out the keyword from its value                */
  246. /*--------------------------------------------------------------------*/
  247.  
  248.    if ((cp = strchr(buff, '=')) == nil(char))
  249.    {
  250.       printmsg(0,"Missing equals sign after keyword \"%s\", ignored",
  251.                   buff);
  252.       return TRUE;
  253.    }
  254.    *cp++ = '\0';
  255.    strlwr(buff);
  256.  
  257. /*--------------------------------------------------------------------*/
  258. /*    Determine if the keyword should processed in this environment   */
  259. /*--------------------------------------------------------------------*/
  260.  
  261.    keyword = strchr( buff, '.' );   /* Look for environment          */
  262.  
  263.    if ( keyword == NULL )     /* No environment?                     */
  264.    {
  265.       keyword = buff;         /* Then buffer starts with keyword     */
  266.       target_env = active_env;
  267.    }
  268.    else {
  269.       *keyword++ = '\0';      /* Terminate environment string        */
  270.  
  271.       if ( equal( buff, "dos" ))
  272.          target_env = DOS_ENV;
  273.       else if ( equal( buff, "os2" ))
  274.          target_env = OS2_ENV;
  275.       else {
  276.          printmsg(0,"Unknown environment \"%s\", keyword \"%s\" ignored",
  277.                buff, keyword );
  278.          return FALSE;
  279.       } /* else */
  280.    } /* else */
  281.  
  282. /*--------------------------------------------------------------------*/
  283. /*                    Scan the table for its value                    */
  284. /*--------------------------------------------------------------------*/
  285.  
  286.    for (tptr = table; tptr->sym != nil(char); tptr++)
  287.    {
  288.       boolean error = FALSE;
  289.       if (equal(keyword, tptr->sym)) {
  290. /*--------------------------------------------------------------------*/
  291. /*            Skip the keyword because of the environment?            */
  292. /*--------------------------------------------------------------------*/
  293.         if (active_env != target_env )
  294.             printmsg(2,"%s-only keyword \"%s\" skipped.",
  295.                         buff, keyword);
  296. /*--------------------------------------------------------------------*/
  297. /*                      Handle obsolete options                       */
  298. /*--------------------------------------------------------------------*/
  299.         else if (tptr->bits & B_OBSOLETE)
  300.             printmsg(2,"Obsolete keyword \"%s\" ignored.", keyword);
  301. /*--------------------------------------------------------------------*/
  302. /*                  Handle mis-placed system options                  */
  303. /*--------------------------------------------------------------------*/
  304.         else if ((tptr->bits & B_GLOBAL) && (sysmode != SYSTEM_CONFIG))
  305.             printmsg(0,
  306.                "User specified system keyword \"%s\" ignored.",
  307.                keyword);
  308. /*--------------------------------------------------------------------*/
  309. /*                       Handle Boolean options                       */
  310. /*--------------------------------------------------------------------*/
  311.          else {
  312.             if (tptr->bits & B_BOOLEAN)
  313.                options(cp, sysmode, btable, (boolean *) tptr->loc);
  314. /*--------------------------------------------------------------------*/
  315. /*                       Handle integer values                        */
  316. /*--------------------------------------------------------------------*/
  317.             else if (tptr->bits & B_INTEGER)
  318.             {
  319.                int *value = (int *) tptr->loc;
  320.                cp = strtok(cp,WHITESPACE);
  321.                if ( equal(cp,"0"))
  322.                   *value = 0;
  323.                else {
  324.                   *value = atoi(cp);
  325.                   if ( *value == 0)
  326.                   {
  327.                      printmsg(0,
  328.                         "Unable to convert \"%s\" value \"%s\" to integer",
  329.                         keyword, cp);
  330.                      error = TRUE;
  331.                   } /* if */
  332.                } /* else */
  333.             } /* else */
  334. /*--------------------------------------------------------------------*/
  335. /*                       Handle lists of tokens                       */
  336. /*--------------------------------------------------------------------*/
  337.             else if ((tptr->bits & program) && (tptr->bits & (B_LIST | B_CLIST)))
  338.             {
  339.                char **list = malloc( (MAXLIST+1) * sizeof (*list));
  340.                char *colon;
  341.                int words;
  342.  
  343.                checkref( list );
  344.  
  345.                if (tptr->bits & B_CLIST)  /* Use colon as delimiter? */
  346.                   while ( (colon = strchr( cp , ':')) != NULL)
  347.                      *colon = ' ';     /* Make colons spaces ...           */
  348.  
  349.                words = getargs(cp, list);
  350.                if( words > MAXLIST)
  351.                   panic();
  352.  
  353.                if (words > 0)
  354.                {
  355.                   if ( *(tptr->loc) )
  356.                      free( *(tptr->loc) );
  357.                   list = realloc( list, (words+1) * sizeof(*list));
  358.                   checkref( list );
  359.                   *(tptr->loc) = (char *) list;
  360.                   list[words] = NULL;
  361.  
  362.                   while( *list != NULL)
  363.                   {
  364.                      if (strlen(*list))
  365.                      {
  366.                         *list = newstr(*list);
  367.                         checkref( *list++ );
  368.                      }
  369.                      else
  370.                         *list++ = "";
  371.                   } /* while */
  372.                } /* if (words > 0) */
  373.                else {
  374.                   printmsg(0,"No parameters given for keyword \"%s\"",
  375.                            keyword);
  376.                   error = TRUE;
  377.                } /* else */
  378.             } /* else if */
  379. /*--------------------------------------------------------------------*/
  380. /*                  Handle single tokens and strings                  */
  381. /*--------------------------------------------------------------------*/
  382.             else if (tptr->bits & program)
  383.             {
  384.                while( *cp == ' ' )     /* Trim leading whitespace    */
  385.                   cp++;
  386.  
  387.                if (*cp == '\0')
  388.                {
  389.                   error = TRUE;
  390.                   printmsg(0,"No parameter given for keyword \"%s\""
  391.                            ", ignored.",
  392.                            keyword);
  393.                } /* if */
  394.  
  395.                if (tptr->bits & B_TOKEN)  /* One word value?      */
  396.                   cp = strtok(cp,WHITESPACE); /* Yes --> Tokenize */
  397.  
  398.                if (tptr->bits & B_NORMAL)  /* Normalize path?     */
  399.                   cp = normalize( cp );
  400.  
  401.                if (tptr->bits & B_MALLOC)  /* Allocate normally?  */
  402.                {
  403.                   *(tptr->loc) = strdup(cp); /* Save string          */
  404.                   checkref( *(tptr->loc) );  /* Verify malloc()      */
  405.                }
  406.                else
  407.                   *(tptr->loc) = newstr(cp); /* Save string          */
  408.  
  409.             } /* else */
  410.          } /* else */
  411.  
  412.          if (!error)
  413.             tptr->bits |= B_FOUND;
  414.          return TRUE;         /* Report we found the keyword      */
  415.       } /* if (equal(keyword, tptr->sym)) */
  416.    } /* for */
  417.  
  418. /*--------------------------------------------------------------------*/
  419. /*      We didn't find the keyword; report failure to the caller      */
  420. /*--------------------------------------------------------------------*/
  421.  
  422.    return FALSE;
  423.  
  424. } /* processconfig */
  425.  
  426. /*--------------------------------------------------------------------*/
  427. /*    g e t c o n f i g                                               */
  428. /*                                                                    */
  429. /*    Process a single configuration file                             */
  430. /*--------------------------------------------------------------------*/
  431.  
  432. boolean getconfig(FILE *fp,
  433.                   SYSMODE sysmode,
  434.                   CONFIGBITS program,
  435.                   CONFIGTABLE *table,
  436.                   FLAGTABLE *btable)
  437. {
  438.  
  439.    char buff[BUFSIZ];
  440.    char *cp;
  441.  
  442.  
  443.  
  444.    while(!(fgets(buff, sizeof buff, fp) == nil(char))) {
  445.  
  446. /*--------------------------------------------------------------------*/
  447. /*                        Ingore comment lines                        */
  448. /*--------------------------------------------------------------------*/
  449.  
  450.       if (*buff == '#')
  451.          continue;            /* comment line   */
  452.  
  453. /*--------------------------------------------------------------------*/
  454. /*                       Drop trailing new line                       */
  455. /*--------------------------------------------------------------------*/
  456.  
  457.       if (*(cp = buff + strlen(buff) - 1) == '\n')
  458.          *cp = '\0';
  459.  
  460. /*--------------------------------------------------------------------*/
  461. /*                 Drop leading blanks on input line                  */
  462. /*--------------------------------------------------------------------*/
  463.  
  464.       cp = buff;
  465.       while( isspace( *cp ) )
  466.          cp ++ ;
  467.  
  468. /*--------------------------------------------------------------------*/
  469. /*                 If line was not blank, process it.                 */
  470. /*--------------------------------------------------------------------*/
  471.  
  472.       if ( (*cp != '\0') && !processconfig(cp,sysmode,program,table,btable))
  473.          printmsg(0,
  474.                "Unknown keyword \"%s\" in %s configuration file ignored",
  475.                buff, sysmode ? "system" : "user");
  476.  
  477.    } /*while*/
  478.  
  479.    return TRUE;
  480.  
  481. } /*getconfig*/
  482.  
  483. /*--------------------------------------------------------------------*/
  484. /*    o p t i o n s                                                   */
  485. /*                                                                    */
  486. /*    Process a line of boolean option flags.                         */
  487. /*--------------------------------------------------------------------*/
  488.  
  489. void options(char *s, SYSMODE sysmode , FLAGTABLE *flags, boolean *barray)
  490. {
  491.    char *token;
  492.  
  493.    strlwr(s);
  494.    token = strtok(s,WHITESPACE);
  495.  
  496.    while (token != NULL)
  497.    {
  498.       size_t subscript;
  499.       boolean hit = FALSE;
  500.       boolean negate;
  501.       negate = equaln(token,"no",2) && (strlen(token) > 2);
  502.  
  503.       for (subscript = 0; (subscript < F_LAST) && !hit; subscript++)
  504.       {
  505.          if ((flags[subscript].bits & B_GLOBAL) && (sysmode != SYSTEM_CONFIG))
  506.             continue;
  507.          if (negate)
  508.          {
  509.             if (equal(&token[2],flags[subscript].sym))
  510.             {
  511.                barray[ flags[subscript].position ] = FALSE;
  512.                hit = TRUE;
  513.             }
  514.          } /* if negate */
  515.          else {
  516.             if (equal(token,flags[subscript].sym))
  517.             {
  518.                barray[ flags[subscript].position ] = TRUE;
  519.                hit = TRUE;
  520.             }
  521.          } /* else */
  522.       } /* for */
  523.  
  524.       if (!hit)
  525.          printf("Invalid or system option '%s' specified\n",token);
  526.  
  527.       token = strtok(NULL,WHITESPACE);  /* Step to next token on line */
  528.  
  529.    } /* while */
  530. } /* options */
  531.  
  532. /*--------------------------------------------------------------------*/
  533. /*    c o n f i g u r e                                               */
  534. /*                                                                    */
  535. /*    Define the global parameters of UUPC/extended                   */
  536. /*--------------------------------------------------------------------*/
  537.  
  538. boolean configure( CONFIGBITS program)
  539. {
  540.    char *sysrc, *usrrc;
  541.    FILE *fp;
  542.    boolean success;
  543.  
  544.    static char *envlist[] = { "EDITOR",   "EDITOR",
  545.                               "HOME",     "HOME",
  546.                               "NAME",     "NAME",
  547.                               "MAILBOX",  "MAILBOX",
  548.                               "TEMP",     "TEMPDIR",
  549.                               "TMP",      "TEMPDIR",
  550.                               NULL } ;
  551.  
  552.    int subscript = 0;
  553.  
  554.    CONFIGTABLE *tptr;
  555.  
  556. /*--------------------------------------------------------------------*/
  557. /*                  Determine the active environment                  */
  558. /*--------------------------------------------------------------------*/
  559.  
  560. #ifndef __TURBOC__
  561. #ifndef __GNUC__
  562.    if (_osmode != DOS_MODE)
  563.       active_env = OS2_ENV;
  564. #endif
  565. #endif
  566.  
  567.    if (!getrcnames(&sysrc, &usrrc))
  568.       return FALSE;
  569.  
  570. /*--------------------------------------------------------------------*/
  571. /*          Extract selected variables from our environment           */
  572. /*--------------------------------------------------------------------*/
  573.  
  574.    while( envlist[subscript] != NULL )
  575.    {
  576.       char *s = getenv( envlist[subscript++] );
  577.  
  578.       if (s != NULL )
  579.       {
  580.          char buf[BUFSIZ];
  581.          sprintf(buf,"%s=%s",envlist[subscript], s );
  582.          processconfig( buf, SYSTEM_CONFIG, program, envtable, configFlags);
  583.       } /* if (sysrc != NULL ) */
  584.  
  585.       subscript++;            /* Step to next environment var in list   */
  586.    }
  587.  
  588. /*--------------------------------------------------------------------*/
  589. /*               Process the system configuration file                */
  590. /*--------------------------------------------------------------------*/
  591.  
  592.    if ((fp = FOPEN(sysrc, "r", TEXT)) == nil(FILE))
  593.    {
  594.       printmsg(0, "Cannot open system configuration file \"%s\"", sysrc);
  595.       printerr(sysrc);
  596.       return FALSE;
  597.    }
  598.  
  599.    success = getconfig(fp, SYSTEM_CONFIG, program, envtable, configFlags);
  600.    fclose(fp);
  601.    if (!success)
  602.       return FALSE;
  603.  
  604. /*--------------------------------------------------------------------*/
  605. /*                Process the user configuration value                */
  606. /*--------------------------------------------------------------------*/
  607.  
  608.    if (usrrc != nil(char))
  609.    {
  610.       if ((fp = FOPEN(usrrc, "r", TEXT)) == nil(FILE))
  611.       {
  612.          printmsg(0, "Cannot open user configuration file \"%s\"", usrrc);
  613.          return FALSE;
  614.       }
  615.  
  616.       success = getconfig(fp, USER_CONFIG, program, envtable, configFlags);
  617.       fclose(fp);
  618.       if (!success)
  619.          return FALSE;
  620.    }
  621.  
  622. /*--------------------------------------------------------------------*/
  623. /*                       Display our copyright                        */
  624. /*--------------------------------------------------------------------*/
  625.  
  626.    if (! bflag[F_SUPPRESSCOPYRIGHT] &&
  627.         (program != B_MTA) &&
  628.         isatty(fileno(stdout)))
  629.       fprintf(stdout,
  630. "Changes Copyright (c) 1989 by Andrew H. Derbyshire.  Changes and\n"
  631. "Compilation Copyright (c) 1990-%s by Kendra Electronic Wonderworks.  May\n"
  632. "be freely distributed if original documentation and source is included.\n",
  633.               &compiled[7]);
  634.  
  635. /*--------------------------------------------------------------------*/
  636. /*          Validate that all required parameters were given          */
  637. /*--------------------------------------------------------------------*/
  638.  
  639.    for (tptr = envtable; tptr->sym != nil(char); tptr++)
  640.    {
  641.  
  642.       if ((tptr->bits & (B_REQUIRED | B_FOUND)) == B_REQUIRED)
  643.       {
  644.          printmsg(0, "%s configuration parameter \"%s\" must be set.",
  645.             (tptr->bits & B_GLOBAL) ? "System" : "User",
  646.             tptr->sym);
  647.          success = FALSE;
  648.       } /* if */
  649.  
  650.    } /* for */
  651.  
  652.    return success;
  653.  
  654. } /*configure*/
  655.  
  656. /*--------------------------------------------------------------------*/
  657. /*    g e t r c n a m e s                                             */
  658. /*                                                                    */
  659. /*    Return the name of the configuration files                      */
  660. /*--------------------------------------------------------------------*/
  661.  
  662. static boolean getrcnames(char **sysp,char **usrp)
  663. {
  664.    char *debugp = NULL;      /* Pointer to debug environment variable  */
  665.  
  666.    if ((*sysp = getenv(SYSRCSYM)) == nil(char))
  667.    {
  668.       printf("environment variable %s must be specified\n", SYSRCSYM);
  669.       return FALSE;
  670.    }
  671.  
  672.    *usrp = getenv(USRRCSYM);
  673.  
  674.    debugp = getenv(SYSDEBUG);
  675.  
  676.    if ( debugp != nil(char))        /* Debug specified in environment?     */
  677.       debuglevel = atoi(debugp);    /* Yes --> preset debuglevel for user  */
  678.  
  679.    return TRUE;
  680.  
  681. } /*getrcnames*/
  682.