--- pgp/src/config.c 2018/04/24 16:44:43 1.1.1.8 +++ pgp/src/config.c 2018/04/24 16:45:38 1.1.1.9 @@ -1,694 +1,750 @@ -/* config.c - config file parser by Peter Gutmann - Parses config file for PGP - - (c) Copyright 1990-1994 by Philip Zimmermann. All rights reserved. - The author assumes no liability for damages resulting from the use - of this software, even if the damage results from defects in this - software. No warranty is expressed or implied. - - Note that while most PGP source modules bear Philip Zimmermann's - copyright notice, many of them have been revised or entirely written - by contributors who frequently failed to put their names in their - code. Code that has been incorporated into PGP from other authors - was either originally published in the public domain or is used with - permission from the various authors. - - PGP is available for free to the public under certain restrictions. - See the PGP User's Guide (included in the release package) for - important information about licensing, patent restrictions on - certain algorithms, trademarks, copyrights, and export controls. - - Modified 24 Jun 92 - HAJK - Misc fixes for VAX C restrictions - - Updated by Peter Gutmann to only warn about unrecognized options, - so future additions to the config file will give old versions a - chance to still run. A number of code cleanups, too. */ - -#include -#include -#include -#include -#include -#include "usuals.h" -#include "fileio.h" -#include "pgp.h" -#include "config.h" -#include "charset.h" - -/* Various maximum/minimum allowable settings for config options */ - -#define MIN_MARGINALS 1 -#define MIN_COMPLETE 1 -#define MAX_COMPLETE 4 -#define MIN_CERT_DEPTH 0 -#define MAX_CERT_DEPTH 8 - -/* Prototypes for local functions */ - -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 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: - -