From: Harlan Stenn Date: Sun, 7 Jul 2013 05:39:47 +0000 (+0000) Subject: Upgrade to libopts-39.0.14 from 5.17.5pre10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aff37c68433e1ae8acccccbc2ad47c75df4dbd54;p=thirdparty%2Fntp.git Upgrade to libopts-39.0.14 from 5.17.5pre10 bk: 51d8ff23Jubgtu01TGrWFVnKkGwBhA --- diff --git a/ChangeLog b/ChangeLog index 8a13b17651..fe2d226ff8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ +* Upgrade to libopts-39.0.14 from 5.17.5pre10. (4.2.7p368) 2013/05/01 Released by Harlan Stenn * [Bug 2145] ntpq dumps core when displaying sys_var_list and more. (4.2.7p367) 2013/04/25 Released by Harlan Stenn diff --git a/sntp/libopts/Makefile.am b/sntp/libopts/Makefile.am index 777cfc2888..44c6d27280 100644 --- a/sntp/libopts/Makefile.am +++ b/sntp/libopts/Makefile.am @@ -7,16 +7,16 @@ noinst_LTLIBRARIES = libopts.la endif libopts_la_SOURCES = libopts.c libopts_la_CPPFLAGS = -I$(top_srcdir) -libopts_la_LDFLAGS = -version-info 38:0:13 +libopts_la_LDFLAGS = -version-info 39:0:14 EXTRA_DIST = \ COPYING.gplv3 COPYING.lgplv3 COPYING.mbsd \ MakeDefs.inc README ag-char-map.h \ alias.c ao-strs.c ao-strs.h \ - autoopts/usage-txt.h autoopts/project.h autoopts/options.h \ + autoopts/options.h autoopts/project.h autoopts/usage-txt.h \ autoopts.c autoopts.h boolean.c \ - check.c compat/snprintf.c compat/strchr.c \ - compat/pathfind.c compat/windows-config.h compat/compat.h \ - compat/strdup.c configfile.c cook.c \ + check.c compat/compat.h compat/snprintf.c \ + compat/pathfind.c compat/strdup.c compat/windows-config.h \ + compat/strchr.c configfile.c cook.c \ enum.c env.c file.c \ find.c genshell.c genshell.h \ gettext.h init.c load.c \ diff --git a/sntp/libopts/ag-char-map.h b/sntp/libopts/ag-char-map.h index 908aa9353e..bffb2f120c 100644 --- a/sntp/libopts/ag-char-map.h +++ b/sntp/libopts/ag-char-map.h @@ -1,6 +1,6 @@ /* * 29 bits for 46 character classifications - * generated by char-mapper on 03/25/13 at 14:10:19 + * generated by char-mapper on 07/05/13 at 20:32:35 * * This file contains the character classifications * used by AutoGen and AutoOpts for identifying tokens. @@ -103,7 +103,7 @@ // file-name +dir-sep +suffix // end-token +nul-byte +whitespace // end-list-entry +comma +end-token -// set-separator "|+" +end-list-entry +// set-separator "|+-!" +end-list-entry // signed-number +inversion +dec-digit // make-script +dollar +newline // load-line-skip +horiz-white +option-marker diff --git a/sntp/libopts/alias.c b/sntp/libopts/alias.c index d05cc4be9b..2fa16fd11c 100644 --- a/sntp/libopts/alias.c +++ b/sntp/libopts/alias.c @@ -74,7 +74,7 @@ optionAlias(tOptions * opts, tOptDesc * old_od, unsigned int alias) new_od = opts->pOptDesc + alias; if ((unsigned)opts->optCt <= alias) { fputs(zbad_alias_id, stderr); - exit(EXIT_FAILURE); + option_exits(EXIT_FAILURE); } /* diff --git a/sntp/libopts/ao-strs.c b/sntp/libopts/ao-strs.c index b0df990d88..a80e78310d 100644 --- a/sntp/libopts/ao-strs.c +++ b/sntp/libopts/ao-strs.c @@ -2,7 +2,7 @@ * * DO NOT EDIT THIS FILE (ao-strs.c) * - * It has been AutoGen-ed March 25, 2013 at 02:10:19 PM by AutoGen 5.17.3.pre9 + * It has been AutoGen-ed July 5, 2013 at 08:32:35 PM by AutoGen 5.17.5pre9 * From the definitions ao-strs.def * and the template file strings * @@ -38,7 +38,7 @@ */ #include "ao-strs.h" -char const ao_strs_strtable[6637] = +char const ao_strs_strtable[6633] = /* 0 */ "-_^\0" /* 4 */ " %s%s\n\0" /* 12 */ "auto-options\0" @@ -130,65 +130,67 @@ char const ao_strs_strtable[6637] = /* 625 */ "=%1$lu # 0x%1$lX\n\0" /* 643 */ "stdout\0" /* 650 */ "%A %B %e, %Y at %r %Z\0" -/* 672 */ "/tmp/use.%lu\0" -/* 685 */ "true\0" -/* 690 */ "<%s type=%s>\0" -/* 703 */ "VERSION\0" -/* 711 */ "#x%02X;\0" -/* 719 */ "OPT_ARG_NEEDED=YES\0" -/* 738 */ "'\\''\0" -/* 743 */ " '%s'\0" -/* 749 */ "\n" +/* 672 */ "%s/use-%u.XXXXXX\0" +/* 689 */ "true\0" +/* 694 */ "<%s type=%s>\0" +/* 707 */ "VERSION\0" +/* 715 */ "#x%02X;\0" +/* 723 */ "OPT_ARG_NEEDED=YES\0" +/* 742 */ "'\\''\0" +/* 747 */ " '%s'\0" +/* 753 */ "\n" "OPTION_CT=0\n\0" -/* 763 */ "set --\0" -/* 770 */ " ;;\n\n\0" -/* 787 */ " '%c' )\n\0" -/* 803 */ " '%s' )\n\0" -/* 819 */ " '%s' | \\\n\0" -/* 837 */ "%1$s /tmp/use.%2$lu ; rm -f /tmp/use.%2$lu\0" -/* 880 */ "<%1$s type=boolean>%2$s\n\0" -/* 912 */ "# From the %s option definitions\n" +/* 767 */ "set --\0" +/* 774 */ " ;;\n\n\0" +/* 791 */ " '%c' )\n\0" +/* 807 */ " '%s' )\n\0" +/* 823 */ " '%s' | \\\n\0" +/* 841 */ "TMPDIR\0" +/* 848 */ "/tmp\0" +/* 853 */ "%1$s %2$s ; rm -f %2$s\0" +/* 876 */ "<%1$s type=boolean>%2$s\n\0" +/* 908 */ "# From the %s option definitions\n" "#\n\0" -/* 949 */ "echo 'Warning: Cannot load options files' >&2\0" -/* 996 */ "echo 'Warning: Cannot save options files' >&2\0" -/* 1043 */ "echo 'Warning: Cannot suppress the loading of options files' >&2\0" -/* 1109 */ "<%1$s type=integer>0x%2$lX\n\0" -/* 1144 */ "%1$s_%2$s_TEXT='no %2$s text'\n\0" -/* 1175 */ "%1$s_%2$s_MODE='%3$s'\n" +/* 945 */ "echo 'Warning: Cannot load options files' >&2\0" +/* 992 */ "echo 'Warning: Cannot save options files' >&2\0" +/* 1039 */ "echo 'Warning: Cannot suppress the loading of options files' >&2\0" +/* 1105 */ "<%1$s type=integer>0x%2$lX\n\0" +/* 1140 */ "%1$s_%2$s_TEXT='no %2$s text'\n\0" +/* 1171 */ "%1$s_%2$s_MODE='%3$s'\n" "export %1$s_%2$s_MODE\n\0" -/* 1220 */ "%1$s_%2$s='%3$s'\n" +/* 1216 */ "%1$s_%2$s='%3$s'\n" "export %1$s_%2$s\n\0" -/* 1255 */ "%1$s_%2$s_CT=%3$d\n" +/* 1251 */ "%1$s_%2$s_CT=%3$d\n" "export %1$s_%2$s_CT\n\0" -/* 1294 */ "OPTION_CT=%d\n" +/* 1290 */ "OPTION_CT=%d\n" "export OPTION_CT\n\0" -/* 1325 */ "%1$s_%2$s=%3$s\n" +/* 1321 */ "%1$s_%2$s=%3$s\n" "export %1$s_%2$s\n\0" -/* 1358 */ "%1$s_%2$s=%3$d # 0x%3$X\n" +/* 1354 */ "%1$s_%2$s=%3$d # 0x%3$X\n" "export %1$s_%2$s\n\0" -/* 1400 */ " case \"${OPT_CODE}\" in\n\0" -/* 1431 */ " if [ $%1$s_%2$s_CT -gt %3$u ] ; then\n" +/* 1396 */ " case \"${OPT_CODE}\" in\n\0" +/* 1427 */ " if [ $%1$s_%2$s_CT -gt %3$u ] ; then\n" " echo 'Error: more than %3$d %2$s options'\n" " echo \"$%1$s_USAGE_TEXT\"\n" " exit 1\n" " fi >&2\n\0" -/* 1622 */ "test ${%1$s_%2$s_CT-0} -ge %3$u || {\n" +/* 1618 */ "test ${%1$s_%2$s_CT-0} -ge %3$u || {\n" " echo %1$s_%2$s has not been set\n" " exit 1\n" "} 1>&2\n\0" -/* 1714 */ "test -n \"$%1$s_%2$s\" || {\n" +/* 1710 */ "test -n \"$%1$s_%2$s\" || {\n" " echo %1$s_%2$s has not been set\n" " exit 1\n" "} 1>&2\n\0" -/* 1795 */ " echo \"$%s_%s_TEXT\"\n" +/* 1791 */ " echo \"$%s_%s_TEXT\"\n" " exit 0\n\0" -/* 1846 */ "\n" +/* 1842 */ "\n" "# # # # # # # # # #\n" "#\n" "# END OF AUTOMATED OPTION PROCESSING\n" "#\n" "# # # # # # # # # # -- do not modify this marker --\n\0" -/* 1962 */ " if [ -n \"${OPT_ARG_VAL}\" ]\n" +/* 1958 */ " if [ -n \"${OPT_ARG_VAL}\" ]\n" " then\n" " eval %1$s_${OPT_NAME}${OPT_ELEMENT}=\"'${OPT_ARG_VAL}'\"\n" " export %1$s_${OPT_NAME}${OPT_ELEMENT}\n" @@ -203,15 +205,15 @@ char const ao_strs_strtable[6637] = "unset OPT_NAME || :\n" "unset OPT_CODE || :\n" "unset OPT_ARG_VAL || :\n\0" -/* 2341 */ " OPT_CODE=`echo \"X${OPT_ARG}\"|sed 's/^X-*//'`\n" +/* 2337 */ " OPT_CODE=`echo \"X${OPT_ARG}\"|sed 's/^X-*//'`\n" " shift\n" " OPT_ARG=$1\n" " case \"${OPT_CODE}\" in *=* )\n" " OPT_ARG_VAL=`echo \"${OPT_CODE}\"|sed 's/^[^=]*=//'`\n" " OPT_CODE=`echo \"${OPT_CODE}\"|sed 's/=.*$//'` ;; esac\n\0" -/* 2592 */ " OPT_CODE=`echo \"X${OPT_ARG}\" | sed 's/X-\\(.\\).*/\\1/'`\n" +/* 2588 */ " OPT_CODE=`echo \"X${OPT_ARG}\" | sed 's/X-\\(.\\).*/\\1/'`\n" " OPT_ARG=` echo \"X${OPT_ARG}\" | sed 's/X-.//'`\n\0" -/* 2709 */ "\n" +/* 2705 */ "\n" "ARG_COUNT=$#\n" "OPT_PROCESS=true\n" "OPT_ARG=$1\n" @@ -224,7 +226,7 @@ char const ao_strs_strtable[6637] = " OPT_PROCESS=false\n" " shift\n" " ;;\n\0" -/* 2916 */ " case \"${OPT_ARG_NEEDED}\" in\n" +/* 2912 */ " case \"${OPT_ARG_NEEDED}\" in\n" " NO )\n" " OPT_ARG_VAL=''\n" " ;;\n" @@ -252,10 +254,10 @@ char const ao_strs_strtable[6637] = " fi\n" " ;;\n" " esac\n\0" -/* 3695 */ " %1$s_%2$s_CT=`expr ${%1$s_%2$s_CT} + 1`\n" +/* 3691 */ " %1$s_%2$s_CT=`expr ${%1$s_%2$s_CT} + 1`\n" " OPT_ELEMENT=\"_${%1$s_%2$s_CT}\"\n" " OPT_NAME='%2$s'\n\0" -/* 3819 */ "\n" +/* 3815 */ "\n" "if test -z \"${%1$s_%2$s}\"\n" "then\n" " %1$s_%2$s_CT=0\n" @@ -265,16 +267,16 @@ char const ao_strs_strtable[6637] = " %1$s_%2$s_1=${%1$s_%2$s}\n" " export %1$s_%2$s_CT %1$s_%2$s_1\n" "fi\n\0" -/* 3977 */ " * )\n" +/* 3973 */ " * )\n" " OPT_PROCESS=false\n" " ;;\n" " esac\n\0" -/* 4034 */ " %1$s_%2$s_CT=0\n" +/* 4030 */ " %1$s_%2$s_CT=0\n" " OPT_ELEMENT=''\n" " %1$s_%2$s='%3$s'\n" " export %1$s_%2$s\n" " OPT_NAME='%2$s'\n\0" -/* 4175 */ " if [ -n \"${%1$s_%2$s}\" ] && ${%1$s_%2$s_set} ; then\n" +/* 4171 */ " if [ -n \"${%1$s_%2$s}\" ] && ${%1$s_%2$s_set} ; then\n" " echo 'Error: duplicate %2$s option'\n" " echo \"$%1$s_USAGE_TEXT\"\n" " exit 1\n" @@ -283,7 +285,7 @@ char const ao_strs_strtable[6637] = " %1$s_%2$s='%3$s'\n" " export %1$s_%2$s\n" " OPT_NAME='%2$s'\n\0" -/* 4492 */ "\n" +/* 4488 */ "\n" "ARG_COUNT=$#\n" "OPT_ARG=$1\n" "while [ $# -gt 0 ]\n" @@ -291,7 +293,7 @@ char const ao_strs_strtable[6637] = " OPT_ELEMENT=''\n" " OPT_ARG_VAL=''\n" " OPT_ARG=${1}\n\0" -/* 4595 */ " case \"${OPT_ARG_NEEDED}\" in\n" +/* 4591 */ " case \"${OPT_ARG_NEEDED}\" in\n" " NO )\n" " if [ -n \"${OPT_ARG}\" ]\n" " then\n" @@ -336,33 +338,33 @@ char const ao_strs_strtable[6637] = " fi\n" " ;;\n" " esac\n\0" -/* 5749 */ " echo \"$%s_LONGUSAGE_TEXT\" | ${PAGER-more}\n" +/* 5745 */ " echo \"$%s_LONGUSAGE_TEXT\" | ${PAGER-more}\n" " exit 0\n\0" -/* 5823 */ "%s OF %s\n" +/* 5819 */ "%s OF %s\n" "#\n" "# From here to the next `-- do not modify this marker --',\n" "# the text has been generated %s\n\0" -/* 5929 */ " eval %1$s_%2$s${OPT_ELEMENT}=true\n" +/* 5925 */ " eval %1$s_%2$s${OPT_ELEMENT}=true\n" " export %1$s_%2$s${OPT_ELEMENT}\n\0" -/* 6019 */ " if [ -n \"${%1$s_%2$s}\" ] && ${%1$s_%2$s_set} ; then\n" +/* 6015 */ " if [ -n \"${%1$s_%2$s}\" ] && ${%1$s_%2$s_set} ; then\n" " echo 'Error: duplicate %2$s option'\n" " echo \"$%1$s_USAGE_TEXT\"\n" " exit 1\n" " fi >&2\n" " %1$s_%2$s_set=true\n" " OPT_NAME='%2$s'\n\0" -/* 6278 */ "\n" +/* 6274 */ "\n" "%1$s_%2$s=${%1$s_%2$s-'%3$s'}\n" "%1$s_%2$s_set=false\n" "export %1$s_%2$s\n\0" -/* 6347 */ "\n" +/* 6343 */ "\n" "%1$s_%2$s=${%1$s_%2$s}\n" "%1$s_%2$s_set=false\n" "export %1$s_%2$s\n\0" -/* 6409 */ "# # # # # # # # # # -- do not modify this marker --\n" +/* 6405 */ "# # # # # # # # # # -- do not modify this marker --\n" "#\n" "# DO NOT EDIT THIS SECTION\n\0" -/* 6492 */ " * )\n" +/* 6488 */ " * )\n" " echo Unknown %s: \"${OPT_CODE}\" >&2\n" " echo \"$%s_USAGE_TEXT\" >&2\n" " exit 1\n" diff --git a/sntp/libopts/ao-strs.h b/sntp/libopts/ao-strs.h index f055adb604..696f3c3d66 100644 --- a/sntp/libopts/ao-strs.h +++ b/sntp/libopts/ao-strs.h @@ -2,7 +2,7 @@ * * DO NOT EDIT THIS FILE (ao-strs.h) * - * It has been AutoGen-ed March 25, 2013 at 02:10:19 PM by AutoGen 5.17.3.pre9 + * It has been AutoGen-ed July 5, 2013 at 08:32:35 PM by AutoGen 5.17.5pre9 * From the definitions ao-strs.def * and the template file strings * @@ -39,29 +39,29 @@ #ifndef STRINGS_AO_STRS_H_GUARD #define STRINGS_AO_STRS_H_GUARD 1 /* - * 140 strings in ao_strs_strtable string table + * 142 strings in ao_strs_strtable string table */ #define ARG_BREAK_STR (ao_strs_strtable+261) #define ARG_BREAK_STR_LEN 5 #define ARG_BY_NUM_FMT (ao_strs_strtable+267) #define ARG_BY_NUM_FMT_LEN 9 -#define BOOL_ATR_FMT (ao_strs_strtable+880) +#define BOOL_ATR_FMT (ao_strs_strtable+876) #define BOOL_ATR_FMT_LEN 31 -#define CHK_MAX_COUNT (ao_strs_strtable+1431) +#define CHK_MAX_COUNT (ao_strs_strtable+1427) #define CHK_MAX_COUNT_LEN 190 -#define CHK_MIN_COUNT (ao_strs_strtable+1622) +#define CHK_MIN_COUNT (ao_strs_strtable+1618) #define CHK_MIN_COUNT_LEN 91 -#define CHK_ONE_REQUIRED (ao_strs_strtable+1714) +#define CHK_ONE_REQUIRED (ao_strs_strtable+1710) #define CHK_ONE_REQUIRED_LEN 80 -#define ECHO_N_EXIT (ao_strs_strtable+1795) +#define ECHO_N_EXIT (ao_strs_strtable+1791) #define ECHO_N_EXIT_LEN 50 #define EMPTY_ARG (ao_strs_strtable+277) #define EMPTY_ARG_LEN 2 -#define END_MARK (ao_strs_strtable+1846) +#define END_MARK (ao_strs_strtable+1842) #define END_MARK_LEN 115 #define END_OPT_SEL_STR (ao_strs_strtable+280) #define END_OPT_SEL_STR_LEN 12 -#define END_PRE_FMT (ao_strs_strtable+912) +#define END_PRE_FMT (ao_strs_strtable+908) #define END_PRE_FMT_LEN 36 #define END_SET_TEXT (ao_strs_strtable+293) #define END_SET_TEXT_LEN 3 @@ -75,15 +75,15 @@ #define EXPORT_ARG_FMT_LEN 17 #define FALSE_STR (ao_strs_strtable+335) #define FALSE_STR_LEN 5 -#define FINISH_LOOP (ao_strs_strtable+1962) +#define FINISH_LOOP (ao_strs_strtable+1958) #define FINISH_LOOP_LEN 378 #define FLAG_OPT_MARK (ao_strs_strtable+341) #define FLAG_OPT_MARK_LEN 9 #define FLAG_STR (ao_strs_strtable+351) #define FLAG_STR_LEN 4 -#define INIT_LOPT_STR (ao_strs_strtable+2341) +#define INIT_LOPT_STR (ao_strs_strtable+2337) #define INIT_LOPT_STR_LEN 250 -#define INIT_OPT_STR (ao_strs_strtable+2592) +#define INIT_OPT_STR (ao_strs_strtable+2588) #define INIT_OPT_STR_LEN 116 #define INVALID_FMT (ao_strs_strtable+356) #define INVALID_FMT_LEN 10 @@ -97,9 +97,9 @@ #define LONG_OPT_MARK_LEN 10 #define LONG_USE_STR (ao_strs_strtable+396) #define LONG_USE_STR_LEN 9 -#define LOOP_STR (ao_strs_strtable+2709) +#define LOOP_STR (ao_strs_strtable+2705) #define LOOP_STR_LEN 206 -#define LOPT_ARG_FMT (ao_strs_strtable+2916) +#define LOPT_ARG_FMT (ao_strs_strtable+2912) #define LOPT_ARG_FMT_LEN 778 #define LVL3_CMD (ao_strs_strtable+406) #define LVL3_CMD_LEN 15 @@ -107,9 +107,9 @@ #define MK_STR_OCT_FMT_LEN 5 #define MORE_STR (ao_strs_strtable+428) #define MORE_STR_LEN 4 -#define MULTI_ARG_FMT (ao_strs_strtable+3695) +#define MULTI_ARG_FMT (ao_strs_strtable+3691) #define MULTI_ARG_FMT_LEN 123 -#define MULTI_DEF_FMT (ao_strs_strtable+3819) +#define MULTI_DEF_FMT (ao_strs_strtable+3815) #define MULTI_DEF_FMT_LEN 157 #define NESTED_OPT_FMT (ao_strs_strtable+433) #define NESTED_OPT_FMT_LEN 17 @@ -119,29 +119,29 @@ #define NLSTR_SPACE_FMT_LEN 5 #define NONE_STR (ao_strs_strtable+91) #define NONE_STR_LEN 4 -#define NOT_FOUND_STR (ao_strs_strtable+3977) +#define NOT_FOUND_STR (ao_strs_strtable+3973) #define NOT_FOUND_STR_LEN 56 #define NO_ARG_NEEDED (ao_strs_strtable+461) #define NO_ARG_NEEDED_LEN 17 -#define NO_LOAD_WARN (ao_strs_strtable+949) +#define NO_LOAD_WARN (ao_strs_strtable+945) #define NO_LOAD_WARN_LEN 46 -#define NO_MULTI_ARG_FMT (ao_strs_strtable+4034) +#define NO_MULTI_ARG_FMT (ao_strs_strtable+4030) #define NO_MULTI_ARG_FMT_LEN 140 -#define NO_SAVE_OPTS (ao_strs_strtable+996) +#define NO_SAVE_OPTS (ao_strs_strtable+992) #define NO_SAVE_OPTS_LEN 46 -#define NO_SGL_ARG_FMT (ao_strs_strtable+4175) +#define NO_SGL_ARG_FMT (ao_strs_strtable+4171) #define NO_SGL_ARG_FMT_LEN 316 -#define NO_SUPPRESS_LOAD (ao_strs_strtable+1043) +#define NO_SUPPRESS_LOAD (ao_strs_strtable+1039) #define NO_SUPPRESS_LOAD_LEN 65 #define NULL_ATR_FMT (ao_strs_strtable+479) #define NULL_ATR_FMT_LEN 6 -#define NUMB_ATR_FMT (ao_strs_strtable+1109) +#define NUMB_ATR_FMT (ao_strs_strtable+1105) #define NUMB_ATR_FMT_LEN 34 #define OK_NEED_OPT_ARG (ao_strs_strtable+486) #define OK_NEED_OPT_ARG_LEN 17 #define ONE_TAB_STR (ao_strs_strtable+504) #define ONE_TAB_STR_LEN 1 -#define ONLY_OPTS_LOOP (ao_strs_strtable+4492) +#define ONLY_OPTS_LOOP (ao_strs_strtable+4488) #define ONLY_OPTS_LOOP_LEN 102 #define OPEN_CLOSE_FMT (ao_strs_strtable+479) #define OPEN_CLOSE_FMT_LEN 6 @@ -149,7 +149,7 @@ #define OPEN_XML_FMT_LEN 4 #define OPTION_STR (ao_strs_strtable+511) #define OPTION_STR_LEN 6 -#define OPT_ARG_FMT (ao_strs_strtable+4595) +#define OPT_ARG_FMT (ao_strs_strtable+4591) #define OPT_ARG_FMT_LEN 1153 #define OPT_END_FMT (ao_strs_strtable+518) #define OPT_END_FMT_LEN 14 @@ -159,15 +159,13 @@ #define OR_STR_LEN 3 #define PAGER_NAME (ao_strs_strtable+544) #define PAGER_NAME_LEN 5 -#define PAGE_USAGE_FMT (ao_strs_strtable+837) -#define PAGE_USAGE_FMT (ao_strs_strtable+837) -#define PAGE_USAGE_FMT_LEN 42 -#define PAGE_USAGE_FMT_LEN 42 -#define PAGE_USAGE_TEXT (ao_strs_strtable+5749) +#define PAGE_USAGE_FMT (ao_strs_strtable+853) +#define PAGE_USAGE_FMT_LEN 22 +#define PAGE_USAGE_TEXT (ao_strs_strtable+5745) #define PAGE_USAGE_TEXT_LEN 73 #define PLUS_STR (ao_strs_strtable+550) #define PLUS_STR_LEN 3 -#define PREAMBLE_FMT (ao_strs_strtable+5823) +#define PREAMBLE_FMT (ao_strs_strtable+5819) #define PREAMBLE_FMT_LEN 105 #define PUTS_FMT (ao_strs_strtable+554) #define PUTS_FMT_LEN 15 @@ -175,19 +173,19 @@ #define QUOT_APOS_LEN 2 #define QUOT_ARG_FMT (ao_strs_strtable+573) #define QUOT_ARG_FMT_LEN 4 -#define SET_MULTI_ARG (ao_strs_strtable+5929) +#define SET_MULTI_ARG (ao_strs_strtable+5925) #define SET_MULTI_ARG_LEN 89 -#define SET_NO_TEXT_FMT (ao_strs_strtable+1144) +#define SET_NO_TEXT_FMT (ao_strs_strtable+1140) #define SET_NO_TEXT_FMT_LEN 30 #define SET_OFF_FMT (ao_strs_strtable+578) #define SET_OFF_FMT_LEN 6 #define SET_TEXT_FMT (ao_strs_strtable+585) #define SET_TEXT_FMT_LEN 12 -#define SGL_ARG_FMT (ao_strs_strtable+6019) +#define SGL_ARG_FMT (ao_strs_strtable+6015) #define SGL_ARG_FMT_LEN 258 -#define SGL_DEF_FMT (ao_strs_strtable+6278) +#define SGL_DEF_FMT (ao_strs_strtable+6274) #define SGL_DEF_FMT_LEN 68 -#define SGL_NO_DEF_FMT (ao_strs_strtable+6347) +#define SGL_NO_DEF_FMT (ao_strs_strtable+6343) #define SGL_NO_DEF_FMT_LEN 61 #define SHELL_MAGIC (ao_strs_strtable+598) #define SHELL_MAGIC_LEN 6 @@ -195,49 +193,55 @@ #define SHOW_PROG_ENV_LEN 19 #define SHOW_VAL_FMT (ao_strs_strtable+625) #define SHOW_VAL_FMT_LEN 17 -#define START_MARK (ao_strs_strtable+6409) +#define START_MARK (ao_strs_strtable+6405) #define START_MARK_LEN 82 #define STDOUT (ao_strs_strtable+643) #define STDOUT_LEN 6 #define TIME_FMT (ao_strs_strtable+650) #define TIME_FMT_LEN 21 +#define TMPDIR (ao_strs_strtable+841) +#define TMPDIR_LEN 6 +#define TMP_FILE_FMT (ao_strs_strtable+672) +#define TMP_FILE_FMT_LEN 16 #define TMP_USAGE_FMT (ao_strs_strtable+672) -#define TMP_USAGE_FMT_LEN 12 -#define TRUE_STR (ao_strs_strtable+685) +#define TMP_USAGE_FMT_LEN 16 +#define TRUE_STR (ao_strs_strtable+689) #define TRUE_STR_LEN 4 #define TWO_SPACES_STR (ao_strs_strtable+254) #define TWO_SPACES_STR_LEN 2 -#define TYPE_ATR_FMT (ao_strs_strtable+690) +#define TYPE_ATR_FMT (ao_strs_strtable+694) #define TYPE_ATR_FMT_LEN 12 -#define UNK_OPT_FMT (ao_strs_strtable+6492) +#define UNK_OPT_FMT (ao_strs_strtable+6488) #define UNK_OPT_FMT_LEN 144 -#define VER_STR (ao_strs_strtable+703) +#define VER_STR (ao_strs_strtable+707) #define VER_STR_LEN 7 -#define XML_HEX_BYTE_FMT (ao_strs_strtable+711) +#define XML_HEX_BYTE_FMT (ao_strs_strtable+715) #define XML_HEX_BYTE_FMT_LEN 7 -#define YES_NEED_OPT_ARG (ao_strs_strtable+719) +#define YES_NEED_OPT_ARG (ao_strs_strtable+723) #define YES_NEED_OPT_ARG_LEN 18 -#define apostrophe (ao_strs_strtable+738) +#define apostrophe (ao_strs_strtable+742) #define apostrophe_LEN 4 -#define arg_fmt (ao_strs_strtable+743) +#define arg_fmt (ao_strs_strtable+747) #define arg_fmt_LEN 5 -#define init_optct (ao_strs_strtable+749) +#define init_optct (ao_strs_strtable+753) #define init_optct_LEN 13 -#define set_dash (ao_strs_strtable+763) +#define set_dash (ao_strs_strtable+767) #define set_dash_LEN 6 +#define tmp_dir (ao_strs_strtable+848) +#define tmp_dir_LEN 4 #define zAll (ao_strs_strtable+257) #define zAll_LEN 3 #define zCfgAO_Flags (ao_strs_strtable+12) #define zCfgAO_Flags_LEN 12 #define zCfgProg (ao_strs_strtable+25) #define zCfgProg_LEN 7 -#define zEquivMode (ao_strs_strtable+1175) +#define zEquivMode (ao_strs_strtable+1171) #define zEquivMode_LEN 44 #define zFiveSpaces (ao_strs_strtable+244) #define zFiveSpaces_LEN 5 #define zFmtFmt (ao_strs_strtable+33) #define zFmtFmt_LEN 11 -#define zFullOptFmt (ao_strs_strtable+1220) +#define zFullOptFmt (ao_strs_strtable+1216) #define zFullOptFmt_LEN 34 #define zGnuBreak (ao_strs_strtable+45) #define zGnuBreak_LEN 5 @@ -255,23 +259,23 @@ #define zGnuTimeArg_LEN 4 #define zNone (ao_strs_strtable+91) #define zNone_LEN 4 -#define zOptCookieCt (ao_strs_strtable+1255) +#define zOptCookieCt (ao_strs_strtable+1251) #define zOptCookieCt_LEN 38 -#define zOptCtFmt (ao_strs_strtable+1294) +#define zOptCtFmt (ao_strs_strtable+1290) #define zOptCtFmt_LEN 30 -#define zOptDisabl (ao_strs_strtable+1325) +#define zOptDisabl (ao_strs_strtable+1321) #define zOptDisabl_LEN 32 -#define zOptNumFmt (ao_strs_strtable+1358) +#define zOptNumFmt (ao_strs_strtable+1354) #define zOptNumFmt_LEN 41 -#define zOptionCase (ao_strs_strtable+1400) +#define zOptionCase (ao_strs_strtable+1396) #define zOptionCase_LEN 30 -#define zOptionEndSelect (ao_strs_strtable+770) +#define zOptionEndSelect (ao_strs_strtable+774) #define zOptionEndSelect_LEN 16 -#define zOptionFlag (ao_strs_strtable+787) +#define zOptionFlag (ao_strs_strtable+791) #define zOptionFlag_LEN 15 -#define zOptionFullName (ao_strs_strtable+803) +#define zOptionFullName (ao_strs_strtable+807) #define zOptionFullName_LEN 15 -#define zOptionPartName (ao_strs_strtable+819) +#define zOptionPartName (ao_strs_strtable+823) #define zOptionPartName_LEN 17 #define zPresetFile (ao_strs_strtable+96) #define zPresetFile_LEN 37 @@ -321,6 +325,6 @@ #define zTwoSpaces_LEN 2 #define zambig_file (ao_strs_strtable+4) #define zambig_file_LEN 7 -extern char const ao_strs_strtable[6637]; +extern char const ao_strs_strtable[6633]; #endif /* STRINGS_AO_STRS_H_GUARD */ diff --git a/sntp/libopts/autoopts.c b/sntp/libopts/autoopts.c index ff54b1619c..bbf27df567 100644 --- a/sntp/libopts/autoopts.c +++ b/sntp/libopts/autoopts.c @@ -32,21 +32,6 @@ * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd */ -#ifndef PKGDATADIR -# define PKGDATADIR "" -#endif - -static char const zNil[] = ""; -static arg_types_t argTypes = { NULL }; -static char line_fmt_buf[32]; -static bool displayEnum = false; -static char const pkgdatadir_default[] = PKGDATADIR; -static char const * program_pkgdatadir = pkgdatadir_default; -static tOptionLoadMode option_load_mode = OPTION_LOAD_UNCOOKED; -static tePagerState pagerState = PAGER_STATE_INITIAL; - - FILE * option_usage_fp = NULL; - /** * The number of tab characters to skip when printing continuation lines. */ @@ -58,7 +43,7 @@ ao_malloc(size_t sz) void * res = malloc(sz); if (res == NULL) { fprintf(stderr, zalloc_fail, (int)sz); - exit(EXIT_FAILURE); + option_exits(EXIT_FAILURE); } return res; } @@ -71,7 +56,7 @@ ao_realloc(void *p, size_t sz) void * res = (p == NULL) ? malloc(sz) : realloc(p, sz); if (res == NULL) { fprintf(stderr, zrealloc_fail, (int)sz, p); - exit(EXIT_FAILURE); + option_exits(EXIT_FAILURE); } return res; } @@ -84,7 +69,7 @@ ao_strdup(char const *str) char * res = strdup(str); if (res == NULL) { fprintf(stderr, zalloc_fail, (int)strlen(str)); - exit(EXIT_FAILURE); + option_exits(EXIT_FAILURE); } return res; } @@ -386,7 +371,7 @@ optionProcess(tOptions * opts, int a_ct, char ** a_v) if (SELECTED_OPT(od)) { optionSaveFile(opts); - exit(EXIT_SUCCESS); + option_exits(EXIT_SUCCESS); } } } diff --git a/sntp/libopts/autoopts.h b/sntp/libopts/autoopts.h index 67fb86d7d0..d66e7419b9 100644 --- a/sntp/libopts/autoopts.h +++ b/sntp/libopts/autoopts.h @@ -392,6 +392,65 @@ static char const * program_pkgdatadir; */ extern tOptProc optionPrintVersion, optionPagedUsage, optionLoadOpt; +#ifdef AUTOOPTS_INTERNAL + +#ifndef PKGDATADIR +# define PKGDATADIR "" +#endif +#define APOSTROPHE '\'' + +#define OPTPROC_L_N_S (OPTPROC_LONGOPT | OPTPROC_SHORTOPT) +#if defined(ENABLE_NLS) && defined(HAVE_LIBINTL_H) +# include +#endif + +typedef struct { + size_t fnm_len; + uint32_t fnm_mask; + char const * fnm_name; +} ao_flag_names_t; + +/** + * Automated Options Usage Flags. + * NB: no entry may be a prefix of another entry + */ +#define AOFLAG_TABLE \ + _aof_(gnu, OPTPROC_GNUUSAGE ) \ + _aof_(autoopts, ~OPTPROC_GNUUSAGE) \ + _aof_(no_misuse_usage, OPTPROC_MISUSE ) \ + _aof_(misuse_usage, ~OPTPROC_MISUSE ) \ + _aof_(compute, OPTPROC_COMPUTE ) + +#define _aof_(_n, _f) AOUF_ ## _n ## _ID, +typedef enum { AOFLAG_TABLE AOUF_COUNT } ao_flag_id_t; +#undef _aof_ + +#define _aof_(_n, _f) AOUF_ ## _n = (1 << AOUF_ ## _n ## _ID), +typedef enum { AOFLAG_TABLE } ao_flags_t; +#undef _aof_ + +static char const zNil[] = ""; +static arg_types_t argTypes = { NULL }; +static char line_fmt_buf[32]; +static bool displayEnum = false; +static char const pkgdatadir_default[] = PKGDATADIR; +static char const * program_pkgdatadir = pkgdatadir_default; +static tOptionLoadMode option_load_mode = OPTION_LOAD_UNCOOKED; +static tePagerState pagerState = PAGER_STATE_INITIAL; + + FILE * option_usage_fp = NULL; + +static char const * pz_enum_err_fmt; + +tOptions * optionParseShellOptions = NULL; + +static char const * shell_prog = NULL; +static char * script_leader = NULL; +static char * script_trailer = NULL; +static char * script_text = NULL; +static bool print_exit = false; +#endif /* AUTOOPTS_INTERNAL */ + #endif /* AUTOGEN_AUTOOPTS_H */ /** * @} diff --git a/sntp/libopts/autoopts/options.h b/sntp/libopts/autoopts/options.h index 44fdb50e78..36ec370fd6 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 March 25, 2013 at 02:10:26 PM by AutoGen 5.17.3.pre9 + * It has been AutoGen-ed July 5, 2013 at 08:32:42 PM by AutoGen 5.17.5pre9 * From the definitions funcs.def * and the template file options_h * @@ -101,15 +101,15 @@ * @{ */ /// autoopts structure version -#define OPTIONS_STRUCT_VERSION 155648 +#define OPTIONS_STRUCT_VERSION 159744 /// autoopts structure version string -#define OPTIONS_VERSION_STRING "38:0:13" +#define OPTIONS_VERSION_STRING "39:0:14" /// minimum version the autoopts library supports #define OPTIONS_MINIMUM_VERSION 102400 /// minimum version the autoopts library supports as a string #define OPTIONS_MIN_VER_STRING "25:0:0" /// the display version of the autoopts library, as a string -#define OPTIONS_DOTTED_VERSION "38.0" +#define OPTIONS_DOTTED_VERSION "39.0" /// convert a version/release number pair to an integer value #define OPTIONS_VER_TO_NUM(_v, _r) (((_v) * 4096) + (_r)) /// @} @@ -375,13 +375,16 @@ typedef uint32_t proc_state_mask_t; #define OPTPROC_PRESETTING 0x080000U /** proc_state_mask_t - Ignore pzFullUsage, compute usage text */ #define OPTPROC_COMPUTE 0x100000U +/** proc_state_mask_t - Program outputs digested option state for shell scripts. +Usage text always written to stderr */ +#define OPTPROC_SHELL_OUTPUT 0x200000U /** bits in NO_XLAT mask: * nxlat_opt_cfg nxlat_opt */ #define OPTPROC_NO_XLAT_MASK 0x030000U /** all bits in proc_state_mask_t masks */ -#define OPTPROC_MASK_ALL 0x1FFFFFU +#define OPTPROC_MASK_ALL 0x3FFFFFU /** no bits in proc_state_mask_t */ #define OPTPROC_NONE 0x000000U @@ -911,6 +914,19 @@ extern const tOptionValue* optionGetValue(const tOptionValue*, char const*); extern void optionLoadLine(tOptions*, char const*); +/** + * optionMemberList - Get the list of members of a bit mask set + * + * This converts the OPT_VALUE_name mask value to a allocated string. + * It is the caller's responsibility to free the string. + * + * @param od the set membership option description + * + * @return char* - the names of the set bits + */ +extern char* optionMemberList(tOptDesc *); + + /** * optionNextValue - get the next value from a hierarchical list * @@ -1167,7 +1183,7 @@ extern void optionNestedVal(tOptions*, tOptDesc*); extern void optionNumericVal(tOptions*, tOptDesc*); -extern void optionPagedUsage(tOptions*, tOptDesc*); +extern void optionPagedUsage(tOptions *, tOptDesc *); extern void optionParseShell(tOptions*); diff --git a/sntp/libopts/autoopts/project.h b/sntp/libopts/autoopts/project.h index 34a215368d..fe97e66683 100644 --- a/sntp/libopts/autoopts/project.h +++ b/sntp/libopts/autoopts/project.h @@ -71,5 +71,7 @@ typedef int tSuccess; # define MODE extern #endif +#define parse_duration option_parse_duration + #endif /* AUTOGEN_PROJECT_H */ /* end of project.h */ diff --git a/sntp/libopts/autoopts/usage-txt.h b/sntp/libopts/autoopts/usage-txt.h index 6808e7a9d3..383e9871d6 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 March 25, 2013 at 02:10:24 PM by AutoGen 5.17.3.pre9 + * It has been AutoGen-ed July 5, 2013 at 08:32:40 PM by AutoGen 5.17.5pre9 * From the definitions usage-txt.def * and the template file usage-txt.tpl * @@ -362,39 +362,39 @@ do not compile this section. */ static void dummy_func(void) { /* LIBOPTS-MESSAGES: */ -#line 60 "../autoopts.c" +#line 45 "../autoopts.c" puts(_("allocation of %d bytes failed\n")); -#line 86 "../autoopts.c" +#line 71 "../autoopts.c" puts(_("allocation of %d bytes failed\n")); #line 53 "../init.c" puts(_("AutoOpts function called without option descriptor\n")); -#line 89 "../init.c" +#line 90 "../init.c" puts(_("\tThis exceeds the compiled library version: ")); -#line 87 "../init.c" +#line 88 "../init.c" puts(_("Automated Options Processing Error!\n" "\t%s called AutoOpts function with structure version %d:%d:%d.\n")); -#line 73 "../autoopts.c" +#line 58 "../autoopts.c" puts(_("realloc of %d bytes at 0x%p failed\n")); -#line 91 "../init.c" +#line 92 "../init.c" puts(_("\tThis is less than the minimum library version: ")); #line 121 "../version.c" puts(_("Automated Options version %s\n" "\tCopyright (C) 1999-2013 by Bruce Korb - all rights reserved\n")); -#line 310 "../usage.c" +#line 82 "../makeshell.c" puts(_("(AutoOpts bug): %s.\n")); #line 90 "../reset.c" puts(_("optionResetOpt() called, but reset-option not configured")); -#line 329 "../usage.c" +#line 292 "../usage.c" puts(_("could not locate the 'help' option")); -#line 351 "../autoopts.c" +#line 336 "../autoopts.c" puts(_("optionProcess() was called with invalid data")); -#line 783 "../usage.c" +#line 747 "../usage.c" puts(_("invalid argument type specified")); #line 589 "../find.c" puts(_("defaulted to option with optional arg")); #line 76 "../alias.c" puts(_("aliasing option is out of range.")); -#line 229 "../enum.c" +#line 234 "../enum.c" puts(_("%s error: the keyword '%s' is ambiguous for %s\n")); #line 108 "../find.c" puts(_(" The following options match:\n")); @@ -404,9 +404,9 @@ static void dummy_func(void) { puts(_("%s: Command line arguments required\n")); #line 43 "../alias.c" puts(_("%d %s%s options allowed\n")); -#line 81 "../makeshell.c" +#line 89 "../makeshell.c" puts(_("%s error %d (%s) calling %s for '%s'\n")); -#line 293 "../makeshell.c" +#line 301 "../makeshell.c" puts(_("interprocess pipe")); #line 168 "../version.c" puts(_("error: version option argument '%c' invalid. Use:\n" @@ -433,19 +433,19 @@ static void dummy_func(void) { puts(_("%s: illegal option -- %s\n")); #line 332 "../find.c" puts(_("%s: unknown vendor extension option -- %s\n")); -#line 154 "../enum.c" +#line 159 "../enum.c" puts(_(" or an integer from %d through %d\n")); -#line 164 "../enum.c" +#line 169 "../enum.c" puts(_(" or an integer from %d through %d\n")); -#line 782 "../usage.c" +#line 746 "../usage.c" puts(_("%s error: invalid option descriptor for %s\n")); -#line 1110 "../usage.c" +#line 1080 "../usage.c" puts(_("%s error: invalid option descriptor for %s\n")); #line 379 "../find.c" puts(_("%s: invalid option name: %s\n")); #line 518 "../find.c" puts(_("%s: The '%s' option requires an argument.\n")); -#line 171 "../autoopts.c" +#line 156 "../autoopts.c" puts(_("(AutoOpts bug): Equivalenced option '%s' was equivalenced to both\n" "\t'%s' and '%s'.")); #line 94 "../check.c" @@ -454,9 +454,9 @@ static void dummy_func(void) { puts(_("%s: The '%s' option cannot have an argument.\n")); #line 151 "../check.c" puts(_("%s: Command line arguments are not allowed.\n")); -#line 531 "../save.c" +#line 535 "../save.c" puts(_("error %d (%s) creating %s\n")); -#line 229 "../enum.c" +#line 234 "../enum.c" puts(_("%s error: '%s' does not match any %s keywords.\n")); #line 93 "../reset.c" puts(_("%s error: The '%s' option requires an argument.\n")); @@ -466,7 +466,7 @@ static void dummy_func(void) { puts(_("error %d (%s) stat-ing %s\n")); #line 143 "../restore.c" puts(_("%s error: no saved option state\n")); -#line 246 "../autoopts.c" +#line 231 "../autoopts.c" puts(_("'%s' is not a command line option.\n")); #line 114 "../time.c" puts(_("%s error: '%s' is not a recognizable date/time.\n")); @@ -478,41 +478,41 @@ static void dummy_func(void) { puts(_("%s error: The %s option must appear %d times.\n")); #line 157 "../numeric.c" puts(_("%s error: '%s' is not a recognizable number.\n")); -#line 195 "../enum.c" +#line 200 "../enum.c" puts(_("%s error: %s exceeds %s keyword count\n")); -#line 366 "../usage.c" +#line 329 "../usage.c" puts(_("Try '%s %s' for more information.\n")); #line 45 "../alias.c" puts(_("one %s%s option allowed\n")); -#line 195 "../makeshell.c" +#line 203 "../makeshell.c" puts(_("standard output")); -#line 930 "../makeshell.c" +#line 938 "../makeshell.c" puts(_("standard output")); -#line 304 "../usage.c" +#line 274 "../usage.c" puts(_("standard output")); -#line 451 "../usage.c" +#line 414 "../usage.c" puts(_("standard output")); -#line 660 "../usage.c" +#line 624 "../usage.c" puts(_("standard output")); #line 175 "../version.c" puts(_("standard output")); -#line 304 "../usage.c" +#line 274 "../usage.c" puts(_("standard error")); -#line 451 "../usage.c" +#line 414 "../usage.c" puts(_("standard error")); -#line 660 "../usage.c" +#line 624 "../usage.c" puts(_("standard error")); #line 175 "../version.c" puts(_("standard error")); -#line 195 "../makeshell.c" +#line 203 "../makeshell.c" puts(_("write")); -#line 930 "../makeshell.c" +#line 938 "../makeshell.c" puts(_("write")); -#line 303 "../usage.c" +#line 273 "../usage.c" puts(_("write")); -#line 450 "../usage.c" +#line 413 "../usage.c" puts(_("write")); -#line 659 "../usage.c" +#line 623 "../usage.c" puts(_("write")); #line 174 "../version.c" puts(_("write")); @@ -528,70 +528,70 @@ static void dummy_func(void) { puts(_("%s warning: cannot save options - %s not regular file\n")); #line 256 "../save.c" puts(_("%s warning: cannot save options - %s not regular file\n")); -#line 530 "../save.c" +#line 534 "../save.c" puts(_("%s warning: cannot save options - %s not regular file\n")); /* END-LIBOPTS-MESSAGES */ /* USAGE-TEXT: */ -#line 908 "../usage.c" +#line 872 "../usage.c" puts(_("\t\t\t\t- an alternate for '%s'\n")); -#line 1177 "../usage.c" +#line 1147 "../usage.c" puts(_("Version, usage and configuration options:")); -#line 959 "../usage.c" +#line 923 "../usage.c" puts(_("\t\t\t\t- default option for unnamed options\n")); -#line 872 "../usage.c" +#line 836 "../usage.c" puts(_("\t\t\t\t- disabled as '--%s'\n")); -#line 1146 "../usage.c" +#line 1116 "../usage.c" puts(_(" --- %-14s %s\n")); -#line 1144 "../usage.c" +#line 1114 "../usage.c" puts(_("This option has been disabled")); -#line 899 "../usage.c" +#line 863 "../usage.c" puts(_("\t\t\t\t- enabled by default\n")); #line 40 "../alias.c" puts(_("%s error: only ")); -#line 1221 "../usage.c" +#line 1193 "../usage.c" puts(_(" - examining environment variables named %s_*\n")); #line 168 "../file.c" puts(_("\t\t\t\t- file must not pre-exist\n")); #line 172 "../file.c" puts(_("\t\t\t\t- file must pre-exist\n")); -#line 416 "../usage.c" +#line 379 "../usage.c" puts(_("Options are specified by doubled hyphens and their name or by a single\n" "hyphen and the flag character.\n")); -#line 908 "../makeshell.c" +#line 916 "../makeshell.c" puts(_("\n" "= = = = = = = =\n\n" "This incarnation of genshell will produce\n" "a shell script to parse the options for %s:\n\n")); -#line 161 "../enum.c" +#line 166 "../enum.c" puts(_(" or an integer mask with any of the lower %d bits set\n")); -#line 932 "../usage.c" +#line 896 "../usage.c" puts(_("\t\t\t\t- is a set membership option\n")); -#line 953 "../usage.c" +#line 917 "../usage.c" puts(_("\t\t\t\t- must appear between %d and %d times\n")); -#line 418 "../usage.c" +#line 381 "../usage.c" puts(_("Options are specified by single or double hyphens and their name.\n")); -#line 939 "../usage.c" +#line 903 "../usage.c" puts(_("\t\t\t\t- may appear multiple times\n")); -#line 926 "../usage.c" +#line 890 "../usage.c" puts(_("\t\t\t\t- may not be preset\n")); -#line 1336 "../usage.c" +#line 1308 "../usage.c" puts(_(" Arg Option-Name Description\n")); -#line 1272 "../usage.c" +#line 1244 "../usage.c" puts(_(" Flg Arg Option-Name Description\n")); -#line 1330 "../usage.c" +#line 1302 "../usage.c" puts(_(" Flg Arg Option-Name Description\n")); -#line 1331 "../usage.c" +#line 1303 "../usage.c" puts(_(" %3s %s")); -#line 1337 "../usage.c" +#line 1309 "../usage.c" puts(_(" %3s %s")); -#line 423 "../usage.c" +#line 386 "../usage.c" puts(_("The '-#' option may omit the hash char\n")); -#line 419 "../usage.c" +#line 382 "../usage.c" puts(_("All arguments are named options.\n")); -#line 1006 "../usage.c" +#line 970 "../usage.c" puts(_(" - reading file %s")); -#line 445 "../usage.c" +#line 408 "../usage.c" puts(_("\n" "Please send bug reports to: <%s>\n")); #line 100 "../version.c" @@ -600,17 +600,17 @@ static void dummy_func(void) { #line 129 "../version.c" puts(_("\n" "Please send bug reports to: <%s>\n")); -#line 938 "../usage.c" +#line 902 "../usage.c" puts(_("\t\t\t\t- may NOT appear - preset only\n")); -#line 978 "../usage.c" +#line 943 "../usage.c" puts(_("\n" "The following option preset mechanisms are supported:\n")); -#line 1219 "../usage.c" +#line 1191 "../usage.c" puts(_("\n" "The following option preset mechanisms are supported:\n")); -#line 717 "../usage.c" +#line 681 "../usage.c" puts(_("prohibits these options:\n")); -#line 712 "../usage.c" +#line 676 "../usage.c" puts(_("prohibits the option '%s'\n")); #line 81 "../numeric.c" puts(_("%s%ld to %ld")); @@ -628,28 +628,28 @@ static void dummy_func(void) { puts(_("%sis scalable with a suffix: k/K/m/M/g/G/t/T\n")); #line 77 "../numeric.c" puts(_("%sless than or equal to %ld")); -#line 426 "../usage.c" +#line 389 "../usage.c" puts(_("Operands and options may be intermixed. They will be reordered.\n")); -#line 687 "../usage.c" +#line 651 "../usage.c" puts(_("requires the option '%s'\n")); -#line 690 "../usage.c" +#line 654 "../usage.c" puts(_("requires these options:\n")); -#line 1348 "../usage.c" +#line 1320 "../usage.c" puts(_(" Arg Option-Name Req? Description\n")); -#line 1342 "../usage.c" +#line 1314 "../usage.c" puts(_(" Flg Arg Option-Name Req? Description\n")); -#line 162 "../enum.c" +#line 167 "../enum.c" puts(_("or you may use a numeric representation. Preceding these with a '!'\n" "will clear the bits, specifying 'none' will clear all bits, and 'all'\n" "will set them all. Multiple entries may be passed as an option\n" "argument list.\n")); -#line 945 "../usage.c" +#line 909 "../usage.c" puts(_("\t\t\t\t- may appear up to %d times\n")); -#line 72 "../enum.c" +#line 77 "../enum.c" puts(_("The valid \"%s\" option keywords are:\n")); -#line 1181 "../usage.c" +#line 1151 "../usage.c" puts(_("The next option supports vendor supported extra options:")); -#line 808 "../usage.c" +#line 772 "../usage.c" puts(_("These additional options are:")); /* END-USAGE-TEXT */ } diff --git a/sntp/libopts/enum.c b/sntp/libopts/enum.c index 6529083b0c..4d52aa7361 100644 --- a/sntp/libopts/enum.c +++ b/sntp/libopts/enum.c @@ -33,8 +33,6 @@ * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd */ -static char const * pz_enum_err_fmt; - /* = = = START-STATIC-FORWARD = = = */ static void enum_err(tOptions * pOpts, tOptDesc * pOD, @@ -49,8 +47,15 @@ set_memb_shell(tOptions * pOpts, tOptDesc * pOD, char const * const * paz_names, unsigned int name_ct); static void -set_memb_names(tOptions * pOpts, tOptDesc * pOD, char const * const * paz_names, - unsigned int name_ct); +set_memb_names(tOptions * opts, tOptDesc * od, char const * const * nm_list, + unsigned int nm_ct); + +static uintptr_t +check_membership_start(tOptDesc * od, char const ** argp, bool * invert); + +static uintptr_t +find_member_bit(tOptions * opts, tOptDesc * od, char const * pz, int len, + char const * const * nm_list, unsigned int nm_ct); /* = = = END-STATIC-FORWARD = = = */ static void @@ -360,16 +365,14 @@ set_memb_shell(tOptions * pOpts, tOptDesc * pOD, char const * const * paz_names, } static void -set_memb_names(tOptions * pOpts, tOptDesc * pOD, char const * const * paz_names, - unsigned int name_ct) +set_memb_names(tOptions * opts, tOptDesc * od, char const * const * nm_list, + unsigned int nm_ct) { char * pz; - uintptr_t bits = (uintptr_t)pOD->optCookie; + uintptr_t mask = (1UL << (uintptr_t)nm_ct) - 1UL; + uintptr_t bits = (uintptr_t)od->optCookie & mask; unsigned int ix = 0; - size_t len = NONE_STR_LEN + 1; - - (void)pOpts; - bits &= ((uintptr_t)1 << (uintptr_t)name_ct) - (uintptr_t)1; + size_t len = 1; /* * Replace the enumeration value with the name string. @@ -377,46 +380,161 @@ set_memb_names(tOptions * pOpts, tOptDesc * pOD, char const * const * paz_names, */ while (bits != 0) { if (bits & 1) - len += strlen(paz_names[ix]) + PLUS_STR_LEN + 1; - if (++ix >= name_ct) break; + len += strlen(nm_list[ix]) + PLUS_STR_LEN + 1; + if (++ix >= nm_ct) break; bits >>= 1; } - pOD->optArg.argString = pz = AGALOC(len, "enum"); + od->optArg.argString = pz = AGALOC(len, "enum"); + bits = (uintptr_t)od->optCookie & mask; + if (bits == 0) { + *pz = NUL; + return; + } - /* - * Start by clearing all the bits. We want to turn off any defaults - * because we will be restoring to current state, not adding to - * the default set of bits. - */ - memcpy(pz, NONE_STR, NONE_STR_LEN); - pz += NONE_STR_LEN; - bits = (uintptr_t)pOD->optCookie; - bits &= ((uintptr_t)1 << (uintptr_t)name_ct) - (uintptr_t)1; - ix = 0; + for (ix = 0; ; ix++) { + size_t nln; + int doit = bits & 1; - while (bits != 0) { - if (bits & 1) { - size_t nln = strlen(paz_names[ix]); - memcpy(pz, PLUS_STR, PLUS_STR_LEN); - memcpy(pz+PLUS_STR_LEN, paz_names[ix], nln); - pz += nln + PLUS_STR_LEN; - } - if (++ix >= name_ct) break; bits >>= 1; + if (doit == 0) + continue; + + nln = strlen(nm_list[ix]); + memcpy(pz, nm_list[ix], nln); + pz += nln; + if (bits == 0) + break; + memcpy(pz, PLUS_STR, PLUS_STR_LEN); + pz += PLUS_STR_LEN; } *pz = NUL; + (void)opts; +} + +/** + * Check membership start conditions. An equal character (@samp{=}) says to + * clear the result and not carry over any residual value. A carat + * (@samp{^}), which may follow the equal character, says to invert the + * result. The scanning pointer is advanced past these characters and any + * leading white space. Invalid sequences are indicated by setting the + * scanning pointer to NULL. + * + * @param od the set membership option description + * @param argp a pointer to the string scanning pointer + * @param invert a pointer to the boolean inversion indicator + * + * @returns either zero or the original value for the optCookie. + */ +static uintptr_t +check_membership_start(tOptDesc * od, char const ** argp, bool * invert) +{ + uintptr_t res = (uintptr_t)od->optCookie; + char const * arg = SPN_WHITESPACE_CHARS(od->optArg.argString); + if ((arg == NULL) || (*arg == NUL)) + goto member_start_fail; + + *invert = false; + + switch (*arg) { + case '=': + res = 0UL; + arg = SPN_WHITESPACE_CHARS(arg + 1); + switch (*arg) { + case '=': case ',': + goto member_start_fail; + case '^': + goto inversion; + default: + break; + } + break; + + case '^': + inversion: + *invert = true; + arg = SPN_WHITESPACE_CHARS(arg + 1); + if (*arg != ',') + break; + /* FALLTHROUGH */ + + case ',': + goto member_start_fail; + + default: + break; + } + + *argp = arg; + return res; + +member_start_fail: + *argp = NULL; + return 0UL; +} + +/** + * convert a name to a bit. Look up a name string to get a bit number + * and shift the value "1" left that number of bits. + * + * @param opts program options descriptor + * @param od the set membership option description + * @param pz address of the start of the bit name + * @param nm_list the list of names for this option + * @param nm_ct the number of entries in this list + * + * @returns 0UL on error, other an unsigned long with the correct bit set. + */ +static uintptr_t +find_member_bit(tOptions * opts, tOptDesc * od, char const * pz, int len, + char const * const * nm_list, unsigned int nm_ct) +{ + char nm_buf[ AO_NAME_SIZE ]; + + memcpy(nm_buf, pz, len); + nm_buf[len] = NUL; + + { + unsigned int shift_ct = (unsigned int) + find_name(nm_buf, opts, od, nm_list, nm_ct); + if (shift_ct >= nm_ct) + return 0UL; + + return 1UL << shift_ct; + } +} + +/*=export_func optionMemberList + * what: Get the list of members of a bit mask set + * + * arg: tOptDesc *, od, the set membership option description + * + * ret_type: char* + * ret_desc: the names of the set bits + * + * doc: This converts the OPT_VALUE_name mask value to a allocated string. + * It is the caller's responsibility to free the string. +=*/ +char * +optionMemberList(tOptDesc * od) +{ + uintptr_t sv = od->optArg.argIntptr; + char * res; + (*(od->pOptProc))(OPTPROC_RETURN_VALNAME, od); + res = (void *)od->optArg.argString; + od->optArg.argIntptr = sv; + return res; } /*=export_func optionSetMembers * what: Convert between bit flag values and strings * private: * - * arg: tOptions*, pOpts, the program options descriptor - * arg: tOptDesc*, pOD, enumeration option description + * arg: tOptions*, opts, the program options descriptor + * arg: tOptDesc*, od, the set membership option description * arg: char const * const *, - * paz_names, list of enumeration names - * arg: unsigned int, name_ct, number of names in list + * nm_list, list of enumeration names + * arg: unsigned int, nm_ct, number of names in list * * doc: This converts the optArg.argString string from the option description * into the index corresponding to an entry in the name list. @@ -425,105 +543,103 @@ set_memb_names(tOptions * pOpts, tOptDesc * pOD, char const * const * paz_names, * if there is only one partial match. =*/ void -optionSetMembers(tOptions * pOpts, tOptDesc * pOD, - char const* const * paz_names, unsigned int name_ct) +optionSetMembers(tOptions * opts, tOptDesc * od, + char const * const * nm_list, unsigned int nm_ct) { /* * IF the program option descriptor pointer is invalid, * then it is some sort of special request. */ - switch ((uintptr_t)pOpts) { + switch ((uintptr_t)opts) { case (uintptr_t)OPTPROC_EMIT_USAGE: - enum_err(OPTPROC_EMIT_USAGE, pOD, paz_names, name_ct); + enum_err(OPTPROC_EMIT_USAGE, od, nm_list, nm_ct); return; case (uintptr_t)OPTPROC_EMIT_SHELL: - set_memb_shell(pOpts, pOD, paz_names, name_ct); + set_memb_shell(opts, od, nm_list, nm_ct); return; case (uintptr_t)OPTPROC_RETURN_VALNAME: - set_memb_names(pOpts, pOD, paz_names, name_ct); + set_memb_names(opts, od, nm_list, nm_ct); return; default: break; } - if ((pOD->fOptState & OPTST_RESET) != 0) + if ((od->fOptState & OPTST_RESET) != 0) return; { - char const * pzArg = pOD->optArg.argString; - uintptr_t res; - if ((pzArg == NULL) || (*pzArg == NUL)) { - pOD->optCookie = (void*)0; - return; - } - - res = (uintptr_t)pOD->optCookie; - for (;;) { - int iv, len; - - pzArg = SPN_SET_SEPARATOR_CHARS(pzArg); - iv = (*pzArg == '!'); - if (iv) - pzArg = SPN_WHITESPACE_CHARS(pzArg+1); + char const * arg; + bool invert; + uintptr_t res = check_membership_start(od, &arg, &invert); + if (arg == NULL) + goto fail_return; + + while (*arg != NUL) { + bool inv_val = false; + int len; + + switch (*arg) { + case ',': + arg = SPN_WHITESPACE_CHARS(arg+1); + if ((*arg == ',') || (*arg == '|')) + goto fail_return; + continue; + + case '-': + case '!': + inv_val = true; + /* FALLTHROUGH */ + + case '+': + case '|': + arg = SPN_WHITESPACE_CHARS(arg+1); + } - len = (int)(BRK_SET_SEPARATOR_CHARS(pzArg) - pzArg); + len = (int)(BRK_SET_SEPARATOR_CHARS(arg) - arg); if (len == 0) break; - if ((len == 3) && (strncmp(pzArg, zAll, 3) == 0)) { - if (iv) + if ((len == 3) && (strncmp(arg, zAll, 3) == 0)) { + if (inv_val) res = 0; else res = ~0UL; } - else if ((len == 4) && (strncmp(pzArg, zNone, 4) == 0)) { - if (! iv) + else if ((len == 4) && (strncmp(arg, zNone, 4) == 0)) { + if (! inv_val) res = 0; } else do { - char* pz; - uintptr_t bit = strtoul(pzArg, &pz, 0); - - if (pz != pzArg + len) { - char z[ AO_NAME_SIZE ]; - char const* p; - unsigned int shift_ct; - - if (*pz != NUL) { - if (len >= AO_NAME_LIMIT) - break; - memcpy(z, pzArg, (size_t)len); - z[len] = NUL; - p = z; - } else { - p = pzArg; - } - - shift_ct = (unsigned int) - find_name(p, pOpts, pOD, paz_names, name_ct); - if (shift_ct >= name_ct) { - pOD->optCookie = (void*)0; - return; - } - bit = 1UL << shift_ct; + char * pz; + uintptr_t bit = strtoul(arg, &pz, 0); + + if (pz != arg + len) { + bit = find_member_bit(opts, od, pz, len, nm_list, nm_ct); + if (bit == 0UL) + goto fail_return; } - if (iv) + if (inv_val) res &= ~bit; else res |= bit; } while (false); - if (pzArg[len] == NUL) - break; - pzArg += len + 1; - } - if (name_ct < (8 * sizeof(uintptr_t))) { - res &= (1UL << name_ct) - 1UL; + arg = SPN_WHITESPACE_CHARS(arg + len); } - pOD->optCookie = (void*)res; + if (invert) + res ^= ~0UL; + + if (nm_ct < (8 * sizeof(uintptr_t))) + res &= (1UL << nm_ct) - 1UL; + + od->optCookie = (void *)res; } + return; + +fail_return: + od->optCookie = (void *)0; } /** @} diff --git a/sntp/libopts/find.c b/sntp/libopts/find.c index e3534291d1..92584d8f33 100644 --- a/sntp/libopts/find.c +++ b/sntp/libopts/find.c @@ -500,7 +500,7 @@ get_opt_arg_must(tOptions * opts, tOptState * o_st) default: #ifdef DEBUG fputs("AutoOpts lib error: option type not selected\n", stderr); - exit(EXIT_FAILURE); + option_exits(EXIT_FAILURE); #endif case TOPT_DEFAULT: diff --git a/sntp/libopts/genshell.c b/sntp/libopts/genshell.c index 81c1403866..394f8fec08 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 March 25, 2013 at 02:10:23 PM by AutoGen 5.17.3.pre9 + * It has been AutoGen-ed July 5, 2013 at 08:32:39 PM by AutoGen 5.17.5pre9 * From the definitions genshell.def * and the template file options * - * Generated from AutoOpts 38:0:13 templates. + * Generated from AutoOpts 39:0:14 templates. * * AutoOpts is a copyrighted work. This source file is not encumbered * by AutoOpts licensing, but is provided under the licensing terms chosen @@ -146,8 +146,8 @@ static char const genshellopt_opt_strs[1769] = #define MORE_HELP_name (genshellopt_opt_strs+1134) #define MORE_HELP_FLAGS (OPTST_IMM | OPTST_NO_INIT) #else -#define MORE_HELP_DESC NULL -#define MORE_HELP_name NULL +#define MORE_HELP_DESC HELP_DESC +#define MORE_HELP_name HELP_name #define MORE_HELP_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) #endif #ifdef NO_OPTIONAL_OPT_ARGS @@ -258,7 +258,7 @@ static tOptDesc optDesc[GENSHELL_OPTION_CT] = { #define zDetail (genshellopt_opt_strs+1534) /** The full version string for genshellopt. */ #define zFullVersion (genshellopt_opt_strs+1755) -/* extracted from optcode.tlib near line 371 */ +/* extracted from optcode.tlib near line 364 */ #if defined(ENABLE_NLS) # define OPTPROC_BASE OPTPROC_TRANSLATE @@ -279,19 +279,21 @@ static tOptDesc optDesc[GENSHELL_OPTION_CT] = { /** * The callout function that invokes the genshelloptUsage function. * - * @param[in] pOptions the AutoOpts option description structure - * @param[in] pOptDesc the descriptor for the "help" (usage) option. + * @param[in] opts the AutoOpts option description structure + * @param[in] od the descriptor for the "help" (usage) option. * @noreturn */ static void -doUsageOpt(tOptions * pOptions, tOptDesc * pOptDesc) +doUsageOpt(tOptions * opts, tOptDesc * od) { - genshelloptUsage(&genshelloptOptions, GENSHELLOPT_EXIT_SUCCESS); + int ex_code; + ex_code = GENSHELLOPT_EXIT_SUCCESS; + genshelloptUsage(&genshelloptOptions, ex_code); /* NOTREACHED */ - (void)pOptDesc; - (void)pOptions; + (void)opts; + (void)od; } -/* extracted from optmain.tlib near line 1254 */ +/* extracted from optmain.tlib near line 1266 */ /** * The directory containing the data associated with genshellopt. @@ -546,39 +548,39 @@ by the newly generated text. The first '#!' line will be regenerated.\n")); /* referenced via genshelloptOptions.pzShortUsage */ puts(_("<<>>")); /* LIBOPTS-MESSAGES: */ -#line 60 "../autoopts.c" +#line 45 "../autoopts.c" puts(_("allocation of %d bytes failed\n")); -#line 86 "../autoopts.c" +#line 71 "../autoopts.c" puts(_("allocation of %d bytes failed\n")); #line 53 "../init.c" puts(_("AutoOpts function called without option descriptor\n")); -#line 89 "../init.c" +#line 90 "../init.c" puts(_("\tThis exceeds the compiled library version: ")); -#line 87 "../init.c" +#line 88 "../init.c" puts(_("Automated Options Processing Error!\n" "\t%s called AutoOpts function with structure version %d:%d:%d.\n")); -#line 73 "../autoopts.c" +#line 58 "../autoopts.c" puts(_("realloc of %d bytes at 0x%p failed\n")); -#line 91 "../init.c" +#line 92 "../init.c" puts(_("\tThis is less than the minimum library version: ")); #line 121 "../version.c" puts(_("Automated Options version %s\n" "\tCopyright (C) 1999-2013 by Bruce Korb - all rights reserved\n")); -#line 310 "../usage.c" +#line 82 "../makeshell.c" puts(_("(AutoOpts bug): %s.\n")); #line 90 "../reset.c" puts(_("optionResetOpt() called, but reset-option not configured")); -#line 329 "../usage.c" +#line 292 "../usage.c" puts(_("could not locate the 'help' option")); -#line 351 "../autoopts.c" +#line 336 "../autoopts.c" puts(_("optionProcess() was called with invalid data")); -#line 783 "../usage.c" +#line 747 "../usage.c" puts(_("invalid argument type specified")); #line 589 "../find.c" puts(_("defaulted to option with optional arg")); #line 76 "../alias.c" puts(_("aliasing option is out of range.")); -#line 229 "../enum.c" +#line 234 "../enum.c" puts(_("%s error: the keyword '%s' is ambiguous for %s\n")); #line 108 "../find.c" puts(_(" The following options match:\n")); @@ -588,9 +590,9 @@ by the newly generated text. The first '#!' line will be regenerated.\n")); puts(_("%s: Command line arguments required\n")); #line 43 "../alias.c" puts(_("%d %s%s options allowed\n")); -#line 81 "../makeshell.c" +#line 89 "../makeshell.c" puts(_("%s error %d (%s) calling %s for '%s'\n")); -#line 293 "../makeshell.c" +#line 301 "../makeshell.c" puts(_("interprocess pipe")); #line 168 "../version.c" puts(_("error: version option argument '%c' invalid. Use:\n" @@ -617,19 +619,19 @@ by the newly generated text. The first '#!' line will be regenerated.\n")); puts(_("%s: illegal option -- %s\n")); #line 332 "../find.c" puts(_("%s: unknown vendor extension option -- %s\n")); -#line 154 "../enum.c" +#line 159 "../enum.c" puts(_(" or an integer from %d through %d\n")); -#line 164 "../enum.c" +#line 169 "../enum.c" puts(_(" or an integer from %d through %d\n")); -#line 782 "../usage.c" +#line 746 "../usage.c" puts(_("%s error: invalid option descriptor for %s\n")); -#line 1110 "../usage.c" +#line 1080 "../usage.c" puts(_("%s error: invalid option descriptor for %s\n")); #line 379 "../find.c" puts(_("%s: invalid option name: %s\n")); #line 518 "../find.c" puts(_("%s: The '%s' option requires an argument.\n")); -#line 171 "../autoopts.c" +#line 156 "../autoopts.c" puts(_("(AutoOpts bug): Equivalenced option '%s' was equivalenced to both\n" "\t'%s' and '%s'.")); #line 94 "../check.c" @@ -638,9 +640,9 @@ by the newly generated text. The first '#!' line will be regenerated.\n")); puts(_("%s: The '%s' option cannot have an argument.\n")); #line 151 "../check.c" puts(_("%s: Command line arguments are not allowed.\n")); -#line 531 "../save.c" +#line 535 "../save.c" puts(_("error %d (%s) creating %s\n")); -#line 229 "../enum.c" +#line 234 "../enum.c" puts(_("%s error: '%s' does not match any %s keywords.\n")); #line 93 "../reset.c" puts(_("%s error: The '%s' option requires an argument.\n")); @@ -650,7 +652,7 @@ by the newly generated text. The first '#!' line will be regenerated.\n")); puts(_("error %d (%s) stat-ing %s\n")); #line 143 "../restore.c" puts(_("%s error: no saved option state\n")); -#line 246 "../autoopts.c" +#line 231 "../autoopts.c" puts(_("'%s' is not a command line option.\n")); #line 114 "../time.c" puts(_("%s error: '%s' is not a recognizable date/time.\n")); @@ -662,41 +664,41 @@ by the newly generated text. The first '#!' line will be regenerated.\n")); puts(_("%s error: The %s option must appear %d times.\n")); #line 157 "../numeric.c" puts(_("%s error: '%s' is not a recognizable number.\n")); -#line 195 "../enum.c" +#line 200 "../enum.c" puts(_("%s error: %s exceeds %s keyword count\n")); -#line 366 "../usage.c" +#line 329 "../usage.c" puts(_("Try '%s %s' for more information.\n")); #line 45 "../alias.c" puts(_("one %s%s option allowed\n")); -#line 195 "../makeshell.c" +#line 203 "../makeshell.c" puts(_("standard output")); -#line 930 "../makeshell.c" +#line 938 "../makeshell.c" puts(_("standard output")); -#line 304 "../usage.c" +#line 274 "../usage.c" puts(_("standard output")); -#line 451 "../usage.c" +#line 414 "../usage.c" puts(_("standard output")); -#line 660 "../usage.c" +#line 624 "../usage.c" puts(_("standard output")); #line 175 "../version.c" puts(_("standard output")); -#line 304 "../usage.c" +#line 274 "../usage.c" puts(_("standard error")); -#line 451 "../usage.c" +#line 414 "../usage.c" puts(_("standard error")); -#line 660 "../usage.c" +#line 624 "../usage.c" puts(_("standard error")); #line 175 "../version.c" puts(_("standard error")); -#line 195 "../makeshell.c" +#line 203 "../makeshell.c" puts(_("write")); -#line 930 "../makeshell.c" +#line 938 "../makeshell.c" puts(_("write")); -#line 303 "../usage.c" +#line 273 "../usage.c" puts(_("write")); -#line 450 "../usage.c" +#line 413 "../usage.c" puts(_("write")); -#line 659 "../usage.c" +#line 623 "../usage.c" puts(_("write")); #line 174 "../version.c" puts(_("write")); @@ -712,70 +714,70 @@ by the newly generated text. The first '#!' line will be regenerated.\n")); puts(_("%s warning: cannot save options - %s not regular file\n")); #line 256 "../save.c" puts(_("%s warning: cannot save options - %s not regular file\n")); -#line 530 "../save.c" +#line 534 "../save.c" puts(_("%s warning: cannot save options - %s not regular file\n")); /* END-LIBOPTS-MESSAGES */ /* USAGE-TEXT: */ -#line 908 "../usage.c" +#line 872 "../usage.c" puts(_("\t\t\t\t- an alternate for '%s'\n")); -#line 1177 "../usage.c" +#line 1147 "../usage.c" puts(_("Version, usage and configuration options:")); -#line 959 "../usage.c" +#line 923 "../usage.c" puts(_("\t\t\t\t- default option for unnamed options\n")); -#line 872 "../usage.c" +#line 836 "../usage.c" puts(_("\t\t\t\t- disabled as '--%s'\n")); -#line 1146 "../usage.c" +#line 1116 "../usage.c" puts(_(" --- %-14s %s\n")); -#line 1144 "../usage.c" +#line 1114 "../usage.c" puts(_("This option has been disabled")); -#line 899 "../usage.c" +#line 863 "../usage.c" puts(_("\t\t\t\t- enabled by default\n")); #line 40 "../alias.c" puts(_("%s error: only ")); -#line 1221 "../usage.c" +#line 1193 "../usage.c" puts(_(" - examining environment variables named %s_*\n")); #line 168 "../file.c" puts(_("\t\t\t\t- file must not pre-exist\n")); #line 172 "../file.c" puts(_("\t\t\t\t- file must pre-exist\n")); -#line 416 "../usage.c" +#line 379 "../usage.c" puts(_("Options are specified by doubled hyphens and their name or by a single\n" "hyphen and the flag character.\n")); -#line 908 "../makeshell.c" +#line 916 "../makeshell.c" puts(_("\n" "= = = = = = = =\n\n" "This incarnation of genshell will produce\n" "a shell script to parse the options for %s:\n\n")); -#line 161 "../enum.c" +#line 166 "../enum.c" puts(_(" or an integer mask with any of the lower %d bits set\n")); -#line 932 "../usage.c" +#line 896 "../usage.c" puts(_("\t\t\t\t- is a set membership option\n")); -#line 953 "../usage.c" +#line 917 "../usage.c" puts(_("\t\t\t\t- must appear between %d and %d times\n")); -#line 418 "../usage.c" +#line 381 "../usage.c" puts(_("Options are specified by single or double hyphens and their name.\n")); -#line 939 "../usage.c" +#line 903 "../usage.c" puts(_("\t\t\t\t- may appear multiple times\n")); -#line 926 "../usage.c" +#line 890 "../usage.c" puts(_("\t\t\t\t- may not be preset\n")); -#line 1336 "../usage.c" +#line 1308 "../usage.c" puts(_(" Arg Option-Name Description\n")); -#line 1272 "../usage.c" +#line 1244 "../usage.c" puts(_(" Flg Arg Option-Name Description\n")); -#line 1330 "../usage.c" +#line 1302 "../usage.c" puts(_(" Flg Arg Option-Name Description\n")); -#line 1331 "../usage.c" +#line 1303 "../usage.c" puts(_(" %3s %s")); -#line 1337 "../usage.c" +#line 1309 "../usage.c" puts(_(" %3s %s")); -#line 423 "../usage.c" +#line 386 "../usage.c" puts(_("The '-#' option may omit the hash char\n")); -#line 419 "../usage.c" +#line 382 "../usage.c" puts(_("All arguments are named options.\n")); -#line 1006 "../usage.c" +#line 970 "../usage.c" puts(_(" - reading file %s")); -#line 445 "../usage.c" +#line 408 "../usage.c" puts(_("\n" "Please send bug reports to: <%s>\n")); #line 100 "../version.c" @@ -784,17 +786,17 @@ by the newly generated text. The first '#!' line will be regenerated.\n")); #line 129 "../version.c" puts(_("\n" "Please send bug reports to: <%s>\n")); -#line 938 "../usage.c" +#line 902 "../usage.c" puts(_("\t\t\t\t- may NOT appear - preset only\n")); -#line 978 "../usage.c" +#line 943 "../usage.c" puts(_("\n" "The following option preset mechanisms are supported:\n")); -#line 1219 "../usage.c" +#line 1191 "../usage.c" puts(_("\n" "The following option preset mechanisms are supported:\n")); -#line 717 "../usage.c" +#line 681 "../usage.c" puts(_("prohibits these options:\n")); -#line 712 "../usage.c" +#line 676 "../usage.c" puts(_("prohibits the option '%s'\n")); #line 81 "../numeric.c" puts(_("%s%ld to %ld")); @@ -812,28 +814,28 @@ by the newly generated text. The first '#!' line will be regenerated.\n")); puts(_("%sis scalable with a suffix: k/K/m/M/g/G/t/T\n")); #line 77 "../numeric.c" puts(_("%sless than or equal to %ld")); -#line 426 "../usage.c" +#line 389 "../usage.c" puts(_("Operands and options may be intermixed. They will be reordered.\n")); -#line 687 "../usage.c" +#line 651 "../usage.c" puts(_("requires the option '%s'\n")); -#line 690 "../usage.c" +#line 654 "../usage.c" puts(_("requires these options:\n")); -#line 1348 "../usage.c" +#line 1320 "../usage.c" puts(_(" Arg Option-Name Req? Description\n")); -#line 1342 "../usage.c" +#line 1314 "../usage.c" puts(_(" Flg Arg Option-Name Req? Description\n")); -#line 162 "../enum.c" +#line 167 "../enum.c" puts(_("or you may use a numeric representation. Preceding these with a '!'\n" "will clear the bits, specifying 'none' will clear all bits, and 'all'\n" "will set them all. Multiple entries may be passed as an option\n" "argument list.\n")); -#line 945 "../usage.c" +#line 909 "../usage.c" puts(_("\t\t\t\t- may appear up to %d times\n")); -#line 72 "../enum.c" +#line 77 "../enum.c" puts(_("The valid \"%s\" option keywords are:\n")); -#line 1181 "../usage.c" +#line 1151 "../usage.c" puts(_("The next option supports vendor supported extra options:")); -#line 808 "../usage.c" +#line 772 "../usage.c" puts(_("These additional options are:")); /* END-USAGE-TEXT */ } diff --git a/sntp/libopts/genshell.h b/sntp/libopts/genshell.h index b64decc008..a3f7d33522 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 March 25, 2013 at 02:10:23 PM by AutoGen 5.17.3.pre9 + * It has been AutoGen-ed July 5, 2013 at 08:32:39 PM by AutoGen 5.17.5pre9 * From the definitions genshell.def * and the template file options * - * Generated from AutoOpts 38:0:13 templates. + * Generated from AutoOpts 39:0:14 templates. * * AutoOpts is a copyrighted work. This header file is not encumbered * by AutoOpts licensing, but is provided under the licensing terms chosen @@ -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 155648 +#define AO_TEMPLATE_VERSION 159744 #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \ || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION) # error option template version mismatches autoopts/options.h header @@ -87,7 +87,7 @@ typedef enum { #define GENSHELL_DESC(n) (genshelloptOptions.pOptDesc[INDEX_GENSHELL_OPT_## n]) /** 'true' if an option has been specified in any way */ #define HAVE_GENSHELL_OPT(n) (! UNUSED_OPT(& GENSHELL_DESC(n))) -/** The string argument to an option. The argument type must be "string". */ +/** The string argument to an option. The argument type must be \"string\". */ #define GENSHELL_OPT_ARG(n) (GENSHELL_DESC(n).optArg.argString) /** Mask the option state revealing how an option was specified. * It will be one and only one of \a OPTST_SET, \a OPTST_PRESET, @@ -114,18 +114,16 @@ typedef enum { if ((GENSHELL_DESC(n).fOptState & OPTST_INITENABLED) == 0) \ GENSHELL_DESC(n).fOptState |= OPTST_DISABLED; \ GENSHELL_DESC(n).optCookie = NULL ) - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /** * Enumeration of genshellopt exit codes */ typedef enum { - GENSHELLOPT_EXIT_SUCCESS = 0, - GENSHELLOPT_EXIT_FAILURE = 1, - GENSHELLOPT_EXIT_USAGE_ERROR = 64, + GENSHELLOPT_EXIT_SUCCESS = 0, + GENSHELLOPT_EXIT_FAILURE = 1, + GENSHELLOPT_EXIT_USAGE_ERROR = 64, GENSHELLOPT_EXIT_LIBOPTS_FAILURE = 70 -} genshellopt_exit_code_t; -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +} genshellopt_exit_code_t; /** * Interface defines for specific options. * @{ @@ -148,7 +146,6 @@ typedef enum { genshelloptOptions.pzCurOpt = NULL ) #define START_GENSHELL_OPT RESTART_GENSHELL_OPT(1) #define GENSHELL_USAGE(c) (*genshelloptOptions.pUsageProc)(&genshelloptOptions, c) -/* extracted from opthead.tlib near line 538 */ #ifdef __cplusplus extern "C" { @@ -203,4 +200,5 @@ static inline char* aoGetsText(char const* pz) { } #endif #endif /* AUTOOPTS_GENSHELL_H_GUARD */ + /* genshell.h ends here */ diff --git a/sntp/libopts/init.c b/sntp/libopts/init.c index 25dc07bd05..9025887d6d 100644 --- a/sntp/libopts/init.c +++ b/sntp/libopts/init.c @@ -53,6 +53,7 @@ validate_struct(tOptions * opts, char const * pname) fputs(zno_opt_arg, stderr); return FAILURE; } + print_exit = ((opts->fOptSet & OPTPROC_SHELL_OUTPUT) != 0); /* * IF the client has enabled translation and the translation procedure diff --git a/sntp/libopts/load.c b/sntp/libopts/load.c index 7f69cdad00..6bc91a4301 100644 --- a/sntp/libopts/load.c +++ b/sntp/libopts/load.c @@ -41,6 +41,9 @@ add_env_val(char * buf, int buf_sz, char const * name); static char * assemble_arg_val(char * txt, tOptionLoadMode mode); + +static char * +trim_quotes(char * arg); /* = = = END-STATIC-FORWARD = = = */ /*=export_func optionMakePath @@ -323,13 +326,13 @@ munge_str(char * txt, tOptionLoadMode mode) static char * assemble_arg_val(char * txt, tOptionLoadMode mode) { - char* pzEnd = strpbrk(txt, ARG_BREAK_STR); - int space_break; + char * end = strpbrk(txt, ARG_BREAK_STR); + int space_break; /* * Not having an argument to a configurable name is okay. */ - if (pzEnd == NULL) + if (end == NULL) return txt + strlen(txt); /* @@ -338,8 +341,8 @@ assemble_arg_val(char * txt, tOptionLoadMode mode) * of which character caused it. */ if (mode == OPTION_LOAD_KEEP) { - *(pzEnd++) = NUL; - return pzEnd; + *(end++) = NUL; + return end; } /* @@ -347,14 +350,25 @@ assemble_arg_val(char * txt, tOptionLoadMode mode) * because we'll have to skip over an immediately following ':' or '=' * (and the white space following *that*). */ - space_break = IS_WHITESPACE_CHAR(*pzEnd); - *(pzEnd++) = NUL; + space_break = IS_WHITESPACE_CHAR(*end); + *(end++) = NUL; - pzEnd = SPN_WHITESPACE_CHARS(pzEnd); - if (space_break && ((*pzEnd == ':') || (*pzEnd == '='))) - pzEnd = SPN_WHITESPACE_CHARS(pzEnd+1); + end = SPN_WHITESPACE_CHARS(end); + if (space_break && ((*end == ':') || (*end == '='))) + end = SPN_WHITESPACE_CHARS(end+1); + + return end; +} - return pzEnd; +static char * +trim_quotes(char * arg) +{ + switch (*arg) { + case '"': + case '\'': + ao_string_cook(arg, NULL); + } + return arg; } /** @@ -370,12 +384,8 @@ assemble_arg_val(char * txt, tOptionLoadMode mode) * @param[in] load_mode option loading mode (OPTION_LOAD_*) */ LOCAL void -loadOptionLine( - tOptions * opts, - tOptState * opt_state, - char * line, - tDirection direction, - tOptionLoadMode load_mode ) +loadOptionLine(tOptions * opts, tOptState * opt_state, char * line, + tDirection direction, tOptionLoadMode load_mode ) { line = SPN_LOAD_LINE_SKIP_CHARS(line); @@ -388,7 +398,7 @@ loadOptionLine( if (opt_state->flags & OPTST_NO_INIT) return; - opt_state->pzOptArg = arg; + opt_state->pzOptArg = trim_quotes(arg); } switch (opt_state->flags & (OPTST_IMM|OPTST_DISABLE_IMM)) { diff --git a/sntp/libopts/m4/libopts.m4 b/sntp/libopts/m4/libopts.m4 index 11a0ef0860..3afa17456c 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 March 25, 2013 at 02:10:15 PM by AutoGen 5.17.3.pre9 +dnl It has been AutoGen-ed July 5, 2013 at 08:32:31 PM by AutoGen 5.17.5pre9 dnl From the definitions libopts.def dnl and the template file conftest.tpl dnl @@ -72,8 +72,7 @@ AC_DEFUN([INVOKE_LIBOPTS_MACROS_FIRST],[ ${lo_have_typ_hdr} || \ ]AC_MSG_ERROR([you must have inttypes.h or stdint.h on your system])[ - for f in sys_types sys_mman sys_param sys_stat sys_wait \ - string errno stdlib memory setjmp + for f in sys_types sys_param sys_stat string errno stdlib memory setjmp do eval as_ac_var=\${ac_cv_header_${f}_h} test "X${as_ac_var}" = Xyes || { ]AC_MSG_ERROR([you must have ${f}.h on your system])[ @@ -102,10 +101,11 @@ AC_DEFUN([INVOKE_LIBOPTS_MACROS_FIRST],[ AC_CHECK_SIZEOF(long, 8) AC_CHECK_SIZEOF(short, 2) - # ---------------------------------------------------------------------- - # AC_CHECK_LIB for SVR4 libgen, and use it if it defines pathfind. - # ---------------------------------------------------------------------- + # ------------ + # AC_CHECK_LIB + # ------------ AC_CHECK_LIB(gen, pathfind) + AC_CHECK_LIB(intl,gettext) AC_FUNC_VPRINTF AC_FUNC_FORK AC_CHECK_FUNCS([mmap canonicalize_file_name snprintf strdup strchr \ @@ -200,8 +200,6 @@ AC_DEFUN([LIBOPTS_WITHLIB_REGEX],[ esac libopts_save_CPPFLAGS="${CPPFLAGS}" libopts_save_LIBS="${LIBS}" - fi ## disabled by request - case "X${libopts_cv_with_libregex_cflags}" in Xyes|Xno|X ) libopts_cv_with_libregex_cflags="" ;; @@ -240,6 +238,7 @@ int main() { [libopts_cv_with_libregex=yes], [libopts_cv_with_libregex=no], [libopts_cv_with_libregex=no]) # end of AC_RUN_IFELSE ]) # end of AC_CACHE_VAL for libopts_cv_with_libregex + fi ## disabled by request AC_MSG_RESULT([${libopts_cv_with_libregex}]) if test "X${libopts_cv_with_libregex}" != Xno then @@ -248,7 +247,10 @@ int main() { else CPPFLAGS="${libopts_save_CPPFLAGS}" LIBS="${libopts_save_LIBS}" - AC_MSG_ERROR([the regex library does not work]) + libopts_cv_with_libregex_root=no +libopts_cv_with_libregex_cflags=no +libopts_cv_with_libregex_libs=no +libopts_cv_with_libregex=no fi ]) # end of AC_DEFUN of LIBOPTS_WITHLIB_REGEX diff --git a/sntp/libopts/makeshell.c b/sntp/libopts/makeshell.c index f22e9f0b84..d65a8b372e 100644 --- a/sntp/libopts/makeshell.c +++ b/sntp/libopts/makeshell.c @@ -30,13 +30,6 @@ * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd */ -tOptions * optionParseShellOptions = NULL; - -static char const * shell_prog = NULL; -static char * script_leader = NULL; -static char * script_trailer = NULL; -static char * script_text = NULL; - /* = = = START-STATIC-FORWARD = = = */ static void emit_var_text(char const * prog, char const * var, int fdin); @@ -75,6 +68,21 @@ static void open_out(char const * fname, char const * pname); /* = = = END-STATIC-FORWARD = = = */ +LOCAL void +option_exits(int exit_code) +{ + if (print_exit) + printf("\nexit %d\n", exit_code); + exit(exit_code); +} + +LOCAL void +ao_bug(char const * msg) +{ + fprintf(stderr, zao_bug_msg, msg); + option_exits(EX_SOFTWARE); +} + LOCAL void fserr_warn(char const * prog, char const * op, char const * fname) { @@ -86,7 +94,7 @@ LOCAL void fserr_exit(char const * prog, char const * op, char const * fname) { fserr_warn(prog, op, fname); - exit(EXIT_FAILURE); + option_exits(EXIT_FAILURE); } /*=export_func optionParseShell @@ -325,7 +333,7 @@ text_to_var(tOptions * opts, teTextTo which, tOptDesc * od) /* NOTREACHED */ default: - exit(EXIT_FAILURE); + option_exits(EXIT_FAILURE); /* NOTREACHED */ } /* NOTREACHED */ @@ -862,7 +870,7 @@ genshelloptUsage(tOptions * opts, int exit_cd) fflush(stderr); fflush(stdout); if (ferror(stdout) || ferror(stderr)) - exit(EXIT_FAILURE); + option_exits(EXIT_FAILURE); option_usage_fp = stdout; @@ -929,7 +937,7 @@ genshelloptUsage(tOptions * opts, int exit_cd) if (ferror(stdout)) fserr_exit(opts->pzProgName, zwriting, zstdout_name); - exit(EXIT_SUCCESS); + option_exits(EXIT_SUCCESS); #endif } diff --git a/sntp/libopts/option-value-type.c b/sntp/libopts/option-value-type.c index 3eac084e8d..f0ceba68a8 100644 --- a/sntp/libopts/option-value-type.c +++ b/sntp/libopts/option-value-type.c @@ -2,7 +2,7 @@ * * DO NOT EDIT THIS FILE (stdin.c) * - * It has been AutoGen-ed March 25, 2013 at 02:10:22 PM by AutoGen 5.17.3.pre9 + * It has been AutoGen-ed July 5, 2013 at 08:32:38 PM by AutoGen 5.17.5pre9 * From the definitions stdin * and the template file str2enum * diff --git a/sntp/libopts/option-value-type.h b/sntp/libopts/option-value-type.h index 51f4f66f89..e1a1758d22 100644 --- a/sntp/libopts/option-value-type.h +++ b/sntp/libopts/option-value-type.h @@ -2,7 +2,7 @@ * * DO NOT EDIT THIS FILE (stdin.h) * - * It has been AutoGen-ed March 25, 2013 at 02:10:21 PM by AutoGen 5.17.3.pre9 + * It has been AutoGen-ed July 5, 2013 at 08:32:37 PM by AutoGen 5.17.5pre9 * From the definitions stdin * and the template file str2enum * diff --git a/sntp/libopts/option-xat-attribute.c b/sntp/libopts/option-xat-attribute.c index c2d770cd6e..0ee1668c54 100644 --- a/sntp/libopts/option-xat-attribute.c +++ b/sntp/libopts/option-xat-attribute.c @@ -2,7 +2,7 @@ * * DO NOT EDIT THIS FILE (stdin.c) * - * It has been AutoGen-ed March 25, 2013 at 02:10:20 PM by AutoGen 5.17.3.pre9 + * It has been AutoGen-ed July 5, 2013 at 08:32:36 PM by AutoGen 5.17.5pre9 * From the definitions stdin * and the template file str2enum * diff --git a/sntp/libopts/option-xat-attribute.h b/sntp/libopts/option-xat-attribute.h index cfb32897cd..b6ce139495 100644 --- a/sntp/libopts/option-xat-attribute.h +++ b/sntp/libopts/option-xat-attribute.h @@ -2,7 +2,7 @@ * * DO NOT EDIT THIS FILE (stdin.h) * - * It has been AutoGen-ed March 25, 2013 at 02:10:20 PM by AutoGen 5.17.3.pre9 + * It has been AutoGen-ed July 5, 2013 at 08:32:36 PM by AutoGen 5.17.5pre9 * From the definitions stdin * and the template file str2enum * diff --git a/sntp/libopts/pgusage.c b/sntp/libopts/pgusage.c index 3bc7fc31e2..5154410239 100644 --- a/sntp/libopts/pgusage.c +++ b/sntp/libopts/pgusage.c @@ -32,12 +32,70 @@ * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd */ +#if defined(HAVE_WORKING_FORK) +static FILE * +open_tmp_usage(char ** buf) +{ + char * bf; + size_t bfsz; + + { + unsigned int my_pid = (unsigned int)getpid(); + char const * tmpdir = getenv(TMPDIR); + if (tmpdir == NULL) + tmpdir = tmp_dir; + bfsz = TMP_FILE_FMT_LEN + strlen(tmpdir) + 10; + bf = AGALOC(bfsz, "tmp fil"); + snprintf(bf, bfsz, TMP_FILE_FMT, tmpdir, my_pid); + } + + { + int fd = mkstemp(bf); + if (fd < 0) { + AGFREE(bf); + return NULL; + } + *buf = bf; + return fdopen(fd, "w"); + } +} + +static char * +mk_pager_cmd(char const * fname) +{ + /* + * Page the file and remove it when done. For shell script processing, + * we must redirect the output to the current stderr, otherwise stdout. + */ + fclose(option_usage_fp); + option_usage_fp = NULL; + + { + char const * pager = (char const *)getenv(PAGER_NAME); + size_t bfsz; + char * res; + + /* + * Use the "more(1)" program if "PAGER" has not been defined + */ + if (pager == NULL) + pager = MORE_STR; + + bfsz = strlen(fname) + strlen(pager) + PAGE_USAGE_FMT_LEN; + res = AGALOC(bfsz, "more cmd"); + snprintf(res, bfsz, PAGE_USAGE_FMT, pager, fname); + AGFREE((void*)fname); + return res; + } +} +#endif + /*=export_func optionPagedUsage * private: * - * what: Decipher a boolean value - * arg: + tOptions* + opts + program options descriptor + - * arg: + tOptDesc* + od + the descriptor for this arg + + * what: emit help text and pass through a pager program. + * arg: + tOptions * + opts + program options descriptor + + * arg: + tOptDesc * + od + the descriptor for this arg + * * doc: * Run the usage output through a pager. @@ -53,8 +111,8 @@ optionPagedUsage(tOptions * opts, tOptDesc * od) (*opts->pUsageProc)(opts, EXIT_SUCCESS); #else - static pid_t my_pid; - char fil_name[1024]; + static bool sv_print_exit = false; + static char * fil_name = NULL; /* * IF we are being called after the usage proc is done @@ -66,20 +124,12 @@ optionPagedUsage(tOptions * opts, tOptDesc * od) { if ((od->fOptState & OPTST_RESET) != 0) return; - - my_pid = getpid(); - snprintf(fil_name, sizeof(fil_name), TMP_USAGE_FMT, - (unsigned long)my_pid); - unlink(fil_name); - - /* - * Set usage output to this temporary file - */ - option_usage_fp = fopen(fil_name, "w" FOPEN_BINARY_FLAG); + option_usage_fp = open_tmp_usage(&fil_name); if (option_usage_fp == NULL) - _exit(EXIT_FAILURE); + (*opts->pUsageProc)(opts, EXIT_SUCCESS); - pagerState = PAGER_STATE_READY; + pagerState = PAGER_STATE_READY; + sv_print_exit = print_exit; /* * Set up so this routine gets called during the exit logic @@ -88,8 +138,10 @@ optionPagedUsage(tOptions * opts, tOptDesc * od) /* * The usage procedure will now put the usage information into - * the temporary file we created above. + * the temporary file we created above. Keep any shell commands + * out of the result. */ + print_exit = false; (*opts->pUsageProc)(opts, EXIT_SUCCESS); /* NOTREACHED */ @@ -97,25 +149,20 @@ optionPagedUsage(tOptions * opts, tOptDesc * od) } case PAGER_STATE_READY: - { - char const * pager = (char const *)getenv(PAGER_NAME); + fil_name = mk_pager_cmd(fil_name); - /* - * Use the "more(1)" program if "PAGER" has not been defined - */ - if (pager == NULL) - pager = MORE_STR; + if (sv_print_exit) { + fputs("\nexit 0\n", stdout); + fclose(stdout); + dup2(STDERR_FILENO, STDOUT_FILENO); - /* - * Page the file and remove it when done. - */ - snprintf(fil_name, sizeof(fil_name), PAGE_USAGE_FMT, pager, - (unsigned long)my_pid); - fclose(stderr); - dup2(STDOUT_FILENO, STDERR_FILENO); + } else { + fclose(stderr); + dup2(STDOUT_FILENO, STDERR_FILENO); + } ignore_val( system( fil_name)); - } + AGFREE(fil_name); case PAGER_STATE_CHILD: /* diff --git a/sntp/libopts/proto.h b/sntp/libopts/proto.h index 9808c1363d..5730fca432 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 Mon Mar 25 14:10:33 PDT 2013 + * Generated Fri Jul 5 20:32:50 PDT 2013 */ #ifndef AUTOOPTS_PROTO_H_GUARD #define AUTOOPTS_PROTO_H_GUARD 1 @@ -92,16 +92,18 @@ static void munge_str(char * txt, tOptionLoadMode mode); static void -loadOptionLine( - tOptions * opts, - tOptState * opt_state, - char * line, - tDirection direction, - tOptionLoadMode load_mode ); +loadOptionLine(tOptions * opts, tOptState * opt_state, char * line, + tDirection direction, tOptionLoadMode load_mode ); /* * Extracted from makeshell.c */ +static void +option_exits(int exit_code); + +static void +ao_bug(char const * msg); + static void fserr_warn(char const * prog, char const * op, char const * fname); @@ -141,7 +143,4 @@ addArgListEntry(void** ppAL, void* entry); static void set_usage_flags(tOptions * opts, char const * flg_txt); -static void -ao_bug(char const * msg); - #endif /* AUTOOPTS_PROTO_H_GUARD */ diff --git a/sntp/libopts/putshell.c b/sntp/libopts/putshell.c index d210392946..a96bc37336 100644 --- a/sntp/libopts/putshell.c +++ b/sntp/libopts/putshell.c @@ -30,7 +30,6 @@ * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3 * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd */ -#define APOSTROPHE '\'' /* = = = START-STATIC-FORWARD = = = */ static size_t @@ -292,6 +291,7 @@ print_enumeration(tOptions * pOpts, tOptDesc * pOD) static void print_membership(tOptions * pOpts, tOptDesc * pOD) { + char const * svstr = pOD->optArg.argString; char const * pz; uintptr_t val = 1; printf(zOptNumFmt, pOpts->pzPROGNAME, pOD->pz_NAME, @@ -299,13 +299,9 @@ print_membership(tOptions * pOpts, tOptDesc * pOD) pOD->optCookie = (void*)(uintptr_t)~0UL; (*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, pOD); - /* - * We are building the typeset list. The list returned starts with - * 'none + ' for use by option saving stuff. We must ignore that. - */ - pz = pOD->optArg.argString + 7; + pz = pOD->optArg.argString; while (*pz != NUL) { - printf("typeset -x -i %s_", pOD->pz_NAME); + printf("readonly %s_", pOD->pz_NAME); pz = SPN_PLUS_N_SPACE_CHARS(pz); for (;;) { @@ -321,8 +317,7 @@ print_membership(tOptions * pOpts, tOptDesc * pOD) } AGFREE(pOD->optArg.argString); - pOD->optArg.argString = NULL; - pOD->fOptState &= ~OPTST_ALLOC_ARG; + pOD->optArg.argString = svstr; } static void diff --git a/sntp/libopts/restore.c b/sntp/libopts/restore.c index 09ecb33264..d3beb14050 100644 --- a/sntp/libopts/restore.c +++ b/sntp/libopts/restore.c @@ -141,7 +141,7 @@ optionRestore(tOptions* pOpts) pzName = zNil; } fprintf(stderr, zNoState, pzName); - exit(EXIT_FAILURE); + option_exits(EXIT_FAILURE); } pOpts->pSavedState = NULL; diff --git a/sntp/libopts/save.c b/sntp/libopts/save.c index 3ae046feaa..404a478e20 100644 --- a/sntp/libopts/save.c +++ b/sntp/libopts/save.c @@ -63,7 +63,7 @@ static void prt_str_arg(FILE * fp, tOptDesc * pOD); static void -prt_enum_arg(FILE * fp, tOptDesc * pOD); +prt_enum_arg(FILE * fp, tOptDesc * od); static void prt_set_arg(FILE * fp, tOptDesc * od); @@ -138,7 +138,7 @@ find_dir_name(tOptions * opts, int * p_free) { size_t sz = strlen(pzEnv) + strlen(pzEndDir) + 2; - pzFileName = (char*)AGALOC(sz, "dir name"); + pzFileName = (char *)AGALOC(sz, "dir name"); } if (pzFileName == NULL) @@ -277,6 +277,8 @@ find_file_name(tOptions * opts, int * p_free_name) static void prt_entry(FILE * fp, tOptDesc * od, char const * l_arg) { + int space_ct; + /* * There is an argument. Pad the name so values line up. * Not disabled *OR* this got equivalenced to another opt, @@ -284,29 +286,29 @@ prt_entry(FILE * fp, tOptDesc * od, char const * l_arg) * Otherwise, there must be a disablement name. */ { - char const * pz; - if (! DISABLED_OPT(od) || (od->optEquivIndex != NO_EQUIVALENT)) - pz = od->pz_Name; - else - pz = od->pz_DisableName; - - fprintf(fp, "%-18s", pz); + char const * pz = + (! DISABLED_OPT(od) || (od->optEquivIndex != NO_EQUIVALENT)) + ? od->pz_Name + : od->pz_DisableName; + space_ct = 17 - strlen(pz); + fputs(pz, fp); } + + if ( (l_arg == NULL) + && (OPTST_GET_ARGTYPE(od->fOptState) != OPARG_TYPE_NUMERIC)) + goto end_entry; + + fputs(" = ", fp); + while (space_ct-- > 0) fputc(' ', fp); + /* * IF the option is numeric only, * THEN the char pointer is really the number */ if (OPTST_GET_ARGTYPE(od->fOptState) == OPARG_TYPE_NUMERIC) - fprintf(fp, " %d\n", (int)(t_word)l_arg); - - /* - * OTHERWISE, FOR each line of the value text, ... - */ - else if (l_arg == NULL) - fputc(NL, fp); + fprintf(fp, "%d", (int)(t_word)l_arg); else { - fputc(' ', fp); fputc(' ', fp); for (;;) { char const * eol = strchr(l_arg, NL); @@ -329,8 +331,10 @@ prt_entry(FILE * fp, tOptDesc * od, char const * l_arg) * Terminate the entry */ fputs(l_arg, fp); - fputc(NL, fp); } + +end_entry: + fputc(NL, fp); } /** @@ -610,20 +614,24 @@ prt_str_arg(FILE * fp, tOptDesc * pOD) } /** + * print the string value of an enumeration. + * + * @param[in] fp the file pointer to write to + * @param[in] od the option descriptor with the enumerated value */ static void -prt_enum_arg(FILE * fp, tOptDesc * pOD) +prt_enum_arg(FILE * fp, tOptDesc * od) { - uintptr_t val = pOD->optArg.argEnum; + uintptr_t val = od->optArg.argEnum; /* * This is a magic incantation that will convert the * bit flag values back into a string suitable for printing. */ - (*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, pOD); - prt_entry(fp, pOD, (void*)(pOD->optArg.argString)); + (*(od->pOptProc))(OPTPROC_RETURN_VALNAME, od); + prt_entry(fp, od, (void*)(od->optArg.argString)); - pOD->optArg.argEnum = val; + od->optArg.argEnum = val; } /** @@ -638,24 +646,14 @@ prt_enum_arg(FILE * fp, tOptDesc * pOD) static void prt_set_arg(FILE * fp, tOptDesc * od) { - uintptr_t val = od->optArg.argEnum; - - /* - * This is a magic incantation that will convert the - * bit flag values back into a string suitable for printing. - */ - (*(od->pOptProc))(OPTPROC_RETURN_VALNAME, od); - prt_entry(fp, od, (void*)(od->optArg.argString)); - - if (od->optArg.argString != NULL) { - /* - * set membership strings get allocated - */ - AGFREE((void*)od->optArg.argString); - od->fOptState &= ~OPTST_ALLOC_ARG; - } - - od->optArg.argEnum = val; + char * list = optionMemberList(od); + size_t len = strlen(list); + char * buf = (char *)AGALOC(len + 3, "dir name"); + *buf= '='; + memcpy(buf+1, list, len + 1); + prt_entry(fp, od, buf); + AGFREE(buf); + AGFREE(list); } /** diff --git a/sntp/libopts/stack.c b/sntp/libopts/stack.c index dc73702afd..62069b561f 100644 --- a/sntp/libopts/stack.c +++ b/sntp/libopts/stack.c @@ -133,8 +133,8 @@ optionUnstackArg(tOptions * pOpts, tOptDesc * pOptDesc) * we are keeping a define. */ for (i = 0, dIdx = 0, ct = pAL->useCt; --ct >= 0; i++) { - const char ** pzSrc = pAL->apzArgs[ i ]; - char * pzEq = strchr(pzSrc, '='); + const char * pzSrc = pAL->apzArgs[ i ]; + char * pzEq = strchr(pzSrc, '='); if (pzEq != NULL) *pzEq = NUL; diff --git a/sntp/libopts/text_mmap.c b/sntp/libopts/text_mmap.c index 8b117c0599..7085f3eb06 100644 --- a/sntp/libopts/text_mmap.c +++ b/sntp/libopts/text_mmap.c @@ -233,7 +233,7 @@ close_mmap_files(tmap_info_t * mi) close(mi->txt_fd); mi->txt_fd = AO_INVALID_FD; -#if ! defined(MAP_ANONYMOUS) +#if defined(HAVE_MMAP) && ! defined(MAP_ANONYMOUS) if (mi->txt_zero_fd == AO_INVALID_FD) return; diff --git a/sntp/libopts/usage.c b/sntp/libopts/usage.c index ca6f332254..da77c61b99 100644 --- a/sntp/libopts/usage.c +++ b/sntp/libopts/usage.c @@ -37,36 +37,6 @@ * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd */ -#define OPTPROC_L_N_S (OPTPROC_LONGOPT | OPTPROC_SHORTOPT) -#if defined(ENABLE_NLS) && defined(HAVE_LIBINTL_H) -# include -#endif - -typedef struct { - size_t fnm_len; - uint32_t fnm_mask; - char const * fnm_name; -} ao_flag_names_t; - -/** - * Automated Options Usage Flags. - * NB: no entry may be a prefix of another entry - */ -#define AOFLAG_TABLE \ - _aof_(gnu, OPTPROC_GNUUSAGE ) \ - _aof_(autoopts, ~OPTPROC_GNUUSAGE) \ - _aof_(no_misuse_usage, OPTPROC_MISUSE ) \ - _aof_(misuse_usage, ~OPTPROC_MISUSE ) \ - _aof_(compute, OPTPROC_COMPUTE ) - -#define _aof_(_n, _f) AOUF_ ## _n ## _ID, -typedef enum { AOFLAG_TABLE AOUF_COUNT } ao_flag_id_t; -#undef _aof_ - -#define _aof_(_n, _f) AOUF_ ## _n = (1 << AOUF_ ## _n ## _ID), -typedef enum { AOFLAG_TABLE } ao_flags_t; -#undef _aof_ - /* = = = START-STATIC-FORWARD = = = */ static unsigned int parse_usage_flags(ao_flag_names_t const * fnt, char const * txt); @@ -100,8 +70,8 @@ static void prt_extd_usage(tOptions * opts, tOptDesc * od, char const * title); static void -prt_ini_list(char const * const * papz, bool * need_intro, - char const * ini_file, char const * path_nm); +prt_ini_list(char const * const * papz, char const * ini_file, + char const * path_nm); static void prt_preamble(tOptions * opts, tOptDesc * od, arg_types_t * at); @@ -304,13 +274,6 @@ optionOnlyUsage(tOptions * pOpts, int ex_code) ? zstderr_name : zstdout_name); } -LOCAL void -ao_bug(char const * msg) -{ - fprintf(stderr, zao_bug_msg, msg); - exit(EX_SOFTWARE); -} - /** * Print a message suggesting how to get help. * @@ -532,7 +495,7 @@ optionPrintParagraphs(char const * text, bool plain, FILE * fp) if (scan == NULL) goto done; - if ((scan - buf) < 8) { + if ((scan - buf) < 40) { scan++; goto try_longer; } @@ -626,7 +589,8 @@ optionUsage(tOptions * opts, int usage_exit_code) ? opts->pzFullUsage : NULL; if (option_usage_fp == NULL) - option_usage_fp = stdout; + option_usage_fp = print_exit ? stderr : stdout; + } else { pz = (opts->structVersion >= 30 * 4096) ? opts->pzShortUsage : NULL; @@ -659,7 +623,7 @@ optionUsage(tOptions * opts, int usage_exit_code) fserr_exit(opts->pzProgName, zwriting, (option_usage_fp == stdout) ? zstdout_name : zstderr_name); - exit(exit_code); + option_exits(exit_code); } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @@ -959,24 +923,24 @@ prt_extd_usage(tOptions * opts, tOptDesc * od, char const * title) fputs(zDefaultOpt + tab_skip_ct, option_usage_fp); } -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/** + * Figure out where all the initialization files might live. This requires + * translating some environment variables and testing to see if a name is a + * directory or a file. It's squishy, but important to tell users how to + * find these files. * - * Figure out where all the initialization files might live. - * This requires translating some environment variables and - * testing to see if a name is a directory or a file. It's - * squishy, but important to tell users how to find these files. + * @param[in] papz search path + * @param[out] ini_file an output buffer of AG_PATH_MAX+1 bytes + * @param[in] path_nm the name of the file we're hunting for */ static void -prt_ini_list(char const * const * papz, bool * need_intro, - char const * ini_file, char const * path_nm) +prt_ini_list(char const * const * papz, char const * ini_file, + char const * path_nm) { char pth_buf[AG_PATH_MAX+1]; - if (papz == NULL) - return; - fputs(zPresetIntro, option_usage_fp); - *need_intro = false; for (;;) { char const * path = *(papz++); @@ -1021,7 +985,13 @@ prt_ini_list(char const * const * papz, bool * need_intro, } } - +/** + * Print the usage line preamble text + * + * @param opts the program option descriptor + * @param od the option descriptor + * @param at names of the option argument types + */ static void prt_preamble(tOptions * opts, tOptDesc * od, arg_types_t * at) { @@ -1108,10 +1078,10 @@ prt_one_usage(tOptions * opts, tOptDesc * od, arg_types_t * at) bogus_desc: fprintf(stderr, zbad_od, opts->pzProgName, od->pz_Name); - exit(EX_SOFTWARE); + option_exits(EX_SOFTWARE); } -/* +/** * Print out the usage information for just the options. */ static void @@ -1196,20 +1166,22 @@ prt_opt_usage(tOptions * opts, int ex_code, char const * title) } -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * - * PROGRAM DETAILS +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/** + * Print program details. + * @param[in] opts the program option descriptor */ static void prt_prog_detail(tOptions * opts) { - bool need_intro = true; + bool need_intro = (opts->papzHomeList == NULL); /* - * Display all the places we look for config files + * Display all the places we look for config files, if we have + * a list of directories to search. */ - prt_ini_list(opts->papzHomeList, &need_intro, - opts->pzRcName, opts->pzProgPath); + if (! need_intro) + prt_ini_list(opts->papzHomeList, opts->pzRcName, opts->pzProgPath); /* * Let the user know about environment variable settings diff --git a/sntp/libopts/version.c b/sntp/libopts/version.c index 8f2b1db322..08d8696db4 100644 --- a/sntp/libopts/version.c +++ b/sntp/libopts/version.c @@ -166,7 +166,7 @@ print_ver(tOptions * opts, tOptDesc * od, FILE * fp) default: fprintf(stderr, zBadVerArg, ch); - exit(EXIT_FAILURE); + option_exits(EXIT_FAILURE); } fflush(fp); @@ -174,7 +174,7 @@ print_ver(tOptions * opts, tOptDesc * od, FILE * fp) fserr_exit(opts->pzProgName, zwriting, (fp == stdout) ? zstdout_name : zstderr_name); - exit(EXIT_SUCCESS); + option_exits(EXIT_SUCCESS); } /*=export_func optionPrintVersion @@ -190,7 +190,7 @@ print_ver(tOptions * opts, tOptDesc * od, FILE * fp) void optionPrintVersion(tOptions * opts, tOptDesc * od) { - print_ver(opts, od, stdout); + print_ver(opts, od, print_exit ? stderr : stdout); } /*=export_func optionVersionStderr