--- pgp/src/config.c 2018/04/24 16:39:27 1.1.1.3 +++ pgp/src/config.c 2018/04/24 16:41:09 1.1.1.5 @@ -1,556 +1,587 @@ -/* config.c - config file parser by Peter Gutmann - Parses config file for PGP - - Modified 24 Jun 92 - HAJK - Misc fixes for VAX C restrictions. - -*/ - -#include -#include -#include -#include -#include "usuals.h" -#include "fileio.h" -#include "pgp.h" -#include "config.h" -#include "charset.h" - -static int lookup( char *key, int keyLength, char *keyWords[], int range ); -static int extractToken( char *buffer, int *endIndex, int *length ); -static int getaString( char *buffer, int *endIndex ); -static int getAssignment( char *buffer, int *endIndex, INPUT_TYPE settingType ); -static void processAssignment( int intrinsicIndex ); - -/* The external config variables we can set here are referenced in pgp.h */ - -/* Return values */ - -#define ERROR -1 -#define OK 0 - -/* The types of error we check for */ - -enum { NO_ERROR, ILLEGAL_CHAR_ERROR, LINELENGTH_ERROR }; - -#define CPM_EOF 0x1A /* ^Z = CPM EOF char */ - -#define MAX_ERRORS 3 /* Max.no.errors before we give up */ - -#define LINEBUF_SIZE 100 /* Size of input buffer */ - -static int line; /* The line on which an error occurred */ -static int errCount; /* Total error count */ -static boolean hasError; /* Whether this line has an error in it */ - -/* The settings parsed out by getAssignment() */ - -static char str[ LINEBUF_SIZE ]; -static int value; -static boolean flag; -static char *errtag; /* prefix for printing error messages */ -static char optstr[100]; /* option being processed */ - -/* A .CFG file roughly follows the format used in the world-famous HPACK - archiver and is as follows: - - - Leading spaces/tabs (whitespace) are ignored. - - - Lines with a '#' as the first non-whitespace character are treated as - comment lines. - - - All other lines are treated as config options for the program. - - - Lines may be terminated by either linefeeds, carriage returns, or - carriage return/linefeed pairs (the latter being the DOS default method - of storing text files). - - - Config options have the form: - -