From: Harlan Stenn Date: Sat, 12 May 2007 19:03:30 +0000 (-0400) Subject: The commandline args for clktest are different for CLKLDISC and STREAM X-Git-Tag: NTP_4_2_5P30~2^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85a0bfec60d00efed719f1d1b3ceb06272873961;p=thirdparty%2Fntp.git The commandline args for clktest are different for CLKLDISC and STREAM bk: 46460f82WaovOU05OPfeUl3sog5KGQ --- diff --git a/clockstuff/clktest-opts.def b/clockstuff/clktest-opts.def index 32567bcba..2960f0f18 100644 --- a/clockstuff/clktest-opts.def +++ b/clockstuff/clktest-opts.def @@ -50,6 +50,7 @@ export = <<- _EOExport_ #endif _EOExport_; +#ifdef CLKLDISC flag = { name = magic2; value = a; @@ -75,7 +76,9 @@ flag = { Or maybe the kill or maybe something else. _EndOfDoc_; }; +#endif CLKLDISC +#ifdef STREAM extern = <<- _EOExtern_ #ifdef STREAM extern char magic[32]; @@ -109,6 +112,7 @@ flag = { } _EOCode_; }; +#endif include = 'extern int speed;'; flag = { diff --git a/libopts/Makefile.am b/libopts/Makefile.am index dfcfb4653..5f1386144 100644 --- a/libopts/Makefile.am +++ b/libopts/Makefile.am @@ -7,7 +7,7 @@ noinst_LTLIBRARIES = libopts.la endif libopts_la_SOURCES = libopts.c libopts_la_CPPFLAGS = -I$(top_srcdir) -libopts_la_LDFLAGS = -version-info 28:0:3 +libopts_la_LDFLAGS = -version-info 29:0:4 EXTRA_DIST = \ COPYING.lgpl COPYING.mbsd MakeDefs.inc \ README autoopts/options.h autoopts/usage-txt.h \ diff --git a/libopts/README b/libopts/README index 7f426fa97..7cbe0b044 100644 --- a/libopts/README +++ b/libopts/README @@ -85,7 +85,7 @@ will need to hand craft the rules for building the library. LICENSING: -This material is copyright 1993-2006 by Bruce Korb. +This material is copyright 1993-2007 by Bruce Korb. You are licensed to use this under the terms of either the GNU Lesser General Public License (see: COPYING.lgpl), or, at your option, the modified Berkeley Software Distribution diff --git a/libopts/autoopts.c b/libopts/autoopts.c index 28f93f1c7..139841bbb 100644 --- a/libopts/autoopts.c +++ b/libopts/autoopts.c @@ -1,7 +1,7 @@ /* - * $Id: autoopts.c,v 4.23 2007/02/13 19:43:46 bkorb Exp $ - * Time-stamp: "2007-02-13 11:26:59 bkorb" + * $Id: autoopts.c,v 4.25 2007/04/15 19:01:18 bkorb Exp $ + * Time-stamp: "2007-04-15 11:10:40 bkorb" * * This file contains all of the routines that must be linked into * an executable to use the generated option processing. The optional @@ -54,9 +54,6 @@ static char const zNil[] = ""; -#define SKIP_RC_FILES(po) \ - DISABLED_OPT(&((po)->pOptDesc[ (po)->specOptIdx.save_opts+1])) - /* = = = START-STATIC-FORWARD = = = */ /* static forward declarations maintained by :mkfwd */ static tSuccess @@ -697,7 +694,7 @@ nextOption( tOptions* pOpts, tOptState* pOptState ) case TOPT_DEFAULT: fputs( "AutoOpts lib error: defaulted to option with optional arg\n", stderr ); - exit( EXIT_FAILURE ); + exit( EX_SOFTWARE ); } /* @@ -830,9 +827,22 @@ doRegularOpts( tOptions* pOpts ) static tSuccess doPresets( tOptions* pOpts ) { + tOptDesc * pOD = NULL; + if (! SUCCESSFUL( doImmediateOpts( pOpts ))) return FAILURE; + /* + * IF this option set has a --save-opts option, then it also + * has a --load-opts option. See if a command line option has disabled + * option presetting. + */ + if (pOpts->specOptIdx.save_opts != 0) { + pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts + 1; + if (DISABLED_OPT(pOD)) + return SUCCESS; + } + /* * Until we return from this procedure, disable non-presettable opts */ @@ -841,13 +851,22 @@ doPresets( tOptions* pOpts ) * IF there are no config files, * THEN do any environment presets and leave. */ - if ( (pOpts->papzHomeList == NULL) - || SKIP_RC_FILES(pOpts) ) { + if (pOpts->papzHomeList == NULL) { doEnvPresets( pOpts, ENV_ALL ); } else { doEnvPresets( pOpts, ENV_IMM ); - internalFileLoad( pOpts ); + + /* + * Check to see if environment variables have disabled presetting. + */ + if ((pOD != NULL) && ! DISABLED_OPT(pOD)) + internalFileLoad( pOpts ); + + /* + * ${PROGRAM_LOAD_OPTS} value of "no" cannot disable other environment + * variable options. Only the loading of .rc files. + */ doEnvPresets( pOpts, ENV_NON_IMM ); } pOpts->fOptSet &= ~OPTPROC_PRESETTING; @@ -1031,7 +1050,7 @@ optionProcess( char** argVect ) { if (! SUCCESSFUL( validateOptionsStruct( pOpts, argVect[0] ))) - exit( EXIT_FAILURE ); + exit( EX_SOFTWARE ); /* * Establish the real program name, the program full path, diff --git a/libopts/autoopts.h b/libopts/autoopts.h index f2ac93e9a..2645757ea 100644 --- a/libopts/autoopts.h +++ b/libopts/autoopts.h @@ -1,8 +1,8 @@ /* - * Time-stamp: "2007-01-17 16:37:34 bkorb" + * Time-stamp: "2007-04-15 09:59:39 bkorb" * - * autoopts.h $Id: autoopts.h,v 4.22 2007/02/04 17:44:12 bkorb Exp $ + * autoopts.h $Id: autoopts.h,v 4.23 2007/04/15 19:01:18 bkorb Exp $ * Time-stamp: "2005-02-14 05:59:50 bkorb" * * This file defines all the global structures and special values @@ -57,19 +57,19 @@ #include "compat/compat.h" -#define AO_NAME_LIMIT 127 -#define AO_NAME_SIZE ((size_t)(AO_NAME_LIMIT + 1)) +#define AO_NAME_LIMIT 127 +#define AO_NAME_SIZE ((size_t)(AO_NAME_LIMIT + 1)) #ifndef AG_PATH_MAX # ifdef PATH_MAX -# define AG_PATH_MAX ((size_t)PATH_MAX) +# define AG_PATH_MAX ((size_t)PATH_MAX) # else -# define AG_PATH_MAX ((size_t)4096) +# define AG_PATH_MAX ((size_t)4096) # endif #else # if defined(PATH_MAX) && (PATH_MAX > MAXPATHLEN) # undef AG_PATH_MAX -# define AG_PATH_MAX ((size_t)PATH_MAX) +# define AG_PATH_MAX ((size_t)PATH_MAX) # endif #endif @@ -77,15 +77,25 @@ #define EXPORT #if defined(_WIN32) && !defined(__CYGWIN__) -# define DIRCH '\\' +# define DIRCH '\\' #else -# define DIRCH '/' +# define DIRCH '/' +#endif + +#ifndef EX_NOINPUT +# define EX_NOINPUT 66 +#endif +#ifndef EX_SOFTWARE +# define EX_SOFTWARE 70 +#endif +#ifndef EX_CONFIG +# define EX_CONFIG 78 #endif /* * Convert the number to a list usable in a printf call */ -#define NUM_TO_VER(n) ((n) >> 12), ((n) >> 7) & 0x001F, (n) & 0x007F +#define NUM_TO_VER(n) ((n) >> 12), ((n) >> 7) & 0x001F, (n) & 0x007F #define NAMED_OPTS(po) \ (((po)->fOptSet & (OPTPROC_SHORTOPT | OPTPROC_LONGOPT)) == 0) @@ -93,14 +103,14 @@ #define SKIP_OPT(p) (((p)->fOptState & (OPTST_DOCUMENT|OPTST_OMITTED)) != 0) typedef int tDirection; -#define DIRECTION_PRESET -1 -#define DIRECTION_PROCESS 1 -#define DIRECTION_CALLED 0 +#define DIRECTION_PRESET -1 +#define DIRECTION_PROCESS 1 +#define DIRECTION_CALLED 0 -#define PROCESSING(d) ((d)>0) -#define PRESETTING(d) ((d)<0) +#define PROCESSING(d) ((d)>0) +#define PRESETTING(d) ((d)<0) -#define ISNAMECHAR( c ) (isalnum(c) || ((c) == '_') || ((c) == '-')) +#define ISNAMECHAR( c ) (isalnum(c) || ((c) == '_') || ((c) == '-')) /* * Procedure success codes @@ -119,16 +129,16 @@ typedef int tDirection; #undef FAILED #undef HADGLITCH -#define SUCCESS ((tSuccess) 0) -#define FAILURE ((tSuccess)-1) -#define PROBLEM ((tSuccess) 1) +#define SUCCESS ((tSuccess) 0) +#define FAILURE ((tSuccess)-1) +#define PROBLEM ((tSuccess) 1) typedef int tSuccess; -#define SUCCEEDED( p ) ((p) == SUCCESS) -#define SUCCESSFUL( p ) SUCCEEDED( p ) -#define FAILED( p ) ((p) < SUCCESS) -#define HADGLITCH( p ) ((p) > SUCCESS) +#define SUCCEEDED( p ) ((p) == SUCCESS) +#define SUCCESSFUL( p ) SUCCEEDED( p ) +#define FAILED( p ) ((p) < SUCCESS) +#define HADGLITCH( p ) ((p) > SUCCESS) /* * When loading a line (or block) of text as an option, the value can @@ -224,10 +234,10 @@ typedef struct { tCC* pzOptFmt; } arg_types_t; -#define AGALOC( c, w ) ao_malloc((size_t)c) -#define AGREALOC( p, c, w ) ao_realloc((void*)p, (size_t)c) -#define AGFREE( p ) ao_free((void*)p) -#define AGDUPSTR( p, s, w ) (p = ao_strdup(s)) +#define AGALOC( c, w ) ao_malloc((size_t)c) +#define AGREALOC( p, c, w ) ao_realloc((void*)p, (size_t)c) +#define AGFREE( p ) ao_free((void*)p) +#define AGDUPSTR( p, s, w ) (p = ao_strdup(s)) static void * ao_malloc( size_t sz ); @@ -324,26 +334,26 @@ ao_strdup( char const *str ); # include #else # ifndef PROT_READ -# define PROT_READ 0x01 +# define PROT_READ 0x01 # endif # ifndef PROT_WRITE -# define PROT_WRITE 0x02 +# define PROT_WRITE 0x02 # endif # ifndef MAP_SHARED -# define MAP_SHARED 0x01 +# define MAP_SHARED 0x01 # endif # ifndef MAP_PRIVATE -# define MAP_PRIVATE 0x02 +# define MAP_PRIVATE 0x02 # endif #endif #ifndef MAP_FAILED -# define MAP_FAILED ((void*)-1) +# define MAP_FAILED ((void*)-1) #endif #ifndef _SC_PAGESIZE # ifdef _SC_PAGE_SIZE -# define _SC_PAGESIZE _SC_PAGE_SIZE +# define _SC_PAGESIZE _SC_PAGE_SIZE # endif #endif diff --git a/libopts/autoopts/options.h b/libopts/autoopts/options.h index db97c72d3..c2ceeb3db 100644 --- a/libopts/autoopts/options.h +++ b/libopts/autoopts/options.h @@ -2,7 +2,7 @@ * * DO NOT EDIT THIS FILE (options.h) * - * It has been AutoGen-ed Saturday February 17, 2007 at 12:49:35 PM PST + * It has been AutoGen-ed Saturday May 5, 2007 at 12:02:34 PM PDT * From the definitions funcs.def * and the template file options_h * @@ -43,6 +43,14 @@ # include #endif /* HAVE_LIMITS/SYS_LIMITS_H */ +#if defined(HAVE_SYSEXITS_H) +# include +#endif /* HAVE_SYSEXITS_H */ + +#ifndef EX_USAGE +# define EX_USAGE 64 +#endif + /* * PUBLIC DEFINES * @@ -60,8 +68,8 @@ * values for "opt_name" are available. */ -#define OPTIONS_STRUCT_VERSION 114688 -#define OPTIONS_VERSION_STRING "28:0:3" +#define OPTIONS_STRUCT_VERSION 118784 +#define OPTIONS_VERSION_STRING "29:0:4" #define OPTIONS_MINIMUM_VERSION 102400 #define OPTIONS_MIN_VER_STRING "25:0:0" @@ -92,28 +100,28 @@ typedef struct optionValue { * Bits in the fOptState option descriptor field. */ typedef enum { - OPTST_SET_ID = 0, /* Set via the "SET_OPT()" macro */ - OPTST_PRESET_ID = 1, /* Set via an RC/INI file */ - OPTST_DEFINED_ID = 2, /* Set via a command line option */ - OPTST_EQUIVALENCE_ID = 4, /* selected by equiv'ed option */ - OPTST_DISABLED_ID = 5, /* option is in disabled state */ - OPTST_ALLOC_ARG_ID = 6, /* pzOptArg was allocated */ - OPTST_NO_INIT_ID = 8, /* option cannot be preset */ - OPTST_NUMBER_OPT_ID = 9, /* opt value (flag) is any digit */ - OPTST_STACKED_ID = 10, /* opt uses optionStackArg proc */ - OPTST_INITENABLED_ID = 11, /* option defaults to enabled */ - OPTST_ARG_TYPE_1_ID = 12, /* bit 1 of arg type enum */ - OPTST_ARG_TYPE_2_ID = 13, /* bit 2 of arg type enum */ - OPTST_ARG_TYPE_3_ID = 14, /* bit 3 of arg type enum */ - OPTST_ARG_TYPE_4_ID = 15, /* bit 4 of arg type enum */ - OPTST_ARG_OPTIONAL_ID = 16, /* the option arg not required */ - OPTST_IMM_ID = 17, /* process opt on first pass */ - OPTST_DISABLE_IMM_ID = 18, /* process disablement immed. */ - OPTST_OMITTED_ID = 19, /* compiled out of program */ - OPTST_MUST_SET_ID = 20, /* must be set or pre-set */ - OPTST_DOCUMENT_ID = 21, /* opt is for doc only */ - OPTST_TWICE_ID = 22, /* process opt twice - imm + reg */ - OPTST_DISABLE_TWICE_ID = 23 /* process disabled option twice */ + OPTST_SET_ID = 0, /* Set via the "SET_OPT()" macro */ + OPTST_PRESET_ID = 1, /* Set via an RC/INI file */ + OPTST_DEFINED_ID = 2, /* Set via a command line option */ + OPTST_EQUIVALENCE_ID = 4, /* selected by equiv'ed option */ + OPTST_DISABLED_ID = 5, /* option is in disabled state */ + OPTST_ALLOC_ARG_ID = 6, /* pzOptArg was allocated */ + OPTST_NO_INIT_ID = 8, /* option cannot be preset */ + OPTST_NUMBER_OPT_ID = 9, /* opt value (flag) is any digit */ + OPTST_STACKED_ID = 10, /* opt uses optionStackArg proc */ + OPTST_INITENABLED_ID = 11, /* option defaults to enabled */ + OPTST_ARG_TYPE_1_ID = 12, /* bit 1 of arg type enum */ + OPTST_ARG_TYPE_2_ID = 13, /* bit 2 of arg type enum */ + OPTST_ARG_TYPE_3_ID = 14, /* bit 3 of arg type enum */ + OPTST_ARG_TYPE_4_ID = 15, /* bit 4 of arg type enum */ + OPTST_ARG_OPTIONAL_ID = 16, /* the option arg not required */ + OPTST_IMM_ID = 17, /* process opt on first pass */ + OPTST_DISABLE_IMM_ID = 18, /* process disablement immed. */ + OPTST_OMITTED_ID = 19, /* compiled out of program */ + OPTST_MUST_SET_ID = 20, /* must be set or pre-set */ + OPTST_DOCUMENT_ID = 21, /* opt is for doc only */ + OPTST_TWICE_ID = 22, /* process opt twice - imm + reg */ + OPTST_DISABLE_TWICE_ID = 23 /* process disabled option twice */ } opt_state_enum_t; #define OPTST_INIT 0U @@ -164,6 +172,11 @@ typedef enum { OPTST_ARG_TYPE_3 | \ OPTST_ARG_TYPE_4 ) +#ifdef NO_OPTIONAL_OPT_ARGS +# undef OPTST_ARG_OPTIONAL +# define OPTST_ARG_OPTIONAL 0 +#endif + #define OPTST_PERSISTENT_MASK (~OPTST_MUTABLE_MASK) #define SELECTED_OPT( pod ) ((pod)->fOptState & OPTST_SELECTED_MASK) @@ -186,22 +199,22 @@ typedef enum { * Define the processing state flags */ typedef enum { - OPTPROC_LONGOPT_ID = 0, /* Process long style options */ - OPTPROC_SHORTOPT_ID = 1, /* Process short style "flags" */ - OPTPROC_ERRSTOP_ID = 2, /* Stop on argument errors */ - OPTPROC_DISABLEDOPT_ID = 3, /* Current option is disabled */ - OPTPROC_NO_REQ_OPT_ID = 4, /* no options are required */ - OPTPROC_NUM_OPT_ID = 5, /* there is a number option */ - OPTPROC_INITDONE_ID = 6, /* have initializations been done? */ - OPTPROC_NEGATIONS_ID = 7, /* any negation options? */ - OPTPROC_ENVIRON_ID = 8, /* check environment? */ - OPTPROC_NO_ARGS_ID = 9, /* Disallow remaining arguments */ - OPTPROC_ARGS_REQ_ID = 10, /* Require arguments after options */ - OPTPROC_REORDER_ID = 11, /* reorder operands after options */ - OPTPROC_GNUUSAGE_ID = 12, /* emit usage in GNU style */ - OPTPROC_TRANSLATE_ID = 13, /* Translate strings in tOptions */ - OPTPROC_HAS_IMMED_ID = 14, /* program defines immed options */ - OPTPROC_PRESETTING_ID = 19 /* opt processing in preset state */ + OPTPROC_LONGOPT_ID = 0, /* Process long style options */ + OPTPROC_SHORTOPT_ID = 1, /* Process short style "flags" */ + OPTPROC_ERRSTOP_ID = 2, /* Stop on argument errors */ + OPTPROC_DISABLEDOPT_ID = 3, /* Current option is disabled */ + OPTPROC_NO_REQ_OPT_ID = 4, /* no options are required */ + OPTPROC_NUM_OPT_ID = 5, /* there is a number option */ + OPTPROC_INITDONE_ID = 6, /* have initializations been done? */ + OPTPROC_NEGATIONS_ID = 7, /* any negation options? */ + OPTPROC_ENVIRON_ID = 8, /* check environment? */ + OPTPROC_NO_ARGS_ID = 9, /* Disallow remaining arguments */ + OPTPROC_ARGS_REQ_ID = 10, /* Require arguments after options */ + OPTPROC_REORDER_ID = 11, /* reorder operands after options */ + OPTPROC_GNUUSAGE_ID = 12, /* emit usage in GNU style */ + OPTPROC_TRANSLATE_ID = 13, /* Translate strings in tOptions */ + OPTPROC_HAS_IMMED_ID = 14, /* program defines immed options */ + OPTPROC_PRESETTING_ID = 19 /* opt processing in preset state */ } optproc_state_enum_t; #define OPTPROC_NONE 0U @@ -350,7 +363,7 @@ struct optSpecIndex { typedef void (tOptionXlateProc)(void); struct options { - const int structVersion; + int const structVersion; int origArgCt; char** origArgVect; unsigned int fOptSet; @@ -364,7 +377,7 @@ struct options { char const* const pzCopyright; char const* const pzCopyNotice; char const* const pzFullVersion; - char const* const* papzHomeList; + char const* const* const papzHomeList; char const* const pzUsageTitle; char const* const pzExplain; char const* const pzDetail; @@ -378,8 +391,8 @@ struct options { tOptionXlateProc* pTransProc; tOptSpecIndex specOptIdx; - const int optCt; - const int presetOptCt; + int const optCt; + int const presetOptCt; }; /* @@ -498,7 +511,7 @@ extern token_list_t* ao_string_tokenize( char const* ); extern const tOptionValue* configFileLoad( char const* ); -/* From: configfile.c line 880 +/* From: configfile.c line 883 * * optionFileLoad - Load the locatable config files, in order * @@ -653,7 +666,7 @@ extern const tOptionValue* optionNextValue( const tOptionValue*, const tOptionVa extern void optionOnlyUsage( tOptions*, int ); -/* From: autoopts.c line 993 +/* From: autoopts.c line 1012 * * optionProcess - this is the main option processing routine * diff --git a/libopts/autoopts/usage-txt.h b/libopts/autoopts/usage-txt.h index 57fc2603a..5aaaa01a6 100644 --- a/libopts/autoopts/usage-txt.h +++ b/libopts/autoopts/usage-txt.h @@ -2,7 +2,7 @@ * * DO NOT EDIT THIS FILE (usage-txt.h) * - * It has been AutoGen-ed Saturday February 17, 2007 at 12:49:33 PM PST + * It has been AutoGen-ed Saturday May 5, 2007 at 12:02:33 PM PDT * From the definitions usage-txt.def * and the template file usage-txt.tpl * diff --git a/libopts/compat/compat.h b/libopts/compat/compat.h index 86fff8e27..b3bd58ff4 100644 --- a/libopts/compat/compat.h +++ b/libopts/compat/compat.h @@ -7,7 +7,7 @@ * Author: Gary V Vaughan * Created: Mon Jun 30 15:54:46 1997 * - * $Id: compat.h,v 4.15 2007/02/04 22:17:39 bkorb Exp $ + * $Id: compat.h,v 4.16 2007/04/27 01:10:47 bkorb Exp $ */ #ifndef COMPAT_H_GUARD #define COMPAT_H_GUARD 1 @@ -199,6 +199,11 @@ # define MAXPATHLEN PATH_MAX #endif /* !MAXPATHLEN && PATH_MAX */ +#if !defined (MAXPATHLEN) && defined(_MAX_PATH) +# define PATH_MAX _MAX_PATH +# define MAXPATHLEN _MAX_PATH +#endif + #if !defined (MAXPATHLEN) # define MAXPATHLEN ((size_t)4096) #endif /* MAXPATHLEN */ diff --git a/libopts/compat/windows-config.h b/libopts/compat/windows-config.h index d4f3d2a82..2612980bf 100644 --- a/libopts/compat/windows-config.h +++ b/libopts/compat/windows-config.h @@ -2,7 +2,7 @@ /* * Time-stamp: "2006-10-14 14:55:09 bkorb" * by: bkorb - * Last Committed: $Date: 2006/10/14 22:39:49 $ + * Last Committed: $Date: 2007/04/28 22:19:23 $ */ #ifndef WINDOWS_CONFIG_HACKERY #define WINDOWS_CONFIG_HACKERY 1 @@ -92,6 +92,7 @@ typedef unsigned long uintptr_t; /* Include Windows headers */ #include #include +#include /* * Compatibility declarations for Windows, assuming SYS_WINNT diff --git a/libopts/configfile.c b/libopts/configfile.c index f3016dcda..e0b8a7487 100644 --- a/libopts/configfile.c +++ b/libopts/configfile.c @@ -1,6 +1,6 @@ /* - * $Id: configfile.c,v 1.20 2007/02/04 17:44:12 bkorb Exp $ - * Time-stamp: "2007-01-13 12:49:10 bkorb" + * $Id: configfile.c,v 1.21 2007/04/15 19:01:18 bkorb Exp $ + * Time-stamp: "2007-04-15 11:22:46 bkorb" * * configuration/rc/ini file handling. */ @@ -869,11 +869,14 @@ internalFileLoad( tOptions* pOpts ) * IF we are now to skip config files AND we are presetting, * THEN change direction. We must go the other way. */ - if (SKIP_RC_FILES(pOpts) && PRESETTING(inc)) { - idx -= inc; /* go back and reprocess current file */ - inc = DIRECTION_PROCESS; + { + tOptDesc * pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts+1; + if (DISABLED_OPT(pOD) && PRESETTING(inc)) { + idx -= inc; /* go back and reprocess current file */ + inc = DIRECTION_PROCESS; + } } - } /* For every path in the home list, ... */ + } /* twice for every path in the home list, ... */ } @@ -937,11 +940,10 @@ void optionLoadOpt( tOptions* pOpts, tOptDesc* pOptDesc ) { /* - * IF the option is not being disabled, - * THEN load the file. There must be a file. - * (If it is being disabled, then the disablement processing - * already took place. It must be done to suppress preloading - * of ini/rc files.) + * IF the option is not being disabled, THEN load the file. There must + * be a file. (If it is being disabled, then the disablement processing + * already took place. It must be done to suppress preloading of ini/rc + * files.) */ if (! DISABLED_OPT( pOptDesc )) { struct stat sb; @@ -951,7 +953,7 @@ optionLoadOpt( tOptions* pOpts, tOptDesc* pOptDesc ) fprintf( stderr, zFSErrOptLoad, errno, strerror( errno ), pOptDesc->optArg.argString ); - (*pOpts->pUsageProc)( pOpts, EXIT_FAILURE ); + exit(EX_NOINPUT); /* NOT REACHED */ } @@ -960,7 +962,7 @@ optionLoadOpt( tOptions* pOpts, tOptDesc* pOptDesc ) return; fprintf( stderr, zNotFile, pOptDesc->optArg.argString ); - (*pOpts->pUsageProc)( pOpts, EXIT_FAILURE ); + exit(EX_NOINPUT); /* NOT REACHED */ } @@ -1223,7 +1225,7 @@ validateOptionsStruct( tOptions* pOpts, char const* pzProgram ) { if (pOpts == NULL) { fputs( zAO_Bad, stderr ); - exit( EXIT_FAILURE ); + exit( EX_CONFIG ); } /* diff --git a/libopts/environment.c b/libopts/environment.c index 4060c4653..9fb155011 100644 --- a/libopts/environment.c +++ b/libopts/environment.c @@ -1,7 +1,7 @@ /* - * $Id: environment.c,v 4.12 2007/02/04 17:44:12 bkorb Exp $ - * Time-stamp: "2007-01-13 10:02:07 bkorb" + * $Id: environment.c,v 4.13 2007/04/15 19:01:18 bkorb Exp $ + * Time-stamp: "2007-04-15 11:50:35 bkorb" * * This file contains all of the routines that must be linked into * an executable to use the generated option processing. The optional @@ -54,6 +54,9 @@ /* = = = START-STATIC-FORWARD = = = */ /* static forward declarations maintained by :mkfwd */ +static void +checkEnvOpt(tOptState * os, char * env_name, + tOptions* pOpts, teEnvPresetType type); /* = = = END-STATIC-FORWARD = = = */ /* @@ -145,6 +148,66 @@ doPrognameEnv( tOptions* pOpts, teEnvPresetType type ) pOpts->fOptSet = sv_flag; } +static void +checkEnvOpt(tOptState * os, char * env_name, + tOptions* pOpts, teEnvPresetType type) +{ + os->pzOptArg = getenv( env_name ); + if (os->pzOptArg == NULL) + return; + + os->flags = OPTST_PRESET | OPTST_ALLOC_ARG | os->pOD->fOptState; + os->optType = TOPT_UNDEFINED; + + if ( (os->pOD->pz_DisablePfx != NULL) + && (streqvcmp( os->pzOptArg, os->pOD->pz_DisablePfx ) == 0)) { + os->flags |= OPTST_DISABLED; + os->pzOptArg = NULL; + } + + switch (type) { + case ENV_IMM: + /* + * Process only immediate actions + */ + if (DO_IMMEDIATELY(os->flags)) + break; + return; + + case ENV_NON_IMM: + /* + * Process only NON immediate actions + */ + if (DO_NORMALLY(os->flags) || DO_SECOND_TIME(os->flags)) + break; + return; + + default: /* process everything */ + break; + } + + /* + * Make sure the option value string is persistent and consistent. + * + * The interpretation of the option value depends + * on the type of value argument the option takes + */ + if (os->pzOptArg != NULL) { + if (OPTST_GET_ARGTYPE(os->pOD->fOptState) == OPARG_TYPE_NONE) { + os->pzOptArg = NULL; + } else if ( (os->pOD->fOptState & OPTST_ARG_OPTIONAL) + && (*os->pzOptArg == NUL)) { + os->pzOptArg = NULL; + } else if (*os->pzOptArg == NUL) { + os->pzOptArg = zNil; + } else { + AGDUPSTR( os->pzOptArg, os->pzOptArg, "option argument" ); + os->flags |= OPTST_ALLOC_ARG; + } + } + + handleOption( pOpts, os ); +} /* * doEnvPresets - check for preset values from the envrionment @@ -194,60 +257,16 @@ doEnvPresets( tOptions* pOpts, teEnvPresetType type ) * Set up the option state */ strcpy( pzFlagName, st.pOD->pz_NAME ); - st.pzOptArg = getenv( zEnvName ); - if (st.pzOptArg == NULL) - continue; - st.flags = OPTST_PRESET | OPTST_ALLOC_ARG | st.pOD->fOptState; - st.optType = TOPT_UNDEFINED; - - if ( (st.pOD->pz_DisablePfx != NULL) - && (streqvcmp( st.pzOptArg, st.pOD->pz_DisablePfx ) == 0)) { - st.flags |= OPTST_DISABLED; - st.pzOptArg = NULL; - } - - switch (type) { - case ENV_IMM: - /* - * Process only immediate actions - */ - if (DO_IMMEDIATELY(st.flags)) - break; - continue; - - case ENV_NON_IMM: - /* - * Process only NON immediate actions - */ - if (DO_NORMALLY(st.flags) || DO_SECOND_TIME(st.flags)) - break; - continue; - - default: /* process everything */ - break; - } - - /* - * Make sure the option value string is persistent and consistent. - * - * The interpretation of the option value depends - * on the type of value argument the option takes - */ - if (st.pzOptArg != NULL) { - if (OPTST_GET_ARGTYPE(st.pOD->fOptState) == OPARG_TYPE_NONE) { - st.pzOptArg = NULL; - } else if ( (st.pOD->fOptState & OPTST_ARG_OPTIONAL) - && (*st.pzOptArg == NUL)) { - st.pzOptArg = NULL; - } else if (*st.pzOptArg == NUL) { - st.pzOptArg = zNil; - } else { - AGDUPSTR( st.pzOptArg, st.pzOptArg, "option argument" ); - st.flags |= OPTST_ALLOC_ARG; - } - } + checkEnvOpt(&st, zEnvName, pOpts, type); + } - handleOption( pOpts, &st ); + /* + * Special handling for ${PROGNAME_LOAD_OPTS} + */ + if (pOpts->specOptIdx.save_opts != 0) { + st.pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts + 1; + strcpy( pzFlagName, st.pOD->pz_NAME ); + checkEnvOpt(&st, zEnvName, pOpts, type); } } diff --git a/libopts/genshell.c b/libopts/genshell.c index a3fcd0fe2..de098a565 100644 --- a/libopts/genshell.c +++ b/libopts/genshell.c @@ -2,11 +2,11 @@ * * DO NOT EDIT THIS FILE (genshell.c) * - * It has been AutoGen-ed Saturday February 17, 2007 at 12:49:35 PM PST + * It has been AutoGen-ed Saturday May 5, 2007 at 12:02:35 PM PDT * From the definitions genshell.def * and the template file options * - * Generated from AutoOpts 28:0:3 templates. + * Generated from AutoOpts 29:0:4 templates. */ /* @@ -20,7 +20,7 @@ * * This source file is copyrighted and licensed under the following terms: * - * genshellopt copyright 1999-2006 Bruce Korb - all rights reserved + * genshellopt copyright 1999-2007 Bruce Korb - all rights reserved * * genshellopt is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -49,7 +49,7 @@ extern "C" { #endif tSCC zCopyright[] = - "genshellopt copyright (c) 1999-2006 Bruce Korb, all rights reserved"; + "genshellopt copyright (c) 1999-2007 Bruce Korb, all rights reserved"; tSCC zCopyrightNotice[] = "genshellopt is free software; you can redistribute it and/or\n\ modify it under the terms of the GNU Lesser General Public\n\ @@ -145,12 +145,18 @@ static tOptDesc optDesc[ OPTION_CT ] = { /* desc, NAME, name */ zShellText, zShell_NAME, zShell_Name, /* disablement strs */ zNotShell_Name, zNotShell_Pfx }, +#ifdef NO_OPTIONAL_OPT_ARGS +# define VERSION_OPT_FLAGS OPTST_IMM | OPTST_NO_INIT +#else +# define VERSION_OPT_FLAGS OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \ + OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT +#endif + { /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION, /* equiv idx value */ NO_EQUIVALENT, 0, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, - /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) - | OPTST_ARG_OPTIONAL | OPTST_IMM, 0, + /* opt state flags */ VERSION_OPT_FLAGS, 0, /* last opt argumnt */ { NULL }, /* arg list/cookie */ NULL, /* must/cannot opts */ NULL, NULL, @@ -158,11 +164,14 @@ static tOptDesc optDesc[ OPTION_CT ] = { /* desc, NAME, name */ zVersionText, NULL, zVersion_Name, /* disablement strs */ NULL, NULL }, +#undef VERSION_OPT_FLAGS + + { /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP, /* equiv idx value */ NO_EQUIVALENT, 0, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, - /* opt state flags */ OPTST_IMM, 0, + /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0, /* last opt argumnt */ { NULL }, /* arg list/cookie */ NULL, /* must/cannot opts */ NULL, NULL, @@ -174,7 +183,7 @@ static tOptDesc optDesc[ OPTION_CT ] = { /* equiv idx value */ NO_EQUIVALENT, 0, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, - /* opt state flags */ OPTST_IMM, 0, + /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0, /* last opt argumnt */ { NULL }, /* arg list/cookie */ NULL, /* must/cannot opts */ NULL, NULL, @@ -204,7 +213,7 @@ If the script file already exists and contains Automated Option Processing\n\ text, the second line of the file through the ending tag will be replaced\n\ by the newly generated text. The first `#!' line will be regenerated.\n"; tSCC zFullVersion[] = GENSHELLOPT_FULL_VERSION; -/* extracted from optcode.tpl near line 378 */ +/* extracted from optcode.tpl near line 408 */ #if defined(ENABLE_NLS) # define OPTPROC_BASE OPTPROC_TRANSLATE @@ -241,7 +250,7 @@ tOptions genshelloptOptions = { NO_EQUIVALENT /* index of '-#' option */, NO_EQUIVALENT /* index of default opt */ }, - OPTION_CT, 2 /* user option count */ + 5 /* full option count */, 2 /* user option count */ }; /* @@ -254,7 +263,7 @@ doUsageOpt( { USAGE( EXIT_SUCCESS ); } -/* extracted from optcode.tpl near line 475 */ +/* extracted from optcode.tpl near line 514 */ #if ENABLE_NLS #include diff --git a/libopts/genshell.h b/libopts/genshell.h index af177d177..b57677dce 100644 --- a/libopts/genshell.h +++ b/libopts/genshell.h @@ -2,11 +2,11 @@ * * DO NOT EDIT THIS FILE (genshell.h) * - * It has been AutoGen-ed Saturday February 17, 2007 at 12:49:35 PM PST + * It has been AutoGen-ed Saturday May 5, 2007 at 12:02:35 PM PDT * From the definitions genshell.def * and the template file options * - * Generated from AutoOpts 28:0:3 templates. + * Generated from AutoOpts 29:0:4 templates. */ /* @@ -20,7 +20,7 @@ * * This source file is copyrighted and licensed under the following terms: * - * genshellopt copyright 1999-2006 Bruce Korb - all rights reserved + * genshellopt copyright 1999-2007 Bruce Korb - all rights reserved * * genshellopt is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -55,7 +55,7 @@ * tolerable version is at least as old as what was current when the header * template was released. */ -#define AO_TEMPLATE_VERSION 114688 +#define AO_TEMPLATE_VERSION 118784 #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \ || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION) # error option template version mismatches autoopts/options.h header @@ -117,7 +117,7 @@ typedef enum { genshelloptOptions.pzCurOpt = NULL ) #define START_OPT RESTART_OPT(1) #define USAGE(c) (*genshelloptOptions.pUsageProc)( &genshelloptOptions, c ) -/* extracted from opthead.tpl near line 345 */ +/* extracted from opthead.tpl near line 360 */ /* * * * * * * diff --git a/libopts/m4/libopts.m4 b/libopts/m4/libopts.m4 index 85f555ba0..adc3235d2 100644 --- a/libopts/m4/libopts.m4 +++ b/libopts/m4/libopts.m4 @@ -2,7 +2,7 @@ dnl -*- buffer-read-only: t -*- vi: set ro: dnl dnl DO NOT EDIT THIS FILE (libopts.m4) dnl -dnl It has been AutoGen-ed Saturday February 17, 2007 at 12:49:37 PM PST +dnl It has been AutoGen-ed Saturday May 5, 2007 at 12:02:37 PM PDT dnl From the definitions libopts.def dnl and the template file conftest.tpl dnl @@ -25,7 +25,7 @@ AC_DEFUN([INVOKE_LIBOPTS_MACROS_FIRST],[ AC_CHECK_HEADERS(dlfcn.h errno.h fcntl.h libgen.h memory.h netinet/in.h \ setjmp.h sys/mman.h sys/param.h sys/poll.h sys/procset.h sys/select.h \ sys/socket.h sys/stropts.h sys/time.h sys/un.h sys/wait.h unistd.h \ - utime.h ) + utime.h sysexits.h) # -------------------------------------------- # Verify certain entries from AC_CHECK_HEADERS @@ -370,6 +370,23 @@ return (fp == NULL) ? 1 : fclose(fp); }], ]) # end of AC_DEFUN of LIBOPTS_RUN_FOPEN_TEXT +AC_DEFUN([LIBOPTS_DISABLE_OPTIONAL_ARGS],[ + AC_ARG_ENABLE([optional-args], + AC_HELP_STRING([--disable-optional-args], [not wanting optional option args]), + [libopts_cv_enable_optional_args=${enable_optional_args}], + AC_CACHE_CHECK([whether not wanting optional option args], libopts_cv_enable_optional_args, + libopts_cv_enable_optional_args=yes) + ) # end of AC_ARG_ENABLE + + if test "X${libopts_cv_enable_optional_args}" = Xno + then + AC_DEFINE([NO_OPTIONAL_OPT_ARGS], [1], + [Define this if optional arguments are disallowed]) + fi + +]) # end of AC_DEFUN of LIBOPTS_DISABLE_OPTIONAL_ARGS + + AC_DEFUN([INVOKE_LIBOPTS_MACROS],[ INVOKE_LIBOPTS_MACROS_FIRST # Check to see if a reg expr header is specified. @@ -396,6 +413,9 @@ AC_DEFUN([INVOKE_LIBOPTS_MACROS],[ # Check to see if fopen accepts "t" mode. LIBOPTS_RUN_FOPEN_TEXT + # Check to see if not wanting optional option args. + LIBOPTS_DISABLE_OPTIONAL_ARGS + ]) # end AC_DEFUN of INVOKE_LIBOPTS_MACROS dnl @synopsis LIBOPTS_CHECK diff --git a/libopts/pgusage.c b/libopts/pgusage.c index 384ef257a..c417c63d5 100644 --- a/libopts/pgusage.c +++ b/libopts/pgusage.c @@ -1,6 +1,6 @@ /* - * $Id: pgusage.c,v 4.11 2006/09/24 02:11:16 bkorb Exp $ + * $Id: pgusage.c,v 4.12 2007/04/28 22:19:23 bkorb Exp $ * Time-stamp: "2006-07-16 08:13:26 bkorb" * * Automated Options Paged Usage module. @@ -10,7 +10,7 @@ */ /* - * Automated Options copyright 1992-2006 Bruce Korb + * Automated Options copyright 1992-2007 Bruce Korb * * Automated Options is free software. * You may redistribute it and/or modify it under the terms of the diff --git a/libopts/proto.h b/libopts/proto.h index 0ab75f65a..e87ab87bd 100644 --- a/libopts/proto.h +++ b/libopts/proto.h @@ -1,7 +1,7 @@ /* -*- buffer-read-only: t -*- vi: set ro: * * Prototypes for autoopts - * Generated Sat Feb 17 12:49:36 PST 2007 + * Generated Sat May 5 12:02:36 PDT 2007 */ #ifndef AUTOOPTS_PROTO_H_GUARD #define AUTOOPTS_PROTO_H_GUARD 1 diff --git a/libopts/save.c b/libopts/save.c index a6fd5634f..22b088803 100644 --- a/libopts/save.c +++ b/libopts/save.c @@ -1,7 +1,7 @@ /* - * save.c $Id: save.c,v 4.17 2007/02/04 17:44:12 bkorb Exp $ - * Time-stamp: "2007-01-13 10:32:27 bkorb" + * save.c $Id: save.c,v 4.18 2007/04/15 19:01:18 bkorb Exp $ + * Time-stamp: "2007-04-15 11:11:10 bkorb" * * This module's routines will take the currently set options and * store them into an ".rc" file for re-interpretation the next diff --git a/libopts/sort.c b/libopts/sort.c index 8ca6860c6..ead713372 100644 --- a/libopts/sort.c +++ b/libopts/sort.c @@ -1,13 +1,13 @@ /* - * sort.c $Id: sort.c,v 4.9 2006/10/21 15:42:49 bkorb Exp $ + * sort.c $Id: sort.c,v 4.10 2007/04/28 22:19:23 bkorb Exp $ * Time-stamp: "2006-10-18 11:29:04 bkorb" * * This module implements argument sorting. */ /* - * Automated Options copyright 1992-2006 Bruce Korb + * Automated Options copyright 1992-2007 Bruce Korb * * Automated Options is free software. * You may redistribute it and/or modify it under the terms of the diff --git a/libopts/streqvcmp.c b/libopts/streqvcmp.c index 166ba8abd..8249794e0 100644 --- a/libopts/streqvcmp.c +++ b/libopts/streqvcmp.c @@ -1,6 +1,6 @@ /* - * $Id: streqvcmp.c,v 4.9 2006/09/24 02:11:16 bkorb Exp $ + * $Id: streqvcmp.c,v 4.10 2007/04/28 22:19:23 bkorb Exp $ * Time-stamp: "2006-07-26 18:25:53 bkorb" * * String Equivalence Comparison @@ -12,7 +12,7 @@ */ /* - * Automated Options copyright 1992-2006 Bruce Korb + * Automated Options copyright 1992-2007 Bruce Korb * * Automated Options is free software. * You may redistribute it and/or modify it under the terms of the diff --git a/libopts/usage.c b/libopts/usage.c index d8b9b6476..960339b63 100644 --- a/libopts/usage.c +++ b/libopts/usage.c @@ -1,7 +1,7 @@ /* - * usage.c $Id: usage.c,v 4.13 2006/11/27 01:52:23 bkorb Exp $ - * Time-stamp: "2006-07-01 12:41:02 bkorb" + * usage.c $Id: usage.c,v 4.15 2007/04/28 22:19:23 bkorb Exp $ + * Time-stamp: "2007-04-15 11:02:46 bkorb" * * This module implements the default usage procedure for * Automated Options. It may be overridden, of course. @@ -13,7 +13,7 @@ */ /* - * Automated Options copyright 1992-2006 Bruce Korb + * Automated Options copyright 1992-2007 Bruce Korb * * Automated Options is free software. * You may redistribute it and/or modify it under the terms of the @@ -169,12 +169,18 @@ optionOnlyUsage( * formats. The descriptor specifies the default, but AUTOOPTS_USAGE will * over-ride this, providing the value of it is set to either "gnu" or * "autoopts". This routine will @strong{not} return. + * + * If "exitCode" is "EX_USAGE" (normally 64), then output will to to stdout + * and the actual exit code will be "EXIT_SUCCESS". =*/ void optionUsage( tOptions* pOptions, - int exitCode ) + int usage_exit_code ) { + int actual_exit_code = + (usage_exit_code == EX_USAGE) ? EXIT_SUCCESS : usage_exit_code; + displayEnum = AG_FALSE; /* @@ -183,7 +189,7 @@ optionUsage( * on successful exit (help was requested), otherwise error out. */ if (option_usage_fp == NULL) - option_usage_fp = (exitCode != EXIT_SUCCESS) ? stderr : stdout; + option_usage_fp = (actual_exit_code != EXIT_SUCCESS) ? stderr : stdout; fprintf( option_usage_fp, pOptions->pzUsageTitle, pOptions->pzProgName ); @@ -207,13 +213,13 @@ optionUsage( * option, we do *NOT* want to emit the column headers. * Otherwise, we do. */ - if ( (exitCode != EXIT_SUCCESS) + if ( (usage_exit_code != EXIT_SUCCESS) || ((pOptions->pOptDesc->fOptState & OPTST_DOCUMENT) == 0) ) fputs( pOptTitle, option_usage_fp ); } - printOptionUsage( pOptions, exitCode, pOptTitle ); + printOptionUsage( pOptions, usage_exit_code, pOptTitle ); } /* @@ -241,14 +247,14 @@ optionUsage( * IF the user is asking for help (thus exiting with SUCCESS), * THEN see what additional information we can provide. */ - if (exitCode == EXIT_SUCCESS) + if (usage_exit_code == EXIT_SUCCESS) printProgramDetails( pOptions ); if (pOptions->pzBugAddr != NULL) fprintf( option_usage_fp, zPlsSendBugs, pOptions->pzBugAddr ); fflush( option_usage_fp ); - exit( exitCode ); + exit( actual_exit_code ); } @@ -344,12 +350,15 @@ printExtendedUsage( /* * IF this particular option can NOT be preset * AND some form of presetting IS allowed, + * AND it is not an auto-managed option (e.g. --help, et al.) * THEN advise that this option may not be preset. */ if ( ((pOD->fOptState & OPTST_NO_INIT) != 0) && ( (pOptions->papzHomeList != NULL) || (pOptions->pzPROGNAME != NULL) - ) ) + ) + && (pOD->optIndex < pOptions->presetOptCt) + ) fputs( zNoPreset, option_usage_fp ); @@ -509,7 +518,7 @@ printOneUsage( bogus_desc: fprintf( stderr, zInvalOptDesc, pOD->pz_Name ); - exit( EXIT_FAILURE ); + exit( EX_SOFTWARE ); } diff --git a/libopts/version.c b/libopts/version.c index a3936540f..85949d5d3 100644 --- a/libopts/version.c +++ b/libopts/version.c @@ -1,13 +1,13 @@ -/* $Id: version.c,v 4.9 2006/09/24 02:11:16 bkorb Exp $ - * Time-stamp: "2006-09-22 18:15:00 bkorb" +/* $Id: version.c,v 4.10 2007/04/28 22:19:23 bkorb Exp $ + * Time-stamp: "2007-04-28 10:08:34 bkorb" * * This module implements the default usage procedure for * Automated Options. It may be overridden, of course. */ static char const zAOV[] = - "Automated Options version %s, copyright (c) 1999-2006 Bruce Korb\n"; + "Automated Options version %s, copyright (c) 1999-2007 Bruce Korb\n"; /* Automated Options is free software. * You may redistribute it and/or modify it under the terms of the @@ -79,9 +79,14 @@ printVersion( tOptions* pOpts, tOptDesc* pOD, FILE* fp ) { char swCh; - if (pOD->optArg.argString == NULL) + /* + * IF the optional argument flag is off, or the argument is not provided, + * then just print the version. + */ + if ( ((pOD->fOptState & OPTST_ARG_OPTIONAL) == 0) + || (pOD->optArg.argString == NULL)) swCh = 'v'; - else swCh = pOD->optArg.argString[0]; + else swCh = tolower(pOD->optArg.argString[0]); if (pOpts->pzFullVersion != NULL) { fputs( pOpts->pzFullVersion, fp ); @@ -89,17 +94,15 @@ printVersion( tOptions* pOpts, tOptDesc* pOD, FILE* fp ) } else { char const *pz = pOpts->pzUsageTitle; - do { fputc( *pz, fp ); } while (*(pz++) != '\n'); + do { fputc(*pz, fp); } while (*(pz++) != '\n'); } switch (swCh) { - case NUL: + case NUL: /* arg provided, but empty */ case 'v': - case 'V': break; case 'c': - case 'C': if (pOpts->pzCopyright != NULL) { fputs( pOpts->pzCopyright, fp ); fputc( '\n', fp ); @@ -110,7 +113,6 @@ printVersion( tOptions* pOpts, tOptDesc* pOD, FILE* fp ) break; case 'n': - case 'N': if (pOpts->pzCopyright != NULL) { fputs( pOpts->pzCopyright, fp ); fputc( '\n', fp ); diff --git a/sntp/libopts/Makefile.am b/sntp/libopts/Makefile.am index dfcfb4653..5f1386144 100644 --- a/sntp/libopts/Makefile.am +++ b/sntp/libopts/Makefile.am @@ -7,7 +7,7 @@ noinst_LTLIBRARIES = libopts.la endif libopts_la_SOURCES = libopts.c libopts_la_CPPFLAGS = -I$(top_srcdir) -libopts_la_LDFLAGS = -version-info 28:0:3 +libopts_la_LDFLAGS = -version-info 29:0:4 EXTRA_DIST = \ COPYING.lgpl COPYING.mbsd MakeDefs.inc \ README autoopts/options.h autoopts/usage-txt.h \ diff --git a/sntp/libopts/README b/sntp/libopts/README index 7f426fa97..7cbe0b044 100644 --- a/sntp/libopts/README +++ b/sntp/libopts/README @@ -85,7 +85,7 @@ will need to hand craft the rules for building the library. LICENSING: -This material is copyright 1993-2006 by Bruce Korb. +This material is copyright 1993-2007 by Bruce Korb. You are licensed to use this under the terms of either the GNU Lesser General Public License (see: COPYING.lgpl), or, at your option, the modified Berkeley Software Distribution diff --git a/sntp/libopts/autoopts.c b/sntp/libopts/autoopts.c index 28f93f1c7..139841bbb 100644 --- a/sntp/libopts/autoopts.c +++ b/sntp/libopts/autoopts.c @@ -1,7 +1,7 @@ /* - * $Id: autoopts.c,v 4.23 2007/02/13 19:43:46 bkorb Exp $ - * Time-stamp: "2007-02-13 11:26:59 bkorb" + * $Id: autoopts.c,v 4.25 2007/04/15 19:01:18 bkorb Exp $ + * Time-stamp: "2007-04-15 11:10:40 bkorb" * * This file contains all of the routines that must be linked into * an executable to use the generated option processing. The optional @@ -54,9 +54,6 @@ static char const zNil[] = ""; -#define SKIP_RC_FILES(po) \ - DISABLED_OPT(&((po)->pOptDesc[ (po)->specOptIdx.save_opts+1])) - /* = = = START-STATIC-FORWARD = = = */ /* static forward declarations maintained by :mkfwd */ static tSuccess @@ -697,7 +694,7 @@ nextOption( tOptions* pOpts, tOptState* pOptState ) case TOPT_DEFAULT: fputs( "AutoOpts lib error: defaulted to option with optional arg\n", stderr ); - exit( EXIT_FAILURE ); + exit( EX_SOFTWARE ); } /* @@ -830,9 +827,22 @@ doRegularOpts( tOptions* pOpts ) static tSuccess doPresets( tOptions* pOpts ) { + tOptDesc * pOD = NULL; + if (! SUCCESSFUL( doImmediateOpts( pOpts ))) return FAILURE; + /* + * IF this option set has a --save-opts option, then it also + * has a --load-opts option. See if a command line option has disabled + * option presetting. + */ + if (pOpts->specOptIdx.save_opts != 0) { + pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts + 1; + if (DISABLED_OPT(pOD)) + return SUCCESS; + } + /* * Until we return from this procedure, disable non-presettable opts */ @@ -841,13 +851,22 @@ doPresets( tOptions* pOpts ) * IF there are no config files, * THEN do any environment presets and leave. */ - if ( (pOpts->papzHomeList == NULL) - || SKIP_RC_FILES(pOpts) ) { + if (pOpts->papzHomeList == NULL) { doEnvPresets( pOpts, ENV_ALL ); } else { doEnvPresets( pOpts, ENV_IMM ); - internalFileLoad( pOpts ); + + /* + * Check to see if environment variables have disabled presetting. + */ + if ((pOD != NULL) && ! DISABLED_OPT(pOD)) + internalFileLoad( pOpts ); + + /* + * ${PROGRAM_LOAD_OPTS} value of "no" cannot disable other environment + * variable options. Only the loading of .rc files. + */ doEnvPresets( pOpts, ENV_NON_IMM ); } pOpts->fOptSet &= ~OPTPROC_PRESETTING; @@ -1031,7 +1050,7 @@ optionProcess( char** argVect ) { if (! SUCCESSFUL( validateOptionsStruct( pOpts, argVect[0] ))) - exit( EXIT_FAILURE ); + exit( EX_SOFTWARE ); /* * Establish the real program name, the program full path, diff --git a/sntp/libopts/autoopts.h b/sntp/libopts/autoopts.h index f2ac93e9a..2645757ea 100644 --- a/sntp/libopts/autoopts.h +++ b/sntp/libopts/autoopts.h @@ -1,8 +1,8 @@ /* - * Time-stamp: "2007-01-17 16:37:34 bkorb" + * Time-stamp: "2007-04-15 09:59:39 bkorb" * - * autoopts.h $Id: autoopts.h,v 4.22 2007/02/04 17:44:12 bkorb Exp $ + * autoopts.h $Id: autoopts.h,v 4.23 2007/04/15 19:01:18 bkorb Exp $ * Time-stamp: "2005-02-14 05:59:50 bkorb" * * This file defines all the global structures and special values @@ -57,19 +57,19 @@ #include "compat/compat.h" -#define AO_NAME_LIMIT 127 -#define AO_NAME_SIZE ((size_t)(AO_NAME_LIMIT + 1)) +#define AO_NAME_LIMIT 127 +#define AO_NAME_SIZE ((size_t)(AO_NAME_LIMIT + 1)) #ifndef AG_PATH_MAX # ifdef PATH_MAX -# define AG_PATH_MAX ((size_t)PATH_MAX) +# define AG_PATH_MAX ((size_t)PATH_MAX) # else -# define AG_PATH_MAX ((size_t)4096) +# define AG_PATH_MAX ((size_t)4096) # endif #else # if defined(PATH_MAX) && (PATH_MAX > MAXPATHLEN) # undef AG_PATH_MAX -# define AG_PATH_MAX ((size_t)PATH_MAX) +# define AG_PATH_MAX ((size_t)PATH_MAX) # endif #endif @@ -77,15 +77,25 @@ #define EXPORT #if defined(_WIN32) && !defined(__CYGWIN__) -# define DIRCH '\\' +# define DIRCH '\\' #else -# define DIRCH '/' +# define DIRCH '/' +#endif + +#ifndef EX_NOINPUT +# define EX_NOINPUT 66 +#endif +#ifndef EX_SOFTWARE +# define EX_SOFTWARE 70 +#endif +#ifndef EX_CONFIG +# define EX_CONFIG 78 #endif /* * Convert the number to a list usable in a printf call */ -#define NUM_TO_VER(n) ((n) >> 12), ((n) >> 7) & 0x001F, (n) & 0x007F +#define NUM_TO_VER(n) ((n) >> 12), ((n) >> 7) & 0x001F, (n) & 0x007F #define NAMED_OPTS(po) \ (((po)->fOptSet & (OPTPROC_SHORTOPT | OPTPROC_LONGOPT)) == 0) @@ -93,14 +103,14 @@ #define SKIP_OPT(p) (((p)->fOptState & (OPTST_DOCUMENT|OPTST_OMITTED)) != 0) typedef int tDirection; -#define DIRECTION_PRESET -1 -#define DIRECTION_PROCESS 1 -#define DIRECTION_CALLED 0 +#define DIRECTION_PRESET -1 +#define DIRECTION_PROCESS 1 +#define DIRECTION_CALLED 0 -#define PROCESSING(d) ((d)>0) -#define PRESETTING(d) ((d)<0) +#define PROCESSING(d) ((d)>0) +#define PRESETTING(d) ((d)<0) -#define ISNAMECHAR( c ) (isalnum(c) || ((c) == '_') || ((c) == '-')) +#define ISNAMECHAR( c ) (isalnum(c) || ((c) == '_') || ((c) == '-')) /* * Procedure success codes @@ -119,16 +129,16 @@ typedef int tDirection; #undef FAILED #undef HADGLITCH -#define SUCCESS ((tSuccess) 0) -#define FAILURE ((tSuccess)-1) -#define PROBLEM ((tSuccess) 1) +#define SUCCESS ((tSuccess) 0) +#define FAILURE ((tSuccess)-1) +#define PROBLEM ((tSuccess) 1) typedef int tSuccess; -#define SUCCEEDED( p ) ((p) == SUCCESS) -#define SUCCESSFUL( p ) SUCCEEDED( p ) -#define FAILED( p ) ((p) < SUCCESS) -#define HADGLITCH( p ) ((p) > SUCCESS) +#define SUCCEEDED( p ) ((p) == SUCCESS) +#define SUCCESSFUL( p ) SUCCEEDED( p ) +#define FAILED( p ) ((p) < SUCCESS) +#define HADGLITCH( p ) ((p) > SUCCESS) /* * When loading a line (or block) of text as an option, the value can @@ -224,10 +234,10 @@ typedef struct { tCC* pzOptFmt; } arg_types_t; -#define AGALOC( c, w ) ao_malloc((size_t)c) -#define AGREALOC( p, c, w ) ao_realloc((void*)p, (size_t)c) -#define AGFREE( p ) ao_free((void*)p) -#define AGDUPSTR( p, s, w ) (p = ao_strdup(s)) +#define AGALOC( c, w ) ao_malloc((size_t)c) +#define AGREALOC( p, c, w ) ao_realloc((void*)p, (size_t)c) +#define AGFREE( p ) ao_free((void*)p) +#define AGDUPSTR( p, s, w ) (p = ao_strdup(s)) static void * ao_malloc( size_t sz ); @@ -324,26 +334,26 @@ ao_strdup( char const *str ); # include #else # ifndef PROT_READ -# define PROT_READ 0x01 +# define PROT_READ 0x01 # endif # ifndef PROT_WRITE -# define PROT_WRITE 0x02 +# define PROT_WRITE 0x02 # endif # ifndef MAP_SHARED -# define MAP_SHARED 0x01 +# define MAP_SHARED 0x01 # endif # ifndef MAP_PRIVATE -# define MAP_PRIVATE 0x02 +# define MAP_PRIVATE 0x02 # endif #endif #ifndef MAP_FAILED -# define MAP_FAILED ((void*)-1) +# define MAP_FAILED ((void*)-1) #endif #ifndef _SC_PAGESIZE # ifdef _SC_PAGE_SIZE -# define _SC_PAGESIZE _SC_PAGE_SIZE +# define _SC_PAGESIZE _SC_PAGE_SIZE # endif #endif diff --git a/sntp/libopts/autoopts/options.h b/sntp/libopts/autoopts/options.h index db97c72d3..c2ceeb3db 100644 --- a/sntp/libopts/autoopts/options.h +++ b/sntp/libopts/autoopts/options.h @@ -2,7 +2,7 @@ * * DO NOT EDIT THIS FILE (options.h) * - * It has been AutoGen-ed Saturday February 17, 2007 at 12:49:35 PM PST + * It has been AutoGen-ed Saturday May 5, 2007 at 12:02:34 PM PDT * From the definitions funcs.def * and the template file options_h * @@ -43,6 +43,14 @@ # include #endif /* HAVE_LIMITS/SYS_LIMITS_H */ +#if defined(HAVE_SYSEXITS_H) +# include +#endif /* HAVE_SYSEXITS_H */ + +#ifndef EX_USAGE +# define EX_USAGE 64 +#endif + /* * PUBLIC DEFINES * @@ -60,8 +68,8 @@ * values for "opt_name" are available. */ -#define OPTIONS_STRUCT_VERSION 114688 -#define OPTIONS_VERSION_STRING "28:0:3" +#define OPTIONS_STRUCT_VERSION 118784 +#define OPTIONS_VERSION_STRING "29:0:4" #define OPTIONS_MINIMUM_VERSION 102400 #define OPTIONS_MIN_VER_STRING "25:0:0" @@ -92,28 +100,28 @@ typedef struct optionValue { * Bits in the fOptState option descriptor field. */ typedef enum { - OPTST_SET_ID = 0, /* Set via the "SET_OPT()" macro */ - OPTST_PRESET_ID = 1, /* Set via an RC/INI file */ - OPTST_DEFINED_ID = 2, /* Set via a command line option */ - OPTST_EQUIVALENCE_ID = 4, /* selected by equiv'ed option */ - OPTST_DISABLED_ID = 5, /* option is in disabled state */ - OPTST_ALLOC_ARG_ID = 6, /* pzOptArg was allocated */ - OPTST_NO_INIT_ID = 8, /* option cannot be preset */ - OPTST_NUMBER_OPT_ID = 9, /* opt value (flag) is any digit */ - OPTST_STACKED_ID = 10, /* opt uses optionStackArg proc */ - OPTST_INITENABLED_ID = 11, /* option defaults to enabled */ - OPTST_ARG_TYPE_1_ID = 12, /* bit 1 of arg type enum */ - OPTST_ARG_TYPE_2_ID = 13, /* bit 2 of arg type enum */ - OPTST_ARG_TYPE_3_ID = 14, /* bit 3 of arg type enum */ - OPTST_ARG_TYPE_4_ID = 15, /* bit 4 of arg type enum */ - OPTST_ARG_OPTIONAL_ID = 16, /* the option arg not required */ - OPTST_IMM_ID = 17, /* process opt on first pass */ - OPTST_DISABLE_IMM_ID = 18, /* process disablement immed. */ - OPTST_OMITTED_ID = 19, /* compiled out of program */ - OPTST_MUST_SET_ID = 20, /* must be set or pre-set */ - OPTST_DOCUMENT_ID = 21, /* opt is for doc only */ - OPTST_TWICE_ID = 22, /* process opt twice - imm + reg */ - OPTST_DISABLE_TWICE_ID = 23 /* process disabled option twice */ + OPTST_SET_ID = 0, /* Set via the "SET_OPT()" macro */ + OPTST_PRESET_ID = 1, /* Set via an RC/INI file */ + OPTST_DEFINED_ID = 2, /* Set via a command line option */ + OPTST_EQUIVALENCE_ID = 4, /* selected by equiv'ed option */ + OPTST_DISABLED_ID = 5, /* option is in disabled state */ + OPTST_ALLOC_ARG_ID = 6, /* pzOptArg was allocated */ + OPTST_NO_INIT_ID = 8, /* option cannot be preset */ + OPTST_NUMBER_OPT_ID = 9, /* opt value (flag) is any digit */ + OPTST_STACKED_ID = 10, /* opt uses optionStackArg proc */ + OPTST_INITENABLED_ID = 11, /* option defaults to enabled */ + OPTST_ARG_TYPE_1_ID = 12, /* bit 1 of arg type enum */ + OPTST_ARG_TYPE_2_ID = 13, /* bit 2 of arg type enum */ + OPTST_ARG_TYPE_3_ID = 14, /* bit 3 of arg type enum */ + OPTST_ARG_TYPE_4_ID = 15, /* bit 4 of arg type enum */ + OPTST_ARG_OPTIONAL_ID = 16, /* the option arg not required */ + OPTST_IMM_ID = 17, /* process opt on first pass */ + OPTST_DISABLE_IMM_ID = 18, /* process disablement immed. */ + OPTST_OMITTED_ID = 19, /* compiled out of program */ + OPTST_MUST_SET_ID = 20, /* must be set or pre-set */ + OPTST_DOCUMENT_ID = 21, /* opt is for doc only */ + OPTST_TWICE_ID = 22, /* process opt twice - imm + reg */ + OPTST_DISABLE_TWICE_ID = 23 /* process disabled option twice */ } opt_state_enum_t; #define OPTST_INIT 0U @@ -164,6 +172,11 @@ typedef enum { OPTST_ARG_TYPE_3 | \ OPTST_ARG_TYPE_4 ) +#ifdef NO_OPTIONAL_OPT_ARGS +# undef OPTST_ARG_OPTIONAL +# define OPTST_ARG_OPTIONAL 0 +#endif + #define OPTST_PERSISTENT_MASK (~OPTST_MUTABLE_MASK) #define SELECTED_OPT( pod ) ((pod)->fOptState & OPTST_SELECTED_MASK) @@ -186,22 +199,22 @@ typedef enum { * Define the processing state flags */ typedef enum { - OPTPROC_LONGOPT_ID = 0, /* Process long style options */ - OPTPROC_SHORTOPT_ID = 1, /* Process short style "flags" */ - OPTPROC_ERRSTOP_ID = 2, /* Stop on argument errors */ - OPTPROC_DISABLEDOPT_ID = 3, /* Current option is disabled */ - OPTPROC_NO_REQ_OPT_ID = 4, /* no options are required */ - OPTPROC_NUM_OPT_ID = 5, /* there is a number option */ - OPTPROC_INITDONE_ID = 6, /* have initializations been done? */ - OPTPROC_NEGATIONS_ID = 7, /* any negation options? */ - OPTPROC_ENVIRON_ID = 8, /* check environment? */ - OPTPROC_NO_ARGS_ID = 9, /* Disallow remaining arguments */ - OPTPROC_ARGS_REQ_ID = 10, /* Require arguments after options */ - OPTPROC_REORDER_ID = 11, /* reorder operands after options */ - OPTPROC_GNUUSAGE_ID = 12, /* emit usage in GNU style */ - OPTPROC_TRANSLATE_ID = 13, /* Translate strings in tOptions */ - OPTPROC_HAS_IMMED_ID = 14, /* program defines immed options */ - OPTPROC_PRESETTING_ID = 19 /* opt processing in preset state */ + OPTPROC_LONGOPT_ID = 0, /* Process long style options */ + OPTPROC_SHORTOPT_ID = 1, /* Process short style "flags" */ + OPTPROC_ERRSTOP_ID = 2, /* Stop on argument errors */ + OPTPROC_DISABLEDOPT_ID = 3, /* Current option is disabled */ + OPTPROC_NO_REQ_OPT_ID = 4, /* no options are required */ + OPTPROC_NUM_OPT_ID = 5, /* there is a number option */ + OPTPROC_INITDONE_ID = 6, /* have initializations been done? */ + OPTPROC_NEGATIONS_ID = 7, /* any negation options? */ + OPTPROC_ENVIRON_ID = 8, /* check environment? */ + OPTPROC_NO_ARGS_ID = 9, /* Disallow remaining arguments */ + OPTPROC_ARGS_REQ_ID = 10, /* Require arguments after options */ + OPTPROC_REORDER_ID = 11, /* reorder operands after options */ + OPTPROC_GNUUSAGE_ID = 12, /* emit usage in GNU style */ + OPTPROC_TRANSLATE_ID = 13, /* Translate strings in tOptions */ + OPTPROC_HAS_IMMED_ID = 14, /* program defines immed options */ + OPTPROC_PRESETTING_ID = 19 /* opt processing in preset state */ } optproc_state_enum_t; #define OPTPROC_NONE 0U @@ -350,7 +363,7 @@ struct optSpecIndex { typedef void (tOptionXlateProc)(void); struct options { - const int structVersion; + int const structVersion; int origArgCt; char** origArgVect; unsigned int fOptSet; @@ -364,7 +377,7 @@ struct options { char const* const pzCopyright; char const* const pzCopyNotice; char const* const pzFullVersion; - char const* const* papzHomeList; + char const* const* const papzHomeList; char const* const pzUsageTitle; char const* const pzExplain; char const* const pzDetail; @@ -378,8 +391,8 @@ struct options { tOptionXlateProc* pTransProc; tOptSpecIndex specOptIdx; - const int optCt; - const int presetOptCt; + int const optCt; + int const presetOptCt; }; /* @@ -498,7 +511,7 @@ extern token_list_t* ao_string_tokenize( char const* ); extern const tOptionValue* configFileLoad( char const* ); -/* From: configfile.c line 880 +/* From: configfile.c line 883 * * optionFileLoad - Load the locatable config files, in order * @@ -653,7 +666,7 @@ extern const tOptionValue* optionNextValue( const tOptionValue*, const tOptionVa extern void optionOnlyUsage( tOptions*, int ); -/* From: autoopts.c line 993 +/* From: autoopts.c line 1012 * * optionProcess - this is the main option processing routine * diff --git a/sntp/libopts/autoopts/usage-txt.h b/sntp/libopts/autoopts/usage-txt.h index 57fc2603a..5aaaa01a6 100644 --- a/sntp/libopts/autoopts/usage-txt.h +++ b/sntp/libopts/autoopts/usage-txt.h @@ -2,7 +2,7 @@ * * DO NOT EDIT THIS FILE (usage-txt.h) * - * It has been AutoGen-ed Saturday February 17, 2007 at 12:49:33 PM PST + * It has been AutoGen-ed Saturday May 5, 2007 at 12:02:33 PM PDT * From the definitions usage-txt.def * and the template file usage-txt.tpl * diff --git a/sntp/libopts/compat/compat.h b/sntp/libopts/compat/compat.h index 86fff8e27..b3bd58ff4 100644 --- a/sntp/libopts/compat/compat.h +++ b/sntp/libopts/compat/compat.h @@ -7,7 +7,7 @@ * Author: Gary V Vaughan * Created: Mon Jun 30 15:54:46 1997 * - * $Id: compat.h,v 4.15 2007/02/04 22:17:39 bkorb Exp $ + * $Id: compat.h,v 4.16 2007/04/27 01:10:47 bkorb Exp $ */ #ifndef COMPAT_H_GUARD #define COMPAT_H_GUARD 1 @@ -199,6 +199,11 @@ # define MAXPATHLEN PATH_MAX #endif /* !MAXPATHLEN && PATH_MAX */ +#if !defined (MAXPATHLEN) && defined(_MAX_PATH) +# define PATH_MAX _MAX_PATH +# define MAXPATHLEN _MAX_PATH +#endif + #if !defined (MAXPATHLEN) # define MAXPATHLEN ((size_t)4096) #endif /* MAXPATHLEN */ diff --git a/sntp/libopts/compat/windows-config.h b/sntp/libopts/compat/windows-config.h index d4f3d2a82..2612980bf 100644 --- a/sntp/libopts/compat/windows-config.h +++ b/sntp/libopts/compat/windows-config.h @@ -2,7 +2,7 @@ /* * Time-stamp: "2006-10-14 14:55:09 bkorb" * by: bkorb - * Last Committed: $Date: 2006/10/14 22:39:49 $ + * Last Committed: $Date: 2007/04/28 22:19:23 $ */ #ifndef WINDOWS_CONFIG_HACKERY #define WINDOWS_CONFIG_HACKERY 1 @@ -92,6 +92,7 @@ typedef unsigned long uintptr_t; /* Include Windows headers */ #include #include +#include /* * Compatibility declarations for Windows, assuming SYS_WINNT diff --git a/sntp/libopts/configfile.c b/sntp/libopts/configfile.c index f3016dcda..e0b8a7487 100644 --- a/sntp/libopts/configfile.c +++ b/sntp/libopts/configfile.c @@ -1,6 +1,6 @@ /* - * $Id: configfile.c,v 1.20 2007/02/04 17:44:12 bkorb Exp $ - * Time-stamp: "2007-01-13 12:49:10 bkorb" + * $Id: configfile.c,v 1.21 2007/04/15 19:01:18 bkorb Exp $ + * Time-stamp: "2007-04-15 11:22:46 bkorb" * * configuration/rc/ini file handling. */ @@ -869,11 +869,14 @@ internalFileLoad( tOptions* pOpts ) * IF we are now to skip config files AND we are presetting, * THEN change direction. We must go the other way. */ - if (SKIP_RC_FILES(pOpts) && PRESETTING(inc)) { - idx -= inc; /* go back and reprocess current file */ - inc = DIRECTION_PROCESS; + { + tOptDesc * pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts+1; + if (DISABLED_OPT(pOD) && PRESETTING(inc)) { + idx -= inc; /* go back and reprocess current file */ + inc = DIRECTION_PROCESS; + } } - } /* For every path in the home list, ... */ + } /* twice for every path in the home list, ... */ } @@ -937,11 +940,10 @@ void optionLoadOpt( tOptions* pOpts, tOptDesc* pOptDesc ) { /* - * IF the option is not being disabled, - * THEN load the file. There must be a file. - * (If it is being disabled, then the disablement processing - * already took place. It must be done to suppress preloading - * of ini/rc files.) + * IF the option is not being disabled, THEN load the file. There must + * be a file. (If it is being disabled, then the disablement processing + * already took place. It must be done to suppress preloading of ini/rc + * files.) */ if (! DISABLED_OPT( pOptDesc )) { struct stat sb; @@ -951,7 +953,7 @@ optionLoadOpt( tOptions* pOpts, tOptDesc* pOptDesc ) fprintf( stderr, zFSErrOptLoad, errno, strerror( errno ), pOptDesc->optArg.argString ); - (*pOpts->pUsageProc)( pOpts, EXIT_FAILURE ); + exit(EX_NOINPUT); /* NOT REACHED */ } @@ -960,7 +962,7 @@ optionLoadOpt( tOptions* pOpts, tOptDesc* pOptDesc ) return; fprintf( stderr, zNotFile, pOptDesc->optArg.argString ); - (*pOpts->pUsageProc)( pOpts, EXIT_FAILURE ); + exit(EX_NOINPUT); /* NOT REACHED */ } @@ -1223,7 +1225,7 @@ validateOptionsStruct( tOptions* pOpts, char const* pzProgram ) { if (pOpts == NULL) { fputs( zAO_Bad, stderr ); - exit( EXIT_FAILURE ); + exit( EX_CONFIG ); } /* diff --git a/sntp/libopts/environment.c b/sntp/libopts/environment.c index 4060c4653..9fb155011 100644 --- a/sntp/libopts/environment.c +++ b/sntp/libopts/environment.c @@ -1,7 +1,7 @@ /* - * $Id: environment.c,v 4.12 2007/02/04 17:44:12 bkorb Exp $ - * Time-stamp: "2007-01-13 10:02:07 bkorb" + * $Id: environment.c,v 4.13 2007/04/15 19:01:18 bkorb Exp $ + * Time-stamp: "2007-04-15 11:50:35 bkorb" * * This file contains all of the routines that must be linked into * an executable to use the generated option processing. The optional @@ -54,6 +54,9 @@ /* = = = START-STATIC-FORWARD = = = */ /* static forward declarations maintained by :mkfwd */ +static void +checkEnvOpt(tOptState * os, char * env_name, + tOptions* pOpts, teEnvPresetType type); /* = = = END-STATIC-FORWARD = = = */ /* @@ -145,6 +148,66 @@ doPrognameEnv( tOptions* pOpts, teEnvPresetType type ) pOpts->fOptSet = sv_flag; } +static void +checkEnvOpt(tOptState * os, char * env_name, + tOptions* pOpts, teEnvPresetType type) +{ + os->pzOptArg = getenv( env_name ); + if (os->pzOptArg == NULL) + return; + + os->flags = OPTST_PRESET | OPTST_ALLOC_ARG | os->pOD->fOptState; + os->optType = TOPT_UNDEFINED; + + if ( (os->pOD->pz_DisablePfx != NULL) + && (streqvcmp( os->pzOptArg, os->pOD->pz_DisablePfx ) == 0)) { + os->flags |= OPTST_DISABLED; + os->pzOptArg = NULL; + } + + switch (type) { + case ENV_IMM: + /* + * Process only immediate actions + */ + if (DO_IMMEDIATELY(os->flags)) + break; + return; + + case ENV_NON_IMM: + /* + * Process only NON immediate actions + */ + if (DO_NORMALLY(os->flags) || DO_SECOND_TIME(os->flags)) + break; + return; + + default: /* process everything */ + break; + } + + /* + * Make sure the option value string is persistent and consistent. + * + * The interpretation of the option value depends + * on the type of value argument the option takes + */ + if (os->pzOptArg != NULL) { + if (OPTST_GET_ARGTYPE(os->pOD->fOptState) == OPARG_TYPE_NONE) { + os->pzOptArg = NULL; + } else if ( (os->pOD->fOptState & OPTST_ARG_OPTIONAL) + && (*os->pzOptArg == NUL)) { + os->pzOptArg = NULL; + } else if (*os->pzOptArg == NUL) { + os->pzOptArg = zNil; + } else { + AGDUPSTR( os->pzOptArg, os->pzOptArg, "option argument" ); + os->flags |= OPTST_ALLOC_ARG; + } + } + + handleOption( pOpts, os ); +} /* * doEnvPresets - check for preset values from the envrionment @@ -194,60 +257,16 @@ doEnvPresets( tOptions* pOpts, teEnvPresetType type ) * Set up the option state */ strcpy( pzFlagName, st.pOD->pz_NAME ); - st.pzOptArg = getenv( zEnvName ); - if (st.pzOptArg == NULL) - continue; - st.flags = OPTST_PRESET | OPTST_ALLOC_ARG | st.pOD->fOptState; - st.optType = TOPT_UNDEFINED; - - if ( (st.pOD->pz_DisablePfx != NULL) - && (streqvcmp( st.pzOptArg, st.pOD->pz_DisablePfx ) == 0)) { - st.flags |= OPTST_DISABLED; - st.pzOptArg = NULL; - } - - switch (type) { - case ENV_IMM: - /* - * Process only immediate actions - */ - if (DO_IMMEDIATELY(st.flags)) - break; - continue; - - case ENV_NON_IMM: - /* - * Process only NON immediate actions - */ - if (DO_NORMALLY(st.flags) || DO_SECOND_TIME(st.flags)) - break; - continue; - - default: /* process everything */ - break; - } - - /* - * Make sure the option value string is persistent and consistent. - * - * The interpretation of the option value depends - * on the type of value argument the option takes - */ - if (st.pzOptArg != NULL) { - if (OPTST_GET_ARGTYPE(st.pOD->fOptState) == OPARG_TYPE_NONE) { - st.pzOptArg = NULL; - } else if ( (st.pOD->fOptState & OPTST_ARG_OPTIONAL) - && (*st.pzOptArg == NUL)) { - st.pzOptArg = NULL; - } else if (*st.pzOptArg == NUL) { - st.pzOptArg = zNil; - } else { - AGDUPSTR( st.pzOptArg, st.pzOptArg, "option argument" ); - st.flags |= OPTST_ALLOC_ARG; - } - } + checkEnvOpt(&st, zEnvName, pOpts, type); + } - handleOption( pOpts, &st ); + /* + * Special handling for ${PROGNAME_LOAD_OPTS} + */ + if (pOpts->specOptIdx.save_opts != 0) { + st.pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts + 1; + strcpy( pzFlagName, st.pOD->pz_NAME ); + checkEnvOpt(&st, zEnvName, pOpts, type); } } diff --git a/sntp/libopts/genshell.c b/sntp/libopts/genshell.c index a3fcd0fe2..de098a565 100644 --- a/sntp/libopts/genshell.c +++ b/sntp/libopts/genshell.c @@ -2,11 +2,11 @@ * * DO NOT EDIT THIS FILE (genshell.c) * - * It has been AutoGen-ed Saturday February 17, 2007 at 12:49:35 PM PST + * It has been AutoGen-ed Saturday May 5, 2007 at 12:02:35 PM PDT * From the definitions genshell.def * and the template file options * - * Generated from AutoOpts 28:0:3 templates. + * Generated from AutoOpts 29:0:4 templates. */ /* @@ -20,7 +20,7 @@ * * This source file is copyrighted and licensed under the following terms: * - * genshellopt copyright 1999-2006 Bruce Korb - all rights reserved + * genshellopt copyright 1999-2007 Bruce Korb - all rights reserved * * genshellopt is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -49,7 +49,7 @@ extern "C" { #endif tSCC zCopyright[] = - "genshellopt copyright (c) 1999-2006 Bruce Korb, all rights reserved"; + "genshellopt copyright (c) 1999-2007 Bruce Korb, all rights reserved"; tSCC zCopyrightNotice[] = "genshellopt is free software; you can redistribute it and/or\n\ modify it under the terms of the GNU Lesser General Public\n\ @@ -145,12 +145,18 @@ static tOptDesc optDesc[ OPTION_CT ] = { /* desc, NAME, name */ zShellText, zShell_NAME, zShell_Name, /* disablement strs */ zNotShell_Name, zNotShell_Pfx }, +#ifdef NO_OPTIONAL_OPT_ARGS +# define VERSION_OPT_FLAGS OPTST_IMM | OPTST_NO_INIT +#else +# define VERSION_OPT_FLAGS OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \ + OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT +#endif + { /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION, /* equiv idx value */ NO_EQUIVALENT, 0, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, - /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) - | OPTST_ARG_OPTIONAL | OPTST_IMM, 0, + /* opt state flags */ VERSION_OPT_FLAGS, 0, /* last opt argumnt */ { NULL }, /* arg list/cookie */ NULL, /* must/cannot opts */ NULL, NULL, @@ -158,11 +164,14 @@ static tOptDesc optDesc[ OPTION_CT ] = { /* desc, NAME, name */ zVersionText, NULL, zVersion_Name, /* disablement strs */ NULL, NULL }, +#undef VERSION_OPT_FLAGS + + { /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP, /* equiv idx value */ NO_EQUIVALENT, 0, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, - /* opt state flags */ OPTST_IMM, 0, + /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0, /* last opt argumnt */ { NULL }, /* arg list/cookie */ NULL, /* must/cannot opts */ NULL, NULL, @@ -174,7 +183,7 @@ static tOptDesc optDesc[ OPTION_CT ] = { /* equiv idx value */ NO_EQUIVALENT, 0, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, - /* opt state flags */ OPTST_IMM, 0, + /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0, /* last opt argumnt */ { NULL }, /* arg list/cookie */ NULL, /* must/cannot opts */ NULL, NULL, @@ -204,7 +213,7 @@ If the script file already exists and contains Automated Option Processing\n\ text, the second line of the file through the ending tag will be replaced\n\ by the newly generated text. The first `#!' line will be regenerated.\n"; tSCC zFullVersion[] = GENSHELLOPT_FULL_VERSION; -/* extracted from optcode.tpl near line 378 */ +/* extracted from optcode.tpl near line 408 */ #if defined(ENABLE_NLS) # define OPTPROC_BASE OPTPROC_TRANSLATE @@ -241,7 +250,7 @@ tOptions genshelloptOptions = { NO_EQUIVALENT /* index of '-#' option */, NO_EQUIVALENT /* index of default opt */ }, - OPTION_CT, 2 /* user option count */ + 5 /* full option count */, 2 /* user option count */ }; /* @@ -254,7 +263,7 @@ doUsageOpt( { USAGE( EXIT_SUCCESS ); } -/* extracted from optcode.tpl near line 475 */ +/* extracted from optcode.tpl near line 514 */ #if ENABLE_NLS #include diff --git a/sntp/libopts/genshell.h b/sntp/libopts/genshell.h index af177d177..b57677dce 100644 --- a/sntp/libopts/genshell.h +++ b/sntp/libopts/genshell.h @@ -2,11 +2,11 @@ * * DO NOT EDIT THIS FILE (genshell.h) * - * It has been AutoGen-ed Saturday February 17, 2007 at 12:49:35 PM PST + * It has been AutoGen-ed Saturday May 5, 2007 at 12:02:35 PM PDT * From the definitions genshell.def * and the template file options * - * Generated from AutoOpts 28:0:3 templates. + * Generated from AutoOpts 29:0:4 templates. */ /* @@ -20,7 +20,7 @@ * * This source file is copyrighted and licensed under the following terms: * - * genshellopt copyright 1999-2006 Bruce Korb - all rights reserved + * genshellopt copyright 1999-2007 Bruce Korb - all rights reserved * * genshellopt is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -55,7 +55,7 @@ * tolerable version is at least as old as what was current when the header * template was released. */ -#define AO_TEMPLATE_VERSION 114688 +#define AO_TEMPLATE_VERSION 118784 #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \ || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION) # error option template version mismatches autoopts/options.h header @@ -117,7 +117,7 @@ typedef enum { genshelloptOptions.pzCurOpt = NULL ) #define START_OPT RESTART_OPT(1) #define USAGE(c) (*genshelloptOptions.pUsageProc)( &genshelloptOptions, c ) -/* extracted from opthead.tpl near line 345 */ +/* extracted from opthead.tpl near line 360 */ /* * * * * * * diff --git a/sntp/libopts/m4/libopts.m4 b/sntp/libopts/m4/libopts.m4 index 85f555ba0..adc3235d2 100644 --- a/sntp/libopts/m4/libopts.m4 +++ b/sntp/libopts/m4/libopts.m4 @@ -2,7 +2,7 @@ dnl -*- buffer-read-only: t -*- vi: set ro: dnl dnl DO NOT EDIT THIS FILE (libopts.m4) dnl -dnl It has been AutoGen-ed Saturday February 17, 2007 at 12:49:37 PM PST +dnl It has been AutoGen-ed Saturday May 5, 2007 at 12:02:37 PM PDT dnl From the definitions libopts.def dnl and the template file conftest.tpl dnl @@ -25,7 +25,7 @@ AC_DEFUN([INVOKE_LIBOPTS_MACROS_FIRST],[ AC_CHECK_HEADERS(dlfcn.h errno.h fcntl.h libgen.h memory.h netinet/in.h \ setjmp.h sys/mman.h sys/param.h sys/poll.h sys/procset.h sys/select.h \ sys/socket.h sys/stropts.h sys/time.h sys/un.h sys/wait.h unistd.h \ - utime.h ) + utime.h sysexits.h) # -------------------------------------------- # Verify certain entries from AC_CHECK_HEADERS @@ -370,6 +370,23 @@ return (fp == NULL) ? 1 : fclose(fp); }], ]) # end of AC_DEFUN of LIBOPTS_RUN_FOPEN_TEXT +AC_DEFUN([LIBOPTS_DISABLE_OPTIONAL_ARGS],[ + AC_ARG_ENABLE([optional-args], + AC_HELP_STRING([--disable-optional-args], [not wanting optional option args]), + [libopts_cv_enable_optional_args=${enable_optional_args}], + AC_CACHE_CHECK([whether not wanting optional option args], libopts_cv_enable_optional_args, + libopts_cv_enable_optional_args=yes) + ) # end of AC_ARG_ENABLE + + if test "X${libopts_cv_enable_optional_args}" = Xno + then + AC_DEFINE([NO_OPTIONAL_OPT_ARGS], [1], + [Define this if optional arguments are disallowed]) + fi + +]) # end of AC_DEFUN of LIBOPTS_DISABLE_OPTIONAL_ARGS + + AC_DEFUN([INVOKE_LIBOPTS_MACROS],[ INVOKE_LIBOPTS_MACROS_FIRST # Check to see if a reg expr header is specified. @@ -396,6 +413,9 @@ AC_DEFUN([INVOKE_LIBOPTS_MACROS],[ # Check to see if fopen accepts "t" mode. LIBOPTS_RUN_FOPEN_TEXT + # Check to see if not wanting optional option args. + LIBOPTS_DISABLE_OPTIONAL_ARGS + ]) # end AC_DEFUN of INVOKE_LIBOPTS_MACROS dnl @synopsis LIBOPTS_CHECK diff --git a/sntp/libopts/pgusage.c b/sntp/libopts/pgusage.c index 384ef257a..c417c63d5 100644 --- a/sntp/libopts/pgusage.c +++ b/sntp/libopts/pgusage.c @@ -1,6 +1,6 @@ /* - * $Id: pgusage.c,v 4.11 2006/09/24 02:11:16 bkorb Exp $ + * $Id: pgusage.c,v 4.12 2007/04/28 22:19:23 bkorb Exp $ * Time-stamp: "2006-07-16 08:13:26 bkorb" * * Automated Options Paged Usage module. @@ -10,7 +10,7 @@ */ /* - * Automated Options copyright 1992-2006 Bruce Korb + * Automated Options copyright 1992-2007 Bruce Korb * * Automated Options is free software. * You may redistribute it and/or modify it under the terms of the diff --git a/sntp/libopts/proto.h b/sntp/libopts/proto.h index 0ab75f65a..e87ab87bd 100644 --- a/sntp/libopts/proto.h +++ b/sntp/libopts/proto.h @@ -1,7 +1,7 @@ /* -*- buffer-read-only: t -*- vi: set ro: * * Prototypes for autoopts - * Generated Sat Feb 17 12:49:36 PST 2007 + * Generated Sat May 5 12:02:36 PDT 2007 */ #ifndef AUTOOPTS_PROTO_H_GUARD #define AUTOOPTS_PROTO_H_GUARD 1 diff --git a/sntp/libopts/save.c b/sntp/libopts/save.c index a6fd5634f..22b088803 100644 --- a/sntp/libopts/save.c +++ b/sntp/libopts/save.c @@ -1,7 +1,7 @@ /* - * save.c $Id: save.c,v 4.17 2007/02/04 17:44:12 bkorb Exp $ - * Time-stamp: "2007-01-13 10:32:27 bkorb" + * save.c $Id: save.c,v 4.18 2007/04/15 19:01:18 bkorb Exp $ + * Time-stamp: "2007-04-15 11:11:10 bkorb" * * This module's routines will take the currently set options and * store them into an ".rc" file for re-interpretation the next diff --git a/sntp/libopts/sort.c b/sntp/libopts/sort.c index 8ca6860c6..ead713372 100644 --- a/sntp/libopts/sort.c +++ b/sntp/libopts/sort.c @@ -1,13 +1,13 @@ /* - * sort.c $Id: sort.c,v 4.9 2006/10/21 15:42:49 bkorb Exp $ + * sort.c $Id: sort.c,v 4.10 2007/04/28 22:19:23 bkorb Exp $ * Time-stamp: "2006-10-18 11:29:04 bkorb" * * This module implements argument sorting. */ /* - * Automated Options copyright 1992-2006 Bruce Korb + * Automated Options copyright 1992-2007 Bruce Korb * * Automated Options is free software. * You may redistribute it and/or modify it under the terms of the diff --git a/sntp/libopts/streqvcmp.c b/sntp/libopts/streqvcmp.c index 166ba8abd..8249794e0 100644 --- a/sntp/libopts/streqvcmp.c +++ b/sntp/libopts/streqvcmp.c @@ -1,6 +1,6 @@ /* - * $Id: streqvcmp.c,v 4.9 2006/09/24 02:11:16 bkorb Exp $ + * $Id: streqvcmp.c,v 4.10 2007/04/28 22:19:23 bkorb Exp $ * Time-stamp: "2006-07-26 18:25:53 bkorb" * * String Equivalence Comparison @@ -12,7 +12,7 @@ */ /* - * Automated Options copyright 1992-2006 Bruce Korb + * Automated Options copyright 1992-2007 Bruce Korb * * Automated Options is free software. * You may redistribute it and/or modify it under the terms of the diff --git a/sntp/libopts/usage.c b/sntp/libopts/usage.c index d8b9b6476..960339b63 100644 --- a/sntp/libopts/usage.c +++ b/sntp/libopts/usage.c @@ -1,7 +1,7 @@ /* - * usage.c $Id: usage.c,v 4.13 2006/11/27 01:52:23 bkorb Exp $ - * Time-stamp: "2006-07-01 12:41:02 bkorb" + * usage.c $Id: usage.c,v 4.15 2007/04/28 22:19:23 bkorb Exp $ + * Time-stamp: "2007-04-15 11:02:46 bkorb" * * This module implements the default usage procedure for * Automated Options. It may be overridden, of course. @@ -13,7 +13,7 @@ */ /* - * Automated Options copyright 1992-2006 Bruce Korb + * Automated Options copyright 1992-2007 Bruce Korb * * Automated Options is free software. * You may redistribute it and/or modify it under the terms of the @@ -169,12 +169,18 @@ optionOnlyUsage( * formats. The descriptor specifies the default, but AUTOOPTS_USAGE will * over-ride this, providing the value of it is set to either "gnu" or * "autoopts". This routine will @strong{not} return. + * + * If "exitCode" is "EX_USAGE" (normally 64), then output will to to stdout + * and the actual exit code will be "EXIT_SUCCESS". =*/ void optionUsage( tOptions* pOptions, - int exitCode ) + int usage_exit_code ) { + int actual_exit_code = + (usage_exit_code == EX_USAGE) ? EXIT_SUCCESS : usage_exit_code; + displayEnum = AG_FALSE; /* @@ -183,7 +189,7 @@ optionUsage( * on successful exit (help was requested), otherwise error out. */ if (option_usage_fp == NULL) - option_usage_fp = (exitCode != EXIT_SUCCESS) ? stderr : stdout; + option_usage_fp = (actual_exit_code != EXIT_SUCCESS) ? stderr : stdout; fprintf( option_usage_fp, pOptions->pzUsageTitle, pOptions->pzProgName ); @@ -207,13 +213,13 @@ optionUsage( * option, we do *NOT* want to emit the column headers. * Otherwise, we do. */ - if ( (exitCode != EXIT_SUCCESS) + if ( (usage_exit_code != EXIT_SUCCESS) || ((pOptions->pOptDesc->fOptState & OPTST_DOCUMENT) == 0) ) fputs( pOptTitle, option_usage_fp ); } - printOptionUsage( pOptions, exitCode, pOptTitle ); + printOptionUsage( pOptions, usage_exit_code, pOptTitle ); } /* @@ -241,14 +247,14 @@ optionUsage( * IF the user is asking for help (thus exiting with SUCCESS), * THEN see what additional information we can provide. */ - if (exitCode == EXIT_SUCCESS) + if (usage_exit_code == EXIT_SUCCESS) printProgramDetails( pOptions ); if (pOptions->pzBugAddr != NULL) fprintf( option_usage_fp, zPlsSendBugs, pOptions->pzBugAddr ); fflush( option_usage_fp ); - exit( exitCode ); + exit( actual_exit_code ); } @@ -344,12 +350,15 @@ printExtendedUsage( /* * IF this particular option can NOT be preset * AND some form of presetting IS allowed, + * AND it is not an auto-managed option (e.g. --help, et al.) * THEN advise that this option may not be preset. */ if ( ((pOD->fOptState & OPTST_NO_INIT) != 0) && ( (pOptions->papzHomeList != NULL) || (pOptions->pzPROGNAME != NULL) - ) ) + ) + && (pOD->optIndex < pOptions->presetOptCt) + ) fputs( zNoPreset, option_usage_fp ); @@ -509,7 +518,7 @@ printOneUsage( bogus_desc: fprintf( stderr, zInvalOptDesc, pOD->pz_Name ); - exit( EXIT_FAILURE ); + exit( EX_SOFTWARE ); } diff --git a/sntp/libopts/version.c b/sntp/libopts/version.c index a3936540f..85949d5d3 100644 --- a/sntp/libopts/version.c +++ b/sntp/libopts/version.c @@ -1,13 +1,13 @@ -/* $Id: version.c,v 4.9 2006/09/24 02:11:16 bkorb Exp $ - * Time-stamp: "2006-09-22 18:15:00 bkorb" +/* $Id: version.c,v 4.10 2007/04/28 22:19:23 bkorb Exp $ + * Time-stamp: "2007-04-28 10:08:34 bkorb" * * This module implements the default usage procedure for * Automated Options. It may be overridden, of course. */ static char const zAOV[] = - "Automated Options version %s, copyright (c) 1999-2006 Bruce Korb\n"; + "Automated Options version %s, copyright (c) 1999-2007 Bruce Korb\n"; /* Automated Options is free software. * You may redistribute it and/or modify it under the terms of the @@ -79,9 +79,14 @@ printVersion( tOptions* pOpts, tOptDesc* pOD, FILE* fp ) { char swCh; - if (pOD->optArg.argString == NULL) + /* + * IF the optional argument flag is off, or the argument is not provided, + * then just print the version. + */ + if ( ((pOD->fOptState & OPTST_ARG_OPTIONAL) == 0) + || (pOD->optArg.argString == NULL)) swCh = 'v'; - else swCh = pOD->optArg.argString[0]; + else swCh = tolower(pOD->optArg.argString[0]); if (pOpts->pzFullVersion != NULL) { fputs( pOpts->pzFullVersion, fp ); @@ -89,17 +94,15 @@ printVersion( tOptions* pOpts, tOptDesc* pOD, FILE* fp ) } else { char const *pz = pOpts->pzUsageTitle; - do { fputc( *pz, fp ); } while (*(pz++) != '\n'); + do { fputc(*pz, fp); } while (*(pz++) != '\n'); } switch (swCh) { - case NUL: + case NUL: /* arg provided, but empty */ case 'v': - case 'V': break; case 'c': - case 'C': if (pOpts->pzCopyright != NULL) { fputs( pOpts->pzCopyright, fp ); fputc( '\n', fp ); @@ -110,7 +113,6 @@ printVersion( tOptions* pOpts, tOptDesc* pOD, FILE* fp ) break; case 'n': - case 'N': if (pOpts->pzCopyright != NULL) { fputs( pOpts->pzCopyright, fp ); fputc( '\n', fp );