home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 2 / RISC_DISC_2.iso / pd_share / utilities / cli / pgp2 / src / c / config < prev    next >
Encoding:
Text File  |  1995-02-04  |  16.5 KB  |  711 lines

  1. /*    config.c  - config file parser by Peter Gutmann
  2.     Parses config file for PGP
  3.  
  4.     (c) Copyright 1990-1994 by Philip Zimmermann.  All rights reserved.
  5.     The author assumes no liability for damages resulting from the use
  6.     of this software, even if the damage results from defects in this
  7.     software.  No warranty is expressed or implied.
  8.  
  9.     Note that while most PGP source modules bear Philip Zimmermann's
  10.     copyright notice, many of them have been revised or entirely written
  11.     by contributors who frequently failed to put their names in their
  12.     code.  Code that has been incorporated into PGP from other authors
  13.     was either originally published in the public domain or is used with
  14.     permission from the various authors.
  15.  
  16.     PGP is available for free to the public under certain restrictions.
  17.     See the PGP User's Guide (included in the release package) for
  18.     important information about licensing, patent restrictions on
  19.     certain algorithms, trademarks, copyrights, and export controls.
  20.  
  21.     Modified 24 Jun 92 - HAJK
  22.     Misc fixes for VAX C restrictions
  23.  
  24.     Updated by Peter Gutmann to only warn about unrecognized options,
  25.     so future additions to the config file will give old versions a
  26.     chance to still run.  A number of code cleanups, too.  */
  27.  
  28. #include <ctype.h>
  29. #include <string.h>
  30. #include <stdio.h>
  31. #include <stdlib.h>
  32. #include <limits.h>
  33. #include "usuals.h"
  34. #include "fileio.h"
  35. #include "pgp.h"
  36. #include "config.h"
  37. #include "charset.h"
  38.  
  39. /* Various maximum/minimum allowable settings for config options */
  40.  
  41. #define MIN_MARGINALS    1
  42. #define MIN_COMPLETE    1
  43. #define MAX_COMPLETE    4
  44. #define MIN_CERT_DEPTH    0
  45. #define MAX_CERT_DEPTH    8
  46.  
  47. /* Prototypes for local functions */
  48.  
  49. static int lookup( char *key, int keyLength, char *keyWords[], int range );
  50. static int extractToken( char *buffer, int *endIndex, int *length );
  51. static int getaString( char *buffer, int *endIndex );
  52. static int getAssignment( char *buffer, int *endIndex, INPUT_TYPE settingType );
  53. static void processAssignment( int intrinsicIndex );
  54.  
  55. /* The external config variables we can set here are referenced in pgp.h */
  56.  
  57. /* Return values */
  58.  
  59. #define ERROR    -1
  60. #define OK        0
  61.  
  62. /* The types of error we check for */
  63.  
  64. enum { NO_ERROR, ILLEGAL_CHAR_ERROR, LINELENGTH_ERROR };
  65.  
  66. #define CPM_EOF        0x1A    /* ^Z = CPM EOF char */
  67.  
  68. #define MAX_ERRORS    3    /* Max.no.errors before we give up */
  69.  
  70. #define LINEBUF_SIZE    100    /* Size of input buffer */
  71.  
  72. static int line;        /* The line on which an error occurred */
  73. static int errCount;        /* Total error count */
  74. static boolean hasError;    /* Whether this line has an error in it */
  75.  
  76. /* The settings parsed out by getAssignment() */
  77.  
  78. static char str[ LINEBUF_SIZE ];
  79. static int value;
  80. static char *errtag;        /* Prefix for printing error messages */
  81. static char optstr[ 100 ];    /* Option being processed */
  82.  
  83. /* A .CFG file roughly follows the format used in the world-famous HPACK
  84.    archiver and is as follows:
  85.  
  86.     - Leading spaces/tabs (whitespace) are ignored.
  87.  
  88.     - Lines with a '#' as the first non-whitespace character are treated
  89.       as comment lines.
  90.  
  91.     - All other lines are treated as config options for the program.
  92.  
  93.     - Lines may be terminated by either linefeeds, carriage returns, or
  94.       carriage return/linefeed pairs (the latter being the DOS default
  95.       method of storing text files).
  96.  
  97.     - Config options have the form:
  98.  
  99.       <option> '=' <setting>
  100.  
  101.       where <setting> may be 'on', 'off', a numeric value, or a string
  102.       value.
  103.  
  104.     - If strings have spaces or the '#' character inside them they must be
  105.       surrounded by quote marks '"' */
  106.  
  107. /* Intrinsic variables */
  108.  
  109. #define NO_INTRINSICS        (sizeof(intrinsics) / sizeof(intrinsics[0]))
  110. #define CONFIG_INTRINSICS    BATCHMODE
  111.  
  112. enum {
  113.     ARMOR, COMPRESS, SHOWPASS, KEEPBINARY, LANGUAGE,
  114.     MYNAME, TEXTMODE, TMP, TZFIX, VERBOSE, BAKRING,
  115.     ARMORLINES, COMPLETES_NEEDED, MARGINALS_NEEDED, PAGER,
  116.     CERT_DEPTH, CHARSET, CLEAR, SELF_ENCRYPT,
  117.     INTERACTIVE, PUBRING, SECRING, RANDSEED,
  118.     COMMENT,
  119. #ifndef MIT
  120.         LEGAL_KLUDGE,
  121. #endif
  122.     /* options below this line can only be used as command line
  123.      * "long" options */
  124.     BATCHMODE, FORCE, NOMANUAL, MAKERANDOM
  125.     };
  126.  
  127. static char *intrinsics[] = {
  128.     "ARMOR", "COMPRESS", "SHOWPASS", "KEEPBINARY", "LANGUAGE",
  129.     "MYNAME", "TEXTMODE", "TMP", "TZFIX", "VERBOSE", "BAKRING",
  130.     "ARMORLINES", "COMPLETES_NEEDED", "MARGINALS_NEEDED", "PAGER",
  131.     "CERT_DEPTH", "CHARSET", "CLEARSIG", "ENCRYPTTOSELF", 
  132.     "INTERACTIVE", "PUBRING", "SECRING", "RANDSEED",
  133.     "COMMENT",
  134. #ifndef MIT
  135.         "LEGAL_KLUDGE",
  136. #endif
  137.     /* command line only */
  138.     "BATCHMODE", "FORCE", "NOMANUAL", "MAKERANDOM"
  139.     };
  140.  
  141. static INPUT_TYPE intrinsicType[] = {
  142.     BOOL, BOOL, BOOL, BOOL, STRING,
  143.     STRING, BOOL, STRING, NUMERIC, NUMERIC, STRING,
  144.     NUMERIC, NUMERIC, NUMERIC, STRING,
  145.     NUMERIC, STRING, BOOL, BOOL,
  146.     BOOL, STRING, STRING, STRING,
  147.     STRING,
  148. #ifndef MIT
  149.         BOOL,
  150. #endif
  151.     /* command line only */
  152.     BOOL, BOOL, BOOL, NUMERIC
  153.     };
  154.  
  155. /* Possible settings for variables */
  156.  
  157. #define NO_SETTINGS            2
  158.  
  159. static char *settings[] = { "OFF", "ON" };
  160.  
  161. /* Search a list of keywords for a match */
  162.  
  163. static int lookup( char *key, int keyLength, char *keyWords[], int range )
  164. {
  165.     int index, position = 0, noMatches = 0;
  166.  
  167.     strncpy( optstr, key, keyLength );
  168.     optstr[ keyLength ] = '\0';
  169.  
  170.     /* Make the search case insensitive */
  171.     for( index = 0; index < keyLength; index++ )
  172.         key[ index ] = to_upper( key[ index ] );
  173.  
  174.     for( index = 0; index < range; index++ )
  175.         if( !strncmp( key, keyWords[ index ], keyLength ) )
  176.             {
  177.             if( strlen( keyWords[ index ] ) == keyLength )
  178.                 return index;    /* exact match */
  179.             position = index;
  180.             noMatches++;
  181.             }
  182.  
  183.     switch( noMatches )
  184.         {
  185.         case 0:
  186.             fprintf( stderr, "%s: unknown keyword: \"%s\"\n",
  187.                      errtag, optstr );
  188.             break;
  189.         case 1:
  190.             return( position );    /* Match succeeded */
  191.         default:
  192.             fprintf( stderr, "%s: \"%s\" is ambiguous\n",
  193.                      errtag, optstr );
  194.         }
  195.     return ERROR;
  196. }
  197.  
  198. /* Extract a token from a buffer */
  199.  
  200. static int extractToken( char *buffer, int *endIndex, int *length )
  201. {
  202.     int index = 0, tokenStart;
  203.     char ch;
  204.  
  205.     /* Skip whitespace */
  206.     for( ch = buffer[ index ]; ch && ( ch == ' ' || ch == '\t' );
  207.          ch = buffer[ index ] )
  208.         index++;
  209.     tokenStart = index;
  210.  
  211.     /* Find end of setting */
  212.     while( index < LINEBUF_SIZE && ( ch = buffer[ index ] ) != '\0'
  213.            && ch != ' ' && ch != '\t' )
  214.         index++;
  215.     *endIndex += index;
  216.     *length = index - tokenStart;
  217.  
  218.     /* Return start position of token in buffer */
  219.     return tokenStart;
  220. }
  221.  
  222. /* Get a string constant */
  223.  
  224. static int getaString( char *buffer, int *endIndex )
  225.     {
  226.     boolean noQuote = FALSE;
  227.     int stringIndex = 0, bufferIndex = 1;
  228.     char ch = *buffer;
  229.  
  230.     /* Skip whitespace */
  231.     while( ch && ( ch == ' ' || ch == '\t' ) )
  232.         ch = buffer[ bufferIndex++ ];
  233.  
  234.     /* Check for non-string */
  235.     if( ch != '\"' )
  236.         {
  237.         *endIndex += bufferIndex;
  238.  
  239.         /* Check for special case of null string */
  240.         if( !ch )
  241.             {
  242.             *str = '\0';
  243.             return OK;
  244.             }
  245.  
  246.         /* Use nasty non-rigorous string format */
  247.         noQuote = TRUE;
  248.         }
  249.  
  250.     /* Get first char of string */
  251.     if( !noQuote )
  252.         ch = buffer[ bufferIndex++ ];
  253.  
  254.     /* Get string into string */
  255.     while( ch && ch != '\"' )
  256.         {
  257.         /* Exit on '#' if using non-rigorous format */
  258.         if( noQuote && ch == '#' )
  259.             break;
  260.  
  261.         str[ stringIndex++ ] = ch;
  262.         ch = buffer[ bufferIndex++ ];
  263.         }
  264.  
  265.     /* If using the non-rigorous format, stomp trailing spaces */
  266.     if( noQuote )
  267.         while( stringIndex > 0 && str[ stringIndex - 1 ] == ' ' )
  268.             stringIndex--;
  269.  
  270.     str[ stringIndex++ ] = '\0';
  271.     *endIndex += bufferIndex;
  272.  
  273.     /* Check for missing string terminator */
  274.     if( ch != '\"' && !noQuote )
  275.         {
  276.         if( line )
  277.             fprintf( stderr, "%s: unterminated string in line %d\n",
  278.                      errtag, line );
  279.         else
  280.             fprintf( stderr, "unterminated string: '\"%s'\n", str );
  281.         hasError = TRUE;
  282.         errCount++;
  283.         return ERROR;
  284.         }
  285.  
  286.     return OK;
  287. }
  288.  
  289. /* Get an assignment to an intrinsic */
  290.  
  291. static int getAssignment( char *buffer, int *endIndex, INPUT_TYPE settingType )
  292. {
  293.     int settingIndex = 0, length;
  294.     long longval;
  295.     char *p;
  296.  
  297.     buffer += extractToken( buffer, endIndex, &length );
  298.  
  299.     /* Check for an assignment operator */
  300.     if( *buffer != '=' )
  301.         {
  302.         if( line )
  303.             fprintf( stderr, "%s: expected '=' in line %d\n",
  304.                      errtag, line );
  305.         else
  306.             fprintf( stderr, "%s: expected '=' after \"%s\"\n",
  307.                      errtag, optstr);
  308.         hasError = TRUE;
  309.         errCount++;
  310.         return ERROR;
  311.         }
  312.     buffer++;    /* Skip '=' */
  313.  
  314.     buffer += extractToken( buffer, endIndex, &length );
  315.  
  316.     switch( settingType )
  317.         {
  318.         case BOOL:
  319.             /* Check for known intrinsic - really more general
  320.                than just checking for TRUE or FALSE */
  321.             settingIndex = lookup( buffer, length, settings,
  322.                                    NO_SETTINGS );
  323.             if( settingIndex == ERROR )
  324.                 {
  325.                 hasError = TRUE;
  326.                 errCount++;
  327.                 return ERROR;
  328.                 }
  329.  
  330.             value = ( settingIndex == 0 ) ? FALSE : TRUE;
  331.             break;
  332.  
  333.         case STRING:
  334.             /* Get a string */
  335.             getaString( buffer, &length );
  336.             break;
  337.  
  338.         case NUMERIC:
  339.             longval = strtol(buffer, &p, 0);
  340.             if (p == buffer+length &&
  341.                 longval <= INT_MAX && longval >= INT_MIN) {
  342.                 value = (int)longval;
  343.                 break;
  344.             }
  345.             if( line )
  346.                 fprintf( stderr,
  347.                   "%s: numeric argument expected in line %d\n",
  348.                          errtag, line );
  349.             else
  350.                 fprintf( stderr,
  351.                    "%s: numeric argument required for \"%s\"\n",
  352.                          errtag, optstr);
  353.             hasError = TRUE;
  354.             errCount++;
  355.             return ERROR;
  356.         }
  357.  
  358.     return settingIndex;
  359. }
  360.  
  361. /* Process an assignment */
  362.  
  363. static void processAssignment( int intrinsicIndex )
  364.     {
  365.     if( !hasError )
  366.         switch( intrinsicIndex )
  367.             {
  368.             case ARMOR:
  369.                 emit_radix_64 = value;
  370.                 break;
  371.  
  372.             case ARMORLINES:
  373.                 pem_lines = value;
  374.                 break;
  375.  
  376.             case BAKRING:
  377.                 strcpy( floppyring, str );
  378.                 break;
  379.  
  380.             case BATCHMODE:
  381.                 batchmode = value;
  382.                 break;
  383.  
  384.             case CERT_DEPTH:
  385.                 max_cert_depth = value;
  386.                 if( max_cert_depth < MIN_CERT_DEPTH )
  387.                     max_cert_depth = MIN_CERT_DEPTH;
  388.                 if( max_cert_depth > MAX_CERT_DEPTH )
  389.                     max_cert_depth = MAX_CERT_DEPTH;
  390.                 break;
  391.  
  392.             case CHARSET:
  393.                 strcpy( charset, str );
  394.                 break;
  395.  
  396.             case CLEAR:
  397.                 clear_signatures = value;
  398.                 break;
  399.  
  400.             case COMMENT:
  401.                 strcpy( globalCommentString, str );
  402.                 break;
  403.  
  404.             case COMPLETES_NEEDED:
  405.                 compl_min = value;
  406.                 /* Keep within range */
  407.                 if( compl_min < MIN_COMPLETE )
  408.                     compl_min = MIN_COMPLETE;
  409.                 if( compl_min > MAX_COMPLETE )
  410.                     compl_min = MAX_COMPLETE;
  411.                 break;
  412.  
  413.             case COMPRESS:
  414.                 compress_enabled = value;
  415.                 break;
  416.  
  417.             case FORCE:
  418.                 force_flag = value;
  419.                 break;
  420.  
  421.             case INTERACTIVE:
  422.                 interactive_add = value;
  423.                 break;
  424.  
  425.             case KEEPBINARY:
  426.                 keepctx = value;
  427.                 break;
  428.  
  429.             case LANGUAGE:
  430.                 strncpy( language, str, 15 );
  431.                 break;
  432.  
  433. #ifndef MIT
  434.             case LEGAL_KLUDGE:
  435.                 if (!value)
  436.                     version_byte = VERSION_BYTE_OLD;
  437.                 break;
  438. #endif
  439.  
  440.             case MAKERANDOM:
  441.                 makerandom = value;
  442.                 break;
  443.  
  444.             case MARGINALS_NEEDED:
  445.                 marg_min = value;
  446.                 /* Keep within range */
  447.                 if( marg_min < MIN_MARGINALS )
  448.                     marg_min = MIN_MARGINALS;
  449.                 break;
  450.  
  451.             case MYNAME:
  452.                 strcpy( my_name, str );
  453.                 break;
  454.  
  455.             case NOMANUAL:
  456.                 nomanual = value;
  457.                 break;
  458.  
  459.             case PAGER:
  460.                 strcpy( pager, str );
  461.                 break;
  462.  
  463.             case PUBRING:
  464.                 strcpy( globalPubringName, str );
  465.                 break;
  466.  
  467.             case RANDSEED:
  468.                 strcpy( globalRandseedName, str );
  469.                 break;
  470.  
  471.             case SECRING:
  472.                 strcpy( globalSecringName, str );
  473.                 break;
  474.  
  475.             case SELF_ENCRYPT:
  476.                 encrypt_to_self = value;
  477.                 break;
  478.  
  479.             case SHOWPASS:
  480.                 showpass = value;
  481.                 break;
  482.  
  483.             case TEXTMODE:
  484.                 if( value )
  485.                     literal_mode = MODE_TEXT;
  486.                 else
  487.                     literal_mode = MODE_BINARY;
  488.                 break;
  489.  
  490.             case TMP:
  491.                 /* directory pathname to store temp files */
  492.                 settmpdir( str );
  493.                 break;
  494.  
  495.             case TZFIX:
  496.                 /* How many hours to add to time() to get GMT.
  497.                    We just compute the seconds from hours to
  498.                    get the GMT shift */
  499.                 timeshift = 3600L * ( long ) value;
  500.                 break;
  501.  
  502.             case VERBOSE:
  503.                 if( value < 1 )
  504.                     {
  505.                     quietmode = TRUE;
  506.                     verbose = FALSE;
  507.                     }
  508.                 else
  509.                     if( value == 1 )
  510.                         {
  511.                         quietmode = FALSE;
  512.                         verbose = FALSE;
  513.                         }
  514.                     else
  515.                         {
  516.                         /* Value > 1 */
  517.                         quietmode = FALSE;
  518.                         verbose = TRUE;
  519.                         }
  520.                 break;
  521.  
  522.             }
  523. }
  524.  
  525. /* Process an option on a line by itself.  This expects options which are
  526.    taken from the command-line, and is less finicky about errors than the
  527.    config-file version */
  528.  
  529. int processConfigLine( char *option )
  530. {
  531.     int index, intrinsicIndex;
  532.     char ch;
  533.  
  534.     /* Give it a pseudo-linenumber of 0 */
  535.     line = 0;
  536.  
  537.     errtag = "pgp";
  538.     errCount = 0;
  539.     for( index = 0;
  540.          index < LINEBUF_SIZE && ( ch = option[ index ] ) != '\0' &&
  541.                 ch != ' ' && ch != '\t' && ch != '=';
  542.          index++ );
  543.     if( ( intrinsicIndex = lookup( ( char * ) option, index, intrinsics,
  544.                       NO_INTRINSICS ) ) == ERROR )
  545.         return -1;
  546.     if( option[ index ] == '\0' && intrinsicType[ intrinsicIndex ] == BOOL)
  547.         {
  548.         /* Boolean option, no '=' means TRUE */
  549.         value = TRUE;
  550.         processAssignment( intrinsicIndex );
  551.         }
  552.     else
  553.         /* Get the value to set to, either as a string, a numeric
  554.            value, or a boolean flag */
  555.         if( getAssignment( ( char * ) option + index,
  556.                &index, intrinsicType[ intrinsicIndex ] ) != ERROR )
  557.             processAssignment( intrinsicIndex );
  558.  
  559.     return errCount ? -1 : 0;
  560. }
  561.  
  562. /* Process a configuration file */
  563.  
  564. int processConfigFile( char *configFileName )
  565. {
  566.     FILE *configFilePtr;
  567.     int ch = 0, theChar;
  568.     int errType, errPos = 0, lineBufCount, intrinsicIndex;
  569.     int index;
  570.     char inBuffer[ LINEBUF_SIZE ];
  571.  
  572.     line = 1;
  573.     errCount = 0;
  574.     errtag = file_tail( configFileName );
  575.  
  576.     if( ( configFilePtr = fopen( configFileName, FOPRTXT ) ) == NULL )
  577.         {
  578.         fprintf( stderr, "Cannot open configuration file %s\n",
  579.                  configFileName );
  580.         return OK;    /* Treat it as if it were an empty file */
  581.         }
  582.  
  583.     /* Process each line in the configFile */
  584.     while( ch != EOF )
  585.         {
  586.         /* Skip whitespace */
  587.         while( ( ( ch = getc( configFilePtr ) ) == ' ' || ch == '\t' )
  588.               && ch != EOF )
  589.             ;
  590.  
  591.         /* Get a line into the inBuffer */
  592.         hasError = FALSE;
  593.         lineBufCount = 0;
  594.         errType = NO_ERROR;
  595.         while( ch != '\r' && ch != '\n' && ch != CPM_EOF && ch != EOF )
  596.             {
  597.             /* Check for an illegal char in the data */
  598.             if( ( ch < ' ' || ch > '~' ) &&
  599.                   ch != '\r' && ch != '\n' &&
  600.                   ch != ' ' && ch != '\t' && ch != CPM_EOF &&
  601.                   ch != EOF )
  602.                 {
  603.                 if( errType == NO_ERROR )
  604.                     /* Save pos of first illegal char */
  605.                     errPos = lineBufCount;
  606.                 errType = ILLEGAL_CHAR_ERROR;
  607.                 }
  608.  
  609.             /* Make sure the path is of the correct length.  Note
  610.                that the code is ordered so that a LINELENGTH_ERROR
  611.                takes precedence over an ILLEGAL_CHAR_ERROR */
  612.             if( lineBufCount > LINEBUF_SIZE )
  613.                 errType = LINELENGTH_ERROR;
  614.             else
  615.                 inBuffer[ lineBufCount++ ] = ch;
  616.  
  617.             if( ( ch = getc( configFilePtr ) ) == '#' )
  618.                 {
  619.                 /* Skip comment section and trailing
  620.                    whitespace */
  621.                 while( ch != '\r' && ch != '\n' &&
  622.                        ch != CPM_EOF && ch != EOF )
  623.                   ch = getc( configFilePtr );
  624.                 break;
  625.                 }
  626.             }
  627.  
  628.         /* Skip trailing whitespace and add der terminador */
  629.         while( lineBufCount &&
  630.                ( ( theChar = inBuffer[ lineBufCount - 1 ] ) == ' ' ||
  631.                theChar == '\t' ) )
  632.           lineBufCount--;
  633.         inBuffer[ lineBufCount ] = '\0';
  634.  
  635.         /* Process the line unless its a blank or comment line */
  636.         if( lineBufCount && *inBuffer != '#' )
  637.             {
  638.             switch( errType )
  639.                 {
  640.                 case LINELENGTH_ERROR:
  641.                     fprintf( stderr,
  642.                         "%s: line '%.30s...' too long\n",
  643.                              errtag, inBuffer );
  644.                     errCount++;
  645.                     break;
  646.  
  647.                 case ILLEGAL_CHAR_ERROR:
  648.                     fprintf( stderr, "> %s\n  ", inBuffer );
  649.                     fprintf( stderr, "%*s^\n", errPos, "" );
  650.                     fprintf( stderr,
  651.                     "%s: bad character in command on line %d\n",
  652.                              errtag, line );
  653.                     errCount++;
  654.                     break;
  655.  
  656.                 default:
  657.                     for( index = 0;
  658.                          index < LINEBUF_SIZE &&
  659.                          ( ch = inBuffer[ index ] ) != '\0'
  660.                          && ch != ' ' && ch != '\t'
  661.                          && ch != '=';
  662.                          index++ )
  663.                         /*Do nothing*/ ;
  664.  
  665.                     /* Try and find the intrinsic.  We
  666.                        don't treat unknown intrinsics as
  667.                        an error to allow older versions to
  668.                        be used with new config files */
  669.                     intrinsicIndex = lookup(inBuffer,
  670.                         index, intrinsics,
  671.                         CONFIG_INTRINSICS );
  672.                 
  673.                     if( intrinsicIndex == ERROR )
  674.                         break;
  675.  
  676.                     /* Get the value to set to, either as
  677.                        a string, a numeric value, or a
  678.                        boolean flag */
  679.                     getAssignment( inBuffer + index, &index,
  680.                          intrinsicType[ intrinsicIndex ] );
  681.                     processAssignment( intrinsicIndex );
  682.                     break;
  683.                 }
  684.             }
  685.  
  686.         /* Handle special-case of ^Z if configFile came off an
  687.            MSDOS system */
  688.         if( ch == CPM_EOF )
  689.             ch = EOF;
  690.  
  691.         /* Exit if there are too many errors */
  692.         if( errCount >= MAX_ERRORS )
  693.             break;
  694.  
  695.         line++;
  696.         }
  697.  
  698.     fclose( configFilePtr );
  699.  
  700.     /* Exit if there were errors */
  701.     if( errCount )
  702.         {
  703.         fprintf( stderr, "%s: %s%d error(s) detected\n\n",
  704.                  configFileName, ( errCount >= MAX_ERRORS ) ?
  705.                  "Maximum level of " : "", errCount );
  706.         return ERROR;
  707.         }
  708.  
  709.     return OK;
  710. }
  711.