+* Upgrade to autogen-5.17 and libopts-37.0.12.
* mdoc2texi fixes: parseQuote, closing of list item tables.
* ntp-wait, ntpd, ntpdc, ntpq, ntpsnmpd autogen documentation updates.
(4.2.7p338) 2012/12/25 Released by Harlan Stenn <stenn@ntp.org>
-#assert (version-compare >= autogen-version "5.16.2")
+#assert (version-compare >= autogen-version "5.17")
guard-option-names;
endif
libopts_la_SOURCES = libopts.c
libopts_la_CPPFLAGS = -I$(top_srcdir)
-libopts_la_LDFLAGS = -version-info 36:5:11
+libopts_la_LDFLAGS = -version-info 37:0:12
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/usage-txt.h autoopts/project.h \
autoopts.c autoopts.h boolean.c \
- check.c compat/strchr.c compat/snprintf.c \
- compat/pathfind.c compat/compat.h compat/windows-config.h \
+ check.c compat/pathfind.c compat/snprintf.c \
+ compat/strchr.c compat/windows-config.h compat/compat.h \
compat/strdup.c configfile.c cook.c \
enum.c env.c file.c \
find.c genshell.c genshell.h \
- load.c m4/liboptschk.m4 m4/libopts.m4 \
- makeshell.c nested.c numeric.c \
+ gettext.h init.c load.c \
+ m4/libopts.m4 m4/liboptschk.m4 makeshell.c \
+ nested.c numeric.c option-value-type.c \
+ option-value-type.h option-xat-attribute.c option-xat-attribute.h \
parse-duration.c parse-duration.h pgusage.c \
proto.h putshell.c reset.c \
restore.c save.c sort.c \
stack.c streqvcmp.c text_mmap.c \
time.c tokenize.c usage.c \
- value-type.c value-type.h version.c \
- xat-attribute.c xat-attribute.h
+ version.c
/*
* 29 bits for 46 character classifications
- * generated by char-mapper on 08/11/12 at 09:41:13
+ * generated by char-mapper on 12/27/12 at 12:58:59
*
* This file contains the character classifications
* used by AutoGen and AutoOpts for identifying tokens.
/* | */ 0x12804000, /* } */ 0x02004000, /* ~ */ 0x0280C000, /*x7F*/ 0x00000000
};
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifndef _
+# define _(_s) _s
+#endif
+
static unsigned char const * ag_char_map_spanners[46];
/**
* Character category masks. Some categories may have multiple bits,
0x00000600, /* LOAD_LINE_SKIP */
};
-#define lock_ag_char_map_spanners()
-#define unlock_ag_char_map_spanners()
+#undef LOCK_SPANNER_TABLES
static unsigned char const *
calc_ag_char_map_spanners(unsigned int mask_ix)
{
- lock_ag_char_map_spanners();
- if (ag_char_map_spanners[mask_ix] == NULL) {
+#ifdef LOCK_SPANNER_TABLES
+ if (ag_char_map_spanners[mask_ix] != NULL)
+ return ag_char_map_spanners[mask_ix];
+
+ pthread_mutex_lock(&ag_char_map_mutex);
+ if (ag_char_map_spanners[mask_ix] == NULL)
+#endif
+ {
int ix = 1;
ag_char_map_mask_t mask = ag_char_map_masks[mask_ix];
unsigned char * res = malloc(256 /* 1 << NBBY */);
+ if (res == NULL) {
+ fputs(_("no memory for char-mapper span map\n"), stderr);
+ exit(EXIT_FAILURE);
+ }
+
memset(res, 0, 256);
for (; ix < 128; ix++)
if (ag_char_map_table[ix] & mask)
res[ix] = 1;
ag_char_map_spanners[mask_ix] = res;
}
- unlock_ag_char_map_spanners();
+#ifdef LOCK_SPANNER_TABLES
+ pthread_mutex_unlock(&ag_char_map_mutex);
+#endif
return ag_char_map_spanners[mask_ix];
}
#define ag_char_map_masks POISONED_ag_char_map_masks
/**
* \file alias.c
*
- * Time-stamp: "2012-08-11 08:15:43 bkorb"
- *
* Automated Options Paged Usage module.
*
* This routine will forward an option alias to the correct option code.
*
* DO NOT EDIT THIS FILE (ao-strs.c)
*
- * It has been AutoGen-ed August 11, 2012 at 09:41:13 AM by AutoGen 5.16.2pre7
+ * It has been AutoGen-ed December 27, 2012 at 12:58:59 PM by AutoGen 5.17.0pre12
* From the definitions ao-strs.def
* and the template file strings
*
- * Copyright (C) 2011-2012 Bruce Korb, all rights reserved.
+ * Copyright (C) 2011- Bruce Korb, all rights reserved.
* This is free software. It is licensed for use, modification and
* redistribution under the terms of the
* Modified (3 clause) Berkeley Software Distribution License
*/
#include "ao-strs.h"
-char const ao_strs_strtable[6265] =
+char const ao_strs_strtable[6407] =
/* 0 */ " \t\n"
":=\0"
-/* 6 */ "INVALID-%d\0"
-/* 17 */ "*INVALID*\0"
-/* 27 */ "none\0"
-/* 32 */ " + \0"
-/* 36 */ " | \0"
-/* 40 */ "%s\n\0"
-/* 44 */ "PAGER\0"
-/* 50 */ "/tmp/use.%lu\0"
-/* 63 */ "more\0"
-/* 68 */ " --* )\n\0"
-/* 79 */ "%s\n"
+/* 6 */ "%s_%s_%d=\0"
+/* 16 */ "\t\t\t\t- \0"
+/* 23 */ "\t\t\t\t \0"
+/* 30 */ "''\0"
+/* 33 */ " ;;\n\n\0"
+/* 46 */ "'\n\n\0"
+/* 50 */ "</%s>\n\0"
+/* 57 */ " %s\n\0"
+/* 63 */ "%%-%ds\0"
+/* 70 */ "\n"
+ "export %s_%s_%d\n\0"
+/* 88 */ "false\0"
+/* 94 */ " -* )\n\0"
+/* 104 */ "flag\0"
+/* 109 */ "INVALID-%d\0"
+/* 120 */ "*INVALID*\0"
+/* 130 */ " --* )\n\0"
+/* 141 */ "--\0"
+/* 144 */ "LONGUSAGE\0"
+/* 154 */ " %s\n\0"
+/* 170 */ "more\0"
+/* 175 */ "<%s type=nested>\n\0"
+/* 193 */ "%s\n\0"
+/* 197 */ "%s\n"
" \0"
-/* 85 */ " \0"
-/* 88 */ " -* )\n\0"
-/* 98 */ " ;;\n\n\0"
-/* 111 */ "stdout\0"
-/* 118 */ "%A %B %e, %Y at %r %Z\0"
-/* 140 */ "#! %s\n\0"
-/* 147 */ "%s_%s=\0"
-/* 154 */ "\n"
+/* 203 */ "none\0"
+/* 208 */ "OPT_ARG_NEEDED=NO\0"
+/* 226 */ "<%s/>\n\0"
+/* 233 */ "OPT_ARG_NEEDED=OK\0"
+/* 251 */ "\t\0"
+/* 253 */ "<%s>\0"
+/* 258 */ "option\0"
+/* 265 */ "\n"
"export %s_%s\n\0"
-/* 169 */ "''\0"
-/* 172 */ "\\'\0"
-/* 175 */ "'%s'\0"
-/* 180 */ "%s_%s_%d=\0"
-/* 190 */ "\n"
- "export %s_%s_%d\n\0"
-/* 208 */ "set --\0"
-/* 215 */ " '%s'\0"
-/* 221 */ "'\\''\0"
-/* 226 */ "\n"
- "OPTION_CT=0\n\0"
-/* 240 */ "=%1$lu # 0x%1$lX\n\0"
-/* 258 */ "true\0"
-/* 263 */ "false\0"
-/* 269 */ "VERSION\0"
-/* 277 */ "OPT_ARG_NEEDED=OK\0"
-/* 295 */ "OPT_ARG_NEEDED=NO\0"
-/* 313 */ "OPT_ARG_NEEDED=YES\0"
-/* 332 */ "LONGUSAGE\0"
-/* 342 */ "flag\0"
-/* 347 */ "%s_%s_TEXT='\0"
-/* 360 */ "'\n\n\0"
-/* 364 */ "option\0"
-/* 371 */ "\n"
+/* 280 */ "%s_%s=\0"
+/* 287 */ " | \0"
+/* 291 */ "PAGER\0"
+/* 297 */ " + \0"
+/* 301 */ "\\'\0"
+/* 304 */ "'%s'\0"
+/* 309 */ " -- %s\0"
+/* 316 */ "%s_%s_TEXT='\0"
+/* 329 */ "#! %s\n\0"
+/* 336 */ "\n"
"env | grep '^%s_'\n\0"
-/* 391 */ " -- %s\0"
-/* 398 */ "--\0"
-/* 401 */ "\t\t\t\t- \0"
-/* 408 */ "\t\t\t\t \0"
-/* 415 */ "\t\0"
-/* 417 */ " * )\n"
- " OPT_PROCESS=false\n"
- " ;;\n"
- " esac\n\0"
-/* 474 */ " %s\n\0"
-/* 480 */ "%%-%ds\0"
-/* 487 */ "%1$s /tmp/use.%2$lu ; rm -f /tmp/use.%2$lu\0"
-/* 530 */ "# # # # # # # # # # -- do not modify this marker --\n"
- "#\n"
- "# DO NOT EDIT THIS SECTION\0"
-/* 612 */ "%s OF %s\n"
- "#\n"
- "# From here to the next `-- do not modify this marker --',\n"
- "# the text has been generated %s\n\0"
-/* 718 */ "# From the %s option definitions\n"
+/* 356 */ "=%1$lu # 0x%1$lX\n\0"
+/* 374 */ "stdout\0"
+/* 381 */ "%A %B %e, %Y at %r %Z\0"
+/* 403 */ "/tmp/use.%lu\0"
+/* 416 */ "true\0"
+/* 421 */ " \0"
+/* 424 */ "<%s type=%s>\0"
+/* 437 */ "VERSION\0"
+/* 445 */ "#x%02X;\0"
+/* 453 */ "OPT_ARG_NEEDED=YES\0"
+/* 472 */ "'\\''\0"
+/* 477 */ " '%s'\0"
+/* 483 */ "\n"
+ "OPTION_CT=0\n\0"
+/* 497 */ "set --\0"
+/* 504 */ " ;;\n\n\0"
+/* 521 */ " '%c' )\n\0"
+/* 537 */ " '%s' )\n\0"
+/* 553 */ " '%s' | \\\n\0"
+/* 571 */ "%1$s /tmp/use.%2$lu ; rm -f /tmp/use.%2$lu\0"
+/* 614 */ "<%1$s type=boolean>%2$s</%1$s>\n\0"
+/* 646 */ "# From the %s option definitions\n"
"#\n\0"
-/* 755 */ "\n"
- "if test -z \"${%1$s_%2$s}\"\n"
- "then\n"
- " %1$s_%2$s_CT=0\n"
- "else\n"
- " %1$s_%2$s_CT=1\n"
- " %1$s_%2$s_1=${%1$s_%2$s}\n"
- "fi\n"
- "export %1$s_%2$s_CT\0"
-/* 876 */ "\n"
- "%1$s_%2$s=${%1$s_%2$s-'%3$s'}\n"
- "%1$s_%2$s_set=false\n"
- "export %1$s_%2$s\0"
-/* 944 */ "\n"
- "%1$s_%2$s=${%1$s_%2$s}\n"
- "%1$s_%2$s_set=false\n"
+/* 683 */ "echo 'Warning: Cannot load options files' >&2\0"
+/* 730 */ "echo 'Warning: Cannot save options files' >&2\0"
+/* 777 */ "echo 'Warning: Cannot suppress the loading of options files' >&2\0"
+/* 843 */ "<%1$s type=integer>0x%2$lX</%1$s>\n\0"
+/* 878 */ "%s WARNING: cannot save options - \0"
+/* 914 */ "%1$s_%2$s_TEXT='no %2$s text'\n\0"
+/* 945 */ "%1$s_%2$s_MODE='%3$s'\n"
+ "export %1$s_%2$s_MODE\n\0"
+/* 990 */ "%1$s_%2$s='%3$s'\n"
"export %1$s_%2$s\n\0"
-/* 1006 */ "\n"
- "OPT_PROCESS=true\n"
- "OPT_ARG=$1\n"
- "while ${OPT_PROCESS} && [ $# -gt 0 ]\n"
- "do\n"
- " OPT_ELEMENT=''\n"
- " OPT_ARG_VAL=''\n\n"
- " case \"${OPT_ARG}\" in\n"
- " -- )\n"
- " OPT_PROCESS=false\n"
- " shift\n"
- " ;;\n\0"
-/* 1200 */ "\n"
- "OPT_ARG=$1\n"
- "while [ $# -gt 0 ]\n"
- "do\n"
- " OPT_ELEMENT=''\n"
- " OPT_ARG_VAL=''\n"
- " OPT_ARG=${1}\n\0"
-/* 1290 */ " if [ -n \"${OPT_ARG_VAL}\" ]\n"
+/* 1025 */ "%1$s_%2$s_CT=%3$d\n"
+ "export %1$s_%2$s_CT\n\0"
+/* 1064 */ "OPTION_CT=%d\n"
+ "export OPTION_CT\n\0"
+/* 1095 */ "%1$s_%2$s=%3$s\n"
+ "export %1$s_%2$s\n\0"
+/* 1128 */ "%1$s_%2$s=%3$d # 0x%3$X\n"
+ "export %1$s_%2$s\n\0"
+/* 1170 */ " case \"${OPT_CODE}\" in\n\0"
+/* 1201 */ " 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"
+/* 1392 */ "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"
+/* 1484 */ "test -n \"$%1$s_%2$s\" || {\n"
+ " echo %1$s_%2$s has not been set\n"
+ " exit 1\n"
+ "} 1>&2\n\0"
+/* 1565 */ " echo \"$%s_%s_TEXT\"\n"
+ " exit 0\n\0"
+/* 1616 */ "\n"
+ "# # # # # # # # # #\n"
+ "#\n"
+ "# END OF AUTOMATED OPTION PROCESSING\n"
+ "#\n"
+ "# # # # # # # # # # -- do not modify this marker --\n\0"
+/* 1732 */ " 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"
" fi\n"
"done\n"
+ "OPTION_COUNT=`expr $ARG_COUNT - $#`\n"
+ "OPERAND_COUNT=$#\n"
"unset OPT_PROCESS || :\n"
"unset OPT_ELEMENT || :\n"
"unset OPT_ARG || :\n"
"unset OPT_ARG_NEEDED || :\n"
"unset OPT_NAME || :\n"
"unset OPT_CODE || :\n"
- "unset OPT_ARG_VAL || :\n"
- "%2$s\0"
-/* 1620 */ "\n"
- "# # # # # # # # # #\n"
- "#\n"
- "# END OF AUTOMATED OPTION PROCESSING\n"
- "#\n"
- "# # # # # # # # # # -- do not modify this marker --\n\0"
-/* 1736 */ " case \"${OPT_CODE}\" in\n\0"
-/* 1767 */ " '%s' | \\\n\0"
-/* 1785 */ " '%s' )\n\0"
-/* 1801 */ " '%c' )\n\0"
-/* 1817 */ " ;;\n\n\0"
-/* 1834 */ " * )\n"
- " echo Unknown %s: \"${OPT_CODE}\" >&2\n"
- " echo \"$%s_USAGE_TEXT\"\n"
- " exit 1\n"
- " ;;\n"
- " esac\n\n\0"
-/* 1976 */ " echo \"$%s_%s_TEXT\"\n"
- " exit 0\n\0"
-/* 2027 */ " echo \"$%s_LONGUSAGE_TEXT\" | ${PAGER-more}\n"
- " exit 0\n\0"
-/* 2101 */ " %s\n\0"
-/* 2117 */ " if [ $%1$s_%2$s_CT -ge %3$d ] ; then\n"
- " echo Error: more than %3$d %2$s options >&2\n"
- " echo \"$%1$s_USAGE_TEXT\"\n"
- " exit 1 ; fi\n\0"
-/* 2296 */ " %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"
-/* 2420 */ " if [ -n \"${%1$s_%2$s}\" ] && ${%1$s_%2$s_set} ; then\n"
- " echo Error: duplicate %2$s option >&2\n"
- " echo \"$%1$s_USAGE_TEXT\"\n"
- " exit 1 ; fi\n"
- " %1$s_%2$s_set=true\n"
- " OPT_NAME='%2$s'\n\0"
-/* 2667 */ " %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"
-/* 2808 */ " if [ -n \"${%1$s_%2$s}\" ] && ${%1$s_%2$s_set} ; then\n"
- " echo 'Error: duplicate %2$s option' >&2\n"
- " echo \"$%1$s_USAGE_TEXT\"\n"
- " exit 1 ; fi\n"
- " %1$s_%2$s_set=true\n"
- " %1$s_%2$s='%3$s'\n"
- " export %1$s_%2$s\n"
- " OPT_NAME='%2$s'\n\0"
-/* 3115 */ " eval %1$s_%2$s${OPT_ELEMENT}=true\n"
- " export %1$s_%2$s${OPT_ELEMENT}\n"
- " OPT_ARG_NEEDED=OK\n\0"
-/* 3235 */ " OPT_ARG_NEEDED=YES\n\0"
-/* 3267 */ " eval %1$s_%2$s${OPT_ELEMENT}=true\n"
- " export %1$s_%2$s${OPT_ELEMENT}\n"
- " OPT_ARG_NEEDED=NO\n\0"
-/* 3387 */ " OPT_CODE=`echo \"X${OPT_ARG}\"|sed 's/^X-*//'`\n"
+ "unset OPT_ARG_VAL || :\n\0"
+/* 2111 */ " 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"
-/* 3638 */ " case \"${OPT_ARG_NEEDED}\" in\n"
+/* 2362 */ " OPT_CODE=`echo \"X${OPT_ARG}\" | sed 's/X-\\(.\\).*/\\1/'`\n"
+ " OPT_ARG=` echo \"X${OPT_ARG}\" | sed 's/X-.//'`\n\0"
+/* 2479 */ "\n"
+ "ARG_COUNT=$#\n"
+ "OPT_PROCESS=true\n"
+ "OPT_ARG=$1\n"
+ "while ${OPT_PROCESS} && [ $# -gt 0 ]\n"
+ "do\n"
+ " OPT_ELEMENT=''\n"
+ " OPT_ARG_VAL=''\n\n"
+ " case \"${OPT_ARG}\" in\n"
+ " -- )\n"
+ " OPT_PROCESS=false\n"
+ " shift\n"
+ " ;;\n\0"
+/* 2686 */ " case \"${OPT_ARG_NEEDED}\" in\n"
" NO )\n"
" OPT_ARG_VAL=''\n"
" ;;\n"
" then\n"
" if [ $# -eq 0 ]\n"
" then\n"
- " echo No argument provided for ${OPT_NAME} option >&2\n"
+ " echo No argument provided for ${OPT_NAME} option\n"
" echo \"$%s_USAGE_TEXT\"\n"
" exit 1\n"
- " fi\n"
+ " fi >&2\n"
" OPT_ARG_VAL=${OPT_ARG}\n"
" shift\n"
" OPT_ARG=$1\n"
" fi\n"
" ;;\n"
" esac\n\0"
-/* 4417 */ " OPT_CODE=`echo \"X${OPT_ARG}\" | sed 's/X-\\(.\\).*/\\1/'`\n"
- " OPT_ARG=` echo \"X${OPT_ARG}\" | sed 's/X-.//'`\n\0"
-/* 4534 */ " case \"${OPT_ARG_NEEDED}\" in\n"
+/* 3465 */ " %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"
+/* 3589 */ "\n"
+ "if test -z \"${%1$s_%2$s}\"\n"
+ "then\n"
+ " %1$s_%2$s_CT=0\n"
+ " export %1$s_%2$s_CT\n"
+ "else\n"
+ " %1$s_%2$s_CT=1\n"
+ " %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"
+/* 3747 */ " * )\n"
+ " OPT_PROCESS=false\n"
+ " ;;\n"
+ " esac\n\0"
+/* 3804 */ " %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"
+/* 3945 */ " 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"
+ " %1$s_%2$s='%3$s'\n"
+ " export %1$s_%2$s\n"
+ " OPT_NAME='%2$s'\n\0"
+/* 4262 */ "\n"
+ "ARG_COUNT=$#\n"
+ "OPT_ARG=$1\n"
+ "while [ $# -gt 0 ]\n"
+ "do\n"
+ " OPT_ELEMENT=''\n"
+ " OPT_ARG_VAL=''\n"
+ " OPT_ARG=${1}\n\0"
+/* 4365 */ " case \"${OPT_ARG_NEEDED}\" in\n"
" NO )\n"
" if [ -n \"${OPT_ARG}\" ]\n"
" then\n"
" else\n"
" if [ $# -eq 0 ]\n"
" then\n"
- " echo No argument provided for ${OPT_NAME} option >&2\n"
+ " echo No argument provided for ${OPT_NAME} option\n"
" echo \"$%s_USAGE_TEXT\"\n"
" exit 1\n"
- " fi\n"
+ " fi >&2\n"
" shift\n"
" OPT_ARG_VAL=$1\n"
" fi\n"
" fi\n"
" ;;\n"
" esac\n\0"
-/* 5688 */ "%1$s_%2$s=%3$d # 0x%3$X\n"
- "export %1$s_%2$s\n\0"
-/* 5730 */ "%1$s_%2$s_CT=%3$d\n"
- "export %1$s_%2$s_CT\n\0"
-/* 5769 */ "OPTION_CT=%d\n"
- "export OPTION_CT\n\0"
-/* 5800 */ "%1$s_%2$s=%3$s\n"
+/* 5519 */ " echo \"$%s_LONGUSAGE_TEXT\" | ${PAGER-more}\n"
+ " exit 0\n\0"
+/* 5593 */ "%s OF %s\n"
+ "#\n"
+ "# From here to the next `-- do not modify this marker --',\n"
+ "# the text has been generated %s\n\0"
+/* 5699 */ " eval %1$s_%2$s${OPT_ELEMENT}=true\n"
+ " export %1$s_%2$s${OPT_ELEMENT}\n\0"
+/* 5789 */ " 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"
+/* 6048 */ "\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"
-/* 5833 */ "%1$s_%2$s='%3$s'\n"
+/* 6117 */ "\n"
+ "%1$s_%2$s=${%1$s_%2$s}\n"
+ "%1$s_%2$s_set=false\n"
"export %1$s_%2$s\n\0"
-/* 5868 */ "%1$s_%2$s_MODE='%3$s'\n"
- "export %1$s_%2$s_MODE\n\0"
-/* 5913 */ "echo 'Warning: Cannot load options files' >&2\0"
-/* 5960 */ "echo 'Warning: Cannot save options files' >&2\0"
-/* 6007 */ "echo 'Warning: Cannot suppress the loading of options files' >&2\0"
-/* 6073 */ "%1$s_%2$s_TEXT='no %2$s text'\n\0"
-/* 6104 */ "%s WARNING: cannot save options - \0"
-/* 6140 */ "<%s/>\n\0"
-/* 6147 */ "<%s>\0"
-/* 6152 */ "</%s>\n\0"
-/* 6159 */ "<%s type=%s>\0"
-/* 6172 */ "<%s type=nested>\n\0"
-/* 6190 */ "#x%02X;\0"
-/* 6198 */ "<%1$s type=boolean>%2$s</%1$s>\n\0"
-/* 6230 */ "<%1$s type=integer>0x%2$lX</%1$s>\n";
+/* 6179 */ "# # # # # # # # # # -- do not modify this marker --\n"
+ "#\n"
+ "# DO NOT EDIT THIS SECTION\n\0"
+/* 6262 */ " * )\n"
+ " echo Unknown %s: \"${OPT_CODE}\" >&2\n"
+ " echo \"$%s_USAGE_TEXT\" >&2\n"
+ " exit 1\n"
+ " ;;\n"
+ " esac\n";
/* end of ao-strs.c */
*
* DO NOT EDIT THIS FILE (ao-strs.h)
*
- * It has been AutoGen-ed August 11, 2012 at 09:41:13 AM by AutoGen 5.16.2pre7
+ * It has been AutoGen-ed December 27, 2012 at 12:58:59 PM by AutoGen 5.17.0pre12
* From the definitions ao-strs.def
* and the template file strings
*
- * Copyright (C) 2011-2012 Bruce Korb, all rights reserved.
+ * Copyright (C) 2011- Bruce Korb, all rights reserved.
* This is free software. It is licensed for use, modification and
* redistribution under the terms of the
* Modified (3 clause) Berkeley Software Distribution License
#ifndef STRINGS_AO_STRS_H_GUARD
#define STRINGS_AO_STRS_H_GUARD 1
/*
- * 102 strings in ao_strs_strtable string table
+ * 103 strings in ao_strs_strtable string table
*/
-#define ARG_BREAK_STR (ao_strs_strtable+0)
-#define ARG_BREAK_STR_LEN 5
-#define ARG_BY_NUM_FMT (ao_strs_strtable+180)
-#define ARG_BY_NUM_FMT_LEN 9
-#define BOOL_ATR_FMT (ao_strs_strtable+6198)
-#define BOOL_ATR_FMT_LEN 31
-#define BULLET_STR (ao_strs_strtable+401)
-#define BULLET_STR_LEN 6
-#define DEEP_INDENT_STR (ao_strs_strtable+408)
-#define DEEP_INDENT_STR_LEN 6
-#define EMPTY_ARG (ao_strs_strtable+169)
-#define EMPTY_ARG_LEN 2
-#define END_MARK (ao_strs_strtable+1620)
-#define END_MARK_LEN 115
-#define END_OPT_SEL_STR (ao_strs_strtable+98)
-#define END_OPT_SEL_STR_LEN 12
-#define END_PRE_FMT (ao_strs_strtable+718)
-#define END_PRE_FMT_LEN 36
-#define END_SET_TEXT (ao_strs_strtable+360)
-#define END_SET_TEXT_LEN 3
-#define END_XML_FMT (ao_strs_strtable+6152)
-#define END_XML_FMT_LEN 6
-#define ENUM_ERR_SEP_LINE_FMT (ao_strs_strtable+474)
-#define ENUM_ERR_SEP_LINE_FMT_LEN 5
-#define ENUM_ERR_STR_WIDTH_FMT (ao_strs_strtable+480)
-#define ENUM_ERR_STR_WIDTH_FMT_LEN 6
-#define EXPORT_ARG_FMT (ao_strs_strtable+190)
-#define EXPORT_ARG_FMT_LEN 17
-#define FALSE_STR (ao_strs_strtable+263)
-#define FALSE_STR_LEN 5
-#define FLAG_OPT_MARK (ao_strs_strtable+88)
-#define FLAG_OPT_MARK_LEN 9
-#define FLAG_STR (ao_strs_strtable+342)
-#define FLAG_STR_LEN 4
-#define INIT_LOPT_STR (ao_strs_strtable+3387)
-#define INIT_LOPT_STR_LEN 250
-#define INIT_OPT_STR (ao_strs_strtable+4417)
-#define INIT_OPT_STR_LEN 116
-#define INVALID_FMT (ao_strs_strtable+6)
-#define INVALID_FMT_LEN 10
-#define INVALID_STR (ao_strs_strtable+17)
-#define INVALID_STR_LEN 9
-#define LONG_OPT_MARK (ao_strs_strtable+68)
-#define LONG_OPT_MARKER (ao_strs_strtable+398)
-#define LONG_OPT_MARKER_LEN 2
-#define LONG_OPT_MARK_LEN 10
-#define LONG_USE_STR (ao_strs_strtable+332)
-#define LONG_USE_STR_LEN 9
-#define LOOP_STR (ao_strs_strtable+1006)
-#define LOOP_STR_LEN 193
-#define LOPT_ARG_FMT (ao_strs_strtable+3638)
-#define LOPT_ARG_FMT_LEN 778
-#define MORE_STR (ao_strs_strtable+63)
-#define MORE_STR_LEN 4
-#define MULTI_ARG_FMT (ao_strs_strtable+2296)
-#define MULTI_ARG_FMT_LEN 123
-#define MULTI_DEF_FMT (ao_strs_strtable+755)
-#define MULTI_DEF_FMT_LEN 120
-#define NESTED_OPT_FMT (ao_strs_strtable+6172)
-#define NESTED_OPT_FMT_LEN 17
-#define NLSTR_FMT (ao_strs_strtable+40)
-#define NLSTR_FMT_LEN 3
-#define NLSTR_SPACE_FMT (ao_strs_strtable+79)
-#define NLSTR_SPACE_FMT_LEN 5
-#define NONE_STR (ao_strs_strtable+27)
-#define NONE_STR_LEN 4
-#define NOT_FOUND_STR (ao_strs_strtable+417)
-#define NOT_FOUND_STR_LEN 56
-#define NO_ARG_NEEDED (ao_strs_strtable+295)
-#define NO_ARG_NEEDED_LEN 17
-#define NO_LOAD_WARN (ao_strs_strtable+5913)
-#define NO_LOAD_WARN_LEN 46
-#define NO_MULTI_ARG_FMT (ao_strs_strtable+2667)
-#define NO_MULTI_ARG_FMT_LEN 140
-#define NO_SAVE_OPTS (ao_strs_strtable+5960)
-#define NO_SAVE_OPTS_LEN 46
-#define NO_SGL_ARG_FMT (ao_strs_strtable+2808)
-#define NO_SGL_ARG_FMT_LEN 306
-#define NO_SUPPRESS_LOAD (ao_strs_strtable+6007)
-#define NO_SUPPRESS_LOAD_LEN 65
-#define NULL_ATR_FMT (ao_strs_strtable+6140)
-#define NULL_ATR_FMT_LEN 6
-#define NUMB_ATR_FMT (ao_strs_strtable+6230)
-#define NUMB_ATR_FMT_LEN 34
-#define OK_NEED_OPT_ARG (ao_strs_strtable+277)
-#define OK_NEED_OPT_ARG_LEN 17
-#define ONE_TAB_STR (ao_strs_strtable+415)
-#define ONE_TAB_STR_LEN 1
-#define ONLY_OPTS_LOOP (ao_strs_strtable+1200)
-#define ONLY_OPTS_LOOP_LEN 89
-#define OPEN_CLOSE_FMT (ao_strs_strtable+6140)
-#define OPEN_CLOSE_FMT_LEN 6
-#define OPEN_XML_FMT (ao_strs_strtable+6147)
-#define OPEN_XML_FMT_LEN 4
-#define OPTION_STR (ao_strs_strtable+364)
-#define OPTION_STR_LEN 6
-#define OPT_ARG_FMT (ao_strs_strtable+4534)
-#define OPT_ARG_FMT_LEN 1153
-#define OPT_END_FMT (ao_strs_strtable+154)
-#define OPT_END_FMT_LEN 14
-#define OPT_VAL_FMT (ao_strs_strtable+147)
-#define OPT_VAL_FMT_LEN 6
-#define OR_STR (ao_strs_strtable+36)
-#define OR_STR_LEN 3
-#define PAGER_NAME (ao_strs_strtable+44)
-#define PAGER_NAME_LEN 5
-#define PAGE_USAGE_FMT (ao_strs_strtable+487)
-#define PAGE_USAGE_FMT_LEN 42
-#define PLUS_STR (ao_strs_strtable+32)
-#define PLUS_STR_LEN 3
-#define PREAMBLE_FMT (ao_strs_strtable+612)
-#define PREAMBLE_FMT_LEN 105
-#define QUOT_APOS (ao_strs_strtable+172)
-#define QUOT_APOS_LEN 2
-#define QUOT_ARG_FMT (ao_strs_strtable+175)
-#define QUOT_ARG_FMT_LEN 4
-#define SAVE_WARN (ao_strs_strtable+6104)
-#define SAVE_WARN_LEN 35
-#define SET_NO_TEXT_FMT (ao_strs_strtable+6073)
-#define SET_NO_TEXT_FMT_LEN 30
-#define SET_OFF_FMT (ao_strs_strtable+391)
-#define SET_OFF_FMT_LEN 6
-#define SET_TEXT_FMT (ao_strs_strtable+347)
-#define SET_TEXT_FMT_LEN 12
-#define SGL_ARG_FMT (ao_strs_strtable+2420)
-#define SGL_ARG_FMT_LEN 246
-#define SGL_DEF_FMT (ao_strs_strtable+876)
-#define SGL_DEF_FMT_LEN 67
-#define SGL_NO_DEF_FMT (ao_strs_strtable+944)
-#define SGL_NO_DEF_FMT_LEN 61
-#define SHELL_MAGIC (ao_strs_strtable+140)
-#define SHELL_MAGIC_LEN 6
-#define SHOW_PROG_ENV (ao_strs_strtable+371)
-#define SHOW_PROG_ENV_LEN 19
-#define SHOW_VAL_FMT (ao_strs_strtable+240)
-#define SHOW_VAL_FMT_LEN 17
-#define START_MARK (ao_strs_strtable+530)
-#define START_MARK_LEN 81
-#define STDOUT (ao_strs_strtable+111)
-#define STDOUT_LEN 6
-#define TIME_FMT (ao_strs_strtable+118)
-#define TIME_FMT_LEN 21
-#define TMP_USAGE_FMT (ao_strs_strtable+50)
-#define TMP_USAGE_FMT_LEN 12
-#define TRUE_STR (ao_strs_strtable+258)
-#define TRUE_STR_LEN 4
-#define TWO_SPACES_STR (ao_strs_strtable+85)
-#define TWO_SPACES_STR_LEN 2
-#define TYPE_ATR_FMT (ao_strs_strtable+6159)
-#define TYPE_ATR_FMT_LEN 12
-#define UNK_OPT_FMT (ao_strs_strtable+1834)
-#define UNK_OPT_FMT_LEN 141
-#define VER_STR (ao_strs_strtable+269)
-#define VER_STR_LEN 7
-#define XML_HEX_BYTE_FMT (ao_strs_strtable+6190)
-#define XML_HEX_BYTE_FMT_LEN 7
-#define YES_NEED_OPT_ARG (ao_strs_strtable+313)
-#define YES_NEED_OPT_ARG_LEN 18
-#define apostrophy (ao_strs_strtable+221)
-#define apostrophy_LEN 4
-#define arg_fmt (ao_strs_strtable+215)
-#define arg_fmt_LEN 5
-#define init_optct (ao_strs_strtable+226)
-#define init_optct_LEN 13
-#define set_dash (ao_strs_strtable+208)
-#define set_dash_LEN 6
-#define zCantArg (ao_strs_strtable+3267)
-#define zCantArg_LEN 119
-#define zCmdFmt (ao_strs_strtable+2101)
-#define zCmdFmt_LEN 15
-#define zCountTest (ao_strs_strtable+2117)
-#define zCountTest_LEN 178
-#define zEquivMode (ao_strs_strtable+5868)
-#define zEquivMode_LEN 44
-#define zFullOptFmt (ao_strs_strtable+5833)
-#define zFullOptFmt_LEN 34
-#define zLoopEnd (ao_strs_strtable+1290)
-#define zLoopEnd_LEN 329
-#define zMayArg (ao_strs_strtable+3115)
-#define zMayArg_LEN 119
-#define zMustArg (ao_strs_strtable+3235)
-#define zMustArg_LEN 31
-#define zOptCookieCt (ao_strs_strtable+5730)
-#define zOptCookieCt_LEN 38
-#define zOptCtFmt (ao_strs_strtable+5769)
-#define zOptCtFmt_LEN 30
-#define zOptDisabl (ao_strs_strtable+5800)
-#define zOptDisabl_LEN 32
-#define zOptNumFmt (ao_strs_strtable+5688)
-#define zOptNumFmt_LEN 41
-#define zOptionCase (ao_strs_strtable+1736)
-#define zOptionCase_LEN 30
-#define zOptionEndSelect (ao_strs_strtable+1817)
-#define zOptionEndSelect_LEN 16
-#define zOptionFlag (ao_strs_strtable+1801)
-#define zOptionFlag_LEN 15
-#define zOptionFullName (ao_strs_strtable+1785)
-#define zOptionFullName_LEN 15
-#define zOptionPartName (ao_strs_strtable+1767)
-#define zOptionPartName_LEN 17
-#define zPagedUsageExit (ao_strs_strtable+2027)
-#define zPagedUsageExit_LEN 73
-#define zTextExit (ao_strs_strtable+1976)
-#define zTextExit_LEN 50
-extern char const ao_strs_strtable[6265];
+#define ARG_BREAK_STR (ao_strs_strtable+0)
+#define ARG_BREAK_STR_LEN 5
+#define ARG_BY_NUM_FMT (ao_strs_strtable+6)
+#define ARG_BY_NUM_FMT_LEN 9
+#define BOOL_ATR_FMT (ao_strs_strtable+614)
+#define BOOL_ATR_FMT_LEN 31
+#define BULLET_STR (ao_strs_strtable+16)
+#define BULLET_STR_LEN 6
+#define CHK_MAX_COUNT (ao_strs_strtable+1201)
+#define CHK_MAX_COUNT_LEN 190
+#define CHK_MIN_COUNT (ao_strs_strtable+1392)
+#define CHK_MIN_COUNT_LEN 91
+#define CHK_ONE_REQUIRED (ao_strs_strtable+1484)
+#define CHK_ONE_REQUIRED_LEN 80
+#define DEEP_INDENT_STR (ao_strs_strtable+23)
+#define DEEP_INDENT_STR_LEN 6
+#define ECHO_N_EXIT (ao_strs_strtable+1565)
+#define ECHO_N_EXIT_LEN 50
+#define EMPTY_ARG (ao_strs_strtable+30)
+#define EMPTY_ARG_LEN 2
+#define END_MARK (ao_strs_strtable+1616)
+#define END_MARK_LEN 115
+#define END_OPT_SEL_STR (ao_strs_strtable+33)
+#define END_OPT_SEL_STR_LEN 12
+#define END_PRE_FMT (ao_strs_strtable+646)
+#define END_PRE_FMT_LEN 36
+#define END_SET_TEXT (ao_strs_strtable+46)
+#define END_SET_TEXT_LEN 3
+#define END_XML_FMT (ao_strs_strtable+50)
+#define END_XML_FMT_LEN 6
+#define ENUM_ERR_LINE (ao_strs_strtable+57)
+#define ENUM_ERR_LINE_LEN 5
+#define ENUM_ERR_WIDTH (ao_strs_strtable+63)
+#define ENUM_ERR_WIDTH_LEN 6
+#define EXPORT_ARG_FMT (ao_strs_strtable+70)
+#define EXPORT_ARG_FMT_LEN 17
+#define FALSE_STR (ao_strs_strtable+88)
+#define FALSE_STR_LEN 5
+#define FINISH_LOOP (ao_strs_strtable+1732)
+#define FINISH_LOOP_LEN 378
+#define FLAG_OPT_MARK (ao_strs_strtable+94)
+#define FLAG_OPT_MARK_LEN 9
+#define FLAG_STR (ao_strs_strtable+104)
+#define FLAG_STR_LEN 4
+#define INIT_LOPT_STR (ao_strs_strtable+2111)
+#define INIT_LOPT_STR_LEN 250
+#define INIT_OPT_STR (ao_strs_strtable+2362)
+#define INIT_OPT_STR_LEN 116
+#define INVALID_FMT (ao_strs_strtable+109)
+#define INVALID_FMT_LEN 10
+#define INVALID_STR (ao_strs_strtable+120)
+#define INVALID_STR_LEN 9
+#define LONG_OPT_MARK (ao_strs_strtable+130)
+#define LONG_OPT_MARKER (ao_strs_strtable+141)
+#define LONG_OPT_MARKER_LEN 2
+#define LONG_OPT_MARK_LEN 10
+#define LONG_USE_STR (ao_strs_strtable+144)
+#define LONG_USE_STR_LEN 9
+#define LOOP_STR (ao_strs_strtable+2479)
+#define LOOP_STR_LEN 206
+#define LOPT_ARG_FMT (ao_strs_strtable+2686)
+#define LOPT_ARG_FMT_LEN 778
+#define LVL3_CMD (ao_strs_strtable+154)
+#define LVL3_CMD_LEN 15
+#define MORE_STR (ao_strs_strtable+170)
+#define MORE_STR_LEN 4
+#define MULTI_ARG_FMT (ao_strs_strtable+3465)
+#define MULTI_ARG_FMT_LEN 123
+#define MULTI_DEF_FMT (ao_strs_strtable+3589)
+#define MULTI_DEF_FMT_LEN 157
+#define NESTED_OPT_FMT (ao_strs_strtable+175)
+#define NESTED_OPT_FMT_LEN 17
+#define NLSTR_FMT (ao_strs_strtable+193)
+#define NLSTR_FMT_LEN 3
+#define NLSTR_SPACE_FMT (ao_strs_strtable+197)
+#define NLSTR_SPACE_FMT_LEN 5
+#define NONE_STR (ao_strs_strtable+203)
+#define NONE_STR_LEN 4
+#define NOT_FOUND_STR (ao_strs_strtable+3747)
+#define NOT_FOUND_STR_LEN 56
+#define NO_ARG_NEEDED (ao_strs_strtable+208)
+#define NO_ARG_NEEDED_LEN 17
+#define NO_LOAD_WARN (ao_strs_strtable+683)
+#define NO_LOAD_WARN_LEN 46
+#define NO_MULTI_ARG_FMT (ao_strs_strtable+3804)
+#define NO_MULTI_ARG_FMT_LEN 140
+#define NO_SAVE_OPTS (ao_strs_strtable+730)
+#define NO_SAVE_OPTS_LEN 46
+#define NO_SGL_ARG_FMT (ao_strs_strtable+3945)
+#define NO_SGL_ARG_FMT_LEN 316
+#define NO_SUPPRESS_LOAD (ao_strs_strtable+777)
+#define NO_SUPPRESS_LOAD_LEN 65
+#define NULL_ATR_FMT (ao_strs_strtable+226)
+#define NULL_ATR_FMT_LEN 6
+#define NUMB_ATR_FMT (ao_strs_strtable+843)
+#define NUMB_ATR_FMT_LEN 34
+#define OK_NEED_OPT_ARG (ao_strs_strtable+233)
+#define OK_NEED_OPT_ARG_LEN 17
+#define ONE_TAB_STR (ao_strs_strtable+251)
+#define ONE_TAB_STR_LEN 1
+#define ONLY_OPTS_LOOP (ao_strs_strtable+4262)
+#define ONLY_OPTS_LOOP_LEN 102
+#define OPEN_CLOSE_FMT (ao_strs_strtable+226)
+#define OPEN_CLOSE_FMT_LEN 6
+#define OPEN_XML_FMT (ao_strs_strtable+253)
+#define OPEN_XML_FMT_LEN 4
+#define OPTION_STR (ao_strs_strtable+258)
+#define OPTION_STR_LEN 6
+#define OPT_ARG_FMT (ao_strs_strtable+4365)
+#define OPT_ARG_FMT_LEN 1153
+#define OPT_END_FMT (ao_strs_strtable+265)
+#define OPT_END_FMT_LEN 14
+#define OPT_VAL_FMT (ao_strs_strtable+280)
+#define OPT_VAL_FMT_LEN 6
+#define OR_STR (ao_strs_strtable+287)
+#define OR_STR_LEN 3
+#define PAGER_NAME (ao_strs_strtable+291)
+#define PAGER_NAME_LEN 5
+#define PAGE_USAGE_FMT (ao_strs_strtable+571)
+#define PAGE_USAGE_FMT (ao_strs_strtable+571)
+#define PAGE_USAGE_FMT_LEN 42
+#define PAGE_USAGE_FMT_LEN 42
+#define PAGE_USAGE_TEXT (ao_strs_strtable+5519)
+#define PAGE_USAGE_TEXT_LEN 73
+#define PLUS_STR (ao_strs_strtable+297)
+#define PLUS_STR_LEN 3
+#define PREAMBLE_FMT (ao_strs_strtable+5593)
+#define PREAMBLE_FMT_LEN 105
+#define QUOT_APOS (ao_strs_strtable+301)
+#define QUOT_APOS_LEN 2
+#define QUOT_ARG_FMT (ao_strs_strtable+304)
+#define QUOT_ARG_FMT_LEN 4
+#define SAVE_WARN (ao_strs_strtable+878)
+#define SAVE_WARN_LEN 35
+#define SET_MULTI_ARG (ao_strs_strtable+5699)
+#define SET_MULTI_ARG_LEN 89
+#define SET_NO_TEXT_FMT (ao_strs_strtable+914)
+#define SET_NO_TEXT_FMT_LEN 30
+#define SET_OFF_FMT (ao_strs_strtable+309)
+#define SET_OFF_FMT_LEN 6
+#define SET_TEXT_FMT (ao_strs_strtable+316)
+#define SET_TEXT_FMT_LEN 12
+#define SGL_ARG_FMT (ao_strs_strtable+5789)
+#define SGL_ARG_FMT_LEN 258
+#define SGL_DEF_FMT (ao_strs_strtable+6048)
+#define SGL_DEF_FMT_LEN 68
+#define SGL_NO_DEF_FMT (ao_strs_strtable+6117)
+#define SGL_NO_DEF_FMT_LEN 61
+#define SHELL_MAGIC (ao_strs_strtable+329)
+#define SHELL_MAGIC_LEN 6
+#define SHOW_PROG_ENV (ao_strs_strtable+336)
+#define SHOW_PROG_ENV_LEN 19
+#define SHOW_VAL_FMT (ao_strs_strtable+356)
+#define SHOW_VAL_FMT_LEN 17
+#define START_MARK (ao_strs_strtable+6179)
+#define START_MARK_LEN 82
+#define STDOUT (ao_strs_strtable+374)
+#define STDOUT_LEN 6
+#define TIME_FMT (ao_strs_strtable+381)
+#define TIME_FMT_LEN 21
+#define TMP_USAGE_FMT (ao_strs_strtable+403)
+#define TMP_USAGE_FMT_LEN 12
+#define TRUE_STR (ao_strs_strtable+416)
+#define TRUE_STR_LEN 4
+#define TWO_SPACES_STR (ao_strs_strtable+421)
+#define TWO_SPACES_STR_LEN 2
+#define TYPE_ATR_FMT (ao_strs_strtable+424)
+#define TYPE_ATR_FMT_LEN 12
+#define UNK_OPT_FMT (ao_strs_strtable+6262)
+#define UNK_OPT_FMT_LEN 144
+#define VER_STR (ao_strs_strtable+437)
+#define VER_STR_LEN 7
+#define XML_HEX_BYTE_FMT (ao_strs_strtable+445)
+#define XML_HEX_BYTE_FMT_LEN 7
+#define YES_NEED_OPT_ARG (ao_strs_strtable+453)
+#define YES_NEED_OPT_ARG_LEN 18
+#define apostrophy (ao_strs_strtable+472)
+#define apostrophy_LEN 4
+#define arg_fmt (ao_strs_strtable+477)
+#define arg_fmt_LEN 5
+#define init_optct (ao_strs_strtable+483)
+#define init_optct_LEN 13
+#define set_dash (ao_strs_strtable+497)
+#define set_dash_LEN 6
+#define zEquivMode (ao_strs_strtable+945)
+#define zEquivMode_LEN 44
+#define zFullOptFmt (ao_strs_strtable+990)
+#define zFullOptFmt_LEN 34
+#define zOptCookieCt (ao_strs_strtable+1025)
+#define zOptCookieCt_LEN 38
+#define zOptCtFmt (ao_strs_strtable+1064)
+#define zOptCtFmt_LEN 30
+#define zOptDisabl (ao_strs_strtable+1095)
+#define zOptDisabl_LEN 32
+#define zOptNumFmt (ao_strs_strtable+1128)
+#define zOptNumFmt_LEN 41
+#define zOptionCase (ao_strs_strtable+1170)
+#define zOptionCase_LEN 30
+#define zOptionEndSelect (ao_strs_strtable+504)
+#define zOptionEndSelect_LEN 16
+#define zOptionFlag (ao_strs_strtable+521)
+#define zOptionFlag_LEN 15
+#define zOptionFullName (ao_strs_strtable+537)
+#define zOptionFullName_LEN 15
+#define zOptionPartName (ao_strs_strtable+553)
+#define zOptionPartName_LEN 17
+extern char const ao_strs_strtable[6407];
#endif /* STRINGS_AO_STRS_H_GUARD */
/**
* \file autoopts.c
*
- * Time-stamp: "2012-03-04 19:44:56 bkorb"
- *
* This file contains all of the routines that must be linked into
* an executable to use the generated option processing. The optional
* routines are in separately compiled modules so that they will not
FILE * option_usage_fp = NULL;
-/* = = = START-STATIC-FORWARD = = = */
-static tSuccess
-next_opt_arg_must(tOptions * pOpts, tOptState* pOptState);
-
-static tSuccess
-next_opt_arg_may(tOptions * pOpts, tOptState * pOptState);
-
-static tSuccess
-next_opt_arg_none(tOptions * pOpts, tOptState* pOptState);
-
-static tSuccess
-next_opt(tOptions * pOpts, tOptState * pOptState);
-
-static tSuccess
-doPresets(tOptions * pOpts);
-/* = = = END-STATIC-FORWARD = = = */
-
LOCAL void *
ao_malloc(size_t sz)
{
return res;
}
#undef malloc
-#define malloc(_s) ao_malloc(_s)
+#define malloc(_s) ao_malloc(_s)
LOCAL void *
ao_realloc(void *p, size_t sz)
return res;
}
#undef realloc
-#define realloc(_p,_s) ao_realloc(_p,_s)
+#define realloc(_p,_s) ao_realloc(_p,_s)
LOCAL char *
ao_strdup(char const *str)
return res;
}
#undef strdup
-#define strdup(_p) ao_strdup(_p)
+#define strdup(_p) ao_strdup(_p)
#ifndef HAVE_PATHFIND
+# define pathfind(_p, _n, _m) option_pathfind(_p, _n, _m)
# include "compat/pathfind.c"
#endif
#ifndef HAVE_SNPRINTF
+# define vsnprintf option_vsnprintf
+# define snprintf option_snprintf
# include "compat/snprintf.c"
#endif
#ifndef HAVE_STRDUP
+# define strdup(_s) option_strdup(_s)
# include "compat/strdup.c"
#endif
#ifndef HAVE_STRCHR
+# define strrchr(_s, _c) option_strrchr(_s, _c)
+# define strchr(_s, _c) option_strchr(_s, _c)
# include "compat/strchr.c"
#endif
-/*
- * handle_opt
+/**
+ * handle an option.
*
* This routine handles equivalencing, sets the option state flags and
* invokes the handler procedure, if any.
*/
LOCAL tSuccess
-handle_opt(tOptions * pOpts, tOptState* pOptState)
+handle_opt(tOptions * pOpts, tOptState * o_st)
{
/*
* Save a copy of the option procedure pointer.
* If this is an equivalence class option, we still want this proc.
*/
- tOptDesc* pOD = pOptState->pOD;
+ tOptDesc* pOD = o_st->pOD;
tOptProc* pOP = pOD->pOptProc;
if (pOD->fOptState & OPTST_ALLOC_ARG)
AGFREE(pOD->optArg.argString);
- pOD->optArg.argString = pOptState->pzOptArg;
+ pOD->optArg.argString = o_st->pzOptArg;
/*
* IF we are presetting options, then we will ignore any un-presettable
*/
p->optActualValue = pOD->optValue;
p->optActualIndex = pOD->optIndex;
- pOptState->flags |= OPTST_EQUIVALENCE;
+ o_st->flags |= OPTST_EQUIVALENCE;
}
/*
}
pOD->fOptState &= OPTST_PERSISTENT_MASK;
- pOD->fOptState |= (pOptState->flags & ~OPTST_PERSISTENT_MASK);
+ pOD->fOptState |= (o_st->flags & ~OPTST_PERSISTENT_MASK);
/*
* Keep track of count only for DEFINED (command line) options.
return SUCCESS;
}
-static tSuccess
-next_opt_arg_must(tOptions * pOpts, tOptState* pOptState)
-{
- /*
- * An option argument is required. Long options can either have
- * a separate command line argument, or an argument attached by
- * the '=' character. Figure out which.
- */
- switch (pOptState->optType) {
- case TOPT_SHORT:
- /*
- * See if an arg string follows the flag character
- */
- if (*++(pOpts->pzCurOpt) == NUL)
- pOpts->pzCurOpt = pOpts->origArgVect[ pOpts->curOptIdx++ ];
- pOptState->pzOptArg = pOpts->pzCurOpt;
- break;
-
- case TOPT_LONG:
- /*
- * See if an arg string has already been assigned (glued on
- * with an `=' character)
- */
- if (pOptState->pzOptArg == NULL)
- pOptState->pzOptArg = pOpts->origArgVect[ pOpts->curOptIdx++ ];
- break;
-
- default:
-#ifdef DEBUG
- fputs("AutoOpts lib error: option type not selected\n", stderr);
- exit(EXIT_FAILURE);
-#endif
-
- case TOPT_DEFAULT:
- /*
- * The option was selected by default. The current token is
- * the option argument.
- */
- break;
- }
-
- /*
- * Make sure we did not overflow the argument list.
- */
- if (pOpts->curOptIdx > pOpts->origArgCt) {
- fprintf(stderr, zMisArg, pOpts->pzProgPath, pOptState->pOD->pz_Name);
- return FAILURE;
- }
-
- pOpts->pzCurOpt = NULL; /* next time advance to next arg */
- return SUCCESS;
-}
-
-/**
- * Process an optional option argument. For short options, it looks at the
- * character after the option character, or it consumes the next full argument.
- * For long options, it looks for an '=' character attachment to the long
- * option name before deciding to take the next command line argument.
- *
- * @param pOpts the option descriptor
- * @param pOptState a structure for managing the current processing state
- * @returns SUCCESS or does not return
- */
-static tSuccess
-next_opt_arg_may(tOptions * pOpts, tOptState * pOptState)
-{
- /*
- * An option argument is optional.
- */
- switch (pOptState->optType) {
- case TOPT_SHORT:
- if (*++pOpts->pzCurOpt != NUL)
- pOptState->pzOptArg = pOpts->pzCurOpt;
- else {
- char* pzLA = pOpts->origArgVect[ pOpts->curOptIdx ];
-
- /*
- * BECAUSE it is optional, we must make sure
- * we did not find another flag and that there
- * is such an argument.
- */
- if ((pzLA == NULL) || (*pzLA == '-'))
- pOptState->pzOptArg = NULL;
- else {
- pOpts->curOptIdx++; /* argument found */
- pOptState->pzOptArg = pzLA;
- }
- }
- break;
-
- case TOPT_LONG:
- /*
- * Look for an argument if we don't already have one (glued on
- * with a `=' character) *AND* we are not in named argument mode
- */
- if ( (pOptState->pzOptArg == NULL)
- && (! NAMED_OPTS(pOpts))) {
- char* pzLA = pOpts->origArgVect[ pOpts->curOptIdx ];
-
- /*
- * BECAUSE it is optional, we must make sure
- * we did not find another flag and that there
- * is such an argument.
- */
- if ((pzLA == NULL) || (*pzLA == '-'))
- pOptState->pzOptArg = NULL;
- else {
- pOpts->curOptIdx++; /* argument found */
- pOptState->pzOptArg = pzLA;
- }
- }
- break;
-
- default:
- case TOPT_DEFAULT:
- fputs(zAO_Woops, stderr );
- exit(EX_SOFTWARE);
- }
-
- /*
- * After an option with an optional argument, we will
- * *always* start with the next option because if there
- * were any characters following the option name/flag,
- * they would be interpreted as the argument.
- */
- pOpts->pzCurOpt = NULL;
- return SUCCESS;
-}
-
-
-static tSuccess
-next_opt_arg_none(tOptions * pOpts, tOptState* pOptState)
-{
- /*
- * No option argument. Make sure next time around we find
- * the correct option flag character for short options
- */
- if (pOptState->optType == TOPT_SHORT)
- (pOpts->pzCurOpt)++;
-
- /*
- * It is a long option. Make sure there was no ``=xxx'' argument
- */
- else if (pOptState->pzOptArg != NULL) {
- fprintf(stderr, zNoArg, pOpts->pzProgPath, pOptState->pOD->pz_Name);
- return FAILURE;
- }
-
- /*
- * It is a long option. Advance to next command line argument.
- */
- else
- pOpts->pzCurOpt = NULL;
- return SUCCESS;
-}
-
/**
* Find the option descriptor and option argument (if any) for the
* next command line argument. DO NOT modify the descriptor. Put
* all the state in the state argument so that the option can be skipped
* without consequence (side effect).
*
- * @param pOpts the program option descriptor
- * @param pOptState the state of the next found option
+ * @param opts the program option descriptor
+ * @param o_st the state of the next found option
*/
-static tSuccess
-next_opt(tOptions * pOpts, tOptState * pOptState)
+LOCAL tSuccess
+next_opt(tOptions * opts, tOptState * o_st)
{
{
- tSuccess res = find_opt(pOpts, pOptState);
+ tSuccess res = find_opt(opts, o_st);
if (! SUCCESSFUL(res))
return res;
}
- if ( ((pOptState->flags & OPTST_DEFINED) != 0)
- && ((pOptState->pOD->fOptState & OPTST_NO_COMMAND) != 0)) {
- fprintf(stderr, zNotCmdOpt, pOptState->pOD->pz_Name);
+ if ( ((o_st->flags & OPTST_DEFINED) != 0)
+ && ((o_st->pOD->fOptState & OPTST_NO_COMMAND) != 0)) {
+ fprintf(stderr, zNotCmdOpt, o_st->pOD->pz_Name);
return FAILURE;
}
- return get_opt_arg(pOpts, pOptState);
-}
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *
- * DO PRESETS
- *
- * The next several routines do the immediate action pass on the command
- * line options, then the environment variables, then the config files in
- * reverse order. Once done with that, the order is reversed and all
- * the config files and environment variables are processed again, this
- * time only processing the non-immediate action options. doPresets()
- * will then return for optionProcess() to do the final pass on the command
- * line arguments.
- */
-
-/**
- * scan the command line for immediate action options.
- * This is only called the first time through.
- * While this procedure is active, the OPTPROC_IMMEDIATE is true.
- *
- * @param pOpts program options descriptor
- * @returns SUCCESS or FAILURE
- */
-LOCAL tSuccess
-immediate_opts(tOptions * pOpts)
-{
- tSuccess res;
-
- pOpts->fOptSet |= OPTPROC_IMMEDIATE;
- pOpts->curOptIdx = 1; /* start by skipping program name */
- pOpts->pzCurOpt = NULL;
-
- /*
- * Examine all the options from the start. We process any options that
- * are marked for immediate processing.
- */
- for (;;) {
- tOptState opt_st = OPTSTATE_INITIALIZER(PRESET);
-
- res = next_opt(pOpts, &opt_st);
- switch (res) {
- case FAILURE: goto failed_option;
- case PROBLEM: res = SUCCESS; goto leave;
- case SUCCESS: break;
- }
-
- /*
- * IF this is an immediate-attribute option, then do it.
- */
- if (! DO_IMMEDIATELY(opt_st.flags))
- continue;
-
- if (! SUCCESSFUL(handle_opt(pOpts, &opt_st)))
- break;
- } failed_option:;
-
- if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0)
- (*pOpts->pUsageProc)(pOpts, EXIT_FAILURE);
-
-leave:
-
- pOpts->fOptSet &= ~OPTPROC_IMMEDIATE;
- return res;
+ return get_opt_arg(opts, o_st);
}
/**
* require it.) Thus, do not rewind option indexes because some programs
* choose to re-invoke after a non-option.
*
- * @param pOpts program options descriptor
+ * @param[in,out] opts program options descriptor
* @returns SUCCESS or FAILURE
*/
LOCAL tSuccess
-regular_opts(tOptions * pOpts)
+regular_opts(tOptions * opts)
{
- /* assert: pOpts->fOptSet & OPTPROC_IMMEDIATE == 0 */
+ /* assert: opts->fOptSet & OPTPROC_IMMEDIATE == 0 */
for (;;) {
tOptState opt_st = OPTSTATE_INITIALIZER(DEFINED);
- switch (next_opt(pOpts, &opt_st)) {
+ switch (next_opt(opts, &opt_st)) {
case FAILURE: goto failed_option;
case PROBLEM: return SUCCESS; /* no more args */
case SUCCESS: break;
opt_st.pOD->optOccCt--; /* don't count this repetition */
}
- if (! SUCCESSFUL(handle_opt(pOpts, &opt_st)))
+ if (! SUCCESSFUL(handle_opt(opts, &opt_st)))
break;
} failed_option:;
- if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0)
- (*pOpts->pUsageProc)(pOpts, EXIT_FAILURE);
+ if ((opts->fOptSet & OPTPROC_ERRSTOP) != 0)
+ (*opts->pUsageProc)(opts, EXIT_FAILURE);
return FAILURE;
}
-
-/**
- * check for preset values from a config files or envrionment variables
- */
-static tSuccess
-doPresets(tOptions * pOpts)
-{
- tOptDesc * pOD = NULL;
-
- if (! SUCCESSFUL(immediate_opts(pOpts)))
- return FAILURE;
-
- /*
- * IF this option set has a --save-opts option, then it also
- * has a --load-opts option. See if a command line option has disabled
- * option presetting.
- */
- if ( (pOpts->specOptIdx.save_opts != NO_EQUIVALENT)
- && (pOpts->specOptIdx.save_opts != 0)) {
- pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts + 1;
- if (DISABLED_OPT(pOD))
- return SUCCESS;
- }
-
- /*
- * Until we return from this procedure, disable non-presettable opts
- */
- pOpts->fOptSet |= OPTPROC_PRESETTING;
- /*
- * IF there are no config files,
- * THEN do any environment presets and leave.
- */
- if (pOpts->papzHomeList == NULL) {
- env_presets(pOpts, ENV_ALL);
- }
- else {
- env_presets(pOpts, ENV_IMM);
-
- /*
- * Check to see if environment variables have disabled presetting.
- */
- if ((pOD != NULL) && ! DISABLED_OPT(pOD))
- intern_file_load(pOpts);
-
- /*
- * ${PROGRAM_LOAD_OPTS} value of "no" cannot disable other environment
- * variable options. Only the loading of .rc files.
- */
- env_presets(pOpts, ENV_NON_IMM);
- }
- pOpts->fOptSet &= ~OPTPROC_PRESETTING;
-
- return SUCCESS;
-}
-
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* THESE ROUTINES ARE CALLABLE FROM THE GENERATED OPTION PROCESSING CODE
*
* what: this is the main option processing routine
*
- * arg: + tOptions* + pOpts + program options descriptor +
- * arg: + int + argc + program arg count +
- * arg: + char** + argv + program arg vector +
+ * arg: + tOptions* + opts + program options descriptor +
+ * arg: + int + a_ct + program arg count +
+ * arg: + char** + a_v + program arg vector +
*
* ret_type: int
* ret_desc: the count of the arguments processed
* ERRSKIP_OPTERR or ERRSTOP_OPTERR macros were invoked.
=*/
int
-optionProcess(tOptions * pOpts, int argCt, char ** argVect)
+optionProcess(tOptions * opts, int a_ct, char ** a_v)
{
- if (! SUCCESSFUL(validate_struct(pOpts, argVect[0])))
+ if (! SUCCESSFUL(validate_struct(opts, a_v[0])))
exit(EX_SOFTWARE);
/*
* Establish the real program name, the program full path,
* and do all the presetting the first time thru only.
*/
- if ((pOpts->fOptSet & OPTPROC_INITDONE) == 0) {
- pOpts->origArgCt = (unsigned int)argCt;
- pOpts->origArgVect = argVect;
- pOpts->fOptSet |= OPTPROC_INITDONE;
- if (HAS_pzPkgDataDir(pOpts))
- program_pkgdatadir = pOpts->pzPkgDataDir;
-
- if (! SUCCESSFUL(doPresets(pOpts)))
- return 0;
-
- /*
- * IF option name conversion was suppressed but it is not suppressed
- * for the command line, then it's time to translate option names.
- * Usage text will not get retranslated.
- */
- if ( ((pOpts->fOptSet & OPTPROC_TRANSLATE) != 0)
- && (pOpts->pTransProc != NULL)
- && ((pOpts->fOptSet & OPTPROC_NO_XLAT_MASK)
- == OPTPROC_NXLAT_OPT_CFG) ) {
-
- pOpts->fOptSet &= ~OPTPROC_NXLAT_OPT_CFG;
- (*pOpts->pTransProc)();
- }
-
- if ((pOpts->fOptSet & OPTPROC_REORDER) != 0)
- optionSort(pOpts);
-
- pOpts->curOptIdx = 1;
- pOpts->pzCurOpt = NULL;
- }
+ if (! ao_initialize(opts, a_ct, a_v))
+ return 0;
/*
* IF we are (re)starting,
* THEN reset option location
*/
- else if (pOpts->curOptIdx <= 0) {
- pOpts->curOptIdx = 1;
- pOpts->pzCurOpt = NULL;
+ if (opts->curOptIdx <= 0) {
+ opts->curOptIdx = 1;
+ opts->pzCurOpt = NULL;
}
- if (! SUCCESSFUL(regular_opts(pOpts)))
- return pOpts->origArgCt;
+ if (! SUCCESSFUL(regular_opts(opts)))
+ return (int)opts->origArgCt;
/*
* IF there were no errors
* THEN do that now before testing for conflicts.
* (conflicts are ignored in preset options)
*/
- if ( (pOpts->specOptIdx.save_opts != NO_EQUIVALENT)
- && (pOpts->specOptIdx.save_opts != 0)) {
- tOptDesc* pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts;
+ switch (opts->specOptIdx.save_opts) {
+ case 0:
+ case NO_EQUIVALENT:
+ break;
+ default:
+ {
+ tOptDesc * od = opts->pOptDesc + opts->specOptIdx.save_opts;
- if (SELECTED_OPT(pOD)) {
- optionSaveFile(pOpts);
+ if (SELECTED_OPT(od)) {
+ optionSaveFile(opts);
exit(EXIT_SUCCESS);
}
}
+ }
/*
* IF we are checking for errors,
* THEN look for too few occurrences of required options
*/
- if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0) {
- if (! is_consistent(pOpts))
- (*pOpts->pUsageProc)(pOpts, EXIT_FAILURE);
- }
+ if (((opts->fOptSet & OPTPROC_ERRSTOP) != 0)
+ && (! is_consistent(opts)))
+ (*opts->pUsageProc)(opts, EXIT_FAILURE);
- return pOpts->curOptIdx;
+ return (int)opts->curOptIdx;
}
/*
/*
* \file autoopts.h
*
- * Time-stamp: "2012-03-04 19:05:01 bkorb"
- *
* This file defines all the global structures and special values
* used in the automated option processing library.
*
# define DIRCH '/'
#endif
-#define AO_EXIT_REQ_USAGE 64
+#ifndef EX_USAGE
+ /**
+ * Command line usage problem
+ */
+# define EX_USAGE 64
+#endif
+#ifndef EX_DATAERR
+ /**
+ * The input data was incorrect in some way.
+ */
+# define EX_DATAERR 64
+#endif
#ifndef EX_NOINPUT
/**
* option state was requested from a file that cannot be loaded.
*/
# define EX_SOFTWARE 70
#endif
+#ifndef EX_OSERR
+ /**
+ * Command line usage problem
+ */
+# define EX_OSERR 71
+#endif
#define NL '\n'
+#ifndef C
+/**
+ * Coercive cast. Compel an address to be interpreted as the type
+ * of the first argument. No complaints, just do it.
+ */
+#define C(_t,_p) ((_t)(void *)(_p))
+#endif
+
+/* The __attribute__((__warn_unused_result__)) feature
+ is available in gcc versions 3.4 and newer,
+ while the typeof feature has been available since 2.7 at least. */
+# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4)
+# define ignore_val(x) ((void) (x))
+# else
+# define ignore_val(x) (({ __typeof__ (x) __x = (x); (void) __x; }))
+# endif
/*
* Convert the number to a list usable in a printf call
} teOptType;
typedef struct {
- tOptDesc* pOD;
- tCC* pzOptArg;
- tAoUL flags;
- teOptType optType;
+ tOptDesc * pOD;
+ char const * pzOptArg;
+ opt_state_mask_t flags;
+ teOptType optType;
} tOptState;
#define OPTSTATE_INITIALIZER(st) \
{ NULL, NULL, OPTST_ ## st, TOPT_UNDEFINED }
*
* DO NOT EDIT THIS FILE (options.h)
*
- * It has been AutoGen-ed August 11, 2012 at 09:41:18 AM by AutoGen 5.16.2pre7
+ * It has been AutoGen-ed December 27, 2012 at 12:59:05 PM by AutoGen 5.17.0pre12
* From the definitions funcs.def
* and the template file options_h
*
* was requested. It is used to distinguish a --usage from a --help request.
* --usage is abbreviated and --help gives as much help as possible.
*/
-#define AO_EXIT_REQ_USAGE 64
+#define AO_EXIT_REQ_USAGE 10064
/*
* PUBLIC DEFINES
* See the relevant generated header file to determine which and what
* values for "opt_name" are available.
*/
-#define OPTIONS_STRUCT_VERSION 147461
-#define OPTIONS_VERSION_STRING "36:5:11"
+#define OPTIONS_STRUCT_VERSION 151552
+#define OPTIONS_VERSION_STRING "37:0:12"
#define OPTIONS_MINIMUM_VERSION 102400
#define OPTIONS_MIN_VER_STRING "25:0:0"
#define OPTIONS_VER_TO_NUM(_v, _r) (((_v) * 4096) + (_r))
-
+
typedef enum {
OPARG_TYPE_NONE = 0,
OPARG_TYPE_STRING = 1, /* default type/ vanilla string */
/*
* Bits in the fOptState option descriptor field.
*/
-typedef enum {
- OPTST_SET_ID = 0, /* Set via the "SET_OPT()" macro */
- OPTST_PRESET_ID = 1, /* Set via an RC/INI file */
- OPTST_DEFINED_ID = 2, /* Set via a command line option */
- OPTST_RESET_ID = 3, /* Reset via command line option */
- OPTST_EQUIVALENCE_ID = 4, /* selected by equiv'ed option */
- OPTST_DISABLED_ID = 5, /* option is in disabled state */
- OPTST_ALLOC_ARG_ID = 6, /* pzOptArg was allocated */
- OPTST_NO_INIT_ID = 8, /* option cannot be preset */
- OPTST_NUMBER_OPT_ID = 9, /* opt value (flag) is any digit */
- OPTST_STACKED_ID = 10, /* opt uses optionStackArg proc */
- OPTST_INITENABLED_ID = 11, /* option defaults to enabled */
- OPTST_ARG_TYPE_1_ID = 12, /* bit 1 of arg type enum */
- OPTST_ARG_TYPE_2_ID = 13, /* bit 2 of arg type enum */
- OPTST_ARG_TYPE_3_ID = 14, /* bit 3 of arg type enum */
- OPTST_ARG_TYPE_4_ID = 15, /* bit 4 of arg type enum */
- OPTST_ARG_OPTIONAL_ID = 16, /* the option arg not required */
- OPTST_IMM_ID = 17, /* process opt on first pass */
- OPTST_DISABLE_IMM_ID = 18, /* process disablement immed. */
- OPTST_OMITTED_ID = 19, /* compiled out of program */
- OPTST_MUST_SET_ID = 20, /* must be set or pre-set */
- OPTST_DOCUMENT_ID = 21, /* opt is for doc only */
- OPTST_TWICE_ID = 22, /* process opt twice - imm + reg */
- OPTST_DISABLE_TWICE_ID = 23, /* process disabled option twice */
- OPTST_SCALED_NUM_ID = 24, /* scaled integer value */
- OPTST_NO_COMMAND_ID = 25, /* disable from cmd line */
- OPTST_DEPRECATED_ID = 26, /* support is being removed */
- OPTST_ALIAS_ID = 27 /* alias for other option */
-} opt_state_enum_t;
-
-#define OPTST_INIT 0U
-#define OPTST_SET (1U << OPTST_SET_ID)
-#define OPTST_PRESET (1U << OPTST_PRESET_ID)
-#define OPTST_DEFINED (1U << OPTST_DEFINED_ID)
-#define OPTST_RESET (1U << OPTST_RESET_ID)
-#define OPTST_EQUIVALENCE (1U << OPTST_EQUIVALENCE_ID)
-#define OPTST_DISABLED (1U << OPTST_DISABLED_ID)
-#define OPTST_ALLOC_ARG (1U << OPTST_ALLOC_ARG_ID)
-#define OPTST_NO_INIT (1U << OPTST_NO_INIT_ID)
-#define OPTST_NUMBER_OPT (1U << OPTST_NUMBER_OPT_ID)
-#define OPTST_STACKED (1U << OPTST_STACKED_ID)
-#define OPTST_INITENABLED (1U << OPTST_INITENABLED_ID)
-#define OPTST_ARG_TYPE_1 (1U << OPTST_ARG_TYPE_1_ID)
-#define OPTST_ARG_TYPE_2 (1U << OPTST_ARG_TYPE_2_ID)
-#define OPTST_ARG_TYPE_3 (1U << OPTST_ARG_TYPE_3_ID)
-#define OPTST_ARG_TYPE_4 (1U << OPTST_ARG_TYPE_4_ID)
-#define OPTST_ARG_OPTIONAL (1U << OPTST_ARG_OPTIONAL_ID)
-#define OPTST_IMM (1U << OPTST_IMM_ID)
-#define OPTST_DISABLE_IMM (1U << OPTST_DISABLE_IMM_ID)
-#define OPTST_OMITTED (1U << OPTST_OMITTED_ID)
-#define OPTST_MUST_SET (1U << OPTST_MUST_SET_ID)
-#define OPTST_DOCUMENT (1U << OPTST_DOCUMENT_ID)
-#define OPTST_TWICE (1U << OPTST_TWICE_ID)
-#define OPTST_DISABLE_TWICE (1U << OPTST_DISABLE_TWICE_ID)
-#define OPTST_SCALED_NUM (1U << OPTST_SCALED_NUM_ID)
-#define OPTST_NO_COMMAND (1U << OPTST_NO_COMMAND_ID)
-#define OPTST_DEPRECATED (1U << OPTST_DEPRECATED_ID)
-#define OPTST_ALIAS (1U << OPTST_ALIAS_ID)
-#define OPT_STATE_MASK 0x0FFFFF7FU
-
-#define OPTST_SET_MASK ( \
- OPTST_DEFINED | OPTST_PRESET | OPTST_RESET | \
- OPTST_SET \
- /* 0x0000000FU */ )
-
-#define OPTST_MUTABLE_MASK ( \
- OPTST_ALLOC_ARG | OPTST_DEFINED | \
- OPTST_DISABLED | OPTST_EQUIVALENCE | \
- OPTST_PRESET | OPTST_RESET | \
- OPTST_SET \
- /* 0x0000007FU */ )
-
-#define OPTST_SELECTED_MASK ( \
- OPTST_DEFINED | OPTST_SET \
- /* 0x00000005U */ )
-
-#define OPTST_ARG_TYPE_MASK ( \
- OPTST_ARG_TYPE_1 | OPTST_ARG_TYPE_2 | OPTST_ARG_TYPE_3 | \
- OPTST_ARG_TYPE_4 \
- /* 0x0000F000U */ )
-
-#define OPTST_NO_USAGE_MASK ( \
- OPTST_DEPRECATED | OPTST_NO_COMMAND | OPTST_OMITTED \
- /* 0x06080000U */ )
-
-#define OPTST_IMMUTABLE_MASK ( \
- OPTST_DOCUMENT | OPTST_OMITTED \
- /* 0x00280000U */ )
-
-#define OPTST_DO_NOT_SAVE_MASK ( \
- OPTST_DOCUMENT | OPTST_NO_INIT | OPTST_OMITTED \
- /* 0x00280100U */ )
-
-#define OPTST_NO_OUTPUT_MASK ( \
- OPTST_ALIAS | OPTST_DOCUMENT | OPTST_OMITTED \
- /* 0x08280000U */ )
+
+/** integral type for holding opt_state masks */
+typedef uint32_t opt_state_mask_t;
+
+#define OPTST_ARG_TYPE_SHIFT 12
+/** bits defined for opt_state_mask_t */
+#define OPTST_SET 0x0000001U
+#define OPTST_PRESET 0x0000002U
+#define OPTST_DEFINED 0x0000004U
+#define OPTST_RESET 0x0000008U
+#define OPTST_EQUIVALENCE 0x0000010U
+#define OPTST_DISABLED 0x0000020U
+#define OPTST_ALLOC_ARG 0x0000040U
+#define OPTST_NO_INIT 0x0000100U
+#define OPTST_NUMBER_OPT 0x0000200U
+#define OPTST_STACKED 0x0000400U
+#define OPTST_INITENABLED 0x0000800U
+#define OPTST_ARG_TYPE_1 0x0001000U
+#define OPTST_ARG_TYPE_2 0x0002000U
+#define OPTST_ARG_TYPE_3 0x0004000U
+#define OPTST_ARG_TYPE_4 0x0008000U
+#define OPTST_ARG_OPTIONAL 0x0010000U
+#define OPTST_IMM 0x0020000U
+#define OPTST_DISABLE_IMM 0x0040000U
+#define OPTST_OMITTED 0x0080000U
+#define OPTST_MUST_SET 0x0100000U
+#define OPTST_DOCUMENT 0x0200000U
+#define OPTST_TWICE 0x0400000U
+#define OPTST_DISABLE_TWICE 0x0800000U
+#define OPTST_SCALED_NUM 0x1000000U
+#define OPTST_NO_COMMAND 0x2000000U
+#define OPTST_DEPRECATED 0x4000000U
+#define OPTST_ALIAS 0x8000000U
+
+/** bits in SET mask:
+ * set preset reset defined */
+#define OPTST_SET_MASK 0x000000FU
+
+/** bits in MUTABLE mask:
+ * set preset reset defined equivalence disabled
+ * alloc_arg */
+#define OPTST_MUTABLE_MASK 0x000007FU
+
+/** bits omitted from PERSISTENT mask:
+ * mutable_mask */
+#define OPTST_PERSISTENT_MASK 0xFFFFF00U
+
+/** bits in SELECTED mask:
+ * set defined */
+#define OPTST_SELECTED_MASK 0x0000005U
+
+/** bits in ARG_TYPE mask:
+ * arg_type_1 arg_type_2 arg_type_3 arg_type_4 */
+#define OPTST_ARG_TYPE_MASK 0x000F000U
+
+/** bits in NO_USAGE mask:
+ * omitted no_command deprecated */
+#define OPTST_NO_USAGE_MASK 0x6080000U
+
+/** bits in IMMUTABLE mask:
+ * document omitted */
+#define OPTST_IMMUTABLE_MASK 0x0280000U
+
+/** bits in DO_NOT_SAVE mask:
+ * document omitted no_init */
+#define OPTST_DO_NOT_SAVE_MASK 0x0280100U
+
+/** bits in NO_OUTPUT mask:
+ * document omitted alias */
+#define OPTST_NO_OUTPUT_MASK 0x8280000U
+
+/** all bits in opt_state_mask_t masks */
+#define OPTST_MASK_ALL 0xFFFFF7FU
+
+/** no bits in opt_state_mask_t */
+#define OPTST_INIT 0x0000000U
#ifdef NO_OPTIONAL_OPT_ARGS
# undef OPTST_ARG_OPTIONAL
#define VENDOR_OPTION_VALUE 'W'
-#define OPTST_PERSISTENT_MASK (~OPTST_MUTABLE_MASK)
-
#define SELECTED_OPT(_od) ((_od)->fOptState & OPTST_SELECTED_MASK)
#define UNUSED_OPT( _od) (((_od)->fOptState & OPTST_SET_MASK) == 0)
#define DISABLED_OPT(_od) ((_od)->fOptState & OPTST_DISABLED)
#define OPTION_STATE(_od) ((_od)->fOptState)
-#define OPTST_SET_ARGTYPE(_n) ((_n) << OPTST_ARG_TYPE_1_ID)
-#define OPTST_GET_ARGTYPE(_f) (((_f)&OPTST_ARG_TYPE_MASK)>>OPTST_ARG_TYPE_1_ID)
+#define OPTST_SET_ARGTYPE(_n) ((_n) << OPTST_ARG_TYPE_SHIFT)
+#define OPTST_GET_ARGTYPE(_f) \
+ (((_f)&OPTST_ARG_TYPE_MASK) >> OPTST_ARG_TYPE_SHIFT)
-/*
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
* PRIVATE INTERFACES
*
* The following values are used in the generated code to communicate
/*
* Define the processing state flags
*/
-typedef enum {
- OPTPROC_LONGOPT_ID = 0, /* Process long style options */
- OPTPROC_SHORTOPT_ID = 1, /* Process short style "flags" */
- OPTPROC_ERRSTOP_ID = 2, /* Stop on argument errors */
- OPTPROC_DISABLEDOPT_ID = 3, /* Current option is disabled */
- OPTPROC_NO_REQ_OPT_ID = 4, /* no options are required */
- OPTPROC_NUM_OPT_ID = 5, /* there is a number option */
- OPTPROC_INITDONE_ID = 6, /* have inits been done? */
- OPTPROC_NEGATIONS_ID = 7, /* any negation options? */
- OPTPROC_ENVIRON_ID = 8, /* check environment? */
- OPTPROC_NO_ARGS_ID = 9, /* Disallow remaining arguments */
- OPTPROC_ARGS_REQ_ID = 10, /* Require args after options */
- OPTPROC_REORDER_ID = 11, /* reorder operands after opts */
- OPTPROC_GNUUSAGE_ID = 12, /* emit usage in GNU style */
- OPTPROC_TRANSLATE_ID = 13, /* Translate strings in tOptions */
- OPTPROC_MISUSE_ID = 14, /* no usage on usage error */
- OPTPROC_IMMEDIATE_ID = 15, /* immediate options active */
- OPTPROC_NXLAT_OPT_CFG_ID = 16, /* suppress for config only */
- OPTPROC_NXLAT_OPT_ID = 17, /* suppress xlation always */
- OPTPROC_VENDOR_OPT_ID = 18, /* vendor options active */
- OPTPROC_PRESETTING_ID = 19 /* opt processing in preset state */
-} optproc_state_enum_t;
-
-#define OPTPROC_NONE 0U
-#define OPTPROC_LONGOPT (1U << OPTPROC_LONGOPT_ID)
-#define OPTPROC_SHORTOPT (1U << OPTPROC_SHORTOPT_ID)
-#define OPTPROC_ERRSTOP (1U << OPTPROC_ERRSTOP_ID)
-#define OPTPROC_DISABLEDOPT (1U << OPTPROC_DISABLEDOPT_ID)
-#define OPTPROC_NO_REQ_OPT (1U << OPTPROC_NO_REQ_OPT_ID)
-#define OPTPROC_NUM_OPT (1U << OPTPROC_NUM_OPT_ID)
-#define OPTPROC_INITDONE (1U << OPTPROC_INITDONE_ID)
-#define OPTPROC_NEGATIONS (1U << OPTPROC_NEGATIONS_ID)
-#define OPTPROC_ENVIRON (1U << OPTPROC_ENVIRON_ID)
-#define OPTPROC_NO_ARGS (1U << OPTPROC_NO_ARGS_ID)
-#define OPTPROC_ARGS_REQ (1U << OPTPROC_ARGS_REQ_ID)
-#define OPTPROC_REORDER (1U << OPTPROC_REORDER_ID)
-#define OPTPROC_GNUUSAGE (1U << OPTPROC_GNUUSAGE_ID)
-#define OPTPROC_TRANSLATE (1U << OPTPROC_TRANSLATE_ID)
-#define OPTPROC_MISUSE (1U << OPTPROC_MISUSE_ID)
-#define OPTPROC_IMMEDIATE (1U << OPTPROC_IMMEDIATE_ID)
-#define OPTPROC_NXLAT_OPT_CFG (1U << OPTPROC_NXLAT_OPT_CFG_ID)
-#define OPTPROC_NXLAT_OPT (1U << OPTPROC_NXLAT_OPT_ID)
-#define OPTPROC_VENDOR_OPT (1U << OPTPROC_VENDOR_OPT_ID)
-#define OPTPROC_PRESETTING (1U << OPTPROC_PRESETTING_ID)
-#define OPTPROC_STATE_MASK 0x000FFFFFU
-
-#define OPTPROC_NO_XLAT_MASK ( \
- OPTPROC_NXLAT_OPT | OPTPROC_NXLAT_OPT_CFG \
- /* 0x00030000U */ )
+
+/** integral type for holding proc_state masks */
+typedef uint32_t proc_state_mask_t;
+
+/** bits defined for proc_state_mask_t */
+#define OPTPROC_LONGOPT 0x00001U
+#define OPTPROC_SHORTOPT 0x00002U
+#define OPTPROC_ERRSTOP 0x00004U
+#define OPTPROC_DISABLEDOPT 0x00008U
+#define OPTPROC_NO_REQ_OPT 0x00010U
+#define OPTPROC_NUM_OPT 0x00020U
+#define OPTPROC_INITDONE 0x00040U
+#define OPTPROC_NEGATIONS 0x00080U
+#define OPTPROC_ENVIRON 0x00100U
+#define OPTPROC_NO_ARGS 0x00200U
+#define OPTPROC_ARGS_REQ 0x00400U
+#define OPTPROC_REORDER 0x00800U
+#define OPTPROC_GNUUSAGE 0x01000U
+#define OPTPROC_TRANSLATE 0x02000U
+#define OPTPROC_MISUSE 0x04000U
+#define OPTPROC_IMMEDIATE 0x08000U
+#define OPTPROC_NXLAT_OPT_CFG 0x10000U
+#define OPTPROC_NXLAT_OPT 0x20000U
+#define OPTPROC_VENDOR_OPT 0x40000U
+#define OPTPROC_PRESETTING 0x80000U
+
+/** bits in NO_XLAT mask:
+ * nxlat_opt_cfg nxlat_opt */
+#define OPTPROC_NO_XLAT_MASK 0x30000U
+
+/** all bits in proc_state_mask_t masks */
+#define OPTPROC_MASK_ALL 0xFFFFFU
+
+/** no bits in proc_state_mask_t */
+#define OPTPROC_NONE 0x00000U
#define STMTS(s) do { s; } while (false)
/*
* The following must be #defined instead of typedef-ed
- * because "static const" cannot both be applied to a type,
+ * because "char const" cannot both be applied to a type,
* tho each individually can...so they all are
*/
-#define tSCC static char const
#define tCC char const
-#define tAoSC static char
-#define tAoUC unsigned char
-#define tAoUI unsigned int
-#define tAoUL unsigned long
-#define tAoUS unsigned short
-
-/*
- * It is so disgusting that there must be so many ways
- * of specifying TRUE and FALSE.
- */
-typedef enum { AG_FALSE = 0, AG_TRUE } ag_bool;
/*
* Define a structure that describes each option and
* The option procedures do the special processing for each
* option flag that needs it.
*/
-typedef void (tOptProc)(tOptions* pOpts, tOptDesc* pOptDesc);
-typedef tOptProc* tpOptProc;
+typedef void (tOptProc)(tOptions * pOpts, tOptDesc * pOptDesc);
+typedef tOptProc * tpOptProc;
/*
* The usage procedure will never return. It calls "exit(2)"
unsigned int argBool;
FILE * argFp;
int argFd;
-} optArgBucket_t;
+} opt_arg_union_t;
-#define pzLastArg optArg.argString
+#define pzLastArg optArg.argString
+#define optArgBucket_t opt_arg_union_t
/*
* Descriptor structure for each option.
* Only the fields marked "PUBLIC" are for public use.
*/
struct optDesc {
- tAoUS const optIndex; /* PUBLIC */
- tAoUS const optValue; /* PUBLIC */
- tAoUS optActualIndex; /* PUBLIC */
- tAoUS optActualValue; /* PUBLIC */
-
- tAoUS const optEquivIndex; /* PUBLIC */
- tAoUS const optMinCt;
- tAoUS const optMaxCt;
- tAoUS optOccCt; /* PUBLIC */
-
- tAoUI fOptState; /* PUBLIC */
- tAoUI reserved;
- optArgBucket_t optArg; /* PUBLIC */
- void* optCookie; /* PUBLIC */
-
- int const * const pOptMust;
- int const * const pOptCant;
- tpOptProc const pOptProc;
- char const* const pzText;
-
- char const* const pz_NAME;
- char const* const pz_Name;
- char const* const pz_DisableName;
- char const* const pz_DisablePfx;
+ unsigned short const optIndex; /* PUBLIC */
+ unsigned short const optValue; /* PUBLIC */
+ unsigned short optActualIndex; /* PUBLIC */
+ unsigned short optActualValue; /* PUBLIC */
+
+ unsigned short const optEquivIndex; /* PUBLIC */
+ unsigned short const optMinCt;
+ unsigned short const optMaxCt;
+ unsigned short optOccCt; /* PUBLIC */
+
+ opt_state_mask_t fOptState; /* PUBLIC */
+ unsigned int reserved;
+ opt_arg_union_t optArg; /* PUBLIC */
+ void * optCookie; /* PUBLIC */
+
+ int const * const pOptMust;
+ int const * const pOptCant;
+ tpOptProc const pOptProc;
+ char const * const pzText;
+
+ char const * const pz_NAME;
+ char const * const pz_Name;
+ char const * const pz_DisableName;
+ char const * const pz_DisablePfx;
};
/*
*/
typedef struct optSpecIndex tOptSpecIndex;
struct optSpecIndex {
- const tAoUS more_help;
- const tAoUS save_opts;
- const tAoUS number_option;
- const tAoUS default_opt;
+ const unsigned short more_help;
+ const unsigned short save_opts;
+ const unsigned short number_option;
+ const unsigned short default_opt;
};
/*
* Do not even look at these outside of libopts.
*/
struct options {
- int const structVersion;
- unsigned int origArgCt;
- char** origArgVect;
- unsigned int fOptSet;
- unsigned int curOptIdx;
- char* pzCurOpt;
-
- char const* const pzProgPath; /* PUBLIC */
- char const* const pzProgName; /* PUBLIC */
- char const* const pzPROGNAME; /* PUBLIC */
- char const* const pzRcName; /* PUBLIC */
- char const* const pzCopyright; /* PUBLIC */
- char const* const pzCopyNotice; /* PUBLIC */
- char const* const pzFullVersion; /* PUBLIC */
- char const* const* const papzHomeList;
- char const* const pzUsageTitle;
- char const* const pzExplain;
- char const* const pzDetail;
- tOptDesc* const pOptDesc; /* PUBLIC */
- char const* const pzBugAddr; /* PUBLIC */
-
- void* pExtensions;
- void* pSavedState;
+ int const structVersion;
+ unsigned int origArgCt;
+ char ** origArgVect;
+ proc_state_mask_t fOptSet;
+ unsigned int curOptIdx;
+ char * pzCurOpt;
+
+ char const * const pzProgPath; /* PUBLIC */
+ char const * const pzProgName; /* PUBLIC */
+ char const * const pzPROGNAME; /* PUBLIC */
+ char const * const pzRcName; /* PUBLIC */
+ char const * const pzCopyright; /* PUBLIC */
+ char const * const pzCopyNotice; /* PUBLIC */
+ char const * const pzFullVersion; /* PUBLIC */
+ char const * const * const papzHomeList;
+ char const * const pzUsageTitle;
+ char const * const pzExplain;
+ char const * const pzDetail;
+ tOptDesc * const pOptDesc; /* PUBLIC */
+ char const * const pzBugAddr; /* PUBLIC */
+
+ void* pExtensions;
+ void* pSavedState;
// coverity[+kill]
- tpUsageProc pUsageProc;
- tOptionXlateProc* pTransProc;
-
- tOptSpecIndex specOptIdx;
- int const optCt;
- int const presetOptCt;
- char const * pzFullUsage;
- char const * pzShortUsage;
+ tpUsageProc pUsageProc;
+ tOptionXlateProc* pTransProc;
+
+ tOptSpecIndex specOptIdx;
+ int const optCt;
+ int const presetOptCt;
+ char const * pzFullUsage;
+ char const * pzShortUsage;
/* PUBLIC: */
- optArgBucket_t const * const originalOptArgArray;
- void * const * const originalOptArgCookie;
- char const * const pzPkgDataDir;
- char const * const pzPackager;
+ opt_arg_union_t const * const originalOptArgArray;
+ void * const * const originalOptArgCookie;
+ char const * const pzPkgDataDir;
+ char const * const pzPackager;
};
/*
* The following routines may be coded into AutoOpts client code:
*/
-/* From: tokenize.c line 164
+/* From: tokenize.c line 162
*
* ao_string_tokenize - tokenize an input string
*
extern token_list_t* ao_string_tokenize(char const*);
-/* From: configfile.c line 77
+/* From: configfile.c line 83
*
* configFileLoad - parse a configuration file
*
* Arguments:
- * pzFile the file to load
+ * fname the file to load
*
* Returns: const tOptionValue* - An allocated, compound value structure
*
extern const tOptionValue* configFileLoad(char const*);
-/* From: configfile.c line 1066
+/* From: configfile.c line 1083
*
* optionFileLoad - Load the locatable config files, in order
*
* Arguments:
- * pOpts program options descriptor
- * pzProg program name
+ * opts program options descriptor
+ * prog program name
*
* Returns: int - 0 -> SUCCESS, -1 -> FAILURE
*
extern int optionFileLoad(tOptions*, char const*);
-/* From: configfile.c line 211
+/* From: configfile.c line 215
*
* optionFindNextValue - find a hierarcicaly valued option instance
*
* Arguments:
- * pOptDesc an option with a nested arg type
+ * odesc an option with a nested arg type
* pPrevVal the last entry
* name name of value to find
* value the matching value
extern const tOptionValue* optionFindNextValue(const tOptDesc*, const tOptionValue*, char const*, char const*);
-/* From: configfile.c line 137
+/* From: configfile.c line 142
*
* optionFindValue - find a hierarcicaly valued option instance
*
* Arguments:
- * pOptDesc an option with a nested arg type
+ * odesc an option with a nested arg type
* name name of value to find
- * value the matching value
+ * val the matching value
*
* Returns: const tOptionValue* - a compound value structure
*
extern const tOptionValue* optionFindValue(const tOptDesc*, char const*, char const*);
-/* From: restore.c line 166
+/* From: restore.c line 165
*
* optionFree - free allocated option processing memory
*
extern void optionFree(tOptions*);
-/* From: configfile.c line 280
+/* From: configfile.c line 284
*
* optionGetValue - get a specific value from a hierarcical list
*
extern const tOptionValue* optionGetValue(const tOptionValue*, char const*);
-/* From: load.c line 478
+/* From: load.c line 484
*
* optionLoadLine - process a string for an option name and value
*
extern void optionLoadLine(tOptions*, char const*);
-/* From: configfile.c line 340
+/* From: configfile.c line 343
*
* optionNextValue - get the next value from a hierarchical list
*
extern const tOptionValue* optionNextValue(const tOptionValue*, const tOptionValue*);
-/* From: usage.c line 201
+/* From: usage.c line 199
*
* optionOnlyUsage - Print usage text for just the options
*
extern void optionOnlyUsage(tOptions*, int);
-/* From: autoopts.c line 607
+/* From: autoopts.c line 319
*
* optionProcess - this is the main option processing routine
*
* Arguments:
- * pOpts program options descriptor
- * argc program arg count
- * argv program arg vector
+ * opts program options descriptor
+ * a_ct program arg count
+ * a_v program arg vector
*
* Returns: int - the count of the arguments processed
*
extern int optionProcess(tOptions*, int, char**);
-/* From: restore.c line 123
+/* From: restore.c line 122
*
* optionRestore - restore option state from memory copy
*
extern void optionRestore(tOptions*);
-/* From: save.c line 648
+/* From: save.c line 646
*
* optionSaveFile - saves the option state to a file
*
extern void optionSaveFile(tOptions*);
-/* From: restore.c line 71
+/* From: restore.c line 69
*
* optionSaveState - saves the option state to memory
*
extern void optionSaveState(tOptions*);
-/* From: nested.c line 563
+/* From: nested.c line 628
*
* optionUnloadNested - Deallocate the memory for a nested value
*
extern void optionUnloadNested(tOptionValue const *);
-/* From: version.c line 31
+/* From: version.c line 29
*
* optionVersion - return the compiled AutoOpts version number
*
extern char const* optionVersion(void);
-/* From: ../compat/pathfind.c line 29
- *
- * pathfind - fild a file in a list of directories
- *
- * Arguments:
- * path colon separated list of search directories
- * file the name of the file to look for
- * mode the mode bits that must be set to match
- *
- * Returns: char* - the path to the located file
- *
- * the pathfind function is available only if HAVE_PATHFIND is not defined
- *
- * pathfind looks for a a file with name "FILE" and "MODE" access
- * along colon delimited "PATH", and returns the full pathname as a
- * string, or NULL if not found. If "FILE" contains a slash, then
- * it is treated as a relative or absolute path and "PATH" is ignored.
- *
- * @strong{NOTE}: this function is compiled into @file{libopts} only if
- * it is not natively supplied.
- *
- * The "MODE" argument is a string of option letters chosen from the
- * list below:
- * @example
- * Letter Meaning
- * r readable
- * w writable
- * x executable
- * f normal file (NOT IMPLEMENTED)
- * b block special (NOT IMPLEMENTED)
- * c character special (NOT IMPLEMENTED)
- * d directory (NOT IMPLEMENTED)
- * p FIFO (pipe) (NOT IMPLEMENTED)
- * u set user ID bit (NOT IMPLEMENTED)
- * g set group ID bit (NOT IMPLEMENTED)
- * k sticky bit (NOT IMPLEMENTED)
- * s size nonzero (NOT IMPLEMENTED)
- * @end example
- */
-#ifndef HAVE_PATHFIND
-extern char* pathfind(char const*, char const*, char const*);
-#endif /* HAVE_PATHFIND */
-
-
-/* From: streqvcmp.c line 209
+/* From: streqvcmp.c line 207
*
* strequate - map a list of characters to the same value
*
extern void strequate(char const*);
-/* From: streqvcmp.c line 119
+/* From: streqvcmp.c line 117
*
* streqvcmp - compare two strings with an equivalence mapping
*
extern int streqvcmp(char const*, char const*);
-/* From: streqvcmp.c line 156
+/* From: streqvcmp.c line 154
*
* streqvmap - Set the character mappings for the streqv functions
*
extern void streqvmap(char, char, int);
-/* From: streqvcmp.c line 78
+/* From: streqvcmp.c line 76
*
* strneqvcmp - compare two strings with an equivalence mapping
*
extern int strneqvcmp(char const*, char const*, int);
-/* From: streqvcmp.c line 235
+/* From: streqvcmp.c line 233
*
* strtransform - convert a string into its mapped-to value
*
-/* -*- buffer-read-only: t -*- vi: set ro:
+/** -*- buffer-read-only: t -*- vi: set ro:
*
* DO NOT EDIT THIS FILE (usage-txt.h)
*
- * It has been AutoGen-ed August 11, 2012 at 09:41:15 AM by AutoGen 5.16.2pre7
+ * It has been AutoGen-ed December 27, 2012 at 12:59:03 PM by AutoGen 5.17.0pre12
* From the definitions usage-txt.def
* and the template file usage-txt.tpl
+ * @file usage-txt.h
*
* This file handles all the bookkeeping required for tracking all the little
* tiny strings used by the AutoOpts library. There are 146
#ifndef AUTOOPTS_USAGE_TXT_H_GUARD
#define AUTOOPTS_USAGE_TXT_H_GUARD 1
-#undef cch_t
-#define cch_t char const
-
/*
- * One structure to hold all the pointers to all the stringlets.
+ * One structure to hold all the pointers to all the translatable strings.
*/
typedef struct {
- int field_ct;
- char* utpz_GnuBoolArg;
- char* utpz_GnuKeyArg;
- char* utpz_GnuFileArg;
- char* utpz_GnuKeyLArg;
- char* utpz_GnuTimeArg;
- char* utpz_GnuNumArg;
- char* utpz_GnuStrArg;
- cch_t* apz_str[ 139 ];
+ int field_ct;
+ char * utpz_GnuBoolArg;
+ char * utpz_GnuFileArg;
+ char * utpz_GnuKeyArg;
+ char * utpz_GnuKeyLArg;
+ char * utpz_GnuNumArg;
+ char * utpz_GnuStrArg;
+ char * utpz_GnuTimeArg;
+ char const * apz_str[91];
} usage_text_t;
/*
- * Declare the global structure with all the pointers to translated
- * strings. This is then used by the usage generation procedure.
+ * Declare the global structure with all the pointers to translatable
+ * strings and the text array containing untranslatable strings.
*/
-extern usage_text_t option_usage_text;
+extern usage_text_t option_xlateable_txt;
+extern char const option_lib_text[4660];
-#if defined(AUTOOPTS_INTERNAL) /* DEFINE ALL THE STRINGS = = = = = */
+#if defined(AUTOOPTS_INTERNAL)
/*
- * Provide a mapping from a short name to fields in this structure.
+ * Provide a mapping from a short name to either the text directly
+ * (for untranslatable strings), or to pointers to the text, rendering
+ * them translatable.
*/
-#define zAO_Alloc (option_usage_text.apz_str[ 0])
-#define zAO_Bad (option_usage_text.apz_str[ 1])
-#define zAO_Big (option_usage_text.apz_str[ 2])
-#define zAO_Err (option_usage_text.apz_str[ 3])
-#define zAO_Realloc (option_usage_text.apz_str[ 4])
-#define zAO_Sml (option_usage_text.apz_str[ 5])
-#define zAO_Strdup (option_usage_text.apz_str[ 6])
-#define zAO_Ver (option_usage_text.apz_str[ 7])
-#define zAO_Woops (option_usage_text.apz_str[ 8])
-#define zAliasRange (option_usage_text.apz_str[ 9])
-#define zAll (option_usage_text.apz_str[ 10])
-#define zAlt (option_usage_text.apz_str[ 11])
-#define zAmbigKey (option_usage_text.apz_str[ 12])
-#define zAmbigList (option_usage_text.apz_str[ 13])
-#define zAmbigOptStr (option_usage_text.apz_str[ 14])
-#define zAmbiguous (option_usage_text.apz_str[ 15])
-#define zArgsMust (option_usage_text.apz_str[ 16])
-#define zAtMost (option_usage_text.apz_str[ 17])
-#define zAuto (option_usage_text.apz_str[ 18])
-#define zBadPipe (option_usage_text.apz_str[ 19])
-#define zBadVerArg (option_usage_text.apz_str[ 20])
-#define zCantFmt (option_usage_text.apz_str[ 21])
-#define zCantSave (option_usage_text.apz_str[ 22])
-#define zCfgAO_Flags (option_usage_text.apz_str[ 23])
-#define zCfgProg (option_usage_text.apz_str[ 24])
-#define zDefaultOpt (option_usage_text.apz_str[ 25])
-#define zDis (option_usage_text.apz_str[ 26])
-#define zDisabledErr (option_usage_text.apz_str[ 27])
-#define zDisabledOpt (option_usage_text.apz_str[ 28])
-#define zDisabledWhy (option_usage_text.apz_str[ 29])
-#define zEnab (option_usage_text.apz_str[ 30])
-#define zEquiv (option_usage_text.apz_str[ 31])
-#define zErrOnly (option_usage_text.apz_str[ 32])
-#define zExamineFmt (option_usage_text.apz_str[ 33])
-#define zFiveSpaces (option_usage_text.apz_str[ 34])
-#define zFlagOkay (option_usage_text.apz_str[ 35])
-#define zFmtFmt (option_usage_text.apz_str[ 36])
-#define zForkFail (option_usage_text.apz_str[ 37])
-#define zFreopenFail (option_usage_text.apz_str[ 38])
-#define zFSErrOptLoad (option_usage_text.apz_str[ 39])
-#define zFSErrReadFile (option_usage_text.apz_str[ 40])
-#define zFSOptError (option_usage_text.apz_str[ 41])
-#define zFSOptErrMayExist (option_usage_text.apz_str[ 42])
-#define zFSOptErrMustExist (option_usage_text.apz_str[ 43])
-#define zFSOptErrNoExist (option_usage_text.apz_str[ 44])
-#define zFSOptErrOpen (option_usage_text.apz_str[ 45])
-#define zFSOptErrFopen (option_usage_text.apz_str[ 46])
-#define zFileCannotExist (option_usage_text.apz_str[ 47])
-#define zFileMustExist (option_usage_text.apz_str[ 48])
-#define zGenshell (option_usage_text.apz_str[ 49])
-#define zGnuBoolArg (option_usage_text.utpz_GnuBoolArg)
-#define zGnuBreak (option_usage_text.apz_str[ 50])
-#define zGnuKeyArg (option_usage_text.utpz_GnuKeyArg)
-#define zGnuFileArg (option_usage_text.utpz_GnuFileArg)
-#define zGnuKeyLArg (option_usage_text.utpz_GnuKeyLArg)
-#define zGnuTimeArg (option_usage_text.utpz_GnuTimeArg)
-#define zGnuNestArg (option_usage_text.apz_str[ 51])
-#define zGnuNumArg (option_usage_text.utpz_GnuNumArg)
-#define zGnuOptArg (option_usage_text.apz_str[ 52])
-#define zGnuOptFmt (option_usage_text.apz_str[ 53])
-#define zGnuStrArg (option_usage_text.utpz_GnuStrArg)
-#define zIllOptChr (option_usage_text.apz_str[ 54])
-#define zIllOptStr (option_usage_text.apz_str[ 55])
-#define zIllVendOptStr (option_usage_text.apz_str[ 56])
-#define zIntRange (option_usage_text.apz_str[ 57])
-#define zInvalOptDesc (option_usage_text.apz_str[ 58])
-#define zInvalOptName (option_usage_text.apz_str[ 59])
-#define zLowerBits (option_usage_text.apz_str[ 60])
-#define zMembers (option_usage_text.apz_str[ 61])
-#define zMisArg (option_usage_text.apz_str[ 62])
-#define zMultiEquiv (option_usage_text.apz_str[ 63])
-#define zMust (option_usage_text.apz_str[ 64])
-#define zNeedOne (option_usage_text.apz_str[ 65])
-#define zNoArg (option_usage_text.apz_str[ 66])
-#define zNoArgs (option_usage_text.apz_str[ 67])
-#define zNoCreat (option_usage_text.apz_str[ 68])
-#define zNoFlags (option_usage_text.apz_str[ 69])
-#define zNoKey (option_usage_text.apz_str[ 70])
-#define zNoLim (option_usage_text.apz_str[ 71])
-#define zNoPreset (option_usage_text.apz_str[ 72])
-#define zNoResetArg (option_usage_text.apz_str[ 73])
-#define zNoRq_NoShrtTtl (option_usage_text.apz_str[ 74])
-#define zNoRq_ShrtTtl (option_usage_text.apz_str[ 75])
-#define zNoStat (option_usage_text.apz_str[ 76])
-#define zNoState (option_usage_text.apz_str[ 77])
-#define zNone (option_usage_text.apz_str[ 78])
-#define zNotDef (option_usage_text.apz_str[ 79])
-#define zNotCmdOpt (option_usage_text.apz_str[ 80])
-#define zNotEnough (option_usage_text.apz_str[ 81])
-#define zNotFile (option_usage_text.apz_str[ 82])
-#define zNotNumber (option_usage_text.apz_str[ 83])
-#define zNotDate (option_usage_text.apz_str[ 84])
-#define zNotDuration (option_usage_text.apz_str[ 85])
-#define zNrmOptFmt (option_usage_text.apz_str[ 86])
-#define zNumberOpt (option_usage_text.apz_str[ 87])
-#define zOnlyOne (option_usage_text.apz_str[ 88])
-#define zOptsOnly (option_usage_text.apz_str[ 89])
-#define zOutputFail (option_usage_text.apz_str[ 90])
-#define zPathFmt (option_usage_text.apz_str[ 91])
-#define zPlsSendBugs (option_usage_text.apz_str[ 92])
-#define zPreset (option_usage_text.apz_str[ 93])
-#define zPresetFile (option_usage_text.apz_str[ 94])
-#define zPresetIntro (option_usage_text.apz_str[ 95])
-#define zProhib (option_usage_text.apz_str[ 96])
-#define zReorder (option_usage_text.apz_str[ 97])
-#define zRange (option_usage_text.apz_str[ 98])
-#define zRangeAbove (option_usage_text.apz_str[ 99])
-#define zRangeLie (option_usage_text.apz_str[100])
-#define zRangeOnly (option_usage_text.apz_str[101])
-#define zRangeOr (option_usage_text.apz_str[102])
-#define zRangeErr (option_usage_text.apz_str[103])
-#define zRangeExact (option_usage_text.apz_str[104])
-#define zRangeScaled (option_usage_text.apz_str[105])
-#define zRangeUpto (option_usage_text.apz_str[106])
-#define zResetNotConfig (option_usage_text.apz_str[107])
-#define zReqFmt (option_usage_text.apz_str[108])
-#define zReqOptFmt (option_usage_text.apz_str[109])
-#define zReqThese (option_usage_text.apz_str[110])
-#define zReq_NoShrtTtl (option_usage_text.apz_str[111])
-#define zReq_ShrtTtl (option_usage_text.apz_str[112])
-#define zSepChars (option_usage_text.apz_str[113])
-#define zSetMemberSettings (option_usage_text.apz_str[114])
-#define zShrtGnuOptFmt (option_usage_text.apz_str[115])
-#define zSixSpaces (option_usage_text.apz_str[116])
-#define zStdBoolArg (option_usage_text.apz_str[117])
-#define zStdBreak (option_usage_text.apz_str[118])
-#define zStdFileArg (option_usage_text.apz_str[119])
-#define zStdKeyArg (option_usage_text.apz_str[120])
-#define zStdKeyLArg (option_usage_text.apz_str[121])
-#define zStdTimeArg (option_usage_text.apz_str[122])
-#define zStdNestArg (option_usage_text.apz_str[123])
-#define zStdNoArg (option_usage_text.apz_str[124])
-#define zStdNumArg (option_usage_text.apz_str[125])
-#define zStdOptArg (option_usage_text.apz_str[126])
-#define zStdReqArg (option_usage_text.apz_str[127])
-#define zStdStrArg (option_usage_text.apz_str[128])
-#define zTabHyp (option_usage_text.apz_str[129])
-#define zTabHypAnd (option_usage_text.apz_str[130])
-#define zTabout (option_usage_text.apz_str[131])
-#define zThreeSpaces (option_usage_text.apz_str[132])
-#define zTooLarge (option_usage_text.apz_str[133])
-#define zTwoSpaces (option_usage_text.apz_str[134])
-#define zUpTo (option_usage_text.apz_str[135])
-#define zValidKeys (option_usage_text.apz_str[136])
-#define zVendOptsAre (option_usage_text.apz_str[137])
-#define zVendIntro (option_usage_text.apz_str[138])
+#define zAO_Alloc (option_xlateable_txt.apz_str[ 0])
+#define zAO_Bad (option_xlateable_txt.apz_str[ 1])
+#define zAO_Big (option_xlateable_txt.apz_str[ 2])
+#define zAO_Err (option_xlateable_txt.apz_str[ 3])
+#define zAO_Realloc (option_xlateable_txt.apz_str[ 4])
+#define zAO_Sml (option_xlateable_txt.apz_str[ 5])
+#define zAO_Strdup (option_xlateable_txt.apz_str[ 6])
+#define zAO_Ver (option_xlateable_txt.apz_str[ 7])
+#define zAO_Woops (option_xlateable_txt.apz_str[ 8])
+#define zAliasRange (option_xlateable_txt.apz_str[ 9])
+#define zAll (option_xlateable_txt.apz_str[ 10])
+#define zAlt (option_lib_text + 547)
+#define zAmbigKey (option_xlateable_txt.apz_str[ 11])
+#define zAmbigList (option_xlateable_txt.apz_str[ 12])
+#define zAmbigOptStr (option_xlateable_txt.apz_str[ 13])
+#define zAmbiguous (option_xlateable_txt.apz_str[ 14])
+#define zArgsMust (option_xlateable_txt.apz_str[ 15])
+#define zAtMost (option_xlateable_txt.apz_str[ 16])
+#define zAuto (option_xlateable_txt.apz_str[ 17])
+#define zBadPipe (option_xlateable_txt.apz_str[ 18])
+#define zBadVerArg (option_xlateable_txt.apz_str[ 19])
+#define zCantFmt (option_xlateable_txt.apz_str[ 20])
+#define zCantSave (option_xlateable_txt.apz_str[ 21])
+#define zCfgAO_Flags (option_xlateable_txt.apz_str[ 22])
+#define zCfgProg (option_xlateable_txt.apz_str[ 23])
+#define zDefaultOpt (option_xlateable_txt.apz_str[ 24])
+#define zDis (option_xlateable_txt.apz_str[ 25])
+#define zDisabledErr (option_xlateable_txt.apz_str[ 26])
+#define zDisabledOpt (option_lib_text + 1225)
+#define zDisabledWhy (option_xlateable_txt.apz_str[ 27])
+#define zEnab (option_lib_text + 1270)
+#define zEquiv (option_xlateable_txt.apz_str[ 28])
+#define zErrOnly (option_xlateable_txt.apz_str[ 29])
+#define zExamineFmt (option_xlateable_txt.apz_str[ 30])
+#define zFSErrOptLoad (option_xlateable_txt.apz_str[ 31])
+#define zFSErrReadFile (option_xlateable_txt.apz_str[ 32])
+#define zFSOptErrFopen (option_xlateable_txt.apz_str[ 33])
+#define zFSOptErrMayExist (option_xlateable_txt.apz_str[ 34])
+#define zFSOptErrMustExist (option_xlateable_txt.apz_str[ 35])
+#define zFSOptErrNoExist (option_xlateable_txt.apz_str[ 36])
+#define zFSOptErrOpen (option_xlateable_txt.apz_str[ 37])
+#define zFSOptError (option_xlateable_txt.apz_str[ 38])
+#define zFileCannotExist (option_lib_text + 1605)
+#define zFileMustExist (option_lib_text + 1636)
+#define zFiveSpaces (option_lib_text + 1663)
+#define zFlagOkay (option_xlateable_txt.apz_str[ 39])
+#define zFmtFmt (option_lib_text + 1772)
+#define zForkFail (option_xlateable_txt.apz_str[ 40])
+#define zFreopenFail (option_xlateable_txt.apz_str[ 41])
+#define zGenshell (option_xlateable_txt.apz_str[ 42])
+#define zGnuBoolArg (option_xlateable_txt.utpz_GnuBoolArg)
+#define zGnuBreak (option_lib_text + 1970)
+#define zGnuFileArg (option_xlateable_txt.utpz_GnuFileArg)
+#define zGnuKeyArg (option_xlateable_txt.utpz_GnuKeyArg)
+#define zGnuKeyLArg (option_xlateable_txt.utpz_GnuKeyLArg)
+#define zGnuNestArg (option_lib_text + 1976)
+#define zGnuNumArg (option_xlateable_txt.utpz_GnuNumArg)
+#define zGnuOptArg (option_lib_text + 1982)
+#define zGnuOptFmt (option_lib_text + 1989)
+#define zGnuStrArg (option_xlateable_txt.utpz_GnuStrArg)
+#define zGnuTimeArg (option_xlateable_txt.utpz_GnuTimeArg)
+#define zIllOptChr (option_xlateable_txt.apz_str[ 43])
+#define zIllOptStr (option_xlateable_txt.apz_str[ 44])
+#define zIllVendOptStr (option_xlateable_txt.apz_str[ 45])
+#define zIntRange (option_xlateable_txt.apz_str[ 46])
+#define zInvalOptDesc (option_xlateable_txt.apz_str[ 47])
+#define zInvalOptName (option_xlateable_txt.apz_str[ 48])
+#define zLowerBits (option_xlateable_txt.apz_str[ 49])
+#define zMembers (option_lib_text + 2267)
+#define zMisArg (option_xlateable_txt.apz_str[ 50])
+#define zMultiEquiv (option_xlateable_txt.apz_str[ 51])
+#define zMust (option_lib_text + 2404)
+#define zNeedOne (option_xlateable_txt.apz_str[ 52])
+#define zNoArg (option_xlateable_txt.apz_str[ 53])
+#define zNoArgs (option_xlateable_txt.apz_str[ 54])
+#define zNoCreat (option_xlateable_txt.apz_str[ 55])
+#define zNoFlags (option_xlateable_txt.apz_str[ 56])
+#define zNoKey (option_xlateable_txt.apz_str[ 57])
+#define zNoLim (option_lib_text + 2705)
+#define zNoPreset (option_lib_text + 2738)
+#define zNoResetArg (option_xlateable_txt.apz_str[ 58])
+#define zNoRq_NoShrtTtl (option_xlateable_txt.apz_str[ 59])
+#define zNoRq_ShrtTtl (option_xlateable_txt.apz_str[ 60])
+#define zNoStat (option_xlateable_txt.apz_str[ 61])
+#define zNoState (option_xlateable_txt.apz_str[ 62])
+#define zNone (option_xlateable_txt.apz_str[ 63])
+#define zNotCmdOpt (option_xlateable_txt.apz_str[ 64])
+#define zNotDate (option_xlateable_txt.apz_str[ 65])
+#define zNotDef (option_xlateable_txt.apz_str[ 66])
+#define zNotDuration (option_xlateable_txt.apz_str[ 67])
+#define zNotEnough (option_xlateable_txt.apz_str[ 68])
+#define zNotFile (option_xlateable_txt.apz_str[ 69])
+#define zNotNumber (option_xlateable_txt.apz_str[ 70])
+#define zNrmOptFmt (option_lib_text + 3264)
+#define zNumberOpt (option_lib_text + 3272)
+#define zOnlyOne (option_xlateable_txt.apz_str[ 71])
+#define zOptsOnly (option_lib_text + 3345)
+#define zOutputFail (option_xlateable_txt.apz_str[ 72])
+#define zPathFmt (option_xlateable_txt.apz_str[ 73])
+#define zPlsSendBugs (option_xlateable_txt.apz_str[ 74])
+#define zPreset (option_lib_text + 3461)
+#define zPresetFile (option_lib_text + 3497)
+#define zPresetIntro (option_xlateable_txt.apz_str[ 75])
+#define zProhib (option_lib_text + 3591)
+#define zRange (option_lib_text + 3617)
+#define zRangeAbove (option_lib_text + 3630)
+#define zRangeErr (option_xlateable_txt.apz_str[ 76])
+#define zRangeExact (option_lib_text + 3710)
+#define zRangeLie (option_xlateable_txt.apz_str[ 77])
+#define zRangeOnly (option_xlateable_txt.apz_str[ 78])
+#define zRangeOr (option_lib_text + 3789)
+#define zRangeScaled (option_lib_text + 3795)
+#define zRangeUpto (option_lib_text + 3841)
+#define zReorder (option_xlateable_txt.apz_str[ 79])
+#define zReqFmt (option_xlateable_txt.apz_str[ 80])
+#define zReqOptFmt (option_lib_text + 3977)
+#define zReqThese (option_xlateable_txt.apz_str[ 81])
+#define zReq_NoShrtTtl (option_xlateable_txt.apz_str[ 82])
+#define zReq_ShrtTtl (option_xlateable_txt.apz_str[ 83])
+#define zResetNotConfig (option_xlateable_txt.apz_str[ 84])
+#define zSepChars (option_xlateable_txt.apz_str[ 85])
+#define zSetMemberSettings (option_xlateable_txt.apz_str[ 86])
+#define zShrtGnuOptFmt (option_lib_text + 4367)
+#define zSixSpaces (option_lib_text + 4370)
+#define zStdBoolArg (option_lib_text + 4377)
+#define zStdBreak (option_lib_text + 4381)
+#define zStdFileArg (option_lib_text + 4389)
+#define zStdKeyArg (option_lib_text + 4393)
+#define zStdKeyLArg (option_lib_text + 4397)
+#define zStdNestArg (option_lib_text + 4401)
+#define zStdNoArg (option_lib_text + 4405)
+#define zStdNumArg (option_lib_text + 4409)
+#define zStdOptArg (option_lib_text + 4413)
+#define zStdReqArg (option_lib_text + 4417)
+#define zStdStrArg (option_lib_text + 4421)
+#define zStdTimeArg (option_lib_text + 4425)
+#define zTabHyp (option_lib_text + 4429)
+#define zTabHypAnd (option_lib_text + 4436)
+#define zTabout (option_lib_text + 4448)
+#define zThreeSpaces (option_lib_text + 4456)
+#define zTooLarge (option_xlateable_txt.apz_str[ 87])
+#define zTwoSpaces (option_lib_text + 4500)
+#define zUpTo (option_lib_text + 4503)
+#define zValidKeys (option_xlateable_txt.apz_str[ 88])
+#define zVendIntro (option_xlateable_txt.apz_str[ 89])
+#define zVendOptsAre (option_xlateable_txt.apz_str[ 90])
/*
* First, set up the strings. Some of these are writable. These are all in
* English. This gets compiled into libopts and is distributed here so that
* xgettext (or equivalents) can extract these strings for translation.
*/
-
- static char eng_zGnuBoolArg[] = "=T/F";
- static char eng_zGnuKeyArg[] = "=KWd";
- static char eng_zGnuFileArg[] = "=file";
- static char eng_zGnuKeyLArg[] = "=Mbr";
- static char eng_zGnuTimeArg[] = "=Tim";
- static char eng_zGnuNumArg[] = "=num";
- static char eng_zGnuStrArg[] = "=str";
-static char const usage_txt[4660] =
+static char eng_zGnuBoolArg[] = "=T/F";
+static char eng_zGnuFileArg[] = "=file";
+static char eng_zGnuKeyArg[] = "=KWd";
+static char eng_zGnuKeyLArg[] = "=Mbr";
+static char eng_zGnuNumArg[] = "=num";
+static char eng_zGnuStrArg[] = "=str";
+static char eng_zGnuTimeArg[] = "=Tim";
+char const option_lib_text[4660] =
/* 0 */ "malloc of %d bytes failed\n\0"
/* 27 */ "AutoOpts function called without option descriptor\n\0"
/* 79 */ "\tThis exceeds the compiled library version: \0"
/* 1296 */ "-equivalence\0"
/* 1309 */ "ERROR: only \0"
/* 1323 */ " - examining environment variables named %s_*\n\0"
-/* 1370 */ " \0"
-/* 1376 */ "Options are specified by doubled hyphens and their name or by a single\n"
+/* 1370 */ "File error %d (%s) opening %s for loading options\n\0"
+/* 1421 */ "fs error %d (%s) reading file %s\n\0"
+/* 1455 */ "fopen-ing file\0"
+/* 1470 */ "stat-ing for directory\0"
+/* 1493 */ "stat-ing for regular file\0"
+/* 1519 */ "stat-ing for non-existant file\0"
+/* 1550 */ "open-ing file\0"
+/* 1564 */ "fs error %d (%s) on %s %s for option %s\n\0"
+/* 1605 */ "\t\t\t\t- file must not pre-exist\n\0"
+/* 1636 */ "\t\t\t\t- file must pre-exist\n\0"
+/* 1663 */ " \0"
+/* 1669 */ "Options are specified by doubled hyphens and their name or by a single\n"
"hyphen and the flag character.\n\0"
-/* 1479 */ "%%-%ds %%s\n\0"
-/* 1491 */ "fs error %d (%s) on fork - cannot obtain %s usage\n\0"
-/* 1542 */ "fs error %d (%s) on freopen\n\0"
-/* 1571 */ "File error %d (%s) opening %s for loading options\n\0"
-/* 1622 */ "fs error %d (%s) reading file %s\n\0"
-/* 1656 */ "fs error %d (%s) on %s %s for option %s\n\0"
-/* 1697 */ "stat-ing for directory\0"
-/* 1720 */ "stat-ing for regular file\0"
-/* 1746 */ "stat-ing for non-existant file\0"
-/* 1777 */ "open-ing file\0"
-/* 1791 */ "fopen-ing file\0"
-/* 1806 */ "\t\t\t\t- file must not pre-exist\n\0"
-/* 1837 */ "\t\t\t\t- file must pre-exist\n\0"
+/* 1772 */ "%%-%ds %%s\n\0"
+/* 1784 */ "fs error %d (%s) on fork - cannot obtain %s usage\n\0"
+/* 1835 */ "fs error %d (%s) on freopen\n\0"
/* 1864 */ "\n"
"= = = = = = = =\n\n"
"This incarnation of genshell will produce\n"
/* 2884 */ "error %d (%s) stat-ing %s\n\0"
/* 2911 */ "%s(optionRestore): error: no saved option state\n\0"
/* 2960 */ "none\0"
-/* 2965 */ "'%s' not defined\n\0"
-/* 2983 */ "'%s' is not a command line option\n\0"
-/* 3018 */ "ERROR: The %s option must appear %d times\n\0"
-/* 3062 */ "error: cannot load options from non-regular file %s\n\0"
-/* 3116 */ "%s error: `%s' is not a recognizable number\n\0"
-/* 3162 */ "%s error: `%s' is not a recognizable date/time\n\0"
-/* 3211 */ "%s error: `%s' is not a recognizable time duration\n\0"
+/* 2965 */ "'%s' is not a command line option\n\0"
+/* 3000 */ "%s error: `%s' is not a recognizable date/time\n\0"
+/* 3049 */ "'%s' not defined\n\0"
+/* 3067 */ "%s error: `%s' is not a recognizable time duration\n\0"
+/* 3120 */ "ERROR: The %s option must appear %d times\n\0"
+/* 3164 */ "error: cannot load options from non-regular file %s\n\0"
+/* 3218 */ "%s error: `%s' is not a recognizable number\n\0"
/* 3264 */ " %3s %s\0"
/* 3272 */ "The '-#<number>' option may omit the hash char\n\0"
/* 3320 */ "one %s%s option allowed\n\0"
/* 3535 */ "\n"
"The following option preset mechanisms are supported:\n\0"
/* 3591 */ "prohibits these options:\n\0"
-/* 3617 */ "Operands and options may be intermixed. They will be reordered.\n\0"
-/* 3683 */ "%s%ld to %ld\0"
-/* 3696 */ "%sgreater than or equal to %ld\0"
-/* 3727 */ "%sIt must lie in one of the ranges:\n\0"
-/* 3764 */ "%sIt must be in the range:\n\0"
-/* 3792 */ ", or\n\0"
-/* 3798 */ "%s error: %s option value %ld is out of range.\n\0"
-/* 3847 */ "%s%ld exactly\0"
-/* 3861 */ "%sis scalable with a suffix: k/K/m/M/g/G/t/T\n\0"
-/* 3907 */ "%sless than or equal to %ld\0"
-/* 3935 */ "The --reset-option has not been configured.\n\0"
-/* 3980 */ "ERROR: %s option requires the %s option\n\0"
-/* 4022 */ " %3s %-14s %s\0"
-/* 4036 */ "requires these options:\n\0"
-/* 4061 */ " Arg Option-Name Req? Description\n\0"
-/* 4101 */ " Flg Arg Option-Name Req? Description\n\0"
+/* 3617 */ "%s%ld to %ld\0"
+/* 3630 */ "%sgreater than or equal to %ld\0"
+/* 3661 */ "%s error: %s option value %ld is out of range.\n\0"
+/* 3710 */ "%s%ld exactly\0"
+/* 3724 */ "%sIt must lie in one of the ranges:\n\0"
+/* 3761 */ "%sIt must be in the range:\n\0"
+/* 3789 */ ", or\n\0"
+/* 3795 */ "%sis scalable with a suffix: k/K/m/M/g/G/t/T\n\0"
+/* 3841 */ "%sless than or equal to %ld\0"
+/* 3869 */ "Operands and options may be intermixed. They will be reordered.\n\0"
+/* 3935 */ "ERROR: %s option requires the %s option\n\0"
+/* 3977 */ " %3s %-14s %s\0"
+/* 3991 */ "requires these options:\n\0"
+/* 4016 */ " Arg Option-Name Req? Description\n\0"
+/* 4056 */ " Flg Arg Option-Name Req? Description\n\0"
+/* 4099 */ "The --reset-option has not been configured.\n\0"
/* 4144 */ "-_^\0"
/* 4148 */ "or you may use a numeric representation. Preceding these with a '!' will\n"
"clear the bits, specifying 'none' will clear all bits, and 'all' will set them\n"
/* 4389 */ "Fil\0"
/* 4393 */ "KWd\0"
/* 4397 */ "Mbr\0"
-/* 4401 */ "Tim\0"
-/* 4405 */ "Cpx\0"
-/* 4409 */ "no \0"
-/* 4413 */ "Num\0"
-/* 4417 */ "opt\0"
-/* 4421 */ "YES\0"
-/* 4425 */ "Str\0"
+/* 4401 */ "Cpx\0"
+/* 4405 */ "no \0"
+/* 4409 */ "Num\0"
+/* 4413 */ "opt\0"
+/* 4417 */ "YES\0"
+/* 4421 */ "Str\0"
+/* 4425 */ "Tim\0"
/* 4429 */ "\t\t\t\t- \0"
/* 4436 */ "\t\t\t\t-- and \0"
/* 4448 */ "\t\t\t\t%s\n\0"
/* 4500 */ " \0"
/* 4503 */ "\t\t\t\t- may appear up to %d times\n\0"
/* 4536 */ "The valid \"%s\" option keywords are:\n\0"
-/* 4573 */ "These additional options are:\0"
-/* 4603 */ "The next option supports vendor supported extra options:";
+/* 4573 */ "The next option supports vendor supported extra options:\0"
+/* 4630 */ "These additional options are:";
-
- /*
- * Now, define (and initialize) the structure that contains
- * the pointers to all these strings.
- * Aren't you glad you don't maintain this by hand?
- */
- usage_text_t option_usage_text = {
- 146,
- eng_zGnuBoolArg, eng_zGnuKeyArg, eng_zGnuFileArg, eng_zGnuKeyLArg,
- eng_zGnuTimeArg, eng_zGnuNumArg, eng_zGnuStrArg,
+/*
+ * Now, define (and initialize) the structure that contains
+ * the pointers to all these strings.
+ * Aren't you glad you don't maintain this by hand?
+ */
+usage_text_t option_xlateable_txt = {
+ 98,
+ eng_zGnuBoolArg, eng_zGnuFileArg, eng_zGnuKeyArg, eng_zGnuKeyLArg,
+ eng_zGnuNumArg, eng_zGnuStrArg, eng_zGnuTimeArg,
{
- usage_txt + 0, usage_txt + 27, usage_txt + 79, usage_txt + 125,
- usage_txt + 224, usage_txt + 260, usage_txt + 310, usage_txt + 343,
- usage_txt + 434, usage_txt + 493, usage_txt + 543, usage_txt + 547,
- usage_txt + 574, usage_txt + 623, usage_txt + 655, usage_txt + 707,
- usage_txt + 715, usage_txt + 752, usage_txt + 777, usage_txt + 819,
- usage_txt + 859, usage_txt + 996, usage_txt +1044, usage_txt +1098,
- usage_txt +1111, usage_txt +1119, usage_txt +1161, usage_txt +1185,
- usage_txt +1225, usage_txt +1240, usage_txt +1270, usage_txt +1296,
- usage_txt +1309, usage_txt +1323, usage_txt +1370, usage_txt +1376,
- usage_txt +1479, usage_txt +1491, usage_txt +1542, usage_txt +1571,
- usage_txt +1622, usage_txt +1656, usage_txt +1697, usage_txt +1720,
- usage_txt +1746, usage_txt +1777, usage_txt +1791, usage_txt +1806,
- usage_txt +1837, usage_txt +1864, usage_txt +1970, usage_txt +1976,
- usage_txt +1982, usage_txt +1989, usage_txt +2000, usage_txt +2026,
- usage_txt +2052, usage_txt +2095, usage_txt +2131, usage_txt +2182,
- usage_txt +2211, usage_txt +2267, usage_txt +2301, usage_txt +2339,
- usage_txt +2404, usage_txt +2447, usage_txt +2482, usage_txt +2523,
- usage_txt +2563, usage_txt +2590, usage_txt +2657, usage_txt +2705,
- usage_txt +2738, usage_txt +2763, usage_txt +2811, usage_txt +2846,
- usage_txt +2884, usage_txt +2911, usage_txt +2960, usage_txt +2965,
- usage_txt +2983, usage_txt +3018, usage_txt +3062, usage_txt +3116,
- usage_txt +3162, usage_txt +3211, usage_txt +3264, usage_txt +3272,
- usage_txt +3320, usage_txt +3345, usage_txt +3379, usage_txt +3408,
- usage_txt +3427, usage_txt +3461, usage_txt +3497, usage_txt +3535,
- usage_txt +3591, usage_txt +3617, usage_txt +3683, usage_txt +3696,
- usage_txt +3727, usage_txt +3764, usage_txt +3792, usage_txt +3798,
- usage_txt +3847, usage_txt +3861, usage_txt +3907, usage_txt +3935,
- usage_txt +3980, usage_txt +4022, usage_txt +4036, usage_txt +4061,
- usage_txt +4101, usage_txt +4144, usage_txt +4148, usage_txt +4367,
- usage_txt +4370, usage_txt +4377, usage_txt +4381, usage_txt +4389,
- usage_txt +4393, usage_txt +4397, usage_txt +4401, usage_txt +4405,
- usage_txt +4409, usage_txt +4413, usage_txt +4417, usage_txt +4421,
- usage_txt +4425, usage_txt +4429, usage_txt +4436, usage_txt +4448,
- usage_txt +4456, usage_txt +4460, usage_txt +4500, usage_txt +4503,
- usage_txt +4536, usage_txt +4573, usage_txt +4603
- }
- };
+ option_lib_text + 0, option_lib_text + 27, option_lib_text + 79,
+ option_lib_text + 125, option_lib_text + 224, option_lib_text + 260,
+ option_lib_text + 310, option_lib_text + 343, option_lib_text + 434,
+ option_lib_text + 493, option_lib_text + 543, option_lib_text + 574,
+ option_lib_text + 623, option_lib_text + 655, option_lib_text + 707,
+ option_lib_text + 715, option_lib_text + 752, option_lib_text + 777,
+ option_lib_text + 819, option_lib_text + 859, option_lib_text + 996,
+ option_lib_text + 1044, option_lib_text + 1098, option_lib_text + 1111,
+ option_lib_text + 1119, option_lib_text + 1161, option_lib_text + 1185,
+ option_lib_text + 1240, option_lib_text + 1296, option_lib_text + 1309,
+ option_lib_text + 1323, option_lib_text + 1370, option_lib_text + 1421,
+ option_lib_text + 1455, option_lib_text + 1470, option_lib_text + 1493,
+ option_lib_text + 1519, option_lib_text + 1550, option_lib_text + 1564,
+ option_lib_text + 1669, option_lib_text + 1784, option_lib_text + 1835,
+ option_lib_text + 1864, option_lib_text + 2000, option_lib_text + 2026,
+ option_lib_text + 2052, option_lib_text + 2095, option_lib_text + 2131,
+ option_lib_text + 2182, option_lib_text + 2211, option_lib_text + 2301,
+ option_lib_text + 2339, option_lib_text + 2447, option_lib_text + 2482,
+ option_lib_text + 2523, option_lib_text + 2563, option_lib_text + 2590,
+ option_lib_text + 2657, option_lib_text + 2763, option_lib_text + 2811,
+ option_lib_text + 2846, option_lib_text + 2884, option_lib_text + 2911,
+ option_lib_text + 2960, option_lib_text + 2965, option_lib_text + 3000,
+ option_lib_text + 3049, option_lib_text + 3067, option_lib_text + 3120,
+ option_lib_text + 3164, option_lib_text + 3218, option_lib_text + 3320,
+ option_lib_text + 3379, option_lib_text + 3408, option_lib_text + 3427,
+ option_lib_text + 3535, option_lib_text + 3661, option_lib_text + 3724,
+ option_lib_text + 3761, option_lib_text + 3869, option_lib_text + 3935,
+ option_lib_text + 3991, option_lib_text + 4016, option_lib_text + 4056,
+ option_lib_text + 4099, option_lib_text + 4144, option_lib_text + 4148,
+ option_lib_text + 4460, option_lib_text + 4536, option_lib_text + 4573,
+ option_lib_text + 4630
+ } };
+#endif /* AUTOOPTS_INTERNAL */
-#endif /* DO_TRANSLATIONS */
+#ifdef XGETTEXT_SCAN_DO_NOT_COMPILE
+do not compile this section.
+/* TRANSLATORS: The following dummy function was crated solely so that
+ * xgettext can extract the correct strings. These strings are actually
+ * referenced where the preceding "#line" directive states, though you
+ * will not see the literal string there. The literal string is defined
+ * above and referenced via a #define name that redirects into the
+ * "option_xlateable_txt" structure above.
+ */
+static void dummy_func(void) {
+#line 51 "../autoopts.c"
+ puts(_("malloc of %d bytes failed\n"));
+#line 52 "../init.c"
+ puts(_("AutoOpts function called without option descriptor\n"));
+#line 85 "../init.c"
+ puts(_("\tThis exceeds the compiled library version: "));
+#line 83 "../init.c"
+ puts(_("Automated Options Processing Error!\n"
+ "\t%s called AutoOpts function with structure version %d:%d:%d.\n"));
+#line 64 "../autoopts.c"
+ puts(_("realloc of %d bytes at 0x%p failed\n"));
+#line 87 "../init.c"
+ puts(_("\tThis is less than the minimum library version: "));
+#line 77 "../autoopts.c"
+ puts(_("strdup of %d byte string failed\n"));
+#line 122 "../version.c"
+ puts(_("Automated Options version %s\n"
+ "\tcopyright (c) 1999-2012 by Bruce Korb - all rights reserved\n"));
+#line 585 "../find.c"
+ puts(_("AutoOpts lib error: defaulted to option with optional arg\n"));
+#line 53 "../alias.c"
+ puts(_("(AutoOpts bug): Aliasing option is out of range."));
+#line 486 "../enum.c"
+ puts(_("all"));
+#line 228 "../enum.c"
+ puts(_("%s error: the keyword `%s' is ambiguous for %s\n"));
+#line 104 "../find.c"
+ puts(_(" The following options match:\n"));
+#line 286 "../find.c"
+ puts(_("%s: ambiguous option name: %s (matches %d options)\n"));
+#line 107 "../find.c"
+ puts(_(" %s%s\n"));
+#line 112 "../find.c"
+ puts(_(" %s%s\n"));
+#line 157 "../check.c"
+ puts(_("%s: Command line arguments required\n"));
+#line 78 "../alias.c"
+ puts(_("%d %s%s options allowed\n"));
+#line 215 "../autoopts.c"
+ puts(_("%d %s%s options allowed\n"));
+#line 872 "../usage.c"
+ puts(_("version, usage and configuration options:"));
+#line 266 "../makeshell.c"
+ puts(_("Error %d (%s) from the pipe(2) syscall\n"));
+#line 162 "../version.c"
+ puts(_("ERROR: version option argument '%c' invalid. Use:\n"
+ "\t'v' - version only\n"
+ "\t'c' - version and copyright\n"
+ "\t'n' - version and copyright notice\n"));
+#line 56 "../check.c"
+ puts(_("ERROR: %s option conflicts with the %s option\n"));
+#line 108 "../restore.c"
+ puts(_("%s(optionSaveState): error: cannot allocate %d bytes\n"));
+#line 593 "../configfile.c"
+ puts(_("auto-options"));
+#line 592 "../configfile.c"
+ puts(_("program"));
+#line 674 "../configfile.c"
+ puts(_("program"));
+#line 679 "../configfile.c"
+ puts(_("program"));
+#line 654 "../usage.c"
+ puts(_("\t\t\t\t- default option for unnamed options\n"));
+#line 569 "../usage.c"
+ puts(_("\t\t\t\t- disabled as --%s\n"));
+#line 210 "../find.c"
+ puts(_("%s: The ``%s'' option has been disabled"));
+#line 417 "../find.c"
+ puts(_("%s: The ``%s'' option has been disabled"));
+#line 839 "../usage.c"
+ puts(_("This option has been disabled"));
+#line 73 "../alias.c"
+ puts(_("-equivalence"));
+#line 210 "../autoopts.c"
+ puts(_("-equivalence"));
+#line 75 "../alias.c"
+ puts(_("ERROR: only "));
+#line 212 "../autoopts.c"
+ puts(_("ERROR: only "));
+#line 916 "../usage.c"
+ puts(_(" - examining environment variables named %s_*\n"));
+#line 1170 "../configfile.c"
+ puts(_("File error %d (%s) opening %s for loading options\n"));
+#line 98 "../text_mmap.c"
+ puts(_("fs error %d (%s) reading file %s\n"));
+#line 135 "../file.c"
+ puts(_("fopen-ing file"));
+#line 74 "../file.c"
+ puts(_("stat-ing for directory"));
+#line 86 "../file.c"
+ puts(_("stat-ing for regular file"));
+#line 48 "../file.c"
+ puts(_("stat-ing for non-existant file"));
+#line 108 "../file.c"
+ puts(_("open-ing file"));
+#line 47 "../file.c"
+ puts(_("fs error %d (%s) on %s %s for option %s\n"));
+#line 73 "../file.c"
+ puts(_("fs error %d (%s) on %s %s for option %s\n"));
+#line 85 "../file.c"
+ puts(_("fs error %d (%s) on %s %s for option %s\n"));
+#line 107 "../file.c"
+ puts(_("fs error %d (%s) on %s %s for option %s\n"));
+#line 134 "../file.c"
+ puts(_("fs error %d (%s) on %s %s for option %s\n"));
+#line 273 "../usage.c"
+ puts(_("Options are specified by doubled hyphens and their name or by a single\n"
+ "hyphen and the flag character.\n"));
+#line 272 "../makeshell.c"
+ puts(_("fs error %d (%s) on fork - cannot obtain %s usage\n"));
+#line 802 "../makeshell.c"
+ puts(_("fs error %d (%s) on freopen\n"));
+#line 880 "../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 456 "../find.c"
+ puts(_("%s: illegal option -- %c\n"));
+#line 106 "../reset.c"
+ puts(_("%s: illegal option -- %c\n"));
+#line 264 "../find.c"
+ puts(_("%s: illegal option -- %s\n"));
+#line 758 "../find.c"
+ puts(_("%s: illegal option -- %s\n"));
+#line 114 "../reset.c"
+ puts(_("%s: illegal option -- %s\n"));
+#line 328 "../find.c"
+ puts(_("%s: unknown vendor extension option -- %s\n"));
+#line 153 "../enum.c"
+ puts(_(" or an integer from %d through %d\n"));
+#line 163 "../enum.c"
+ puts(_(" or an integer from %d through %d\n"));
+#line 484 "../usage.c"
+ puts(_("AutoOpts ERROR: invalid option descriptor for %s\n"));
+#line 805 "../usage.c"
+ puts(_("AutoOpts ERROR: invalid option descriptor for %s\n"));
+#line 375 "../find.c"
+ puts(_("%s: invalid option name: %s\n"));
+#line 160 "../enum.c"
+ puts(_(" or an integer mask with any of the lower %d bits set\n"));
+#line 514 "../find.c"
+ puts(_("%s: option `%s' requires an argument\n"));
+#line 162 "../autoopts.c"
+ puts(_("Equivalenced option '%s' was equivalenced to both\n"
+ "\t'%s' and '%s'"));
+#line 90 "../check.c"
+ puts(_("ERROR: The %s option is required\n"));
+#line 620 "../find.c"
+ puts(_("%s: option `%s' cannot have an argument\n"));
+#line 147 "../check.c"
+ puts(_("%s: Command line arguments not allowed\n"));
+#line 510 "../save.c"
+ puts(_("error %d (%s) creating %s\n"));
+#line 275 "../usage.c"
+ puts(_("Options are specified by single or double hyphens and their name.\n"));
+#line 228 "../enum.c"
+ puts(_("%s error: `%s' does not match any %s keywords\n"));
+#line 89 "../reset.c"
+ puts(_("The 'reset-option' option requires an argument\n"));
+#line 1031 "../usage.c"
+ puts(_(" Arg Option-Name Description\n"));
+#line 967 "../usage.c"
+ puts(_(" Flg Arg Option-Name Description\n"));
+#line 1025 "../usage.c"
+ puts(_(" Flg Arg Option-Name Description\n"));
+#line 177 "../save.c"
+ puts(_("error %d (%s) stat-ing %s\n"));
+#line 231 "../save.c"
+ puts(_("error %d (%s) stat-ing %s\n"));
+#line 149 "../restore.c"
+ puts(_("%s(optionRestore): error: no saved option state\n"));
+#line 491 "../enum.c"
+ puts(_("none"));
+#line 252 "../autoopts.c"
+ puts(_("'%s' is not a command line option\n"));
+#line 110 "../time.c"
+ puts(_("%s error: `%s' is not a recognizable date/time\n"));
+#line 126 "../save.c"
+ puts(_("'%s' not defined\n"));
+#line 49 "../time.c"
+ puts(_("%s error: `%s' is not a recognizable time duration\n"));
+#line 89 "../check.c"
+ puts(_("ERROR: The %s option must appear %d times\n"));
+#line 1180 "../configfile.c"
+ puts(_("error: cannot load options from non-regular file %s\n"));
+#line 727 "../makeshell.c"
+ puts(_("error: cannot load options from non-regular file %s\n"));
+#line 250 "../save.c"
+ puts(_("error: cannot load options from non-regular file %s\n"));
+#line 149 "../numeric.c"
+ puts(_("%s error: `%s' is not a recognizable number\n"));
+#line 80 "../alias.c"
+ puts(_("one %s%s option allowed\n"));
+#line 217 "../autoopts.c"
+ puts(_("one %s%s option allowed\n"));
+#line 177 "../makeshell.c"
+ puts(_("Write failure to output file"));
+#line 902 "../makeshell.c"
+ puts(_("Write failure to output file"));
+#line 232 "../usage.c"
+ puts(_("Write failure to output file"));
+#line 307 "../usage.c"
+ puts(_("Write failure to output file"));
+#line 168 "../version.c"
+ puts(_("Write failure to output file"));
+#line 701 "../usage.c"
+ puts(_(" - reading file %s"));
+#line 302 "../usage.c"
+ puts(_("\n"
+ "please send bug reports to: %s\n"));
+#line 106 "../version.c"
+ puts(_("\n"
+ "please send bug reports to: %s\n"));
+#line 128 "../version.c"
+ puts(_("\n"
+ "please send bug reports to: %s\n"));
+#line 673 "../usage.c"
+ puts(_("\n"
+ "The following option preset mechanisms are supported:\n"));
+#line 914 "../usage.c"
+ puts(_("\n"
+ "The following option preset mechanisms are supported:\n"));
+#line 54 "../numeric.c"
+ puts(_("%s error: %s option value %ld is out of range.\n"));
+#line 62 "../numeric.c"
+ puts(_("%sIt must lie in one of the ranges:\n"));
+#line 62 "../numeric.c"
+ puts(_("%sIt must be in the range:\n"));
+#line 283 "../usage.c"
+ puts(_("Operands and options may be intermixed. They will be reordered.\n"));
+#line 43 "../check.c"
+ puts(_("ERROR: %s option requires the %s option\n"));
+#line 401 "../usage.c"
+ puts(_("requires these options:\n"));
+#line 1043 "../usage.c"
+ puts(_(" Arg Option-Name Req? Description\n"));
+#line 1037 "../usage.c"
+ puts(_(" Flg Arg Option-Name Req? Description\n"));
+#line 84 "../reset.c"
+ puts(_("The --reset-option has not been configured.\n"));
+#line 117 "../init.c"
+ puts(_("-_^"));
+#line 161 "../enum.c"
+ puts(_("or you may use a numeric representation. Preceding these with a '!' will\n"
+ "clear the bits, specifying 'none' will clear all bits, and 'all' will set them\n"
+ "all. Multiple entries may be passed as an option argument list.\n"));
+#line 194 "../enum.c"
+ puts(_("%s error: %s exceeds %s keyword count\n"));
+#line 71 "../enum.c"
+ puts(_("The valid \"%s\" option keywords are:\n"));
+#line 876 "../usage.c"
+ puts(_("The next option supports vendor supported extra options:"));
+#line 512 "../usage.c"
+ puts(_("These additional options are:"));
+}
+#endif /* XGETTEXT_SCAN_DO_NOT_COMPILE */
#endif /* AUTOOPTS_USAGE_TXT_H_GUARD */
/**
* \file boolean.c
*
- * Time-stamp: "2012-08-11 08:34:39 bkorb"
- *
* Automated Options Paged Usage module.
*
* This routine will run run-on options through a pager so the
*
* @brief consistency checks.
*
- * Time-stamp: "2012-03-31 13:46:35 bkorb"
- *
* This file contains the routines that deal with processing quoted strings
* into an internal format.
*
/**
* \file compat.h --- fake the preprocessor into handlng portability
*
- * Time-stamp: "2012-08-11 08:17:36 bkorb"
- *
* compat.h is free software.
* This file is part of AutoGen.
*
/* pathfind.c --- find a FILE MODE along PATH */
-/*
- * Author: Gary V Vaughan <gvaughan@oranda.demon.co.uk>
- * Time-stamp: "2012-08-11 08:19:39 bkorb"
- */
+/* Author: Gary V Vaughan <gvaughan@oranda.demon.co.uk> */
/* Code: */
+static char *
+pathfind( char const * path,
+ char const * fileName,
+ char const * mode );
+
#include "compat.h"
#ifndef HAVE_PATHFIND
#if defined(__windows__) && !defined(__CYGWIN__)
-char*
-pathfind( char const* path,
- char const* fileName,
- char const* mode )
+static char *
+pathfind( char const * path,
+ char const * fileName,
+ char const * mode )
{
return NULL;
}
*
* err: returns NULL if the file is not found.
=*/
-char*
-pathfind( char const* path,
- char const* fileName,
- char const* mode )
+static char *
+pathfind( char const * path,
+ char const * fileName,
+ char const * mode )
{
int p_index = 0;
int mode_bits = 0;
if (dot_path && dot_path[0]) {
result = malloc( 2 + strlen( dot_path ) + strlen( string ) );
strcpy( result, dot_path );
- result_len = strlen( result );
+ result_len = (int)strlen(result);
if (result[result_len - 1] != '/') {
result[result_len++] = '/';
result[result_len] = '\0';
static char*
extract_colon_unit( char* pzDir, char const *string, int *p_index )
{
- char* pzDest = pzDir;
+ char * pzDest = pzDir;
int ix = *p_index;
if (string == NULL)
return NULL;
{
- char const* pzSrc = string + ix;
+ char const * pzSrc = string + ix;
while (*pzSrc == ':') pzSrc++;
break;
} copy_done:;
- ix = pzSrc - string;
+ ix = (int)(pzSrc - string);
}
if (*pzDir == NUL)
#ifndef HAVE_VPRINTF
#include "choke-me: no vprintf and no snprintf"
+ choke me.
#endif
#if defined(HAVE_STDARG_H)
#else
# include "must-have-stdarg-or-varargs"
+ choke me.
#endif
static int
SVID 3, POSIX, BSD 4.3, ISO 9899
*/
-char*
-strchr( char const *s, int c)
+static char *
+strchr(char const *s, int c);
+
+static char *
+strrchr(char const *s, int c);
+
+static char *
+strchr(char const *s, int c)
{
do {
if ((unsigned)*s == (unsigned)c)
return NULL;
}
-char*
-strrchr( char const *s, int c)
+static char *
+strrchr(char const *s, int c)
{
char const *e = s + strlen(s);
* Platforms without strdup ?!?!?!
*/
+static char *
+strdup( char const *s );
+
static char *
strdup( char const *s )
{
/**
* \file autoopts.c
*
- * Time-stamp: "2012-06-15 12:31:28 bkorb"
- *
* This file contains all of the routines that must be linked into
* an executable to use the generated option processing. The optional
* routines are in separately compiled modules so that they will not
/**
* \file configfile.c
*
- * Time-stamp: "2012-08-11 08:34:55 bkorb"
- *
* configuration/rc/ini file handling.
*
* This file is part of AutoOpts, a companion to AutoGen.
static void
file_preset(tOptions * opts, char const * fname, int dir);
-static char*
-handle_comment(char* pzText);
+static char *
+handle_comment(char* txt);
static char *
-handle_cfg(tOptions * pOpts, tOptState * pOS, char * pzText, int dir);
+handle_cfg(tOptions * opts, tOptState * ost, char * txt, int dir);
static char *
-handle_directive(tOptions * pOpts, char * pzText);
+handle_directive(tOptions * opts, char * txt);
static char *
-aoflags_directive(tOptions * pOpts, char * pzText);
+aoflags_directive(tOptions * opts, char * txt);
static char *
-program_directive(tOptions * pOpts, char * pzText);
+program_directive(tOptions * opts, char * txt);
static char *
-handle_section(tOptions * pOpts, char * pzText);
+handle_section(tOptions * opts, char * txt);
static int
parse_xml_encoding(char ** ppz);
cook_xml_text(char * pzData);
static char *
-handle_struct(tOptions * pOpts, tOptState * pOS, char * pzText, int dir);
-
-static char*
-parse_keyword(tOptions * pOpts, char * pzText, tOptionValue * pType);
+handle_struct(tOptions * opts, tOptState * ost, char * txt, int dir);
-static char*
-parse_set_mem(tOptions * pOpts, char * pzText, tOptionValue * pType);
+static char *
+parse_keyword(tOptions * opts, char * txt, tOptionValue * typ);
static char *
-parse_value(char * pzText, tOptionValue * pType);
+parse_set_mem(tOptions * opts, char * txt, tOptionValue * typ);
static char *
-skip_unkn(char* pzText);
+parse_value(char * txt, tOptionValue * typ);
/* = = = END-STATIC-FORWARD = = = */
+/**
+ * Skip over some unknown attribute
+ * @param[in] txt start of skpped text
+ * @returns character after skipped text
+ */
+inline static char *
+skip_unkn(char * txt)
+{
+ txt = BRK_END_XML_TOKEN_CHARS(txt);
+ return (*txt == NUL) ? NULL : txt;
+}
/*=export_func configFileLoad
*
* what: parse a configuration file
- * arg: + char const* + pzFile + the file to load +
+ * arg: + char const* + fname + the file to load +
*
* ret_type: const tOptionValue*
* ret_desc: An allocated, compound value structure
* @code{ENOMEM} - not enough memory to allocate the needed structures.
* @end itemize
=*/
-const tOptionValue*
-configFileLoad(char const* pzFile)
+const tOptionValue *
+configFileLoad(char const * fname)
{
- tmap_info_t cfgfile;
- tOptionValue* pRes = NULL;
+ tmap_info_t cfgfile;
+ tOptionValue * res = NULL;
tOptionLoadMode save_mode = option_load_mode;
- char* pzText =
- text_mmap(pzFile, PROT_READ, MAP_PRIVATE, &cfgfile);
+ char * txt = text_mmap(fname, PROT_READ, MAP_PRIVATE, &cfgfile);
- if (TEXT_MMAP_FAILED_ADDR(pzText))
+ if (TEXT_MMAP_FAILED_ADDR(txt))
return NULL; /* errno is set */
option_load_mode = OPTION_LOAD_COOKED;
- pRes = optionLoadNested(pzText, pzFile, strlen(pzFile));
+ res = optionLoadNested(txt, fname, strlen(fname));
- if (pRes == NULL) {
+ if (res == NULL) {
int err = errno;
text_munmap(&cfgfile);
errno = err;
text_munmap(&cfgfile);
option_load_mode = save_mode;
- return pRes;
+ return res;
}
/*=export_func optionFindValue
*
* what: find a hierarcicaly valued option instance
- * arg: + const tOptDesc* + pOptDesc + an option with a nested arg type +
- * arg: + char const* + name + name of value to find +
- * arg: + char const* + value + the matching value +
+ * arg: + const tOptDesc* + odesc + an option with a nested arg type +
+ * arg: + char const* + name + name of value to find +
+ * arg: + char const* + val + the matching value +
*
* ret_type: const tOptionValue*
* ret_desc: a compound value structure
* @code{ENOENT} - no entry matched the given name.
* @end itemize
=*/
-const tOptionValue*
-optionFindValue(const tOptDesc* pOptDesc, char const* pzName,
- char const* pzVal)
+const tOptionValue *
+optionFindValue(const tOptDesc * odesc, char const * name, char const * val)
{
- const tOptionValue* pRes = NULL;
+ const tOptionValue * res = NULL;
- if ( (pOptDesc == NULL)
- || (OPTST_GET_ARGTYPE(pOptDesc->fOptState) != OPARG_TYPE_HIERARCHY)) {
+ if ( (odesc == NULL)
+ || (OPTST_GET_ARGTYPE(odesc->fOptState) != OPARG_TYPE_HIERARCHY)) {
errno = EINVAL;
}
- else if (pOptDesc->optCookie == NULL) {
+ else if (odesc->optCookie == NULL) {
errno = ENOENT;
}
else do {
- tArgList* pAL = pOptDesc->optCookie;
- int ct = pAL->useCt;
- void** ppOV = (void**)(pAL->apzArgs);
+ tArgList* argl = odesc->optCookie;
+ int argct = argl->useCt;
+ void ** poptv = (void**)(argl->apzArgs);
- if (ct == 0) {
+ if (argct == 0) {
errno = ENOENT;
break;
}
- if (pzName == NULL) {
- pRes = (tOptionValue*)*ppOV;
+ if (name == NULL) {
+ res = (tOptionValue*)*poptv;
break;
}
- while (--ct >= 0) {
- const tOptionValue* pOV = *(ppOV++);
- const tOptionValue* pRV = optionGetValue(pOV, pzName);
+ while (--argct >= 0) {
+ const tOptionValue * ov = *(poptv++);
+ const tOptionValue * rv = optionGetValue(ov, name);
- if (pRV == NULL)
+ if (rv == NULL)
continue;
- if (pzVal == NULL) {
- pRes = pOV;
+ if (val == NULL) {
+ res = ov;
break;
}
}
- if (pRes == NULL)
+ if (res == NULL)
errno = ENOENT;
} while (false);
- return pRes;
+ return res;
}
* FIXME: the handling of 'pzName' and 'pzVal' is just wrong.
*
* what: find a hierarcicaly valued option instance
- * arg: + const tOptDesc* + pOptDesc + an option with a nested arg type +
+ * arg: + const tOptDesc* + odesc + an option with a nested arg type +
* arg: + const tOptionValue* + pPrevVal + the last entry +
* arg: + char const* + name + name of value to find +
* arg: + char const* + value + the matching value +
* @end itemize
=*/
tOptionValue const *
-optionFindNextValue(const tOptDesc * pOptDesc, const tOptionValue * pPrevVal,
+optionFindNextValue(const tOptDesc * odesc, const tOptionValue * pPrevVal,
char const * pzName, char const * pzVal)
{
bool old_found = false;
- tOptionValue* pRes = NULL;
+ tOptionValue* res = NULL;
(void)pzName;
(void)pzVal;
- if ( (pOptDesc == NULL)
- || (OPTST_GET_ARGTYPE(pOptDesc->fOptState) != OPARG_TYPE_HIERARCHY)) {
+ if ( (odesc == NULL)
+ || (OPTST_GET_ARGTYPE(odesc->fOptState) != OPARG_TYPE_HIERARCHY)) {
errno = EINVAL;
}
- else if (pOptDesc->optCookie == NULL) {
+ else if (odesc->optCookie == NULL) {
errno = ENOENT;
}
else do {
- tArgList* pAL = pOptDesc->optCookie;
- int ct = pAL->useCt;
- void** ppOV = (void**)pAL->apzArgs;
+ tArgList* argl = odesc->optCookie;
+ int ct = argl->useCt;
+ void** poptv = (void**)argl->apzArgs;
while (--ct >= 0) {
- tOptionValue* pOV = *(ppOV++);
+ tOptionValue* pOV = *(poptv++);
if (old_found) {
- pRes = pOV;
+ res = pOV;
break;
}
if (pOV == pPrevVal)
old_found = true;
}
- if (pRes == NULL)
+ if (res == NULL)
errno = ENOENT;
} while (false);
- return pRes;
+ return res;
}
* @code{ENOENT} - no entry matched the given name.
* @end itemize
=*/
-const tOptionValue*
-optionGetValue(tOptionValue const * pOld, char const * pzValName)
+tOptionValue const *
+optionGetValue(tOptionValue const * oov, char const * vname)
{
- tArgList * pAL;
- tOptionValue * pRes = NULL;
+ tArgList * arg_list;
+ tOptionValue * res = NULL;
- if ((pOld == NULL) || (pOld->valType != OPARG_TYPE_HIERARCHY)) {
+ if ((oov == NULL) || (oov->valType != OPARG_TYPE_HIERARCHY)) {
errno = EINVAL;
- return pRes;
+ return res;
}
- pAL = pOld->v.nestVal;
+ arg_list = oov->v.nestVal;
- if (pAL->useCt > 0) {
- int ct = pAL->useCt;
- void ** papOV = (void**)(pAL->apzArgs);
+ if (arg_list->useCt > 0) {
+ int ct = arg_list->useCt;
+ void ** ovlist = (void**)(arg_list->apzArgs);
- if (pzValName == NULL) {
- pRes = (tOptionValue*)*papOV;
+ if (vname == NULL) {
+ res = (tOptionValue*)*ovlist;
} else do {
- tOptionValue * pOV = *(papOV++);
- if (strcmp(pOV->pzName, pzValName) == 0) {
- pRes = pOV;
+ tOptionValue * opt_val = *(ovlist++);
+ if (strcmp(opt_val->pzName, vname) == 0) {
+ res = opt_val;
break;
}
} while (--ct > 0);
}
- if (pRes == NULL)
+ if (res == NULL)
errno = ENOENT;
- return pRes;
+ return res;
}
-
/*=export_func optionNextValue
*
* what: get the next value from a hierarchical list
* @end itemize
=*/
tOptionValue const *
-optionNextValue(tOptionValue const * pOVList,tOptionValue const * pOldOV )
+optionNextValue(tOptionValue const * ov_list,tOptionValue const * oov )
{
- tArgList* pAL;
- tOptionValue* pRes = NULL;
- int err = EINVAL;
+ tArgList * arg_list;
+ tOptionValue * res = NULL;
+ int err = EINVAL;
- if ((pOVList == NULL) || (pOVList->valType != OPARG_TYPE_HIERARCHY)) {
+ if ((ov_list == NULL) || (ov_list->valType != OPARG_TYPE_HIERARCHY)) {
errno = EINVAL;
return NULL;
}
- pAL = pOVList->v.nestVal;
+ arg_list = ov_list->v.nestVal;
{
- int ct = pAL->useCt;
- void** papNV = (void**)(pAL->apzArgs);
+ int ct = arg_list->useCt;
+ void ** o_list = (void**)(arg_list->apzArgs);
while (ct-- > 0) {
- tOptionValue* pNV = *(papNV++);
- if (pNV == pOldOV) {
+ tOptionValue * nov = *(o_list++);
+ if (nov == oov) {
if (ct == 0) {
err = ENOENT;
} else {
- err = 0;
- pRes = (tOptionValue*)*papNV;
+ err = 0;
+ res = (tOptionValue*)*o_list;
}
break;
}
}
if (err != 0)
errno = err;
- return pRes;
+ return res;
}
-
/**
* Load a file containing presetting information (a configuration file).
*/
static void
file_preset(tOptions * opts, char const * fname, int dir)
{
- tmap_info_t cfgfile;
- tOptState optst = OPTSTATE_INITIALIZER(PRESET);
- unsigned long st_flags = optst.flags;
- char * ftext =
+ tmap_info_t cfgfile;
+ tOptState optst = OPTSTATE_INITIALIZER(PRESET);
+ opt_state_mask_t st_flags = optst.flags;
+ char * ftext =
text_mmap(fname, PROT_READ|PROT_WRITE, MAP_PRIVATE, &cfgfile);
if (TEXT_MMAP_FAILED_ADDR(ftext))
break;
default:
- goto all_done;
+ ftext = NULL;
}
+ if (ftext == NULL)
+ goto all_done;
break;
case '[':
}
} while (ftext != NULL);
-all_done:
+ all_done:
text_munmap(&cfgfile);
}
-
/**
- * "pzText" points to a "<!" sequence.
+ * "txt" points to a "<!" sequence.
* Theoretically, we should ensure that it begins with "<!--",
* but actually I don't care that much. It ends with "-->".
*/
-static char*
-handle_comment(char* pzText)
+static char *
+handle_comment(char* txt)
{
- char* pz = strstr(pzText, "-->");
+ char* pz = strstr(txt, "-->");
if (pz != NULL)
pz += 3;
return pz;
}
-
/**
- * "pzText" points to the start of some value name.
+ * "txt" points to the start of some value name.
* The end of the entry is the end of the line that is not preceded by
* a backslash escape character. The string value is always processed
* in "cooked" mode.
*/
static char *
-handle_cfg(tOptions * pOpts, tOptState * pOS, char * pzText, int dir)
+handle_cfg(tOptions * opts, tOptState * ost, char * txt, int dir)
{
- char* pzName = pzText++;
- char* pzEnd = strchr(pzText, NL);
+ char* pzName = txt++;
+ char* pzEnd = strchr(txt, NL);
if (pzEnd == NULL)
- return pzText + strlen(pzText);
+ return txt + strlen(txt);
- pzText = SPN_VALUE_NAME_CHARS(pzText);
- pzText = SPN_WHITESPACE_CHARS(pzText);
- if (pzText > pzEnd) {
+ txt = SPN_VALUE_NAME_CHARS(txt);
+ txt = SPN_WHITESPACE_CHARS(txt);
+ if (txt > pzEnd) {
name_only:
*pzEnd++ = NUL;
- loadOptionLine(pOpts, pOS, pzName, dir, OPTION_LOAD_UNCOOKED);
+ loadOptionLine(opts, ost, pzName, dir, OPTION_LOAD_UNCOOKED);
return pzEnd;
}
* or else we must have skipped over white space. Anything else
* is an invalid format and we give up parsing the text.
*/
- if ((*pzText == '=') || (*pzText == ':')) {
- pzText = SPN_WHITESPACE_CHARS(pzText+1);
- if (pzText > pzEnd)
+ if ((*txt == '=') || (*txt == ':')) {
+ txt = SPN_WHITESPACE_CHARS(txt+1);
+ if (txt > pzEnd)
goto name_only;
- } else if (! IS_WHITESPACE_CHAR(pzText[-1]))
+ } else if (! IS_WHITESPACE_CHAR(txt[-1]))
return NULL;
/*
* "pzName" points to what looks like text for one option/configurable.
* It is NUL terminated. Process it.
*/
- loadOptionLine(pOpts, pOS, pzName, dir, OPTION_LOAD_UNCOOKED);
+ loadOptionLine(opts, ost, pzName, dir, OPTION_LOAD_UNCOOKED);
return pzEnd;
}
-
/**
- * "pzText" points to a "<?" sequence.
+ * "txt" points to a "<?" sequence.
* We handle "<?program" and "<?auto-options" directives.
* All others are treated as comments.
+ *
+ * @param[in,out] opts program option descriptor
+ * @param[in] txt scanning pointer
+ * @returns the next character to look at
*/
static char *
-handle_directive(tOptions * pOpts, char * pzText)
+handle_directive(tOptions * opts, char * txt)
{
# define DIRECTIVE_TABLE \
_dt_(zCfgProg, program_directive) \
for (ix = 0; ix < dir_ct; ix++) {
size_t len = strlen(dir_names[ix]);
- if ( (strncmp(pzText + 2, dir_names[ix], len) == 0)
- && (! IS_VALUE_NAME_CHAR(pzText[len+2])) )
- return dir_disp[ix](pOpts, pzText + len + 2);
+ if ( (strncmp(txt + 2, dir_names[ix], len) == 0)
+ && (! IS_VALUE_NAME_CHAR(txt[len+2])) )
+ return dir_disp[ix](opts, txt + len + 2);
}
/*
* We don't know what this is. Skip it.
*/
- pzText = strchr(pzText+2, '>');
- if (pzText != NULL)
- pzText++;
- return pzText;
+ txt = strchr(txt+2, '>');
+ if (txt != NULL)
+ txt++;
+ return txt;
+# undef DIRECTIVE_TABLE
}
/**
- * handle AutoOpts mode flags
+ * handle AutoOpts mode flags.
+ *
+ * @param[in,out] opts program option descriptor
+ * @param[in] txt scanning pointer
+ * @returns the next character to look at
*/
static char *
-aoflags_directive(tOptions * pOpts, char * pzText)
+aoflags_directive(tOptions * opts, char * txt)
{
char * pz;
- pz = SPN_WHITESPACE_CHARS(pzText+1);
- pzText = strchr(pz, '>');
- if (pzText != NULL) {
+ pz = SPN_WHITESPACE_CHARS(txt+1);
+ txt = strchr(pz, '>');
+ if (txt != NULL) {
- size_t len = pzText - pz;
+ size_t len = (unsigned)(txt - pz);
char * ftxt = AGALOC(len + 1, "aoflags");
memcpy(ftxt, pz, len);
ftxt[len] = NUL;
- set_usage_flags(pOpts, ftxt);
+ set_usage_flags(opts, ftxt);
AGFREE(ftxt);
- pzText++;
+ txt++;
}
- return pzText;
+ return txt;
}
/**
* handle program segmentation of config file.
+ *
+ * @param[in,out] opts program option descriptor
+ * @param[in] txt scanning pointer
+ * @returns the next character to look at
*/
static char *
-program_directive(tOptions * pOpts, char * pzText)
+program_directive(tOptions * opts, char * txt)
{
static char const ttlfmt[] = "<?";
size_t ttl_len = sizeof(ttlfmt) + strlen(zCfgProg);
char * ttl = AGALOC(ttl_len, "prog title");
- size_t name_len = strlen(pOpts->pzProgName);
+ size_t name_len = strlen(opts->pzProgName);
memcpy(ttl, ttlfmt, sizeof(ttlfmt) - 1);
memcpy(ttl + sizeof(ttlfmt) - 1, zCfgProg, ttl_len - (sizeof(ttlfmt) - 1));
do {
- pzText = SPN_WHITESPACE_CHARS(pzText+1);
+ txt = SPN_WHITESPACE_CHARS(txt+1);
- if ( (strneqvcmp(pzText, pOpts->pzProgName, (int)name_len) == 0)
- && (IS_END_XML_TOKEN_CHAR(pzText[name_len])) ) {
- pzText += name_len;
+ if ( (strneqvcmp(txt, opts->pzProgName, (int)name_len) == 0)
+ && (IS_END_XML_TOKEN_CHAR(txt[name_len])) ) {
+ txt += name_len;
break;
}
- pzText = strstr(pzText, ttl);
- } while (pzText != NULL);
+ txt = strstr(txt, ttl);
+ } while (txt != NULL);
AGFREE(ttl);
- if (pzText != NULL)
+ if (txt != NULL)
for (;;) {
- if (*pzText == NUL) {
- pzText = NULL;
+ if (*txt == NUL) {
+ txt = NULL;
break;
}
- if (*(pzText++) == '>')
+ if (*(txt++) == '>')
break;
}
- return pzText;
+ return txt;
}
-
/**
- * "pzText" points to a '[' character.
+ * "txt" points to a '[' character.
* The "traditional" [PROG_NAME] segmentation of the config file.
* Do not ever mix with the "<?program prog-name>" variation.
+ *
+ * @param[in,out] opts program option descriptor
+ * @param[in] txt scanning pointer
+ * @returns the next character to look at
*/
static char *
-handle_section(tOptions * pOpts, char * pzText)
+handle_section(tOptions * opts, char * txt)
{
- size_t len = strlen(pOpts->pzPROGNAME);
- if ( (strncmp(pzText+1, pOpts->pzPROGNAME, len) == 0)
- && (pzText[len+1] == ']'))
- return strchr(pzText + len + 2, NL);
+ size_t len = strlen(opts->pzPROGNAME);
+ if ( (strncmp(txt+1, opts->pzPROGNAME, len) == 0)
+ && (txt[len+1] == ']'))
+ return strchr(txt + len + 2, NL);
if (len > 16)
return NULL;
{
char z[24];
- sprintf(z, "[%s]", pOpts->pzPROGNAME);
- pzText = strstr(pzText, z);
+ sprintf(z, "[%s]", opts->pzPROGNAME);
+ txt = strstr(txt, z);
}
- if (pzText != NULL)
- pzText = strchr(pzText, NL);
- return pzText;
+ if (txt != NULL)
+ txt = strchr(txt, NL);
+ return txt;
}
/**
if (len >= sizeof(z))
pz = AGALOC(len, "scan name");
- len = sprintf(pz, fmt, pznm);
+ len = (size_t)sprintf(pz, fmt, pznm);
*intxt = ' ';
etext = strstr(intxt, pz);
if (pz != z) AGFREE(pz);
return;
}
- ch = strtoul(bf, NULL, 16);
+ ch = (int)strtoul(bf, NULL, 16);
/* FALLTHROUGH */
default:
}
/**
- * "pzText" points to a '<' character, followed by an alpha.
+ * "txt" points to a '<' character, followed by an alpha.
* The end of the entry is either the "/>" following the name, or else a
* "</name>" string.
*/
static char *
-handle_struct(tOptions * pOpts, tOptState * pOS, char * pzText, int dir)
+handle_struct(tOptions * opts, tOptState * ost, char * txt, int dir)
{
tOptionLoadMode mode = option_load_mode;
tOptionValue valu;
- char* pzName = ++pzText;
+ char* pzName = ++txt;
char* pzData;
char* pcNulPoint;
- pzText = SPN_VALUE_NAME_CHARS(pzText);
- pcNulPoint = pzText;
+ txt = SPN_VALUE_NAME_CHARS(txt);
+ pcNulPoint = txt;
valu.valType = OPARG_TYPE_STRING;
- switch (*pzText) {
+ switch (*txt) {
case ' ':
case '\t':
- pzText = parse_attrs(pOpts, pzText, &mode, &valu);
- if (*pzText == '>')
+ txt = parse_attrs(opts, SPN_WHITESPACE_CHARS(txt), &mode, &valu);
+ if (txt == NULL)
+ return txt;
+ if (*txt == '>')
break;
- if (*pzText != '/')
+ if (*txt != '/')
return NULL;
/* FALLTHROUGH */
case '/':
- if (pzText[1] != '>')
+ if (txt[1] != '>')
return NULL;
- *pzText = NUL;
- pzText += 2;
- loadOptionLine(pOpts, pOS, pzName, dir, mode);
- return pzText;
+ *txt = NUL;
+ txt += 2;
+ loadOptionLine(opts, ost, pzName, dir, mode);
+ return txt;
case '>':
break;
default:
- pzText = strchr(pzText, '>');
- if (pzText != NULL)
- pzText++;
- return pzText;
+ txt = strchr(txt, '>');
+ if (txt != NULL)
+ txt++;
+ return txt;
}
/*
- * If we are here, we have a value. "pzText" points to a closing angle
+ * If we are here, we have a value. "txt" points to a closing angle
* bracket. Separate the name from the value for a moment.
*/
*pcNulPoint = NUL;
- pzData = ++pzText;
- pzText = trim_xml_text(pzText, pzName, mode);
- if (pzText == NULL)
- return pzText;
+ pzData = ++txt;
+ txt = trim_xml_text(txt, pzName, mode);
+ if (txt == NULL)
+ return txt;
/*
* Rejoin the name and value for parsing by "loadOptionLine()".
* Erase any attributes parsed by "parse_attrs()".
*/
- memset(pcNulPoint, ' ', pzData - pcNulPoint);
+ memset(pcNulPoint, ' ', (size_t)(pzData - pcNulPoint));
/*
* If we are getting a "string" value that is to be cooked,
* "pzName" points to what looks like text for one option/configurable.
* It is NUL terminated. Process it.
*/
- loadOptionLine(pOpts, pOS, pzName, dir, mode);
+ loadOptionLine(opts, ost, pzName, dir, mode);
- return pzText;
+ return txt;
}
-
/**
* Load a configuration file. This may be invoked either from
* scanning the "homerc" list, or from a specific file request.
* (see "optionFileLoad()", the implementation for --load-opts)
*/
LOCAL void
-intern_file_load(tOptions* pOpts)
+intern_file_load(tOptions * opts)
{
uint32_t svfl;
int idx;
int inc;
- char zFileName[ AG_PATH_MAX+1 ];
+ char f_name[ AG_PATH_MAX+1 ];
- if (pOpts->papzHomeList == NULL)
+ if (opts->papzHomeList == NULL)
return;
- svfl = pOpts->fOptSet;
+ svfl = opts->fOptSet;
inc = DIRECTION_PRESET;
/*
* Never stop on errors in config files.
*/
- pOpts->fOptSet &= ~OPTPROC_ERRSTOP;
+ opts->fOptSet &= ~OPTPROC_ERRSTOP;
/*
* Find the last RC entry (highest priority entry)
*/
- for (idx = 0; pOpts->papzHomeList[ idx+1 ] != NULL; ++idx) ;
+ for (idx = 0; opts->papzHomeList[ idx+1 ] != NULL; ++idx) ;
/*
* For every path in the home list, ... *TWICE* We start at the last
* Then we go back up, doing the normal options.
*/
for (;;) {
- struct stat StatBuf;
- cch_t* pzPath;
+ struct stat sb;
+ cch_t * path;
/*
* IF we've reached the bottom end, change direction
idx = 0;
}
- pzPath = pOpts->papzHomeList[ idx ];
+ path = opts->papzHomeList[ idx ];
/*
* IF we've reached the top end, bail out
*/
- if (pzPath == NULL)
+ if (path == NULL)
break;
idx += inc;
- if (! optionMakePath(zFileName, (int)sizeof(zFileName),
- pzPath, pOpts->pzProgPath))
+ if (! optionMakePath(f_name, (int)sizeof(f_name),
+ path, opts->pzProgPath))
continue;
/*
* THEN append the Resource Configuration file name
* ELSE we must have the complete file name
*/
- if (stat(zFileName, &StatBuf) != 0)
+ if (stat(f_name, &sb) != 0)
continue; /* bogus name - skip the home list entry */
- if (S_ISDIR(StatBuf.st_mode)) {
- size_t len = strlen(zFileName);
- size_t nln = strlen(pOpts->pzRcName) + 1;
- char * pz = zFileName + len;
+ if (S_ISDIR(sb.st_mode)) {
+ size_t len = strlen(f_name);
+ size_t nln = strlen(opts->pzRcName) + 1;
+ char * pz = f_name + len;
- if (len + 1 + nln >= sizeof(zFileName))
+ if (len + 1 + nln >= sizeof(f_name))
continue;
if (pz[-1] != DIRCH)
*(pz++) = DIRCH;
- memcpy(pz, pOpts->pzRcName, nln);
+ memcpy(pz, opts->pzRcName, nln);
}
- file_preset(pOpts, zFileName, inc);
+ file_preset(opts, f_name, inc);
/*
* IF we are now to skip config files AND we are presetting,
* THEN change direction. We must go the other way.
*/
{
- tOptDesc * pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts+1;
- if (DISABLED_OPT(pOD) && PRESETTING(inc)) {
+ tOptDesc * od = opts->pOptDesc + opts->specOptIdx.save_opts + 1;
+ if (DISABLED_OPT(od) && PRESETTING(inc)) {
idx -= inc; /* go back and reprocess current file */
inc = DIRECTION_PROCESS;
}
}
} /* twice for every path in the home list, ... */
- pOpts->fOptSet = svfl;
+ opts->fOptSet = svfl;
}
-
/*=export_func optionFileLoad
*
* what: Load the locatable config files, in order
*
- * arg: + tOptions* + pOpts + program options descriptor +
- * arg: + char const* + pzProg + program name +
+ * arg: + tOptions* + opts + program options descriptor +
+ * arg: + char const* + prog + program name +
*
* ret_type: int
* ret_desc: 0 -> SUCCESS, -1 -> FAILURE
* always be returned.
=*/
int
-optionFileLoad(tOptions * pOpts, char const * pzProgram)
+optionFileLoad(tOptions * opts, char const * prog)
{
- if (! SUCCESSFUL(validate_struct(pOpts, pzProgram)))
+ if (! SUCCESSFUL(validate_struct(opts, prog)))
return -1;
+ /*
+ * The pointer to the program name is "const". However, the
+ * structure is in writable memory, so we coerce the address
+ * of this pointer to point to writable memory.
+ */
{
char const ** pp =
- (char const **)(void *)&(pOpts->pzProgName);
- *pp = pzProgram;
+ (char const **)(void *)&(opts->pzProgName);
+ *pp = prog;
}
- intern_file_load(pOpts);
+ intern_file_load(opts);
return 0;
}
-
/*=export_func optionLoadOpt
* private:
*
* what: Load an option rc/ini file
- * arg: + tOptions* + pOpts + program options descriptor +
- * arg: + tOptDesc* + pOptDesc + the descriptor for this arg +
+ * arg: + tOptions* + opts + program options descriptor +
+ * arg: + tOptDesc* + odesc + the descriptor for this arg +
*
* doc:
* Processes the options found in the file named with
- * pOptDesc->optArg.argString.
+ * odesc->optArg.argString.
=*/
void
-optionLoadOpt(tOptions * pOpts, tOptDesc * pOptDesc)
+optionLoadOpt(tOptions * opts, tOptDesc * odesc)
{
struct stat sb;
- if (pOpts <= OPTPROC_EMIT_LIMIT)
+ if (opts <= OPTPROC_EMIT_LIMIT)
return;
/*
* already took place. It must be done to suppress preloading of ini/rc
* files.)
*/
- if ( DISABLED_OPT(pOptDesc)
- || ((pOptDesc->fOptState & OPTST_RESET) != 0))
+ if ( DISABLED_OPT(odesc)
+ || ((odesc->fOptState & OPTST_RESET) != 0))
return;
- if (stat(pOptDesc->optArg.argString, &sb) != 0) {
- if ((pOpts->fOptSet & OPTPROC_ERRSTOP) == 0)
+ if (stat(odesc->optArg.argString, &sb) != 0) {
+ if ((opts->fOptSet & OPTPROC_ERRSTOP) == 0)
return;
fprintf(stderr, zFSErrOptLoad, errno, strerror(errno),
- pOptDesc->optArg.argString);
+ odesc->optArg.argString);
exit(EX_NOINPUT);
/* NOT REACHED */
}
if (! S_ISREG(sb.st_mode)) {
- if ((pOpts->fOptSet & OPTPROC_ERRSTOP) == 0)
+ if ((opts->fOptSet & OPTPROC_ERRSTOP) == 0)
return;
- fprintf(stderr, zNotFile, pOptDesc->optArg.argString);
+ fprintf(stderr, zNotFile, odesc->optArg.argString);
exit(EX_NOINPUT);
/* NOT REACHED */
}
- file_preset(pOpts, pOptDesc->optArg.argString, DIRECTION_CALLED);
+ file_preset(opts, odesc->optArg.argString, DIRECTION_CALLED);
}
-
/**
* Parse the various attributes of an XML-styled config file entry
+ *
+ * @returns NULL on failure, otherwise the scan point
*/
LOCAL char*
-parse_attrs(tOptions * pOpts, char * pzText, tOptionLoadMode * pMode,
+parse_attrs(tOptions * opts, char * txt, tOptionLoadMode * pMode,
tOptionValue * pType)
{
size_t len;
- do {
- if (! IS_WHITESPACE_CHAR(*pzText))
- switch (*pzText) {
- case '/': pType->valType = OPARG_TYPE_NONE;
- /* FALLTHROUGH */
- case '>': return pzText;
-
- default:
- case NUL: return NULL;
- }
-
- pzText = SPN_WHITESPACE_CHARS(pzText+1);
- len = SPN_LOWER_CASE_CHARS(pzText) - pzText;
+ for (;;) {
+ len = (size_t)(SPN_LOWER_CASE_CHARS(txt) - txt);
- switch (find_xat_attribute_id(pzText, len)) {
- case XAT_KWD_TYPE:
- pzText = parse_value(pzText+len, pType);
+ switch (find_option_xat_attribute_cmd(txt, len)) {
+ case XAT_CMD_TYPE:
+ txt = parse_value(txt+len, pType);
break;
- case XAT_KWD_WORDS:
- pzText = parse_keyword(pOpts, pzText+len, pType);
+ case XAT_CMD_WORDS:
+ txt = parse_keyword(opts, txt+len, pType);
break;
- case XAT_KWD_MEMBERS:
- pzText = parse_set_mem(pOpts, pzText+len, pType);
+ case XAT_CMD_MEMBERS:
+ txt = parse_set_mem(opts, txt+len, pType);
break;
- case XAT_KWD_COOKED:
- pzText += len;
- if (! IS_END_XML_TOKEN_CHAR(*pzText))
+ case XAT_CMD_COOKED:
+ txt += len;
+ if (! IS_END_XML_TOKEN_CHAR(*txt))
goto invalid_kwd;
*pMode = OPTION_LOAD_COOKED;
break;
- case XAT_KWD_UNCOOKED:
- pzText += len;
- if (! IS_END_XML_TOKEN_CHAR(*pzText))
+ case XAT_CMD_UNCOOKED:
+ txt += len;
+ if (! IS_END_XML_TOKEN_CHAR(*txt))
goto invalid_kwd;
*pMode = OPTION_LOAD_UNCOOKED;
break;
- case XAT_KWD_KEEP:
- pzText += len;
- if (! IS_END_XML_TOKEN_CHAR(*pzText))
+ case XAT_CMD_KEEP:
+ txt += len;
+ if (! IS_END_XML_TOKEN_CHAR(*txt))
goto invalid_kwd;
*pMode = OPTION_LOAD_KEEP;
break;
default:
- case XAT_KWD_INVALID:
+ case XAT_INVALID_CMD:
invalid_kwd:
pType->valType = OPARG_TYPE_NONE;
- return skip_unkn(pzText);
+ return skip_unkn(txt);
}
- } while (pzText != NULL);
- return pzText;
+ if (txt == NULL)
+ return NULL;
+ txt = SPN_WHITESPACE_CHARS(txt);
+ switch (*txt) {
+ case '/': pType->valType = OPARG_TYPE_NONE;
+ /* FALLTHROUGH */
+ case '>': return txt;
+ }
+ if (! IS_LOWER_CASE_CHAR(*txt))
+ return NULL;
+ }
}
-
/**
- * "pzText" points to the character after "words=".
+ * "txt" points to the character after "words=".
* What should follow is a name of a keyword (enumeration) list.
+ *
+ * @param opts unused
+ * @param[in] txt keyword to skip over
+ * @param type unused value type
+ * @returns pointer after skipped text
*/
-static char*
-parse_keyword(tOptions * pOpts, char * pzText, tOptionValue * pType)
+static char *
+parse_keyword(tOptions * opts, char * txt, tOptionValue * typ)
{
- (void)pOpts;
- (void)pType;
+ (void)opts;
+ (void)typ;
- return skip_unkn(pzText);
+ return skip_unkn(txt);
}
-
/**
- * "pzText" points to the character after "members="
+ * "txt" points to the character after "members="
* What should follow is a name of a "set membership".
* A collection of bit flags.
+ *
+ * @param opts unused
+ * @param[in] txt keyword to skip over
+ * @param type unused value type
+ * @returns pointer after skipped text
*/
-static char*
-parse_set_mem(tOptions * pOpts, char * pzText, tOptionValue * pType)
+static char *
+parse_set_mem(tOptions * opts, char * txt, tOptionValue * typ)
{
- (void)pOpts;
- (void)pType;
+ (void)opts;
+ (void)typ;
- return skip_unkn(pzText);
+ return skip_unkn(txt);
}
-
/**
- * "pzText" points to the character after "type="
+ * parse the type. The keyword "type" was found, now figure out
+ * the type that follows the type.
+ *
+ * @param[in] txt points to the '=' character after the "type" keyword.
+ * @param[out] typ where to store the type found
+ * @returns the next byte after the type name
*/
static char *
-parse_value(char * pzText, tOptionValue * pType)
+parse_value(char * txt, tOptionValue * typ)
{
size_t len = 0;
- if (*(pzText++) != '=')
+ if (*(txt++) != '=')
goto woops;
- len = SPN_OPTION_NAME_CHARS(pzText) - pzText;
+ len = (size_t)(SPN_OPTION_NAME_CHARS(txt) - txt);
- if ((len == 0) || (! IS_END_XML_TOKEN_CHAR(pzText[len]))) {
+ if ((len == 0) || (! IS_END_XML_TOKEN_CHAR(txt[len]))) {
woops:
- pType->valType = OPARG_TYPE_NONE;
- return skip_unkn(pzText + len);
+ typ->valType = OPARG_TYPE_NONE;
+ return skip_unkn(txt + len);
}
- switch (find_value_type_id(pzText, len)) {
+ switch (find_option_value_type_cmd(txt, len)) {
default:
- case VTP_KWD_INVALID: goto woops;
+ case VTP_INVALID_CMD: goto woops;
- case VTP_KWD_STRING:
- pType->valType = OPARG_TYPE_STRING;
+ case VTP_CMD_STRING:
+ typ->valType = OPARG_TYPE_STRING;
break;
- case VTP_KWD_INTEGER:
- pType->valType = OPARG_TYPE_NUMERIC;
+ case VTP_CMD_INTEGER:
+ typ->valType = OPARG_TYPE_NUMERIC;
break;
- case VTP_KWD_BOOL:
- case VTP_KWD_BOOLEAN:
- pType->valType = OPARG_TYPE_BOOLEAN;
+ case VTP_CMD_BOOL:
+ case VTP_CMD_BOOLEAN:
+ typ->valType = OPARG_TYPE_BOOLEAN;
break;
- case VTP_KWD_KEYWORD:
- pType->valType = OPARG_TYPE_ENUMERATION;
+ case VTP_CMD_KEYWORD:
+ typ->valType = OPARG_TYPE_ENUMERATION;
break;
- case VTP_KWD_SET:
- case VTP_KWD_SET_MEMBERSHIP:
- pType->valType = OPARG_TYPE_MEMBERSHIP;
+ case VTP_CMD_SET:
+ case VTP_CMD_SET_MEMBERSHIP:
+ typ->valType = OPARG_TYPE_MEMBERSHIP;
break;
- case VTP_KWD_NESTED:
- case VTP_KWD_HIERARCHY:
- pType->valType = OPARG_TYPE_HIERARCHY;
- }
-
- return pzText + len;
-}
-
-
-/**
- * Skip over some unknown attribute
- */
-static char *
-skip_unkn(char* pzText)
-{
- for (;; pzText++) {
- if (IS_END_XML_TOKEN_CHAR(*pzText)) return pzText;
- if (*pzText == NUL) return NULL;
- }
-}
-
-
-/**
- * Make sure the option descriptor is there and that we understand it.
- * This should be called from any user entry point where one needs to
- * worry about validity. (Some entry points are free to assume that
- * the call is not the first to the library and, thus, that this has
- * already been called.)
- *
- * Upon successful completion, pzProgName and pzProgPath are set.
- *
- * @param pOpts program options descriptor
- * @param pzProgram name of program, from argv[]
- * @returns SUCCESS or FAILURE
- */
-LOCAL tSuccess
-validate_struct(tOptions * pOpts, char const * pzProgram)
-{
- if (pOpts == NULL) {
- fputs(zAO_Bad, stderr);
- return FAILURE;
- }
-
- /*
- * IF the client has enabled translation and the translation procedure
- * is available, then go do it.
- */
- if ( ((pOpts->fOptSet & OPTPROC_TRANSLATE) != 0)
- && (pOpts->pTransProc != NULL) ) {
- /*
- * If option names are not to be translated at all, then do not do
- * it for configuration parsing either. (That is the bit that really
- * gets tested anyway.)
- */
- if ((pOpts->fOptSet & OPTPROC_NO_XLAT_MASK) == OPTPROC_NXLAT_OPT)
- pOpts->fOptSet |= OPTPROC_NXLAT_OPT_CFG;
- (*pOpts->pTransProc)();
- pOpts->fOptSet &= ~OPTPROC_TRANSLATE;
- }
-
- /*
- * IF the struct version is not the current, and also
- * either too large (?!) or too small,
- * THEN emit error message and fail-exit
- */
- if ( ( pOpts->structVersion != OPTIONS_STRUCT_VERSION )
- && ( (pOpts->structVersion > OPTIONS_STRUCT_VERSION )
- || (pOpts->structVersion < OPTIONS_MINIMUM_VERSION )
- ) ) {
- static char const aover[] =
- STR(AO_CURRENT)":"STR(AO_REVISION)":"STR(AO_AGE)"\n";
-
- fprintf(stderr, zAO_Err, pzProgram, NUM_TO_VER(pOpts->structVersion));
- if (pOpts->structVersion > OPTIONS_STRUCT_VERSION )
- fputs(zAO_Big, stderr);
- else
- fputs(zAO_Sml, stderr);
-
- fwrite(aover, sizeof(aover) - 1, 1, stderr);
- return FAILURE;
- }
-
- /*
- * If the program name hasn't been set, then set the name and the path
- * and the set of equivalent characters.
- */
- if (pOpts->pzProgName == NULL) {
- char const * pz = strrchr(pzProgram, DIRCH);
- char const ** pp =
- (char const **)(void **)&(pOpts->pzProgName);
-
- if (pz != NULL) {
- *pp = pz+1;
- } else {
- *pp = pzProgram;
- pz = pathfind(getenv("PATH"), (char *)pzProgram, "rx");
- if (pz != NULL)
- pzProgram = (void *)pz;
- }
-
- pp = (char const **)(void **)&(pOpts->pzProgPath);
- *pp = pzProgram;
-
- /*
- * when comparing long names, these are equivalent
- */
- strequate(zSepChars);
+ case VTP_CMD_NESTED:
+ case VTP_CMD_HIERARCHY:
+ typ->valType = OPARG_TYPE_HIERARCHY;
}
- return SUCCESS;
+ return txt + len;
}
-
-/**
+/*
* Local Variables:
* mode: C
* c-file-style: "stroustrup"
/**
* \file cook.c
*
- * Time-stamp: "2012-02-28 19:40:47 bkorb"
- *
* This file contains the routines that deal with processing quoted strings
* into an internal format.
*
* err: @code{NULL} is returned if the string is mal-formed.
=*/
unsigned int
-ao_string_cook_escape_char(char const* pzIn, char* pRes, uint_t nl)
+ao_string_cook_escape_char(char const * pzIn, char * pRes, uint_t nl)
{
- unsigned int res = 1;
+ unsigned int res = 1;
switch (*pRes = *pzIn++) {
case NUL: /* NUL - end of input string */
do *(pz++) = *(pzIn++);
while (IS_HEX_DIGIT_CHAR(*pzIn) && (pz < z + 2));
*pz = NUL;
- *pRes = (unsigned char)strtoul(z, NULL, 16);
- res += pz - z;
+ *pRes = (char)strtoul(z, NULL, 16);
+ res += (unsigned int)(pz - z);
}
break;
val = strtoul(z, NULL, 8);
if (val > 0xFF)
val = 0xFF;
- *pRes = (unsigned char)val;
- res = pz - z;
+ *pRes = (char)val;
+ res = (unsigned int)(pz - z);
break;
}
* THEN we do the full escape character processing
*/
else if (q != '\'') {
- int ct = ao_string_cook_escape_char(pzS, pzD-1, (uint_t)NL);
+ unsigned int ct;
+ ct = ao_string_cook_escape_char(pzS, pzD-1, (uint_t)NL);
if (ct == 0)
return NULL;
/**
* \file enumeration.c
*
- * Time-stamp: "2012-08-11 08:12:58 bkorb"
- *
* Automated Options Paged Usage module.
*
* This routine will run run-on options through a pager so the
*/
if (max_len > 35) {
do {
- fprintf(option_usage_fp, ENUM_ERR_SEP_LINE_FMT, *(paz_names++));
+ fprintf(option_usage_fp, ENUM_ERR_LINE, *(paz_names++));
} while (--ct_down > 0);
}
unsigned int ent_no = 0;
char zFmt[16]; /* format for all-but-last entries on a line */
- sprintf(zFmt, ENUM_ERR_STR_WIDTH_FMT, (int)max_len);
+ sprintf(zFmt, ENUM_ERR_WIDTH, (int)max_len);
max_len = 78 / max_len; /* max_len is now max entries on a line */
fputs(TWO_SPACES_STR, option_usage_fp);
if (res == name_ct)
res = idx; /* save partial match */
else
- res = ~0; /* may yet find full match */
+ res = (uintptr_t)~0; /* may yet find full match */
}
}
if (res < name_ct)
return res; /* partial match */
-oops:
+ oops:
pz_enum_err_fmt = (res == name_ct) ? zNoKey : zAmbigKey;
option_usage_fp = stderr;
char const *
optionKeywordName(tOptDesc * pOD, unsigned int enum_val)
{
- tOptDesc od;
-
+ tOptDesc od = { 0 };
od.optArg.argEnum = enum_val;
+
(*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, &od );
return od.optArg.argString;
}
case (uintptr_t)OPTPROC_EMIT_SHELL:
{
- unsigned int ix = pOD->optArg.argEnum;
+ unsigned int ix = (unsigned int)pOD->optArg.argEnum;
/*
* print the name string.
*/
case (uintptr_t)OPTPROC_RETURN_VALNAME:
{
- unsigned int ix = pOD->optArg.argEnum;
+ unsigned int ix = (unsigned int)pOD->optArg.argEnum;
/*
* Replace the enumeration value with the name string.
*/
if (iv)
pzArg = SPN_WHITESPACE_CHARS(pzArg+1);
- len = BRK_SET_SEPARATOR_CHARS(pzArg) - pzArg;
+ len = (int)(BRK_SET_SEPARATOR_CHARS(pzArg) - pzArg);
if (len == 0)
break;
p = pzArg;
}
- shift_ct = find_name(p, pOpts, pOD, paz_names, name_ct);
+ shift_ct = (unsigned int)
+ find_name(p, pOpts, pOD, paz_names, name_ct);
if (shift_ct >= name_ct) {
pOD->optCookie = (void*)0;
return;
/**
* \file environment.c
*
- * Time-stamp: "2012-08-11 08:18:25 bkorb"
- *
* This file contains all of the routines that must be linked into
* an executable to use the generated option processing. The optional
* routines are in separately compiled modules so that they will not
LOCAL void
doPrognameEnv(tOptions * pOpts, teEnvPresetType type)
{
- char const * pczOptStr = getenv(pOpts->pzPROGNAME);
- token_list_t* pTL;
- int sv_argc;
- tAoUI sv_flag;
- char ** sv_argv;
+ char const * env_opts = getenv(pOpts->pzPROGNAME);
+ token_list_t* pTL;
+ int sv_argc;
+ proc_state_mask_t sv_flag;
+ char ** sv_argv;
/*
* No such beast? Then bail now.
*/
- if (pczOptStr == NULL)
+ if (env_opts == NULL)
return;
/*
* Tokenize the string. If there's nothing of interest, we'll bail
* here immediately.
*/
- pTL = ao_string_tokenize(pczOptStr);
+ pTL = ao_string_tokenize(env_opts);
if (pTL == NULL)
return;
/*
* Substitute our $PROGNAME argument list for the real one
*/
- sv_argc = pOpts->origArgCt;
+ sv_argc = (int)pOpts->origArgCt;
sv_argv = pOpts->origArgVect;
sv_flag = pOpts->fOptSet;
uintptr_t v = (uintptr_t)(pTL->tkn_list);
pOpts->origArgVect = (void *)(v - sizeof(char *));
}
- pOpts->origArgCt = pTL->tkn_ct + 1;
+ pOpts->origArgCt = (unsigned int)pTL->tkn_ct + 1;
pOpts->fOptSet &= ~OPTPROC_ERRSTOP;
pOpts->curOptIdx = 1;
*/
free(pTL);
pOpts->origArgVect = sv_argv;
- pOpts->origArgCt = sv_argc;
+ pOpts->origArgCt = (unsigned int)sv_argc;
pOpts->fOptSet = sv_flag;
}
pzFlagName = zEnvName
+ snprintf(zEnvName, sizeof(zEnvName), "%s_", pOpts->pzPROGNAME);
- spaceLeft = AO_NAME_SIZE - (pzFlagName - zEnvName) - 1;
+ spaceLeft = AO_NAME_SIZE - (unsigned long)(pzFlagName - zEnvName) - 1;
for (;ct-- > 0; st.pOD++) {
size_t nln;
return;
nln = strlen(st.pOD->pz_NAME) + 1;
-
+
if (nln > spaceLeft)
return;
/**
* \file file.c
*
- * Time-stamp: "2011-08-06 08:49:35 bkorb"
- *
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
* AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*/
break;
- l = p - fname;
+ l = (size_t)(p - fname);
p = AGALOC(l + 1, "fname");
memcpy(p, fname, l);
p[l] = NUL;
*
* @brief Hunt for options in the option descriptor list
*
- * Time-stamp: "2012-08-11 08:36:11 bkorb"
- *
* This file contains the routines that deal with processing quoted strings
* into an internal format.
*
* 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd
*/
+/* = = = START-STATIC-FORWARD = = = */
+static int
+parse_opt(char const ** nm_pp, char ** arg_pp, char * buf, size_t bufsz);
+
+static void
+opt_ambiguities(tOptions * opts, char const * name, int nm_len);
+
+static int
+opt_match_ct(tOptions * opts, char const * name, int nm_len,
+ int * ixp, bool * disable);
+
+static tSuccess
+opt_set(tOptions * opts, char * arg, int idx, bool disable, tOptState * st);
+
+static tSuccess
+opt_unknown(tOptions * opts, char const * name, char * arg, tOptState * st);
+
+static tSuccess
+opt_ambiguous(tOptions * opts, char const * name, int match_ct);
+
+static tSuccess
+get_opt_arg_must(tOptions * opts, tOptState * o_st);
+
+static tSuccess
+get_opt_arg_may(tOptions * pOpts, tOptState * o_st);
+
+static tSuccess
+get_opt_arg_none(tOptions * pOpts, tOptState* o_st);
+/* = = = END-STATIC-FORWARD = = = */
+
/**
* find the name and name length we are looking for
*/
case NUL: return res;
case '=':
- memcpy(buf, *nm_pp, res);
+ memcpy(buf, *nm_pp, (size_t)res);
buf[res] = NUL;
*nm_pp = buf;
if ((opts->fOptSet & OPTPROC_ERRSTOP) != 0) {
fprintf(stderr, zAmbigOptStr, opts->pzProgPath, name, match_ct);
if (match_ct <= 4)
- opt_ambiguities(opts, name, strlen(name));
+ opt_ambiguities(opts, name, (int)strlen(name));
(*opts->pUsageProc)(opts, EXIT_FAILURE);
/* NOTREACHED */
_exit(EXIT_FAILURE); /* to be certain */
return SUCCESS;
}
-short_opt_error:
+ short_opt_error:
/*
* IF we are to stop on errors (the default, actually)
return FAILURE;
}
+/**
+ * Process option with a required argument. Long options can either have a
+ * separate command line argument, or an argument attached by the '='
+ * character. Figure out which.
+ *
+ * @param[in,out] opts the program option descriptor
+ * @param[in,out] o_st the option processing state
+ * @returns SUCCESS or FAILURE
+ */
+static tSuccess
+get_opt_arg_must(tOptions * opts, tOptState * o_st)
+{
+ switch (o_st->optType) {
+ case TOPT_SHORT:
+ /*
+ * See if an arg string follows the flag character
+ */
+ if (*++(opts->pzCurOpt) == NUL)
+ opts->pzCurOpt = opts->origArgVect[ opts->curOptIdx++ ];
+ o_st->pzOptArg = opts->pzCurOpt;
+ break;
+
+ case TOPT_LONG:
+ /*
+ * See if an arg string has already been assigned (glued on
+ * with an `=' character)
+ */
+ if (o_st->pzOptArg == NULL)
+ o_st->pzOptArg = opts->origArgVect[ opts->curOptIdx++ ];
+ break;
+
+ default:
+#ifdef DEBUG
+ fputs("AutoOpts lib error: option type not selected\n", stderr);
+ exit(EXIT_FAILURE);
+#endif
+
+ case TOPT_DEFAULT:
+ /*
+ * The option was selected by default. The current token is
+ * the option argument.
+ */
+ break;
+ }
+
+ /*
+ * Make sure we did not overflow the argument list.
+ */
+ if (opts->curOptIdx > opts->origArgCt) {
+ fprintf(stderr, zMisArg, opts->pzProgPath, o_st->pOD->pz_Name);
+ return FAILURE;
+ }
+
+ opts->pzCurOpt = NULL; /* next time advance to next arg */
+ return SUCCESS;
+}
+
+/**
+ * Process an option with an optional argument. For short options, it looks
+ * at the character after the option character, or it consumes the next full
+ * argument. For long options, it looks for an '=' character attachment to
+ * the long option name before deciding to take the next command line
+ * argument.
+ *
+ * @param pOpts the option descriptor
+ * @param o_st a structure for managing the current processing state
+ * @returns SUCCESS or does not return
+ */
+static tSuccess
+get_opt_arg_may(tOptions * pOpts, tOptState * o_st)
+{
+ /*
+ * An option argument is optional.
+ */
+ switch (o_st->optType) {
+ case TOPT_SHORT:
+ if (*++pOpts->pzCurOpt != NUL)
+ o_st->pzOptArg = pOpts->pzCurOpt;
+ else {
+ char* pzLA = pOpts->origArgVect[ pOpts->curOptIdx ];
+
+ /*
+ * BECAUSE it is optional, we must make sure
+ * we did not find another flag and that there
+ * is such an argument.
+ */
+ if ((pzLA == NULL) || (*pzLA == '-'))
+ o_st->pzOptArg = NULL;
+ else {
+ pOpts->curOptIdx++; /* argument found */
+ o_st->pzOptArg = pzLA;
+ }
+ }
+ break;
+
+ case TOPT_LONG:
+ /*
+ * Look for an argument if we don't already have one (glued on
+ * with a `=' character) *AND* we are not in named argument mode
+ */
+ if ( (o_st->pzOptArg == NULL)
+ && (! NAMED_OPTS(pOpts))) {
+ char* pzLA = pOpts->origArgVect[ pOpts->curOptIdx ];
+
+ /*
+ * BECAUSE it is optional, we must make sure
+ * we did not find another flag and that there
+ * is such an argument.
+ */
+ if ((pzLA == NULL) || (*pzLA == '-'))
+ o_st->pzOptArg = NULL;
+ else {
+ pOpts->curOptIdx++; /* argument found */
+ o_st->pzOptArg = pzLA;
+ }
+ }
+ break;
+
+ default:
+ case TOPT_DEFAULT:
+ fputs(zAO_Woops, stderr );
+ exit(EX_SOFTWARE);
+ }
+
+ /*
+ * After an option with an optional argument, we will
+ * *always* start with the next option because if there
+ * were any characters following the option name/flag,
+ * they would be interpreted as the argument.
+ */
+ pOpts->pzCurOpt = NULL;
+ return SUCCESS;
+}
+
+/**
+ * Process option that does not have an argument.
+ *
+ * @param[in,out] opts the program option descriptor
+ * @param[in,out] o_st the option processing state
+ * @returns SUCCESS or FAILURE
+ */
+static tSuccess
+get_opt_arg_none(tOptions * pOpts, tOptState* o_st)
+{
+ /*
+ * No option argument. Make sure next time around we find
+ * the correct option flag character for short options
+ */
+ if (o_st->optType == TOPT_SHORT)
+ (pOpts->pzCurOpt)++;
+
+ /*
+ * It is a long option. Make sure there was no ``=xxx'' argument
+ */
+ else if (o_st->pzOptArg != NULL) {
+ fprintf(stderr, zNoArg, pOpts->pzProgPath, o_st->pOD->pz_Name);
+ return FAILURE;
+ }
+
+ /*
+ * It is a long option. Advance to next command line argument.
+ */
+ else
+ pOpts->pzCurOpt = NULL;
+ return SUCCESS;
+}
+
+/**
+ * Process option. Figure out whether or not to look for an option argument.
+ *
+ * @param[in,out] opts the program option descriptor
+ * @param[in,out] o_st the option processing state
+ * @returns SUCCESS or FAILURE
+ */
LOCAL tSuccess
-get_opt_arg(tOptions * pOpts, tOptState * pOptState)
+get_opt_arg(tOptions * opts, tOptState * o_st)
{
- pOptState->flags |= (pOptState->pOD->fOptState & OPTST_PERSISTENT_MASK);
+ o_st->flags |= (o_st->pOD->fOptState & OPTST_PERSISTENT_MASK);
/*
* Figure out what to do about option arguments. An argument may be
*/
{
enum { ARG_NONE, ARG_MAY, ARG_MUST } arg_type = ARG_NONE;
- tSuccess res;
- if ((pOptState->flags & OPTST_DISABLED) != 0)
+ if ((o_st->flags & OPTST_DISABLED) != 0)
arg_type = ARG_NONE;
- else if (OPTST_GET_ARGTYPE(pOptState->flags) == OPARG_TYPE_NONE)
+ else if (OPTST_GET_ARGTYPE(o_st->flags) == OPARG_TYPE_NONE)
arg_type = ARG_NONE;
- else if (pOptState->flags & OPTST_ARG_OPTIONAL)
+ else if (o_st->flags & OPTST_ARG_OPTIONAL)
arg_type = ARG_MAY;
else
arg_type = ARG_MUST;
switch (arg_type) {
- case ARG_MUST: res = next_opt_arg_must(pOpts, pOptState); break;
- case ARG_MAY: res = next_opt_arg_may( pOpts, pOptState); break;
- case ARG_NONE: res = next_opt_arg_none(pOpts, pOptState); break;
+ case ARG_MUST: return get_opt_arg_must(opts, o_st);
+ case ARG_MAY: return get_opt_arg_may( opts, o_st);
+ case ARG_NONE: return get_opt_arg_none(opts, o_st);
+ default: exit(EX_SOFTWARE);
}
-
- return res;
}
}
/**
- * Find the option descriptor for the current option
+ * Find the option descriptor for the current option.
+ *
+ * @param[in,out] opts the program option descriptor
+ * @param[in,out] o_st the option processing state
+ * @returns SUCCESS or FAILURE
*/
LOCAL tSuccess
-find_opt(tOptions * pOpts, tOptState * pOptState)
+find_opt(tOptions * opts, tOptState * o_st)
{
/*
* IF we are continuing a short option list (e.g. -xyz...)
* THEN continue a single flag option.
* OTHERWISE see if there is room to advance and then do so.
*/
- if ((pOpts->pzCurOpt != NULL) && (*pOpts->pzCurOpt != NUL))
- return opt_find_short(pOpts, (tAoUC)*(pOpts->pzCurOpt), pOptState);
+ if ((opts->pzCurOpt != NULL) && (*opts->pzCurOpt != NUL))
+ return opt_find_short(opts, (uint8_t)*(opts->pzCurOpt), o_st);
- if (pOpts->curOptIdx >= pOpts->origArgCt)
+ if (opts->curOptIdx >= opts->origArgCt)
return PROBLEM; /* NORMAL COMPLETION */
- pOpts->pzCurOpt = pOpts->origArgVect[ pOpts->curOptIdx ];
+ opts->pzCurOpt = opts->origArgVect[ opts->curOptIdx ];
/*
* IF all arguments must be named options, ...
*/
- if (NAMED_OPTS(pOpts)) {
- char * pz = pOpts->pzCurOpt;
- int def;
- tSuccess res;
- tAoUS * def_opt;
+ if (NAMED_OPTS(opts)) {
+ char * pz = opts->pzCurOpt;
+ int def;
+ tSuccess res;
+ uint16_t * def_opt;
- pOpts->curOptIdx++;
+ opts->curOptIdx++;
if (*pz != '-')
- return opt_find_long(pOpts, pz, pOptState);
+ return opt_find_long(opts, pz, o_st);
/*
* The name is prefixed with one or more hyphens. Strip them off
* strip off the "const" quality of the "default_opt" field.
*/
while (*(++pz) == '-') ;
- def_opt = (void *)&(pOpts->specOptIdx.default_opt);
- def = *def_opt;
+ def_opt = (void *)&(opts->specOptIdx.default_opt);
+ def = *def_opt;
*def_opt = NO_EQUIVALENT;
- res = opt_find_long(pOpts, pz, pOptState);
- *def_opt = def;
+ res = opt_find_long(opts, pz, o_st);
+ *def_opt = (uint16_t)def;
return res;
}
/*
* Note the kind of flag/option marker
*/
- if (*((pOpts->pzCurOpt)++) != '-')
+ if (*((opts->pzCurOpt)++) != '-')
return PROBLEM; /* NORMAL COMPLETION - this + rest are operands */
/*
* Special hack for a hyphen by itself
*/
- if (*(pOpts->pzCurOpt) == NUL)
+ if (*(opts->pzCurOpt) == NUL)
return PROBLEM; /* NORMAL COMPLETION - this + rest are operands */
/*
* The current argument is to be processed as an option argument
*/
- pOpts->curOptIdx++;
+ opts->curOptIdx++;
/*
* We have an option marker.
* Test the next character for long option indication
*/
- if (pOpts->pzCurOpt[0] == '-') {
- if (*++(pOpts->pzCurOpt) == NUL)
+ if (opts->pzCurOpt[0] == '-') {
+ if (*++(opts->pzCurOpt) == NUL)
/*
* NORMAL COMPLETION - NOT this arg, but rest are operands
*/
* We do not allow the hyphen to be used as a flag value.
* Therefore, if long options are not to be accepted, we punt.
*/
- if ((pOpts->fOptSet & OPTPROC_LONGOPT) == 0) {
- fprintf(stderr, zIllOptStr, pOpts->pzProgPath,
- pOpts->pzCurOpt-2);
+ if ((opts->fOptSet & OPTPROC_LONGOPT) == 0) {
+ fprintf(stderr, zIllOptStr, opts->pzProgPath, opts->pzCurOpt-2);
return FAILURE;
}
- return opt_find_long(pOpts, pOpts->pzCurOpt, pOptState);
+ return opt_find_long(opts, opts->pzCurOpt, o_st);
}
/*
* option processing. Otherwise the character must be a
* short (i.e. single character) option.
*/
- if ((pOpts->fOptSet & OPTPROC_SHORTOPT) != 0)
- return opt_find_short(pOpts, (tAoUC)*(pOpts->pzCurOpt), pOptState);
+ if ((opts->fOptSet & OPTPROC_SHORTOPT) != 0)
+ return opt_find_short(opts, (uint8_t)*(opts->pzCurOpt), o_st);
- return opt_find_long(pOpts, pOpts->pzCurOpt, pOptState);
+ return opt_find_long(opts, opts->pzCurOpt, o_st);
}
/*
*
* DO NOT EDIT THIS FILE (genshell.c)
*
- * It has been AutoGen-ed August 11, 2012 at 09:41:14 AM by AutoGen 5.16.2pre7
+ * It has been AutoGen-ed December 27, 2012 at 12:59:02 PM by AutoGen 5.17.0pre12
* From the definitions genshell.def
* and the template file options
*
- * Generated from AutoOpts 36:5:11 templates.
+ * Generated from AutoOpts 37:0:12 templates.
*
* AutoOpts is a copyrighted work. This source file is not encumbered
* by AutoOpts licensing, but is provided under the licensing terms chosen
#define zExplain (genshellopt_opt_strs+1271)
#define zDetail (genshellopt_opt_strs+1452)
#define zFullVersion (genshellopt_opt_strs+1676)
-/* extracted from optcode.tlib near line 350 */
+/* extracted from optcode.tlib near line 353 */
#if defined(ENABLE_NLS)
# define OPTPROC_BASE OPTPROC_TRANSLATE
(void)pOptDesc;
(void)pOptions;
}
-/* extracted from optmain.tlib near line 1146 */
+/* extracted from optmain.tlib near line 1188 */
/**
* The directory containing the data associated with genshellopt.
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#ifdef HAVE_DCGETTEXT
+# include <gettext.h>
+#endif
#include <autoopts/usage-txt.h>
-static char* AO_gettext(char const* pz);
-static void coerce_it(void** s);
+static char * AO_gettext(char const * pz);
+static void coerce_it(void ** s);
/**
- * AutoGen specific wrapper function for gettext.
- * It relies on the macro _() to convert from English to the target
- * language, then strdup-duplicates the result string.
+ * AutoGen specific wrapper function for gettext. It relies on the macro _()
+ * to convert from English to the target language, then strdup-duplicates the
+ * result string. It tries the "libopts" domain first, then whatever has been
+ * set via the \a textdomain(3) call.
*
* @param[in] pz the input text used as a lookup key.
* @returns the translated text (if there is one),
* or the original text (if not).
*/
static char *
-AO_gettext(char const* pz)
+AO_gettext(char const * pz)
{
- char* pzRes;
+ char * res;
if (pz == NULL)
return NULL;
- pzRes = _(pz);
- if (pzRes == pz)
- return pzRes;
- pzRes = strdup(pzRes);
- if (pzRes == NULL) {
+#ifdef HAVE_DCGETTEXT
+ /*
+ * While processing the option_xlateable_txt data, try to use the
+ * "libopts" domain. Once we switch to the option descriptor data,
+ * do *not* use that domain.
+ */
+ if (option_xlateable_txt.field_ct != 0) {
+ res = dgettext("libopts", pz);
+ if (res == pz)
+ res = (char *)(void *)_(pz);
+ } else
+ res = (char *)(void *)_(pz);
+#else
+ res = (char *)(void *)_(pz);
+#endif
+ if (res == pz)
+ return res;
+ res = strdup(res);
+ if (res == NULL) {
fputs(_("No memory for duping translated strings\n"), stderr);
exit(GENSHELLOPT_EXIT_FAILURE);
}
- return pzRes;
+ return res;
}
-static void coerce_it(void** s) { *s = AO_gettext(*s);
+/**
+ * All the pointers we use are marked "* const", but they are stored in
+ * writable memory. Coerce the mutability and set the pointer.
+ */
+static void coerce_it(void ** s) { *s = AO_gettext(*s);
}
/**
static void
translate_option_strings(void)
{
- tOptions * const pOpt = &genshelloptOptions;
+ tOptions * const opts = &genshelloptOptions;
/*
* Guard against re-translation. It won't work. The strings will have
* been changed by the first pass through this code. One shot only.
*/
- if (option_usage_text.field_ct != 0) {
+ if (option_xlateable_txt.field_ct != 0) {
/*
* Do the translations. The first pointer follows the field count
* field. The field count field is the size of a pointer.
*/
- tOptDesc * pOD = pOpt->pOptDesc;
- char ** ppz = (char**)(void*)&(option_usage_text);
- int ix = option_usage_text.field_ct;
+ tOptDesc * od = opts->pOptDesc;
+ char ** ppz = (char**)(void*)&(option_xlateable_txt);
+ int ix = option_xlateable_txt.field_ct;
do {
- ppz++;
+ ppz++; /* skip over field_ct */
*ppz = AO_gettext(*ppz);
} while (--ix > 0);
-
- coerce_it((void*)&(pOpt->pzCopyright));
- coerce_it((void*)&(pOpt->pzCopyNotice));
- coerce_it((void*)&(pOpt->pzFullVersion));
- coerce_it((void*)&(pOpt->pzUsageTitle));
- coerce_it((void*)&(pOpt->pzExplain));
- coerce_it((void*)&(pOpt->pzDetail));
- coerce_it((void*)&(pOpt->pzPackager));
- option_usage_text.field_ct = 0;
-
- for (ix = pOpt->optCt; ix > 0; ix--, pOD++)
- coerce_it((void*)&(pOD->pzText));
+ /* prevent re-translation and disable "libopts" domain lookup */
+ option_xlateable_txt.field_ct = 0;
+
+ coerce_it((void*)&(opts->pzCopyright));
+ coerce_it((void*)&(opts->pzCopyNotice));
+ coerce_it((void*)&(opts->pzFullVersion));
+ coerce_it((void*)&(opts->pzUsageTitle));
+ coerce_it((void*)&(opts->pzExplain));
+ coerce_it((void*)&(opts->pzDetail));
+ coerce_it((void*)&(opts->pzPackager));
+
+ for (ix = opts->optCt; ix > 0; ix--, od++)
+ coerce_it((void*)&(od->pzText));
}
- if ((pOpt->fOptSet & OPTPROC_NXLAT_OPT_CFG) == 0) {
- tOptDesc * pOD = pOpt->pOptDesc;
+ if ((opts->fOptSet & OPTPROC_NXLAT_OPT_CFG) == 0) {
+ tOptDesc * od = opts->pOptDesc;
int ix;
- for (ix = pOpt->optCt; ix > 0; ix--, pOD++) {
- coerce_it((void*)&(pOD->pz_Name));
- coerce_it((void*)&(pOD->pz_DisableName));
- coerce_it((void*)&(pOD->pz_DisablePfx));
+ for (ix = opts->optCt; ix > 0; ix--, od++) {
+ coerce_it((void*)&(od->pz_Name));
+ coerce_it((void*)&(od->pz_DisableName));
+ coerce_it((void*)&(od->pz_DisablePfx));
}
- /* prevent re-translation */
genshelloptOptions.fOptSet |= OPTPROC_NXLAT_OPT_CFG | OPTPROC_NXLAT_OPT;
}
}
*
* DO NOT EDIT THIS FILE (genshell.h)
*
- * It has been AutoGen-ed August 11, 2012 at 09:41:14 AM by AutoGen 5.16.2pre7
+ * It has been AutoGen-ed December 27, 2012 at 12:59:02 PM by AutoGen 5.17.0pre12
* From the definitions genshell.def
* and the template file options
*
- * Generated from AutoOpts 36:5:11 templates.
+ * Generated from AutoOpts 37:0:12 templates.
*
* AutoOpts is a copyrighted work. This header file is not encumbered
* by AutoOpts licensing, but is provided under the licensing terms chosen
* tolerable version is at least as old as what was current when the header
* template was released.
*/
-#define AO_TEMPLATE_VERSION 147461
+#define AO_TEMPLATE_VERSION 151552
#if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
|| (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
# error option template version mismatches autoopts/options.h header
* Enumeration of genshellopt exit codes
*/
typedef enum {
- GENSHELLOPT_EXIT_SUCCESS = 0,
- GENSHELLOPT_EXIT_FAILURE = 1,
+ GENSHELLOPT_EXIT_SUCCESS = 0,
+ GENSHELLOPT_EXIT_FAILURE = 1,
+ GENSHELLOPT_EXIT_USAGE_ERROR = 64,
GENSHELLOPT_EXIT_LIBOPTS_FAILURE = 70
} genshellopt_exit_code_t;
/* * * * * *
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 484 */
+/* extracted from opthead.tlib near line 497 */
#ifdef __cplusplus
extern "C" {
--- /dev/null
+/* Convenience header for conditional use of GNU <libintl.h>.
+ Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2012 Free Software
+ Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along
+ with this program; if not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _LIBGETTEXT_H
+#define _LIBGETTEXT_H 1
+
+/* NLS can be disabled through the configure --disable-nls option. */
+#if ENABLE_NLS
+
+/* Get declarations of GNU message catalog functions. */
+# include <libintl.h>
+
+/* You can set the DEFAULT_TEXT_DOMAIN macro to specify the domain used by
+ the gettext() and ngettext() macros. This is an alternative to calling
+ textdomain(), and is useful for libraries. */
+# ifdef DEFAULT_TEXT_DOMAIN
+# undef gettext
+# define gettext(Msgid) \
+ dgettext (DEFAULT_TEXT_DOMAIN, Msgid)
+# undef ngettext
+# define ngettext(Msgid1, Msgid2, N) \
+ dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N)
+# endif
+
+#else
+
+/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
+ chokes if dcgettext is defined as a macro. So include it now, to make
+ later inclusions of <locale.h> a NOP. We don't include <libintl.h>
+ as well because people using "gettext.h" will not include <libintl.h>,
+ and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
+ is OK. */
+#if defined(__sun)
+# include <locale.h>
+#endif
+
+/* Many header files from the libstdc++ coming with g++ 3.3 or newer include
+ <libintl.h>, which chokes if dcgettext is defined as a macro. So include
+ it now, to make later inclusions of <libintl.h> a NOP. */
+#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
+# include <cstdlib>
+# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H
+# include <libintl.h>
+# endif
+#endif
+
+/* Disabled NLS.
+ The casts to 'const char *' serve the purpose of producing warnings
+ for invalid uses of the value returned from these functions.
+ On pre-ANSI systems without 'const', the config.h file is supposed to
+ contain "#define const". */
+# undef gettext
+# define gettext(Msgid) ((const char *) (Msgid))
+# undef dgettext
+# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid))
+# undef dcgettext
+# define dcgettext(Domainname, Msgid, Category) \
+ ((void) (Category), dgettext (Domainname, Msgid))
+# undef ngettext
+# define ngettext(Msgid1, Msgid2, N) \
+ ((N) == 1 \
+ ? ((void) (Msgid2), (const char *) (Msgid1)) \
+ : ((void) (Msgid1), (const char *) (Msgid2)))
+# undef dngettext
+# define dngettext(Domainname, Msgid1, Msgid2, N) \
+ ((void) (Domainname), ngettext (Msgid1, Msgid2, N))
+# undef dcngettext
+# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
+ ((void) (Category), dngettext (Domainname, Msgid1, Msgid2, N))
+# undef textdomain
+# define textdomain(Domainname) ((const char *) (Domainname))
+# undef bindtextdomain
+# define bindtextdomain(Domainname, Dirname) \
+ ((void) (Domainname), (const char *) (Dirname))
+# undef bind_textdomain_codeset
+# define bind_textdomain_codeset(Domainname, Codeset) \
+ ((void) (Domainname), (const char *) (Codeset))
+
+#endif
+
+/* Prefer gnulib's setlocale override over libintl's setlocale override. */
+#ifdef GNULIB_defined_setlocale
+# undef setlocale
+# define setlocale rpl_setlocale
+#endif
+
+/* A pseudo function call that serves as a marker for the automated
+ extraction of messages, but does not call gettext(). The run-time
+ translation is done at a different place in the code.
+ The argument, String, should be a literal string. Concatenated strings
+ and other string expressions won't work.
+ The macro's expansion is not parenthesized, so that it is suitable as
+ initializer for static 'char[]' or 'const char[]' variables. */
+#define gettext_noop(String) String
+
+/* The separator between msgctxt and msgid in a .mo file. */
+#define GETTEXT_CONTEXT_GLUE "\004"
+
+/* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a
+ MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be
+ short and rarely need to change.
+ The letter 'p' stands for 'particular' or 'special'. */
+#ifdef DEFAULT_TEXT_DOMAIN
+# define pgettext(Msgctxt, Msgid) \
+ pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
+#else
+# define pgettext(Msgctxt, Msgid) \
+ pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
+#endif
+#define dpgettext(Domainname, Msgctxt, Msgid) \
+ pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
+#define dcpgettext(Domainname, Msgctxt, Msgid, Category) \
+ pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category)
+#ifdef DEFAULT_TEXT_DOMAIN
+# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
+ npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
+#else
+# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
+ npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
+#endif
+#define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
+ npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
+#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
+ npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static const char *
+pgettext_aux (const char *domain,
+ const char *msg_ctxt_id, const char *msgid,
+ int category)
+{
+ const char *translation = dcgettext (domain, msg_ctxt_id, category);
+ if (translation == msg_ctxt_id)
+ return msgid;
+ else
+ return translation;
+}
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static const char *
+npgettext_aux (const char *domain,
+ const char *msg_ctxt_id, const char *msgid,
+ const char *msgid_plural, unsigned long int n,
+ int category)
+{
+ const char *translation =
+ dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
+ if (translation == msg_ctxt_id || translation == msgid_plural)
+ return (n == 1 ? msgid : msgid_plural);
+ else
+ return translation;
+}
+
+/* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID
+ can be arbitrary expressions. But for string literals these macros are
+ less efficient than those above. */
+
+#include <string.h>
+
+#if (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \
+ /* || __STDC_VERSION__ >= 199901L */ )
+# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1
+#else
+# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0
+#endif
+
+#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+#include <stdlib.h>
+#endif
+
+#define pgettext_expr(Msgctxt, Msgid) \
+ dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
+#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
+ dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static const char *
+dcpgettext_expr (const char *domain,
+ const char *msgctxt, const char *msgid,
+ int category)
+{
+ size_t msgctxt_len = strlen (msgctxt) + 1;
+ size_t msgid_len = strlen (msgid) + 1;
+ const char *translation;
+#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+ char msg_ctxt_id[msgctxt_len + msgid_len];
+#else
+ char buf[1024];
+ char *msg_ctxt_id =
+ (msgctxt_len + msgid_len <= sizeof (buf)
+ ? buf
+ : (char *) malloc (msgctxt_len + msgid_len));
+ if (msg_ctxt_id != NULL)
+#endif
+ {
+ memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
+ msg_ctxt_id[msgctxt_len - 1] = '\004';
+ memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
+ translation = dcgettext (domain, msg_ctxt_id, category);
+#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+ if (msg_ctxt_id != buf)
+ free (msg_ctxt_id);
+#endif
+ if (translation != msg_ctxt_id)
+ return translation;
+ }
+ return msgid;
+}
+
+#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
+ dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
+#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
+ dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static const char *
+dcnpgettext_expr (const char *domain,
+ const char *msgctxt, const char *msgid,
+ const char *msgid_plural, unsigned long int n,
+ int category)
+{
+ size_t msgctxt_len = strlen (msgctxt) + 1;
+ size_t msgid_len = strlen (msgid) + 1;
+ const char *translation;
+#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+ char msg_ctxt_id[msgctxt_len + msgid_len];
+#else
+ char buf[1024];
+ char *msg_ctxt_id =
+ (msgctxt_len + msgid_len <= sizeof (buf)
+ ? buf
+ : (char *) malloc (msgctxt_len + msgid_len));
+ if (msg_ctxt_id != NULL)
+#endif
+ {
+ memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
+ msg_ctxt_id[msgctxt_len - 1] = '\004';
+ memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
+ translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
+#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+ if (msg_ctxt_id != buf)
+ free (msg_ctxt_id);
+#endif
+ if (!(translation == msg_ctxt_id || translation == msgid_plural))
+ return translation;
+ }
+ return (n == 1 ? msgid : msgid_plural);
+}
+
+#endif /* _LIBGETTEXT_H */
--- /dev/null
+/**
+ * \file initialize.c
+ *
+ * initialize the libopts data structures.
+ *
+ * This file is part of AutoOpts, a companion to AutoGen.
+ * AutoOpts is free software.
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
+ *
+ * AutoOpts is available under any one of two licenses. The license
+ * in use must be one of these two and the choice is under the control
+ * of the user of the license.
+ *
+ * The GNU Lesser General Public License, version 3 or later
+ * See the files "COPYING.lgplv3" and "COPYING.gplv3"
+ *
+ * The Modified Berkeley Software Distribution License
+ * See the file "COPYING.mbsd"
+ *
+ * These files have the following md5sums:
+ *
+ * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3
+ * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3
+ * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd
+ */
+
+static char const ao_ver_string[] =
+ STR(AO_CURRENT)":"STR(AO_REVISION)":"STR(AO_AGE)"\n";
+
+/* = = = START-STATIC-FORWARD = = = */
+static tSuccess
+do_presets(tOptions * opts);
+/* = = = END-STATIC-FORWARD = = = */
+
+/**
+ * Make sure the option descriptor is there and that we understand it.
+ * This should be called from any user entry point where one needs to
+ * worry about validity. (Some entry points are free to assume that
+ * the call is not the first to the library and, thus, that this has
+ * already been called.)
+ *
+ * Upon successful completion, pzProgName and pzProgPath are set.
+ *
+ * @param[in,out] opts program options descriptor
+ * @param[in] pname name of program, from argv[]
+ * @returns SUCCESS or FAILURE
+ */
+LOCAL tSuccess
+validate_struct(tOptions * opts, char const * pname)
+{
+ if (opts == NULL) {
+ fputs(zAO_Bad, stderr);
+ return FAILURE;
+ }
+
+ /*
+ * IF the client has enabled translation and the translation procedure
+ * is available, then go do it.
+ */
+ if ( ((opts->fOptSet & OPTPROC_TRANSLATE) != 0)
+ && (opts->pTransProc != NULL) ) {
+ /*
+ * If option names are not to be translated at all, then do not do
+ * it for configuration parsing either. (That is the bit that really
+ * gets tested anyway.)
+ */
+ if ((opts->fOptSet & OPTPROC_NO_XLAT_MASK) == OPTPROC_NXLAT_OPT)
+ opts->fOptSet |= OPTPROC_NXLAT_OPT_CFG;
+ (*opts->pTransProc)();
+ opts->fOptSet &= ~OPTPROC_TRANSLATE;
+ }
+
+ /*
+ * IF the struct version is not the current, and also
+ * either too large (?!) or too small,
+ * THEN emit error message and fail-exit
+ */
+ if ( ( opts->structVersion != OPTIONS_STRUCT_VERSION )
+ && ( (opts->structVersion > OPTIONS_STRUCT_VERSION )
+ || (opts->structVersion < OPTIONS_MINIMUM_VERSION )
+ ) ) {
+
+ fprintf(stderr, zAO_Err, pname, NUM_TO_VER(opts->structVersion));
+ if (opts->structVersion > OPTIONS_STRUCT_VERSION )
+ fputs(zAO_Big, stderr);
+ else
+ fputs(zAO_Sml, stderr);
+
+ fwrite(ao_ver_string, sizeof(ao_ver_string) - 1, 1, stderr);
+ return FAILURE;
+ }
+
+ /*
+ * If the program name hasn't been set, then set the name and the path
+ * and the set of equivalent characters.
+ */
+ if (opts->pzProgName == NULL) {
+ char const * pz = strrchr(pname, DIRCH);
+ char const ** pp =
+ (char const **)(void **)&(opts->pzProgName);
+
+ if (pz != NULL) {
+ *pp = pz+1;
+ } else {
+ *pp = pname;
+ pz = pathfind(getenv("PATH"), (char *)pname, "rx");
+ if (pz != NULL)
+ pname = (void *)pz;
+ }
+
+ pp = (char const **)(void **)&(opts->pzProgPath);
+ *pp = pname;
+
+ /*
+ * when comparing long names, these are equivalent
+ */
+ strequate(zSepChars);
+ }
+
+ return SUCCESS;
+}
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ * DO PRESETS
+ *
+ * The next several routines do the immediate action pass on the command
+ * line options, then the environment variables, then the config files in
+ * reverse order. Once done with that, the order is reversed and all
+ * the config files and environment variables are processed again, this
+ * time only processing the non-immediate action options. do_presets()
+ * will then return for optionProcess() to do the final pass on the command
+ * line arguments.
+ */
+
+/**
+ * scan the command line for immediate action options.
+ * This is only called the first time through.
+ * While this procedure is active, the OPTPROC_IMMEDIATE is true.
+ *
+ * @param pOpts program options descriptor
+ * @returns SUCCESS or FAILURE
+ */
+LOCAL tSuccess
+immediate_opts(tOptions * opts)
+{
+ tSuccess res;
+
+ opts->fOptSet |= OPTPROC_IMMEDIATE;
+ opts->curOptIdx = 1; /* start by skipping program name */
+ opts->pzCurOpt = NULL;
+
+ /*
+ * Examine all the options from the start. We process any options that
+ * are marked for immediate processing.
+ */
+ for (;;) {
+ tOptState opt_st = OPTSTATE_INITIALIZER(PRESET);
+
+ res = next_opt(opts, &opt_st);
+ switch (res) {
+ case FAILURE: goto failed_option;
+ case PROBLEM: res = SUCCESS; goto leave;
+ case SUCCESS: break;
+ }
+
+ /*
+ * IF this is an immediate-attribute option, then do it.
+ */
+ if (! DO_IMMEDIATELY(opt_st.flags))
+ continue;
+
+ if (! SUCCESSFUL(handle_opt(opts, &opt_st)))
+ break;
+ } failed_option:;
+
+ if ((opts->fOptSet & OPTPROC_ERRSTOP) != 0)
+ (*opts->pUsageProc)(opts, EXIT_FAILURE);
+
+ leave:
+
+ opts->fOptSet &= ~OPTPROC_IMMEDIATE;
+ return res;
+}
+
+/**
+ * check for preset values from a config files or envrionment variables
+ *
+ * @param[in,out] opts the structure with the option names to check
+ */
+static tSuccess
+do_presets(tOptions * opts)
+{
+ tOptDesc * od = NULL;
+
+ if (! SUCCESSFUL(immediate_opts(opts)))
+ return FAILURE;
+
+ /*
+ * IF this option set has a --save-opts option, then it also
+ * has a --load-opts option. See if a command line option has disabled
+ * option presetting.
+ */
+ if ( (opts->specOptIdx.save_opts != NO_EQUIVALENT)
+ && (opts->specOptIdx.save_opts != 0)) {
+ od = opts->pOptDesc + opts->specOptIdx.save_opts + 1;
+ if (DISABLED_OPT(od))
+ return SUCCESS;
+ }
+
+ /*
+ * Until we return from this procedure, disable non-presettable opts
+ */
+ opts->fOptSet |= OPTPROC_PRESETTING;
+ /*
+ * IF there are no config files,
+ * THEN do any environment presets and leave.
+ */
+ if (opts->papzHomeList == NULL) {
+ env_presets(opts, ENV_ALL);
+ }
+ else {
+ env_presets(opts, ENV_IMM);
+
+ /*
+ * Check to see if environment variables have disabled presetting.
+ */
+ if ((od != NULL) && ! DISABLED_OPT(od))
+ intern_file_load(opts);
+
+ /*
+ * ${PROGRAM_LOAD_OPTS} value of "no" cannot disable other environment
+ * variable options. Only the loading of .rc files.
+ */
+ env_presets(opts, ENV_NON_IMM);
+ }
+ opts->fOptSet &= ~OPTPROC_PRESETTING;
+
+ return SUCCESS;
+}
+
+/**
+ * AutoOpts initialization
+ *
+ * @param[in,out] opts the structure to initialize
+ * @param[in] a_ct program argument count
+ * @param[in] a_v program argument vector
+ */
+LOCAL bool
+ao_initialize(tOptions * opts, int a_ct, char ** a_v)
+{
+ if ((opts->fOptSet & OPTPROC_INITDONE) != 0)
+ return true;
+
+ opts->origArgCt = (unsigned int)a_ct;
+ opts->origArgVect = a_v;
+ opts->fOptSet |= OPTPROC_INITDONE;
+
+ if (HAS_pzPkgDataDir(opts))
+ program_pkgdatadir = opts->pzPkgDataDir;
+
+ if (! SUCCESSFUL(do_presets(opts)))
+ return false;
+
+ /*
+ * IF option name conversion was suppressed but it is not suppressed
+ * for the command line, then it's time to translate option names.
+ * Usage text will not get retranslated.
+ */
+ if ( ((opts->fOptSet & OPTPROC_TRANSLATE) != 0)
+ && (opts->pTransProc != NULL)
+ && ((opts->fOptSet & OPTPROC_NO_XLAT_MASK) == OPTPROC_NXLAT_OPT_CFG)
+ ) {
+ opts->fOptSet &= ~OPTPROC_NXLAT_OPT_CFG;
+ (*opts->pTransProc)();
+ }
+
+ if ((opts->fOptSet & OPTPROC_REORDER) != 0)
+ optionSort(opts);
+
+ opts->curOptIdx = 1;
+ opts->pzCurOpt = NULL;
+ return true;
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/initialize.c */
#include "autoopts/options.h"
#include "autoopts/usage-txt.h"
#include "genshell.h"
-#include "xat-attribute.h"
-#include "value-type.h"
+#include "option-xat-attribute.h"
+#include "option-value-type.h"
#include "ao-strs.h"
#include "ag-char-map.h"
#include "autoopts.h"
#include "proto.h"
#include "parse-duration.c"
#include "ao-strs.c"
-#include "value-type.c"
-#include "xat-attribute.c"
+#include "option-value-type.c"
+#include "option-xat-attribute.c"
#include "autoopts.c"
#include "alias.c"
#include "boolean.c"
#include "tokenize.c"
#include "usage.c"
#include "version.c"
+#include "init.c"
/**
* \file load.c
- * Time-stamp: "2012-08-11 08:20:09 bkorb"
- *
* This file contains the routines that deal with processing text strings
* for options, either from a NUL-terminated string passed in or from an
* rc/ini file.
/* = = = START-STATIC-FORWARD = = = */
static bool
-add_prog_path(char * pzBuf, int bufSize, char const * pzName,
+add_prog_path(char * pzBuf, int b_sz, char const * pzName,
char const * pzProgPath);
static bool
* errors (cannot resolve the resulting path).
=*/
bool
-optionMakePath(char * pzBuf, int bufSize, char const * pzName,
+optionMakePath(char * pzBuf, int b_sz, char const * pzName,
char const * pzProgPath)
{
size_t name_len = strlen(pzName);
- if (((size_t)bufSize <= name_len) || (name_len == 0))
+ if (((size_t)b_sz <= name_len) || (name_len == 0))
return false;
/*
if (*pzName != '$') {
char const* pzS = pzName;
char* pzD = pzBuf;
- int ct = bufSize;
+ int ct = b_sz;
for (;;) {
if ( (*(pzD++) = *(pzS++)) == NUL)
return false;
case '$':
- if (! add_prog_path(pzBuf, bufSize, pzName, pzProgPath))
+ if (! add_prog_path(pzBuf, b_sz, pzName, pzProgPath))
return false;
break;
if (program_pkgdatadir[0] == NUL)
return false;
- if (snprintf(pzBuf, bufSize, "%s%s", program_pkgdatadir, pzName + 2)
- >= bufSize)
+ if (snprintf(pzBuf, (size_t)b_sz, "%s%s",
+ program_pkgdatadir, pzName + 2) >= b_sz)
return false;
break;
default:
- if (! add_env_val(pzBuf, bufSize, pzName))
+ if (! add_env_val(pzBuf, b_sz, pzName))
return false;
}
return false;
name_len = strlen(pz);
- if (name_len >= (size_t)bufSize) {
+ if (name_len >= (size_t)b_sz) {
free(pz);
return false;
}
return false;
name_len = strlen(z);
- if (name_len >= bufSize)
+ if (name_len >= b_sz)
return false;
memcpy(pzBuf, z, name_len + 1);
}
static bool
-add_prog_path(char * pzBuf, int bufSize, char const * pzName,
+add_prog_path(char * pzBuf, int b_sz, char const * pzName,
char const * pzProgPath)
{
char const* pzPath;
* Concatenate the file name to the end of the executable path.
* The result may be either a file or a directory.
*/
- if ((pz - pzPath)+1 + strlen(pzName) >= (unsigned)bufSize)
+ if ((unsigned)(pz - pzPath) + 1 + strlen(pzName) >= (unsigned)b_sz)
return false;
memcpy(pzBuf, pzPath, (size_t)((pz - pzPath)+1));
return true;
}
+/**
+ * Trim leading and trailing white space.
+ * If we are cooking the text and the text is quoted, then "cook"
+ * the string. To cook, the string must be quoted.
+ *
+ * @param[in,out] txt the input and output string
+ * @param[in] mode the handling mode (cooking method)
+ */
LOCAL void
-mungeString(char * txt, tOptionLoadMode mode)
+munge_str(char * txt, tOptionLoadMode mode)
{
char * pzE;
dnl
dnl DO NOT EDIT THIS FILE (libopts.m4)
dnl
-dnl It has been AutoGen-ed August 11, 2012 at 09:41:10 AM by AutoGen 5.16.2pre7
+dnl It has been AutoGen-ed December 27, 2012 at 12:58:55 PM by AutoGen 5.17.0pre12
dnl From the definitions libopts.def
dnl and the template file conftest.tpl
dnl
dnl @synopsis LIBOPTS_CHECK
dnl
-dnl Time-stamp: "2012-02-25 12:54:32 bkorb"
-dnl
dnl If autoopts-config works, add the linking information to LIBS.
dnl Otherwise, add ``libopts-${ao_rev}'' to SUBDIRS and run all
dnl the config tests that the library needs. Invoke the
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl
-dnl Time-stamp: "2010-12-07 12:57:56 bkorb"
-dnl
AC_DEFUN([ag_FIND_LIBOPTS],
[if test "X${ac_cv_header_autoopts_options_h}" = Xno
then :
/**
* \file makeshell.c
*
- * Time-stamp: "2012-08-11 08:51:32 bkorb"
- *
* This module will interpret the options set in the tOptions
* structure and create a Bourne shell script capable of parsing them.
*
emit_var_text(char const * prog, char const * var, int fdin);
static void
-text_to_var(tOptions * pOpts, teTextTo whichVar, tOptDesc * pOD);
+text_to_var(tOptions * opts, teTextTo which, tOptDesc * od);
+
+static void
+emit_usage(tOptions * opts);
static void
-emit_usage(tOptions * pOpts);
+emit_wrapup(tOptions * opts);
static void
-emit_setup(tOptions * pOpts);
+emit_setup(tOptions * opts);
static void
-emit_action(tOptions * pOpts, tOptDesc* pOptDesc);
+emit_action(tOptions * opts, tOptDesc * od);
static void
-emit_inaction(tOptions * pOpts, tOptDesc* pOptDesc);
+emit_inaction(tOptions * opts, tOptDesc * od);
static void
-emit_flag(tOptions * pOpts);
+emit_flag(tOptions * opts);
static void
-emit_match_expr(char const * pzMatchName, tOptDesc* pCurOpt, tOptions* pOpts);
+emit_match_expr(char const * name, tOptDesc * cod, tOptions * opts);
static void
-emit_long(tOptions * pOpts);
+emit_long(tOptions * opts);
static char *
load_old_output(char const * fname);
* Emit a shell script that will parse the command line options.
=*/
void
-optionParseShell(tOptions * pOpts)
+optionParseShell(tOptions * opts)
{
/*
* Check for our SHELL option now.
if (HAVE_GENSHELL_OPT(SCRIPT))
open_out(GENSHELL_OPT_ARG(SCRIPT));
- emit_usage(pOpts);
- emit_setup(pOpts);
+ emit_usage(opts);
+ emit_setup(opts);
/*
* There are four modes of option processing.
*/
- switch (pOpts->fOptSet & (OPTPROC_LONGOPT|OPTPROC_SHORTOPT)) {
+ switch (opts->fOptSet & (OPTPROC_LONGOPT|OPTPROC_SHORTOPT)) {
case OPTPROC_LONGOPT:
fputs(LOOP_STR, stdout);
fputs(LONG_OPT_MARK, stdout);
fputs(INIT_LOPT_STR, stdout);
- emit_long(pOpts);
- printf(LOPT_ARG_FMT, pOpts->pzPROGNAME);
+ emit_long(opts);
+ printf(LOPT_ARG_FMT, opts->pzPROGNAME);
fputs(END_OPT_SEL_STR, stdout);
fputs(NOT_FOUND_STR, stdout);
case 0:
fputs(ONLY_OPTS_LOOP, stdout);
fputs(INIT_LOPT_STR, stdout);
- emit_long(pOpts);
- printf(LOPT_ARG_FMT, pOpts->pzPROGNAME);
+ emit_long(opts);
+ printf(LOPT_ARG_FMT, opts->pzPROGNAME);
break;
case OPTPROC_SHORTOPT:
fputs(FLAG_OPT_MARK, stdout);
fputs(INIT_OPT_STR, stdout);
- emit_flag(pOpts);
- printf(OPT_ARG_FMT, pOpts->pzPROGNAME);
+ emit_flag(opts);
+ printf(OPT_ARG_FMT, opts->pzPROGNAME);
fputs(END_OPT_SEL_STR, stdout);
fputs(NOT_FOUND_STR, stdout);
fputs(LONG_OPT_MARK, stdout);
fputs(INIT_LOPT_STR, stdout);
- emit_long(pOpts);
- printf(LOPT_ARG_FMT, pOpts->pzPROGNAME);
+ emit_long(opts);
+ printf(LOPT_ARG_FMT, opts->pzPROGNAME);
fputs(END_OPT_SEL_STR, stdout);
fputs(FLAG_OPT_MARK, stdout);
fputs(INIT_OPT_STR, stdout);
- emit_flag(pOpts);
- printf(OPT_ARG_FMT, pOpts->pzPROGNAME);
+ emit_flag(opts);
+ printf(OPT_ARG_FMT, opts->pzPROGNAME);
fputs(END_OPT_SEL_STR, stdout);
fputs(NOT_FOUND_STR, stdout);
break;
}
- printf(zLoopEnd, pOpts->pzPROGNAME, END_MARK);
+ emit_wrapup(opts);
if ((script_trailer != NULL) && (*script_trailer != NUL))
fputs(script_trailer, stdout);
else if (ENABLED_GENSHELL_OPT(SHELL))
- printf(SHOW_PROG_ENV, pOpts->pzPROGNAME);
+ printf(SHOW_PROG_ENV, opts->pzPROGNAME);
#ifdef HAVE_FCHMOD
fchmod(STDOUT_FILENO, 0755);
fclose(fp);
-skip_text:
+ skip_text:
fputs(END_SET_TEXT, stdout);
}
#endif
-/*
+/**
* The purpose of this function is to assign "long usage", short usage
* and version information to a shell variable. Rather than wind our
* way through all the logic necessary to emit the text directly, we
* fork(), have our child process emit the text the normal way and
* capture the output in the parent process.
+ *
+ * @param[in] opts the program options
+ * @param[in] which what to print: long usage, usage or version
+ * @param[in] od for TT_VERSION, it is the version option
*/
static void
-text_to_var(tOptions * pOpts, teTextTo whichVar, tOptDesc * pOD)
+text_to_var(tOptions * opts, teTextTo which, tOptDesc * od)
{
# define _TT_(n) static char const z ## n [] = #n;
TEXTTO_TABLE
# undef _TT_
# define _TT_(n) z ## n ,
- static char const * apzTTNames[] = { TEXTTO_TABLE };
+ static char const * ttnames[] = { TEXTTO_TABLE };
# undef _TT_
#if ! defined(HAVE_WORKING_FORK)
- printf(SET_NO_TEXT_FMT, pOpts->pzPROGNAME, apzTTNames[ whichVar]);
+ printf(SET_NO_TEXT_FMT, opts->pzPROGNAME, ttnames[which]);
#else
- int pipeFd[2];
+ int fdpair[2];
fflush(stdout);
fflush(stderr);
- if (pipe(pipeFd) != 0) {
+ if (pipe(fdpair) != 0) {
fprintf(stderr, zBadPipe, errno, strerror(errno));
exit(EXIT_FAILURE);
}
switch (fork()) {
case -1:
- fprintf(stderr, zForkFail, errno, strerror(errno), pOpts->pzProgName);
+ fprintf(stderr, zForkFail, errno, strerror(errno), opts->pzProgName);
exit(EXIT_FAILURE);
break;
* Send both stderr and stdout to the pipe. No matter which
* descriptor is used, we capture the output on the read end.
*/
- dup2(pipeFd[1], STDERR_FILENO);
- dup2(pipeFd[1], STDOUT_FILENO);
- close(pipeFd[0]);
+ dup2(fdpair[1], STDERR_FILENO);
+ dup2(fdpair[1], STDOUT_FILENO);
+ close(fdpair[0]);
- switch (whichVar) {
+ switch (which) {
case TT_LONGUSAGE:
- (*(pOpts->pUsageProc))(pOpts, EXIT_SUCCESS);
+ (*(opts->pUsageProc))(opts, EXIT_SUCCESS);
/* NOTREACHED */
case TT_USAGE:
- (*(pOpts->pUsageProc))(pOpts, EXIT_FAILURE);
+ (*(opts->pUsageProc))(opts, EXIT_FAILURE);
/* NOTREACHED */
case TT_VERSION:
- if (pOD->fOptState & OPTST_ALLOC_ARG) {
- AGFREE(pOD->optArg.argString);
- pOD->fOptState &= ~OPTST_ALLOC_ARG;
+ if (od->fOptState & OPTST_ALLOC_ARG) {
+ AGFREE(od->optArg.argString);
+ od->fOptState &= ~OPTST_ALLOC_ARG;
}
- pOD->optArg.argString = "c";
- optionPrintVersion(pOpts, pOD);
+ od->optArg.argString = "c";
+ optionPrintVersion(opts, od);
/* NOTREACHED */
default:
exit(EXIT_FAILURE);
+ /* NOTREACHED */
}
+ /* NOTREACHED */
default:
- close(pipeFd[1]);
+ close(fdpair[1]);
}
- emit_var_text(pOpts->pzPROGNAME, apzTTNames[whichVar], pipeFd[0]);
+ emit_var_text(opts->pzPROGNAME, ttnames[which], fdpair[0]);
#endif
}
static void
-emit_usage(tOptions * pOpts)
+emit_usage(tOptions * opts)
{
- char zTimeBuf[AO_NAME_SIZE];
+ char tm_nm_buf[AO_NAME_SIZE];
/*
* First, switch stdout to the output file name.
{
time_t c_tim = time(NULL);
struct tm * ptm = localtime(&c_tim);
- strftime(zTimeBuf, AO_NAME_SIZE, TIME_FMT, ptm );
+ strftime(tm_nm_buf, AO_NAME_SIZE, TIME_FMT, ptm );
}
if (HAVE_GENSHELL_OPT(SCRIPT))
if ((script_leader == NULL) && (shell_prog != NULL))
printf(SHELL_MAGIC, shell_prog);
- printf(PREAMBLE_FMT, START_MARK, out_nm, zTimeBuf);
+ printf(PREAMBLE_FMT, START_MARK, out_nm, tm_nm_buf);
}
- printf(END_PRE_FMT, pOpts->pzPROGNAME);
+ printf(END_PRE_FMT, opts->pzPROGNAME);
/*
* Get a copy of the original program name in lower case and
* fill in an approximation of the program name from it.
*/
{
- char * pzPN = zTimeBuf;
- char const * pz = pOpts->pzPROGNAME;
+ char * pzPN = tm_nm_buf;
+ char const * pz = opts->pzPROGNAME;
char ** pp;
+ /* Copy the program name into the time/name buffer */
for (;;) {
if ((*pzPN++ = (char)tolower(*pz++)) == NUL)
break;
}
- pp = (char **)(void *)&(pOpts->pzProgPath);
- *pp = zTimeBuf;
- pp = (char **)(void *)&(pOpts->pzProgName);
- *pp = zTimeBuf;
+ pp = (char **)(void *)&(opts->pzProgPath);
+ *pp = tm_nm_buf;
+ pp = (char **)(void *)&(opts->pzProgName);
+ *pp = tm_nm_buf;
}
- text_to_var(pOpts, TT_LONGUSAGE, NULL);
- text_to_var(pOpts, TT_USAGE, NULL);
+ text_to_var(opts, TT_LONGUSAGE, NULL);
+ text_to_var(opts, TT_USAGE, NULL);
{
- tOptDesc* pOptDesc = pOpts->pOptDesc;
- int optionCt = pOpts->optCt;
+ tOptDesc* pOptDesc = opts->pOptDesc;
+ int optionCt = opts->optCt;
for (;;) {
if (pOptDesc->pOptProc == optionPrintVersion) {
- text_to_var(pOpts, TT_VERSION, pOptDesc);
+ text_to_var(opts, TT_VERSION, pOptDesc);
break;
}
}
}
+static void
+emit_wrapup(tOptions * opts)
+{
+ tOptDesc * od = opts->pOptDesc;
+ int opt_ct = opts->presetOptCt;
+ char const * fmt;
+
+ printf(FINISH_LOOP, opts->pzPROGNAME);
+ for (;opt_ct > 0; od++, --opt_ct) {
+ /*
+ * Options that are either usage documentation or are compiled out
+ * are not to be processed.
+ */
+ if (SKIP_OPT(od) || (od->pz_NAME == NULL))
+ continue;
+
+ /*
+ * do not presence check if there is no minimum/must-set
+ */
+ if ((od->optMinCt == 0) && ((od->fOptState & OPTST_MUST_SET) == 0))
+ continue;
+
+ if (od->optMaxCt > 1)
+ fmt = CHK_MIN_COUNT;
+ else fmt = CHK_ONE_REQUIRED;
+
+ {
+ int min = (od->optMinCt == 0) ? 1 : od->optMinCt;
+ printf(fmt, opts->pzPROGNAME, od->pz_NAME, min);
+ }
+ }
+ fputs(END_MARK, stdout);
+}
static void
-emit_setup(tOptions * pOpts)
+emit_setup(tOptions * opts)
{
- tOptDesc * pOptDesc = pOpts->pOptDesc;
- int optionCt = pOpts->presetOptCt;
- char const * pzFmt;
- char const * pzDefault;
+ tOptDesc * od = opts->pOptDesc;
+ int opt_ct = opts->presetOptCt;
+ char const * fmt;
+ char const * def_val;
- for (;optionCt > 0; pOptDesc++, --optionCt) {
- char zVal[32];
+ for (;opt_ct > 0; od++, --opt_ct) {
+ char int_val_buf[32];
/*
* Options that are either usage documentation or are compiled out
* are not to be processed.
*/
- if (SKIP_OPT(pOptDesc) || (pOptDesc->pz_NAME == NULL))
+ if (SKIP_OPT(od) || (od->pz_NAME == NULL))
continue;
- if (pOptDesc->optMaxCt > 1)
- pzFmt = MULTI_DEF_FMT;
- else pzFmt = SGL_DEF_FMT;
+ if (od->optMaxCt > 1)
+ fmt = MULTI_DEF_FMT;
+ else fmt = SGL_DEF_FMT;
/*
* IF this is an enumeration/bitmask option, then convert the value
* to a string before printing the default value.
*/
- switch (OPTST_GET_ARGTYPE(pOptDesc->fOptState)) {
+ switch (OPTST_GET_ARGTYPE(od->fOptState)) {
case OPARG_TYPE_ENUMERATION:
- (*(pOptDesc->pOptProc))(OPTPROC_EMIT_SHELL, pOptDesc );
- pzDefault = pOptDesc->optArg.argString;
+ (*(od->pOptProc))(OPTPROC_EMIT_SHELL, od );
+ def_val = od->optArg.argString;
break;
/*
* Numeric and membership bit options are just printed as a number.
*/
case OPARG_TYPE_NUMERIC:
- snprintf(zVal, sizeof(zVal), "%d",
- (int)pOptDesc->optArg.argInt);
- pzDefault = zVal;
+ snprintf(int_val_buf, sizeof(int_val_buf), "%d",
+ (int)od->optArg.argInt);
+ def_val = int_val_buf;
break;
case OPARG_TYPE_MEMBERSHIP:
- snprintf(zVal, sizeof(zVal), "%lu",
- (unsigned long)pOptDesc->optArg.argIntptr);
- pzDefault = zVal;
+ snprintf(int_val_buf, sizeof(int_val_buf), "%lu",
+ (unsigned long)od->optArg.argIntptr);
+ def_val = int_val_buf;
break;
case OPARG_TYPE_BOOLEAN:
- pzDefault = (pOptDesc->optArg.argBool) ? TRUE_STR : FALSE_STR;
+ def_val = (od->optArg.argBool) ? TRUE_STR : FALSE_STR;
break;
default:
- if (pOptDesc->optArg.argString == NULL) {
- if (pzFmt == SGL_DEF_FMT)
- pzFmt = SGL_NO_DEF_FMT;
- pzDefault = NULL;
+ if (od->optArg.argString == NULL) {
+ if (fmt == SGL_DEF_FMT)
+ fmt = SGL_NO_DEF_FMT;
+ def_val = NULL;
}
else
- pzDefault = pOptDesc->optArg.argString;
+ def_val = od->optArg.argString;
}
- printf(pzFmt, pOpts->pzPROGNAME, pOptDesc->pz_NAME, pzDefault);
+ printf(fmt, opts->pzPROGNAME, od->pz_NAME, def_val);
}
}
static void
-emit_action(tOptions * pOpts, tOptDesc* pOptDesc)
+emit_action(tOptions * opts, tOptDesc * od)
{
- if (pOptDesc->pOptProc == optionPrintVersion)
- printf(zTextExit, pOpts->pzPROGNAME, VER_STR);
+ if (od->pOptProc == optionPrintVersion)
+ printf(ECHO_N_EXIT, opts->pzPROGNAME, VER_STR);
- else if (pOptDesc->pOptProc == optionPagedUsage)
- printf(zPagedUsageExit, pOpts->pzPROGNAME);
+ else if (od->pOptProc == optionPagedUsage)
+ printf(PAGE_USAGE_TEXT, opts->pzPROGNAME);
- else if (pOptDesc->pOptProc == optionLoadOpt) {
- printf(zCmdFmt, NO_LOAD_WARN);
- printf(zCmdFmt, YES_NEED_OPT_ARG);
+ else if (od->pOptProc == optionLoadOpt) {
+ printf(LVL3_CMD, NO_LOAD_WARN);
+ printf(LVL3_CMD, YES_NEED_OPT_ARG);
- } else if (pOptDesc->pz_NAME == NULL) {
+ } else if (od->pz_NAME == NULL) {
- if (pOptDesc->pOptProc == NULL) {
- printf(zCmdFmt, NO_SAVE_OPTS);
- printf(zCmdFmt, OK_NEED_OPT_ARG);
+ if (od->pOptProc == NULL) {
+ printf(LVL3_CMD, NO_SAVE_OPTS);
+ printf(LVL3_CMD, OK_NEED_OPT_ARG);
} else
- printf(zTextExit, pOpts->pzPROGNAME, LONG_USE_STR);
+ printf(ECHO_N_EXIT, opts->pzPROGNAME, LONG_USE_STR);
} else {
- if (pOptDesc->optMaxCt == 1)
- printf(SGL_ARG_FMT, pOpts->pzPROGNAME, pOptDesc->pz_NAME);
+ if (od->optMaxCt == 1)
+ printf(SGL_ARG_FMT, opts->pzPROGNAME, od->pz_NAME);
else {
- if ((unsigned)pOptDesc->optMaxCt < NOLIMIT)
- printf(zCountTest, pOpts->pzPROGNAME,
- pOptDesc->pz_NAME, pOptDesc->optMaxCt);
+ if ((unsigned)od->optMaxCt < NOLIMIT)
+ printf(CHK_MAX_COUNT, opts->pzPROGNAME,
+ od->pz_NAME, od->optMaxCt);
- printf(MULTI_ARG_FMT, pOpts->pzPROGNAME, pOptDesc->pz_NAME);
+ printf(MULTI_ARG_FMT, opts->pzPROGNAME, od->pz_NAME);
}
/*
* Fix up the args.
*/
- if (OPTST_GET_ARGTYPE(pOptDesc->fOptState) == OPARG_TYPE_NONE) {
- printf(zCantArg, pOpts->pzPROGNAME, pOptDesc->pz_NAME);
+ if (OPTST_GET_ARGTYPE(od->fOptState) == OPARG_TYPE_NONE) {
+ printf(SET_MULTI_ARG, opts->pzPROGNAME, od->pz_NAME);
+ printf(LVL3_CMD, NO_ARG_NEEDED);
- } else if (pOptDesc->fOptState & OPTST_ARG_OPTIONAL) {
- printf(zMayArg, pOpts->pzPROGNAME, pOptDesc->pz_NAME);
+ } else if (od->fOptState & OPTST_ARG_OPTIONAL) {
+ printf(SET_MULTI_ARG, opts->pzPROGNAME, od->pz_NAME);
+ printf(LVL3_CMD, OK_NEED_OPT_ARG);
} else {
- fputs(zMustArg, stdout);
+ printf(LVL3_CMD, YES_NEED_OPT_ARG);
}
}
fputs(zOptionEndSelect, stdout);
static void
-emit_inaction(tOptions * pOpts, tOptDesc* pOptDesc)
+emit_inaction(tOptions * opts, tOptDesc * od)
{
- if (pOptDesc->pOptProc == optionLoadOpt) {
- printf(zCmdFmt, NO_SUPPRESS_LOAD);
+ if (od->pOptProc == optionLoadOpt) {
+ printf(LVL3_CMD, NO_SUPPRESS_LOAD);
- } else if (pOptDesc->optMaxCt == 1)
- printf(NO_SGL_ARG_FMT, pOpts->pzPROGNAME,
- pOptDesc->pz_NAME, pOptDesc->pz_DisablePfx);
+ } else if (od->optMaxCt == 1)
+ printf(NO_SGL_ARG_FMT, opts->pzPROGNAME,
+ od->pz_NAME, od->pz_DisablePfx);
else
- printf(NO_MULTI_ARG_FMT, pOpts->pzPROGNAME,
- pOptDesc->pz_NAME, pOptDesc->pz_DisablePfx);
+ printf(NO_MULTI_ARG_FMT, opts->pzPROGNAME,
+ od->pz_NAME, od->pz_DisablePfx);
- printf(zCmdFmt, NO_ARG_NEEDED);
+ printf(LVL3_CMD, NO_ARG_NEEDED);
fputs(zOptionEndSelect, stdout);
}
static void
-emit_flag(tOptions * pOpts)
+emit_flag(tOptions * opts)
{
- tOptDesc* pOptDesc = pOpts->pOptDesc;
- int optionCt = pOpts->optCt;
+ tOptDesc* od = opts->pOptDesc;
+ int opt_ct = opts->optCt;
fputs(zOptionCase, stdout);
- for (;optionCt > 0; pOptDesc++, --optionCt) {
+ for (;opt_ct > 0; od++, --opt_ct) {
- if (SKIP_OPT(pOptDesc))
+ if (SKIP_OPT(od))
continue;
- if (IS_GRAPHIC_CHAR(pOptDesc->optValue)) {
- printf(zOptionFlag, pOptDesc->optValue);
- emit_action(pOpts, pOptDesc);
+ if (IS_GRAPHIC_CHAR(od->optValue)) {
+ printf(zOptionFlag, od->optValue);
+ emit_action(opts, od);
}
}
- printf(UNK_OPT_FMT, FLAG_STR, pOpts->pzPROGNAME);
+ printf(UNK_OPT_FMT, FLAG_STR, opts->pzPROGNAME);
}
* Emit the match text for a long option
*/
static void
-emit_match_expr(char const * pzMatchName, tOptDesc* pCurOpt, tOptions* pOpts)
+emit_match_expr(char const * name, tOptDesc * cod, tOptions * opts)
{
- tOptDesc* pOD = pOpts->pOptDesc;
- int oCt = pOpts->optCt;
- int min = 1;
- char zName[ 256 ];
- char* pz = zName;
+ tOptDesc * od = opts->pOptDesc;
+ int oCt = opts->optCt;
+ int min = 1;
+ char name_bf[ 256 ];
+ char * pz = name_bf;
for (;;) {
int matchCt = 0;
/*
* Omit the current option, Documentation opts and compiled out opts.
*/
- if ((pOD == pCurOpt) || SKIP_OPT(pOD)){
+ if ((od == cod) || SKIP_OPT(od)){
if (--oCt <= 0)
break;
- pOD++;
+ od++;
continue;
}
* They must not be the same. They cannot be, because it would
* not compile correctly if they were.
*/
- while ( toupper(pOD->pz_Name[matchCt])
- == toupper(pzMatchName[matchCt]))
+ while ( toupper(od->pz_Name[matchCt])
+ == toupper(name[matchCt]))
matchCt++;
if (matchCt > min)
/*
* Check the disablement name, too.
*/
- if (pOD->pz_DisableName != NULL) {
+ if (od->pz_DisableName != NULL) {
matchCt = 0;
- while ( toupper(pOD->pz_DisableName[matchCt])
- == toupper(pzMatchName[matchCt]))
+ while ( toupper(od->pz_DisableName[matchCt])
+ == toupper(name[matchCt]))
matchCt++;
if (matchCt > min)
min = matchCt;
}
if (--oCt <= 0)
break;
- pOD++;
+ od++;
}
/*
* IF the 'min' is all or one short of the name length,
* THEN the entire string must be matched.
*/
- if ( (pzMatchName[min ] == NUL)
- || (pzMatchName[min+1] == NUL) )
- printf(zOptionFullName, pzMatchName);
+ if ( (name[min ] == NUL)
+ || (name[min+1] == NUL) )
+ printf(zOptionFullName, name);
else {
int matchCt = 0;
for (; matchCt <= min; matchCt++)
- *pz++ = pzMatchName[matchCt];
+ *pz++ = name[matchCt];
for (;;) {
*pz = NUL;
- printf(zOptionPartName, zName);
- *pz++ = pzMatchName[matchCt++];
- if (pzMatchName[matchCt] == NUL) {
+ printf(zOptionPartName, name_bf);
+ *pz++ = name[matchCt++];
+ if (name[matchCt] == NUL) {
*pz = NUL;
- printf(zOptionFullName, zName);
+ printf(zOptionFullName, name_bf);
break;
}
}
* Emit GNU-standard long option handling code.
*/
static void
-emit_long(tOptions * pOpts)
+emit_long(tOptions * opts)
{
- tOptDesc* pOD = pOpts->pOptDesc;
- int ct = pOpts->optCt;
+ tOptDesc * od = opts->pOptDesc;
+ int ct = opts->optCt;
fputs(zOptionCase, stdout);
/*
* Documentation & compiled-out options
*/
- if (SKIP_OPT(pOD))
+ if (SKIP_OPT(od))
continue;
- emit_match_expr(pOD->pz_Name, pOD, pOpts);
- emit_action(pOpts, pOD);
+ emit_match_expr(od->pz_Name, od, opts);
+ emit_action(opts, od);
/*
* Now, do the same thing for the disablement version of the option.
*/
- if (pOD->pz_DisableName != NULL) {
- emit_match_expr(pOD->pz_DisableName, pOD, pOpts);
- emit_inaction(pOpts, pOD);
+ if (od->pz_DisableName != NULL) {
+ emit_match_expr(od->pz_DisableName, od, opts);
+ emit_inaction(opts, od);
}
- } while (pOD++, --ct > 0);
+ } while (od++, --ct > 0);
- printf(UNK_OPT_FMT, OPTION_STR, pOpts->pzPROGNAME);
+ printf(UNK_OPT_FMT, OPTION_STR, opts->pzPROGNAME);
}
/**
* Read in all the data as fast as our OS will let us.
*/
for (;;) {
- int inct = fread((void*)scan, (size_t)1, stbf.st_size, fp);
+ size_t inct = fread((void*)scan, 1, (size_t)stbf.st_size, fp);
if (inct == 0)
break;
- stbf.st_size -= inct;
+ stbf.st_size -= (ssize_t)inct;
if (stbf.st_size == 0)
break;
* private:
* what: The usage function for the genshellopt generated program
*
- * arg: + tOptions* + pOpts + program options descriptor +
- * arg: + int + exitCode + usage text type to produce +
+ * arg: + tOptions* + opts + program options descriptor +
+ * arg: + int + exit_cd + usage text type to produce +
*
* doc:
* This function is used to create the usage strings for the option
* and create shell script variables containing the two types of text.
=*/
void
-genshelloptUsage(tOptions * pOpts, int exitCode)
+genshelloptUsage(tOptions * opts, int exit_cd)
{
#if ! defined(HAVE_WORKING_FORK)
- optionUsage(pOpts, exitCode);
+ optionUsage(opts, exit_cd);
#else
/*
* IF not EXIT_SUCCESS,
* THEN emit the short form of usage.
*/
- if (exitCode != EXIT_SUCCESS)
- optionUsage(pOpts, exitCode);
+ if (exit_cd != EXIT_SUCCESS)
+ optionUsage(opts, exit_cd);
fflush(stderr);
fflush(stdout);
if (ferror(stdout) || ferror(stderr))
*/
switch (fork()) {
case -1:
- optionUsage(pOpts, EXIT_FAILURE);
+ optionUsage(opts, EXIT_FAILURE);
/* NOTREACHED */
case 0:
pagerState = PAGER_STATE_CHILD;
- optionUsage(pOpts, EXIT_SUCCESS);
+ optionUsage(opts, EXIT_SUCCESS);
/* NOTREACHED */
_exit(EXIT_FAILURE);
AGDUPSTR(pz, optionParseShellOptions->pzPROGNAME, "prog name");
*pp = pz;
while (*pz != NUL) {
- *pz = tolower(*pz);
+ *pz = (char)tolower(*pz);
pz++;
}
}
/**
* \file nested.c
*
- * Time-stamp: "2012-03-04 13:30:07 bkorb"
- *
* Automated Options Nested Values module.
*
* This file is part of AutoOpts, a companion to AutoGen.
/* = = = START-STATIC-FORWARD = = = */
static void
-remove_continuation(char* pzSrc);
+remove_continuation(char * src);
static char const*
scan_q_str(char const* pzTxt);
static tOptionValue *
-add_string(void ** pp, char const * pzName, size_t nameLen,
+add_string(void ** pp, char const * name, size_t nm_len,
char const* pzValue, size_t dataLen);
static tOptionValue *
-add_bool(void ** pp, char const * pzName, size_t nameLen,
- char const* pzValue, size_t dataLen);
+add_bool(void ** pp, char const * name, size_t nm_len,
+ char const * val, size_t d_len);
static tOptionValue*
-add_number(void** pp, char const* pzName, size_t nameLen,
- char const* pzValue, size_t dataLen);
+add_number(void** pp, char const* pzName, size_t nm_len,
+ char const* val, size_t d_len);
static tOptionValue*
-add_nested(void** pp, char const* pzName, size_t nameLen,
- char* pzValue, size_t dataLen);
+add_nested(void** pp, char const* pzName, size_t nm_len,
+ char* val, size_t d_len);
static char const *
scan_name(char const* pzName, tOptionValue* pRes);
-static char const*
-scan_xml(char const* pzName, tOptionValue* pRes);
+static char const *
+unnamed_xml(char const * txt);
+
+static char const *
+scan_xml_name(char const * name, size_t * nm_len, tOptionValue * val);
+
+static char const *
+find_end_xml(char const * src, size_t nm_len, char const * val, size_t * len);
+
+static char const *
+scan_xml(char const * xml_name, tOptionValue * res_val);
static void
-sort_list(tArgList* pAL);
+sort_list(tArgList * arg_list);
/* = = = END-STATIC-FORWARD = = = */
/**
* characters, but trim out the backslash:
*/
static void
-remove_continuation(char* pzSrc)
+remove_continuation(char * src)
{
char* pzD;
do {
- while (*pzSrc == NL) pzSrc++;
- pzD = strchr(pzSrc, NL);
+ while (*src == NL) src++;
+ pzD = strchr(src, NL);
if (pzD == NULL)
return;
* points to a newline character. It now becomes the source and
* pzD goes to the previous character.
*/
- pzSrc = pzD--;
+ src = pzD--;
if (*pzD != '\\')
pzD++;
- } while (pzD == pzSrc);
+ } while (pzD == src);
/*
* Start shifting text.
*/
for (;;) {
- char ch = ((*pzD++) = *(pzSrc++));
+ char ch = ((*pzD++) = *(src++));
switch (ch) {
case NUL: return;
case '\\':
- if (*pzSrc == NL)
+ if (*src == NL)
--pzD; /* rewrite on next iteration */
}
}
* Associate a name with either a string or no value.
*/
static tOptionValue *
-add_string(void ** pp, char const * pzName, size_t nameLen,
+add_string(void ** pp, char const * name, size_t nm_len,
char const* pzValue, size_t dataLen)
{
tOptionValue* pNV;
- size_t sz = nameLen + dataLen + sizeof(*pNV);
+ size_t sz = nm_len + dataLen + sizeof(*pNV);
pNV = AGALOC(sz, "option name/str value pair");
if (pNV == NULL)
} else {
pNV->valType = OPARG_TYPE_STRING;
if (dataLen > 0) {
- char const * pzSrc = pzValue;
+ char const * src = pzValue;
char * pzDst = pNV->v.strVal;
- int ct = dataLen;
+ int ct = (int)dataLen;
do {
- int ch = *(pzSrc++) & 0xFF;
+ int ch = *(src++) & 0xFF;
if (ch == NUL) goto data_copy_done;
if (ch == '&')
- ch = get_special_char(&pzSrc, &ct);
+ ch = get_special_char(&src, &ct);
*(pzDst++) = (char)ch;
} while (--ct > 0);
data_copy_done:
pNV->pzName = pNV->v.strVal + dataLen + 1;
}
- memcpy(pNV->pzName, pzName, nameLen);
- pNV->pzName[ nameLen ] = NUL;
+ memcpy(pNV->pzName, name, nm_len);
+ pNV->pzName[ nm_len ] = NUL;
addArgListEntry(pp, pNV);
return pNV;
}
* Associate a name with either a string or no value.
*/
static tOptionValue *
-add_bool(void ** pp, char const * pzName, size_t nameLen,
- char const* pzValue, size_t dataLen)
+add_bool(void ** pp, char const * name, size_t nm_len,
+ char const * val, size_t d_len)
{
- tOptionValue * pNV;
+ tOptionValue * new_val;
{
- size_t sz = nameLen + sizeof(tOptionValue) + 1;
- pNV = AGALOC(sz, "name/bool value");
+ size_t sz = nm_len + sizeof(tOptionValue) + 1;
+ new_val = AGALOC(sz, "name/bool value");
}
{
- char * p = SPN_WHITESPACE_CHARS(pzValue);
- dataLen -= p - pzValue;
- pzValue = p;
+ char * p = SPN_WHITESPACE_CHARS(val);
+ d_len -= (unsigned long)(p - val);
+ val = p;
}
- if (dataLen == 0)
- pNV->v.boolVal = 0;
+ if (d_len == 0)
+ new_val->v.boolVal = 0;
- else if (IS_DEC_DIGIT_CHAR(*pzValue))
- pNV->v.boolVal = atoi(pzValue);
+ else if (IS_DEC_DIGIT_CHAR(*val))
+ new_val->v.boolVal = (unsigned)atoi(val);
- else pNV->v.boolVal = ! IS_FALSE_TYPE_CHAR(*pzValue);
+ else new_val->v.boolVal = ! IS_FALSE_TYPE_CHAR(*val);
- pNV->valType = OPARG_TYPE_BOOLEAN;
- pNV->pzName = (char*)(pNV + 1);
- memcpy(pNV->pzName, pzName, nameLen);
- pNV->pzName[ nameLen ] = NUL;
- addArgListEntry(pp, pNV);
- return pNV;
+ new_val->valType = OPARG_TYPE_BOOLEAN;
+ new_val->pzName = (char*)(new_val + 1);
+ memcpy(new_val->pzName, name, nm_len);
+ new_val->pzName[ nm_len ] = NUL;
+ addArgListEntry(pp, new_val);
+ return new_val;
}
/**
* Associate a name with either a string or no value.
*/
static tOptionValue*
-add_number(void** pp, char const* pzName, size_t nameLen,
- char const* pzValue, size_t dataLen)
+add_number(void** pp, char const* pzName, size_t nm_len,
+ char const* val, size_t d_len)
{
- tOptionValue* pNV;
- size_t sz = nameLen + sizeof(*pNV) + 1;
+ tOptionValue* new_val;
+ size_t sz = nm_len + sizeof(*new_val) + 1;
- pNV = AGALOC(sz, "option name/bool value pair");
- if (pNV == NULL)
+ new_val = AGALOC(sz, "bool val");
+ if (new_val == NULL)
return NULL;
- while (IS_WHITESPACE_CHAR(*pzValue) && (dataLen > 0)) {
- dataLen--; pzValue++;
+ while (IS_WHITESPACE_CHAR(*val) && (d_len > 0)) {
+ d_len--; val++;
}
- if (dataLen == 0)
- pNV->v.longVal = 0;
+ if (d_len == 0)
+ new_val->v.longVal = 0;
else
- pNV->v.longVal = strtol(pzValue, 0, 0);
-
- pNV->valType = OPARG_TYPE_NUMERIC;
- pNV->pzName = (char*)(pNV + 1);
- memcpy(pNV->pzName, pzName, nameLen);
- pNV->pzName[ nameLen ] = NUL;
- addArgListEntry(pp, pNV);
- return pNV;
+ new_val->v.longVal = strtol(val, 0, 0);
+
+ new_val->valType = OPARG_TYPE_NUMERIC;
+ new_val->pzName = (char*)(new_val + 1);
+ memcpy(new_val->pzName, pzName, nm_len);
+ new_val->pzName[ nm_len ] = NUL;
+ addArgListEntry(pp, new_val);
+ return new_val;
}
/**
* Associate a name with either a string or no value.
*/
static tOptionValue*
-add_nested(void** pp, char const* pzName, size_t nameLen,
- char* pzValue, size_t dataLen)
+add_nested(void** pp, char const* pzName, size_t nm_len,
+ char* val, size_t d_len)
{
- tOptionValue* pNV;
+ tOptionValue* new_val;
- if (dataLen == 0) {
- size_t sz = nameLen + sizeof(*pNV) + 1;
- pNV = AGALOC(sz, "empty nested value pair");
- if (pNV == NULL)
+ if (d_len == 0) {
+ size_t sz = nm_len + sizeof(*new_val) + 1;
+ new_val = AGALOC(sz, "empty nest");
+ if (new_val == NULL)
return NULL;
- pNV->v.nestVal = NULL;
- pNV->valType = OPARG_TYPE_HIERARCHY;
- pNV->pzName = (char*)(pNV + 1);
- memcpy(pNV->pzName, pzName, nameLen);
- pNV->pzName[ nameLen ] = NUL;
+ new_val->v.nestVal = NULL;
+ new_val->valType = OPARG_TYPE_HIERARCHY;
+ new_val->pzName = (char*)(new_val + 1);
+ memcpy(new_val->pzName, pzName, nm_len);
+ new_val->pzName[ nm_len ] = NUL;
} else {
- pNV = optionLoadNested(pzValue, pzName, nameLen);
+ new_val = optionLoadNested(val, pzName, nm_len);
}
- if (pNV != NULL)
- addArgListEntry(pp, pNV);
+ if (new_val != NULL)
+ addArgListEntry(pp, new_val);
- return pNV;
+ return new_val;
}
/**
static char const *
scan_name(char const* pzName, tOptionValue* pRes)
{
- tOptionValue* pNV;
+ tOptionValue* new_val;
char const * pzScan = pzName+1; /* we know first char is a name char */
char const * pzVal;
- size_t nameLen = 1;
- size_t dataLen = 0;
+ size_t nm_len = 1;
+ size_t d_len = 0;
/*
* Scan over characters that name a value. These names may not end
pzScan = SPN_VALUE_NAME_CHARS(pzName + 1);
if (pzScan[-1] == ':')
pzScan--;
- nameLen = pzScan - pzName;
+ nm_len = (size_t)(pzScan - pzName);
pzScan = SPN_HORIZ_WHITE_CHARS(pzScan);
/* FALLTHROUGH */
case NUL:
- add_string(&(pRes->v.nestVal), pzName, nameLen, NULL, (size_t)0);
+ add_string(&(pRes->v.nestVal), pzName, nm_len, NULL, (size_t)0);
break;
case '"':
case '\'':
pzVal = pzScan;
pzScan = scan_q_str(pzScan);
- dataLen = pzScan - pzVal;
- pNV = add_string(&(pRes->v.nestVal), pzName, nameLen, pzVal,
- dataLen);
- if ((pNV != NULL) && (option_load_mode == OPTION_LOAD_COOKED))
- ao_string_cook(pNV->v.strVal, NULL);
+ d_len = (size_t)(pzScan - pzVal);
+ new_val = add_string(&(pRes->v.nestVal), pzName, nm_len, pzVal,
+ d_len);
+ if ((new_val != NULL) && (option_load_mode == OPTION_LOAD_COOKED))
+ ao_string_cook(new_val->v.strVal, NULL);
break;
default:
switch (ch) {
case NUL:
pzScan--;
- dataLen = pzScan - pzVal;
+ d_len = (size_t)(pzScan - pzVal);
goto string_done;
/* FALLTHROUGH */
/* FALLTHROUGH */
case ',':
- dataLen = (pzScan - pzVal) - 1;
+ d_len = (size_t)(pzScan - pzVal) - 1;
string_done:
- pNV = add_string(&(pRes->v.nestVal), pzName, nameLen,
- pzVal, dataLen);
- if (pNV != NULL)
- remove_continuation(pNV->v.strVal);
+ new_val = add_string(&(pRes->v.nestVal), pzName, nm_len,
+ pzVal, d_len);
+ if (new_val != NULL)
+ remove_continuation(new_val->v.strVal);
goto leave_scan_name;
}
}
}
/**
- * We've found a '<' character. We ignore this if it is a comment or a
- * directive. If it is something else, then whatever it is we are looking
- * at is bogus. Returning NULL stops processing.
+ * Some xml element that does not start with a name.
+ * The next character must be either '!' (introducing a comment),
+ * or '?' (introducing an XML meta-marker of some sort).
+ * We ignore these and indicate an error (NULL result) otherwise.
+ *
+ * @param[in] txt the text within an xml bracket
+ * @returns the address of the character after the closing marker, or NULL.
*/
-static char const*
-scan_xml(char const* pzName, tOptionValue* pRes)
+static char const *
+unnamed_xml(char const * txt)
{
- size_t nameLen;
- size_t valLen;
- char const* pzScan = ++pzName;
- char const* pzVal;
- tOptionValue valu;
- tOptionValue* pNewVal;
- tOptionLoadMode save_mode = option_load_mode;
-
- if (! IS_VAR_FIRST_CHAR(*pzName)) {
- switch (*pzName) {
- default:
- pzName = NULL;
- break;
+ switch (*txt) {
+ default:
+ txt = NULL;
+ break;
- case '!':
- pzName = strstr(pzName, "-->");
- if (pzName != NULL)
- pzName += 3;
- break;
+ case '!':
+ txt = strstr(txt, "-->");
+ if (txt != NULL)
+ txt += 3;
+ break;
- case '?':
- pzName = strchr(pzName, '>');
- if (pzName != NULL)
- pzName++;
- break;
- }
- return pzName;
+ case '?':
+ txt = strchr(txt, '>');
+ if (txt != NULL)
+ txt++;
+ break;
}
+ return txt;
+}
- pzScan = SPN_VALUE_NAME_CHARS(pzName+1);
- nameLen = pzScan - pzName;
- if (nameLen > 64)
+/**
+ * Scan off the xml element name, and the rest of the header, too.
+ * Set the value type to NONE if it ends with "/>".
+ *
+ * @param[in] name the first name character (alphabetic)
+ * @param[out] nm_len the length of the name
+ * @param[out] val set valType field to STRING or NONE.
+ *
+ * @returns the scan resumption point, or NULL on error
+ */
+static char const *
+scan_xml_name(char const * name, size_t * nm_len, tOptionValue * val)
+{
+ char const * scan = SPN_VALUE_NAME_CHARS(name + 1);
+ *nm_len = (size_t)(scan - name);
+ if (*nm_len > 64)
return NULL;
- valu.valType = OPARG_TYPE_STRING;
+ val->valType = OPARG_TYPE_STRING;
- switch (*pzScan) {
- case ' ':
- case '\t':
- pzScan = parse_attrs(
- NULL, (char*)pzScan, &option_load_mode, &valu );
- if (*pzScan == '>') {
- pzScan++;
- break;
- }
+ if (IS_WHITESPACE_CHAR(*scan)) {
+ /*
+ * There are attributes following the name. Parse 'em.
+ */
+ scan = parse_attrs(NULL, SPN_WHITESPACE_CHARS(scan),
+ &option_load_mode, val);
+ if (scan == NULL)
+ return NULL; /* oops */
+ }
- if (*pzScan != '/') {
- option_load_mode = save_mode;
- return NULL;
- }
- /* FALLTHROUGH */
+ if (! IS_END_XML_TOKEN_CHAR(*scan))
+ return NULL; /* oops */
- case '/':
- if (*++pzScan != '>') {
- option_load_mode = save_mode;
+ if (*scan == '/') {
+ /*
+ * Single element XML entries get inserted as an empty string.
+ */
+ if (*++scan != '>')
return NULL;
- }
- add_string(&(pRes->v.nestVal), pzName, nameLen, NULL, (size_t)0);
- option_load_mode = save_mode;
- return pzScan+1;
-
- default:
- option_load_mode = save_mode;
- return NULL;
-
- case '>':
- pzScan++;
- break;
+ val->valType = OPARG_TYPE_NONE;
}
+ return scan+1;
+}
+
+/**
+ * We've found a closing '>' without a preceding '/', thus we must search
+ * the text for '<name/>' where "name" is the name of the XML element.
+ *
+ * @param[in] name the start of the name in the element header
+ * @param[in] nm_len the length of that name
+ * @param[out] len the length of the value (string between header and
+ * the trailer/tail.
+ * @returns the character after the trailer, or NULL if not found.
+ */
+static char const *
+find_end_xml(char const * src, size_t nm_len, char const * val, size_t * len)
+{
+ char z[72] = "</";
+ char * dst = z + 2;
- pzVal = pzScan;
+ do {
+ *(dst++) = *(src++);
+ } while (--nm_len > 0); /* nm_len is known to be 64 or less */
+ *(dst++) = '>';
+ *dst = NUL;
{
- char z[68];
- char* pzD = z;
- int ct = nameLen;
- char const* pzS = pzName;
-
- *(pzD++) = '<';
- *(pzD++) = '/';
-
- do {
- *(pzD++) = *(pzS++);
- } while (--ct > 0);
- *(pzD++) = '>';
- *pzD = NUL;
-
- pzScan = strstr(pzScan, z);
- if (pzScan == NULL) {
- option_load_mode = save_mode;
- return NULL;
+ char const * res = strstr(val, z);
+
+ if (res != NULL) {
+ char const * end = (option_load_mode != OPTION_LOAD_KEEP)
+ ? SPN_WHITESPACE_BACK(val, res)
+ : res;
+ *len = (size_t)(end - val); /* includes trailing white space */
+ res = SPN_WHITESPACE_CHARS(res + (dst - z));
}
- valLen = (pzScan - pzVal);
- pzScan += nameLen + 3;
- pzScan = SPN_WHITESPACE_CHARS(pzScan);
+ return res;
}
+}
+
+/**
+ * We've found a '<' character. We ignore this if it is a comment or a
+ * directive. If it is something else, then whatever it is we are looking
+ * at is bogus. Returning NULL stops processing.
+ *
+ * @param[in] xml_name the name of an xml bracket (usually)
+ * @param[in,out] res_val the option data derived from the XML element
+ *
+ * @returns the place to resume scanning input
+ */
+static char const *
+scan_xml(char const * xml_name, tOptionValue * res_val)
+{
+ size_t nm_len, v_len;
+ char const * scan;
+ char const * val_str;
+ tOptionValue valu;
+ tOptionLoadMode save_mode = option_load_mode;
+
+ if (! IS_VAR_FIRST_CHAR(*++xml_name))
+ return unnamed_xml(xml_name);
+
+ /*
+ * "scan_xml_name()" may change "option_load_mode".
+ */
+ val_str = scan_xml_name(xml_name, &nm_len, &valu);
+ if (val_str == NULL)
+ goto bail_scan_xml;
+
+ if (valu.valType == OPARG_TYPE_NONE)
+ scan = val_str;
+ else {
+ if (option_load_mode != OPTION_LOAD_KEEP)
+ val_str = SPN_WHITESPACE_CHARS(val_str);
+ scan = find_end_xml(xml_name, nm_len, val_str, &v_len);
+ if (scan == NULL)
+ goto bail_scan_xml;
+ }
+
+ /*
+ * "scan" now points to where the scan is to resume after returning.
+ * It either points after "/>" at the end of the XML element header,
+ * or it points after the "</name>" tail based on the name in the header.
+ */
switch (valu.valType) {
case OPARG_TYPE_NONE:
- add_string(&(pRes->v.nestVal), pzName, nameLen, NULL, (size_t)0);
+ add_string(&(res_val->v.nestVal), xml_name, nm_len, NULL, 0);
break;
case OPARG_TYPE_STRING:
- pNewVal = add_string(
- &(pRes->v.nestVal), pzName, nameLen, pzVal, valLen);
+ {
+ tOptionValue * new_val = add_string(
+ &(res_val->v.nestVal), xml_name, nm_len, val_str, v_len);
+
+ if (option_load_mode != OPTION_LOAD_KEEP)
+ munge_str(new_val->v.strVal, option_load_mode);
- if (option_load_mode == OPTION_LOAD_KEEP)
- break;
- mungeString(pNewVal->v.strVal, option_load_mode);
break;
+ }
case OPARG_TYPE_BOOLEAN:
- add_bool(&(pRes->v.nestVal), pzName, nameLen, pzVal, valLen);
+ add_bool(&(res_val->v.nestVal), xml_name, nm_len, val_str, v_len);
break;
case OPARG_TYPE_NUMERIC:
- add_number(&(pRes->v.nestVal), pzName, nameLen, pzVal, valLen);
+ add_number(&(res_val->v.nestVal), xml_name, nm_len, val_str, v_len);
break;
case OPARG_TYPE_HIERARCHY:
{
- char* pz = AGALOC(valLen+1, "hierarchical scan");
+ char * pz = AGALOC(v_len+1, "h scan");
if (pz == NULL)
break;
- memcpy(pz, pzVal, valLen);
- pz[valLen] = NUL;
- add_nested(&(pRes->v.nestVal), pzName, nameLen, pz, valLen);
+ memcpy(pz, val_str, v_len);
+ pz[v_len] = NUL;
+ add_nested(&(res_val->v.nestVal), xml_name, nm_len, pz, v_len);
AGFREE(pz);
break;
}
}
option_load_mode = save_mode;
- return pzScan;
+ return scan;
+
+bail_scan_xml:
+ option_load_mode = save_mode;
+ return NULL;
}
* knowing what they are doing.
*/
LOCAL void
-unload_arg_list(tArgList* pAL)
+unload_arg_list(tArgList * arg_list)
{
- int ct = pAL->useCt;
- tCC** ppNV = pAL->apzArgs;
+ int ct = arg_list->useCt;
+ char const ** pnew_val = arg_list->apzArgs;
while (ct-- > 0) {
- tOptionValue* pNV = (tOptionValue*)(void*)*(ppNV++);
- if (pNV->valType == OPARG_TYPE_HIERARCHY)
- unload_arg_list(pNV->v.nestVal);
- AGFREE(pNV);
+ tOptionValue* new_val = (tOptionValue*)(void*)*(pnew_val++);
+ if (new_val->valType == OPARG_TYPE_HIERARCHY)
+ unload_arg_list(new_val->v.nestVal);
+ AGFREE(new_val);
}
- AGFREE((void*)pAL);
+ AGFREE((void*)arg_list);
}
/*=export_func optionUnloadNested
* @pxref{libopts-configFileLoad}).
=*/
void
-optionUnloadNested(tOptionValue const * pOV)
+optionUnloadNested(tOptionValue const * opt_val)
{
- if (pOV == NULL) return;
- if (pOV->valType != OPARG_TYPE_HIERARCHY) {
+ if (opt_val == NULL) return;
+ if (opt_val->valType != OPARG_TYPE_HIERARCHY) {
errno = EINVAL;
return;
}
- unload_arg_list(pOV->v.nestVal);
+ unload_arg_list(opt_val->v.nestVal);
- AGFREE((void*)pOV);
+ AGFREE((void*)opt_val);
}
/**
* Typically, we also hope the input is sorted.
*/
static void
-sort_list(tArgList* pAL)
+sort_list(tArgList * arg_list)
{
int ix;
- int lm = pAL->useCt;
+ int lm = arg_list->useCt;
/*
* This loop iterates "useCt" - 1 times.
*/
for (ix = 0; ++ix < lm;) {
int iy = ix-1;
- tOptionValue* pNewNV = (tOptionValue*)(void*)(pAL->apzArgs[ix]);
- tOptionValue* pOldNV = (tOptionValue*)(void*)(pAL->apzArgs[iy]);
+ tOptionValue * new_v = C(tOptionValue *, arg_list->apzArgs[ix]);
+ tOptionValue * old_v = C(tOptionValue *, arg_list->apzArgs[iy]);
/*
* For as long as the new entry precedes the "old" entry,
* move the old pointer. Stop before trying to extract the
* "-1" entry.
*/
- while (strcmp(pOldNV->pzName, pNewNV->pzName) > 0) {
- pAL->apzArgs[iy+1] = (void*)pOldNV;
- pOldNV = (tOptionValue*)(void*)(pAL->apzArgs[--iy]);
+ while (strcmp(old_v->pzName, new_v->pzName) > 0) {
+ arg_list->apzArgs[iy+1] = (void*)old_v;
+ old_v = (tOptionValue*)(void*)(arg_list->apzArgs[--iy]);
if (iy < 0)
break;
}
* Always store the pointer. Sometimes it is redundant,
* but the redundancy is cheaper than a test and branch sequence.
*/
- pAL->apzArgs[iy+1] = (void*)pNewNV;
+ arg_list->apzArgs[iy+1] = (void*)new_v;
}
}
* private:
*
* what: parse a hierarchical option argument
- * arg: + char const* + pzTxt + the text to scan +
- * arg: + char const* + pzName + the name for the text +
- * arg: + size_t + nameLen + the length of "name" +
+ * arg: + char const * + pzTxt + the text to scan +
+ * arg: + char const * + pzName + the name for the text +
+ * arg: + size_t + nm_len + the length of "name" +
*
* ret_type: tOptionValue*
* ret_desc: An allocated, compound value structure
* @code{ENOMSG} no configuration values were found
* @end itemize
=*/
-LOCAL tOptionValue*
-optionLoadNested(char const* pzTxt, char const* pzName, size_t nameLen)
+LOCAL tOptionValue *
+optionLoadNested(char const * text, char const * name, size_t nm_len)
{
- tOptionValue* pRes;
+ tOptionValue* res_val;
/*
* Make sure we have some data and we have space to put what we find.
*/
- if (pzTxt == NULL) {
+ if (text == NULL) {
errno = EINVAL;
return NULL;
}
- pzTxt = SPN_WHITESPACE_CHARS(pzTxt);
- if (*pzTxt == NUL) {
+ text = SPN_WHITESPACE_CHARS(text);
+ if (*text == NUL) {
errno = ENOMSG;
return NULL;
}
- pRes = AGALOC(sizeof(*pRes) + nameLen + 1, "nested args");
- if (pRes == NULL) {
+ res_val = AGALOC(sizeof(*res_val) + nm_len + 1, "nest args");
+ if (res_val == NULL) {
errno = ENOMEM;
return NULL;
}
- pRes->valType = OPARG_TYPE_HIERARCHY;
- pRes->pzName = (char*)(pRes + 1);
- memcpy(pRes->pzName, pzName, nameLen);
- pRes->pzName[nameLen] = NUL;
+ res_val->valType = OPARG_TYPE_HIERARCHY;
+ res_val->pzName = (char*)(res_val + 1);
+ memcpy(res_val->pzName, name, nm_len);
+ res_val->pzName[nm_len] = NUL;
{
- tArgList * pAL = AGALOC(sizeof(*pAL), "nested arg list");
- if (pAL == NULL) {
- AGFREE(pRes);
+ tArgList * arg_list = AGALOC(sizeof(*arg_list), "nest arg l");
+ if (arg_list == NULL) {
+ AGFREE(res_val);
return NULL;
}
- pRes->v.nestVal = pAL;
- pAL->useCt = 0;
- pAL->allocCt = MIN_ARG_ALLOC_CT;
+ res_val->v.nestVal = arg_list;
+ arg_list->useCt = 0;
+ arg_list->allocCt = MIN_ARG_ALLOC_CT;
}
/*
* Scan until we hit a NUL.
*/
do {
- pzTxt = SPN_WHITESPACE_CHARS(pzTxt);
- if (IS_VAR_FIRST_CHAR(*pzTxt))
- pzTxt = scan_name(pzTxt, pRes);
+ text = SPN_WHITESPACE_CHARS(text);
+ if (IS_VAR_FIRST_CHAR(*text))
+ text = scan_name(text, res_val);
- else switch (*pzTxt) {
+ else switch (*text) {
case NUL: goto scan_done;
- case '<': pzTxt = scan_xml(pzTxt, pRes);
- if (pzTxt == NULL) goto woops;
- if (*pzTxt == ',') pzTxt++; break;
- case '#': pzTxt = strchr(pzTxt, NL); break;
+ case '<': text = scan_xml(text, res_val);
+ if (text == NULL) goto woops;
+ if (*text == ',') text++; break;
+ case '#': text = strchr(text, NL); break;
default: goto woops;
}
- } while (pzTxt != NULL); scan_done:;
+ } while (text != NULL); scan_done:;
{
- tArgList * al = pRes->v.nestVal;
+ tArgList * al = res_val->v.nestVal;
if (al->useCt == 0) {
errno = ENOMSG;
goto woops;
sort_list(al);
}
- return pRes;
+ return res_val;
woops:
- AGFREE(pRes->v.nestVal);
- AGFREE(pRes);
+ AGFREE(res_val->v.nestVal);
+ AGFREE(res_val);
return NULL;
}
* private:
*
* what: parse a hierarchical option argument
- * arg: + tOptions* + pOpts + program options descriptor +
- * arg: + tOptDesc* + pOptDesc + the descriptor for this arg +
+ * arg: + tOptions* + opts + program options descriptor +
+ * arg: + tOptDesc* + od + the descriptor for this arg +
*
* doc:
* Nested value was found on the command line
=*/
void
-optionNestedVal(tOptions* pOpts, tOptDesc* pOD)
+optionNestedVal(tOptions * opts, tOptDesc * od)
{
- if (pOpts < OPTPROC_EMIT_LIMIT)
+ if (opts < OPTPROC_EMIT_LIMIT)
return;
- if (pOD->fOptState & OPTST_RESET) {
- tArgList* pAL = pOD->optCookie;
- int ct;
- tCC ** av;
+ if (od->fOptState & OPTST_RESET) {
+ tArgList * arg_list = od->optCookie;
+ int ct;
+ char const ** av;
- if (pAL == NULL)
+ if (arg_list == NULL)
return;
- ct = pAL->useCt;
- av = pAL->apzArgs;
+ ct = arg_list->useCt;
+ av = arg_list->apzArgs;
while (--ct >= 0) {
void * p = (void *)*(av++);
optionUnloadNested((tOptionValue const *)p);
}
- AGFREE(pOD->optCookie);
+ AGFREE(od->optCookie);
} else {
- tOptionValue* pOV = optionLoadNested(
- pOD->optArg.argString, pOD->pz_Name, strlen(pOD->pz_Name));
+ tOptionValue * opt_val = optionLoadNested(
+ od->optArg.argString, od->pz_Name, strlen(od->pz_Name));
- if (pOV != NULL)
- addArgListEntry(&(pOD->optCookie), (void*)pOV);
+ if (opt_val != NULL)
+ addArgListEntry(&(od->optCookie), (void*)opt_val);
}
}
-/*
+/**
* get_special_char
*/
LOCAL int
retch = (int)strtoul(pz, (char **)&pz, base);
if (*pz != ';')
return '&';
- base = ++pz - *ppz;
+ base = (int)(++pz - *ppz);
if (base > *ct)
return '&';
for (;;) {
if ( (*ct >= xlatp->xml_len)
- && (strncmp(pz, xlatp->xml_txt, xlatp->xml_len) == 0)) {
+ && (strncmp(pz, xlatp->xml_txt, (size_t)xlatp->xml_len) == 0)) {
*ppz += xlatp->xml_len;
*ct -= xlatp->xml_len;
return xlatp->xml_ch;
return '&';
}
-/*
+/**
* emit_special_char
*/
LOCAL void
/**
* \file numeric.c
*
- * Time-stamp: "2012-02-25 12:54:32 bkorb"
- *
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
* AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
/*=export_func optionShowRange
* private:
*
- * what:
+ * what: Show info about range constraints
* arg: + tOptions* + pOpts + program options descriptor +
* arg: + tOptDesc* + pOptDesc + the descriptor for this arg +
* arg: + void * + rng_table + the value range tables +
--- /dev/null
+/* -*- buffer-read-only: t -*- vi: set ro:
+ *
+ * DO NOT EDIT THIS FILE (stdin.c)
+ *
+ * It has been AutoGen-ed December 27, 2012 at 12:59:01 PM by AutoGen 5.17.0pre12
+ * From the definitions stdin
+ * and the template file str2enum
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name ``Bruce Korb'' nor the name of any other
+ * contributor may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * str2enum IS PROVIDED BY Bruce Korb ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL Bruce Korb OR ANY OTHER CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "option-value-type.h"
+/* ANSI-C code produced by gperf version 3.0.4 */
+/* Command-line: gperf option-value-type.gp */
+/* Computed positions: -k'1' */
+
+
+
+# if 0 /* gperf build options: */
+// %struct-type
+// %language=ANSI-C
+// %includes
+// %global-table
+// %omit-struct-type
+// %readonly-tables
+// %compare-strncmp
+//
+// %define slot-name vtp_name
+// %define hash-function-name option_value_type_hash
+// %define lookup-function-name find_option_value_type_name
+// %define word-array-name option_value_type_table
+// %define initializer-suffix ,VTP_COUNT_CMD
+//
+# endif
+
+#include "option-value-type.h"
+typedef struct {
+ char const * vtp_name;
+ option_value_type_enum_t vtp_id;
+} option_value_type_map_t;
+#include <string.h>
+
+/* maximum key range = 15, duplicates = 0 */
+
+static unsigned int
+option_value_type_hash (register const char *str, register unsigned int len)
+{
+ static const unsigned char asso_values[] =
+ {
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 0, 18,
+ 18, 18, 18, 18, 0, 10, 18, 5, 18, 18,
+ 5, 18, 18, 18, 18, 0, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18
+ };
+ return len + asso_values[(unsigned char)str[0]];
+}
+
+static const option_value_type_map_t option_value_type_table[] =
+ {
+ {"",VTP_COUNT_CMD}, {"",VTP_COUNT_CMD},
+ {"",VTP_COUNT_CMD},
+ {"set", VTP_CMD_SET},
+ {"bool", VTP_CMD_BOOL},
+ {"",VTP_COUNT_CMD},
+ {"string", VTP_CMD_STRING},
+ {"boolean", VTP_CMD_BOOLEAN},
+ {"",VTP_COUNT_CMD},
+ {"hierarchy", VTP_CMD_HIERARCHY},
+ {"",VTP_COUNT_CMD},
+ {"nested", VTP_CMD_NESTED},
+ {"keyword", VTP_CMD_KEYWORD},
+ {"",VTP_COUNT_CMD},
+ {"set-membership", VTP_CMD_SET_MEMBERSHIP},
+ {"",VTP_COUNT_CMD}, {"",VTP_COUNT_CMD},
+ {"integer", VTP_CMD_INTEGER}
+ };
+
+static inline const option_value_type_map_t *
+find_option_value_type_name (register const char *str, register unsigned int len)
+{
+ if (len <= 14 && len >= 3)
+ {
+ register int key = (int)option_value_type_hash (str, len);
+
+ if (key <= 17 && key >= 0)
+ {
+ register const char *s = option_value_type_table[key].vtp_name;
+
+ if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
+ return &option_value_type_table[key];
+ }
+ }
+ return 0;
+}
+
+/**
+ * Convert a command (keyword) to a option_value_type_enum_t enumeration value.
+ *
+ * @param[in] str a string that should start with a known key word.
+ * @param[in] len the provided length of the keyword at \a str.
+ * @returns the enumeration value.
+ * If not found, that value is VTP_INVALID_CMD.
+ */
+option_value_type_enum_t
+find_option_value_type_cmd(char const * str, size_t len)
+{
+ option_value_type_map_t const * map;
+
+ map = find_option_value_type_name(str, (unsigned int)len);
+ return (map == NULL) ? VTP_INVALID_CMD : map->vtp_id;
+}
+
+/* end of option-value-type.c */
--- /dev/null
+/* -*- buffer-read-only: t -*- vi: set ro:
+ *
+ * DO NOT EDIT THIS FILE (stdin.h)
+ *
+ * It has been AutoGen-ed December 27, 2012 at 12:59:01 PM by AutoGen 5.17.0pre12
+ * From the definitions stdin
+ * and the template file str2enum
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name ``Bruce Korb'' nor the name of any other
+ * contributor may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * str2enum IS PROVIDED BY Bruce Korb ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL Bruce Korb OR ANY OTHER CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Command/Keyword Dispatcher
+ */
+#ifndef STR2ENUM_OPTION_VALUE_TYPE_H_GUARD
+#define STR2ENUM_OPTION_VALUE_TYPE_H_GUARD 1
+#include <sys/types.h>
+#include <inttypes.h>
+
+typedef enum {
+ VTP_INVALID_CMD = 0,
+ VTP_CMD_STRING = 1,
+ VTP_CMD_INTEGER = 2,
+ VTP_CMD_BOOLEAN = 3,
+ VTP_CMD_BOOL = 4,
+ VTP_CMD_KEYWORD = 5,
+ VTP_CMD_SET = 6,
+ VTP_CMD_SET_MEMBERSHIP = 7,
+ VTP_CMD_NESTED = 8,
+ VTP_CMD_HIERARCHY = 9,
+ VTP_COUNT_CMD
+} option_value_type_enum_t;
+
+extern option_value_type_enum_t
+find_option_value_type_cmd(char const * str, size_t len);
+
+#endif /* STR2ENUM_OPTION_VALUE_TYPE_H_GUARD */
+/* end of option-value-type.h */
--- /dev/null
+/* -*- buffer-read-only: t -*- vi: set ro:
+ *
+ * DO NOT EDIT THIS FILE (stdin.c)
+ *
+ * It has been AutoGen-ed December 27, 2012 at 12:59:00 PM by AutoGen 5.17.0pre12
+ * From the definitions stdin
+ * and the template file str2enum
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name ``Bruce Korb'' nor the name of any other
+ * contributor may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * str2enum IS PROVIDED BY Bruce Korb ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL Bruce Korb OR ANY OTHER CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "option-xat-attribute.h"
+/* ANSI-C code produced by gperf version 3.0.4 */
+/* Command-line: gperf option-xat-attribute.gp */
+/* Computed positions: -k'1' */
+
+
+
+# if 0 /* gperf build options: */
+// %struct-type
+// %language=ANSI-C
+// %includes
+// %global-table
+// %omit-struct-type
+// %readonly-tables
+// %compare-strncmp
+//
+// %define slot-name xat_name
+// %define hash-function-name option_xat_attribute_hash
+// %define lookup-function-name find_option_xat_attribute_name
+// %define word-array-name option_xat_attribute_table
+// %define initializer-suffix ,XAT_COUNT_CMD
+//
+# endif
+
+#include "option-xat-attribute.h"
+typedef struct {
+ char const * xat_name;
+ option_xat_attribute_enum_t xat_id;
+} option_xat_attribute_map_t;
+#include <string.h>
+
+/* maximum key range = 6, duplicates = 0 */
+
+static unsigned int
+option_xat_attribute_hash (register const char *str, register unsigned int len)
+{
+ static const unsigned char asso_values[] =
+ {
+ 10,10,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10, 0,
+ 10,10,10,10,10,10,10, 5,10, 0,
+ 10,10,10,10,10,10, 0, 0,10, 0,
+ 10,10,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10
+ };
+ return len + asso_values[(unsigned char)str[0]];
+}
+
+static const option_xat_attribute_map_t option_xat_attribute_table[] =
+ {
+ {"",XAT_COUNT_CMD}, {"",XAT_COUNT_CMD},
+ {"",XAT_COUNT_CMD}, {"",XAT_COUNT_CMD},
+ {"type", XAT_CMD_TYPE},
+ {"words", XAT_CMD_WORDS},
+ {"cooked", XAT_CMD_COOKED},
+ {"members", XAT_CMD_MEMBERS},
+ {"uncooked", XAT_CMD_UNCOOKED},
+ {"keep", XAT_CMD_KEEP}
+ };
+
+static inline const option_xat_attribute_map_t *
+find_option_xat_attribute_name (register const char *str, register unsigned int len)
+{
+ if (len <= 8 && len >= 4)
+ {
+ register int key = (int)option_xat_attribute_hash (str, len);
+
+ if (key <= 9 && key >= 0)
+ {
+ register const char *s = option_xat_attribute_table[key].xat_name;
+
+ if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
+ return &option_xat_attribute_table[key];
+ }
+ }
+ return 0;
+}
+
+/**
+ * Convert a command (keyword) to a option_xat_attribute_enum_t enumeration value.
+ *
+ * @param[in] str a string that should start with a known key word.
+ * @param[in] len the provided length of the keyword at \a str.
+ * @returns the enumeration value.
+ * If not found, that value is XAT_INVALID_CMD.
+ */
+option_xat_attribute_enum_t
+find_option_xat_attribute_cmd(char const * str, size_t len)
+{
+ option_xat_attribute_map_t const * map;
+
+ map = find_option_xat_attribute_name(str, (unsigned int)len);
+ return (map == NULL) ? XAT_INVALID_CMD : map->xat_id;
+}
+
+/* end of option-xat-attribute.c */
--- /dev/null
+/* -*- buffer-read-only: t -*- vi: set ro:
+ *
+ * DO NOT EDIT THIS FILE (stdin.h)
+ *
+ * It has been AutoGen-ed December 27, 2012 at 12:59:00 PM by AutoGen 5.17.0pre12
+ * From the definitions stdin
+ * and the template file str2enum
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name ``Bruce Korb'' nor the name of any other
+ * contributor may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * str2enum IS PROVIDED BY Bruce Korb ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL Bruce Korb OR ANY OTHER CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Command/Keyword Dispatcher
+ */
+#ifndef STR2ENUM_OPTION_XAT_ATTRIBUTE_H_GUARD
+#define STR2ENUM_OPTION_XAT_ATTRIBUTE_H_GUARD 1
+#include <sys/types.h>
+#include <inttypes.h>
+
+typedef enum {
+ XAT_INVALID_CMD = 0,
+ XAT_CMD_TYPE = 1,
+ XAT_CMD_WORDS = 2,
+ XAT_CMD_MEMBERS = 3,
+ XAT_CMD_COOKED = 4,
+ XAT_CMD_UNCOOKED = 5,
+ XAT_CMD_KEEP = 6,
+ XAT_COUNT_CMD
+} option_xat_attribute_enum_t;
+
+extern option_xat_attribute_enum_t
+find_option_xat_attribute_cmd(char const * str, size_t len);
+
+#endif /* STR2ENUM_OPTION_XAT_ATTRIBUTE_H_GUARD */
+/* end of option-xat-attribute.h */
#define TIME_MAX 0x7FFFFFFF
/* Wrapper around strtoul that does not require a cast. */
-static unsigned long inline
+static unsigned long
str_const_to_ul (cch_t * str, cch_t ** ppz, int base)
{
return strtoul (str, (char **)ppz, base);
}
/* Wrapper around strtol that does not require a cast. */
-static long inline
+static long
str_const_to_l (cch_t * str, cch_t ** ppz, int base)
{
return strtol (str, (char **)ppz, base);
/* Returns BASE + VAL * SCALE, interpreting BASE = BAD_TIME
with errno set as an error situation, and returning BAD_TIME
with errno set in an error situation. */
-static time_t inline
+static time_t
scale_n_add (time_t base, time_t val, int scale)
{
if (base == BAD_TIME)
if (errno != 0)
return BAD_TIME;
- start = scale_n_add (v, start, 60);
+ start = scale_n_add ((time_t)v, start, 60);
if (errno != 0)
return BAD_TIME;
return base;
errno = 0;
- val = str_const_to_ul (pz, &pz, 10);
+ val = (time_t)str_const_to_ul (pz, &pz, 10);
if (errno != 0)
return BAD_TIME;
while (isspace ((unsigned char)*pz))
break;
}
- res = scale_n_add (res, val, mult);
+ res = scale_n_add (res, (time_t)val, (int)mult);
pz++;
while (isspace ((unsigned char)*pz))
/**
* \file pgusage.c
*
- * Time-stamp: "2012-02-28 19:49:32 bkorb"
- *
* Automated Options Paged Usage module.
*
* This routine will run run-on options through a pager so the
* private:
*
* what: Decipher a boolean value
- * arg: + tOptions* + pOpts + program options descriptor +
- * arg: + tOptDesc* + pOptDesc + the descriptor for this arg +
+ * arg: + tOptions* + opts + program options descriptor +
+ * arg: + tOptDesc* + od + the descriptor for this arg +
*
* doc:
* Run the usage output through a pager.
* This is disabled on platforms without a working fork() function.
=*/
void
-optionPagedUsage(tOptions * pOptions, tOptDesc * pOD)
+optionPagedUsage(tOptions * opts, tOptDesc * od)
{
#if ! defined(HAVE_WORKING_FORK)
- if ((pOD->fOptState & OPTST_RESET) != 0)
+ if ((od->fOptState & OPTST_RESET) != 0)
return;
- (*pOptions->pUsageProc)(pOptions, EXIT_SUCCESS);
+ (*opts->pUsageProc)(opts, EXIT_SUCCESS);
#else
static pid_t my_pid;
- char zPageUsage[ 1024 ];
+ char fil_name[1024];
/*
* IF we are being called after the usage proc is done
switch (pagerState) {
case PAGER_STATE_INITIAL:
{
- if ((pOD->fOptState & OPTST_RESET) != 0)
+ if ((od->fOptState & OPTST_RESET) != 0)
return;
my_pid = getpid();
- snprintf(zPageUsage, sizeof(zPageUsage), TMP_USAGE_FMT, (tAoUL)my_pid);
- unlink(zPageUsage);
+ 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(zPageUsage, "w" FOPEN_BINARY_FLAG);
+ option_usage_fp = fopen(fil_name, "w" FOPEN_BINARY_FLAG);
if (option_usage_fp == NULL)
_exit(EXIT_FAILURE);
* The usage procedure will now put the usage information into
* the temporary file we created above.
*/
- (*pOptions->pUsageProc)(pOptions, EXIT_SUCCESS);
+ (*opts->pUsageProc)(opts, EXIT_SUCCESS);
/* NOTREACHED */
_exit(EXIT_FAILURE);
case PAGER_STATE_READY:
{
- tCC* pzPager = (tCC*)getenv(PAGER_NAME);
+ char const * pager = (char const *)getenv(PAGER_NAME);
/*
* Use the "more(1)" program if "PAGER" has not been defined
*/
- if (pzPager == NULL)
- pzPager = MORE_STR;
+ if (pager == NULL)
+ pager = MORE_STR;
/*
* Page the file and remove it when done.
*/
- snprintf(zPageUsage, sizeof(zPageUsage), PAGE_USAGE_FMT, pzPager,
- (tAoUL)my_pid);
+ snprintf(fil_name, sizeof(fil_name), PAGE_USAGE_FMT, pager,
+ (unsigned long)my_pid);
fclose(stderr);
dup2(STDOUT_FILENO, STDERR_FILENO);
- (void)system(zPageUsage);
+ ignore_val( system( fil_name));
}
case PAGER_STATE_CHILD:
/* -*- buffer-read-only: t -*- vi: set ro:
*
* Prototypes for autoopts
- * Generated Sat Aug 11 09:41:23 PDT 2012
+ * Generated Thu Dec 27 12:59:13 PST 2012
*/
#ifndef AUTOOPTS_PROTO_H_GUARD
#define AUTOOPTS_PROTO_H_GUARD 1
ao_strdup(char const *str);
LOCAL tSuccess
-handle_opt(tOptions * pOpts, tOptState* pOptState);
+handle_opt(tOptions * pOpts, tOptState * o_st);
LOCAL tSuccess
-immediate_opts(tOptions * pOpts);
+next_opt(tOptions * opts, tOptState * o_st);
LOCAL tSuccess
-regular_opts(tOptions * pOpts);
+regular_opts(tOptions * opts);
/*
* Extracted from check.c
* Extracted from configfile.c
*/
LOCAL void
-intern_file_load(tOptions* pOpts);
+intern_file_load(tOptions * opts);
LOCAL char*
-parse_attrs(tOptions * pOpts, char * pzText, tOptionLoadMode * pMode,
+parse_attrs(tOptions * opts, char * txt, tOptionLoadMode * pMode,
tOptionValue * pType);
-LOCAL tSuccess
-validate_struct(tOptions * pOpts, char const * pzProgram);
-
/*
* Extracted from env.c
*/
opt_find_short(tOptions* pOpts, uint_t optValue, tOptState* pOptState);
LOCAL tSuccess
-get_opt_arg(tOptions * pOpts, tOptState * pOptState);
+get_opt_arg(tOptions * opts, tOptState * o_st);
+
+LOCAL tSuccess
+find_opt(tOptions * opts, tOptState * o_st);
+
+/*
+ * Extracted from init.c
+ */
+LOCAL tSuccess
+validate_struct(tOptions * opts, char const * pname);
LOCAL tSuccess
-find_opt(tOptions * pOpts, tOptState * pOptState);
+immediate_opts(tOptions * opts);
+
+LOCAL bool
+ao_initialize(tOptions * opts, int a_ct, char ** a_v);
/*
* Extracted from load.c
*/
LOCAL void
-mungeString(char * txt, tOptionLoadMode mode);
+munge_str(char * txt, tOptionLoadMode mode);
LOCAL void
loadOptionLine(
* Extracted from nested.c
*/
LOCAL void
-unload_arg_list(tArgList* pAL);
+unload_arg_list(tArgList * arg_list);
-LOCAL tOptionValue*
-optionLoadNested(char const* pzTxt, char const* pzName, size_t nameLen);
+LOCAL tOptionValue *
+optionLoadNested(char const * text, char const * name, size_t nm_len);
LOCAL int
get_special_char(char const ** ppz, int * ct);
/**
* \file putshell.c
*
- * Time-stamp: "2012-03-31 13:14:18 bkorb"
- *
* This module will interpret the options set in the tOptions
* structure and print them to standard out in a fashion that
* will allow them to be interpreted by the Bourne or Korn shells.
/**
* \file reset.c
*
- * Time-stamp: "2012-08-11 08:35:11 bkorb"
- *
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
* AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
return;
}
- succ = opt_find_short(pOpts, (tAoUC)*pzArg, &opt_state);
+ succ = opt_find_short(pOpts, (uint8_t)*pzArg, &opt_state);
if (! SUCCESSFUL(succ)) {
fprintf(stderr, zIllOptChr, pOpts->pzProgPath, *pzArg);
pOpts->pUsageProc(pOpts, EXIT_FAILURE);
/*
* \file restore.c
*
- * Time-stamp: "2010-08-22 11:04:00 bkorb"
- *
* This module's routines will save the current option state to memory
* and restore it. If saved prior to the initial optionProcess call,
* then the initial state will be restored.
* Otherwise, it will always succeed.
=*/
void
-optionSaveState(tOptions* pOpts)
+optionSaveState(tOptions * pOpts)
{
- tOptions* p = (tOptions*)pOpts->pSavedState;
+ tOptions * p = (tOptions*)pOpts->pSavedState;
if (p == NULL) {
- size_t sz = sizeof(*pOpts) + (pOpts->optCt * sizeof(tOptDesc));
+ size_t sz = sizeof(*pOpts)
+ + ((size_t)pOpts->optCt * sizeof(tOptDesc));
p = AGALOC(sz, "saved option state");
if (p == NULL) {
tCC* pzName = pOpts->pzProgName;
}
memcpy(p, pOpts, sizeof(*p));
- memcpy(p + 1, pOpts->pOptDesc, p->optCt * sizeof(tOptDesc));
+ memcpy(p + 1, pOpts->pOptDesc, (size_t)p->optCt * sizeof(tOptDesc));
fixupSavedOptionArgs(pOpts);
}
optionFree(pOpts);
memcpy(pOpts, p, sizeof(*p));
- memcpy(pOpts->pOptDesc, p+1, p->optCt * sizeof(tOptDesc));
+ memcpy(pOpts->pOptDesc, p+1, (size_t)p->optCt * sizeof(tOptDesc));
pOpts->pSavedState = p;
fixupSavedOptionArgs(pOpts);
if (pOpts->pSavedState != NULL) {
tOptions * p = (tOptions*)pOpts->pSavedState;
memcpy(pOpts, p, sizeof(*p));
- memcpy(pOpts->pOptDesc, p+1, p->optCt * sizeof(tOptDesc));
+ memcpy(pOpts->pOptDesc, p+1, (size_t)p->optCt * sizeof(tOptDesc));
AGFREE(pOpts->pSavedState);
pOpts->pSavedState = NULL;
goto free_saved_state;
/*
* \file save.c
*
- * Time-stamp: "2012-03-31 13:15:19 bkorb"
- *
* This module's routines will take the currently set options and
* store them into an ".rc" file for re-interpretation the next
* time the invoking program is run.
case OPARG_TYPE_ENUMERATION:
case OPARG_TYPE_MEMBERSHIP:
if (pOD != NULL) {
- tAoUI opt_state = pOD->fOptState;
+ uint32_t opt_state = pOD->fOptState;
uintptr_t val = pOD->optArg.argEnum;
char const * typ = (ovp->valType == OPARG_TYPE_ENUMERATION)
? "keyword" : "set-membership";
/*
* \file sort.c
*
- * Time-stamp: "2011-05-24 18:07:14 bkorb"
- *
* This module implements argument sorting.
*
* This file is part of AutoOpts, a companion to AutoGen.
char** ppzOpts, int* pOptsIdx)
{
while (*pzArg != NUL) {
- if (FAILED(opt_find_short(pOpts, (tAoUC)*pzArg, pOS)))
+ if (FAILED(opt_find_short(pOpts, (uint8_t)*pzArg, pOS)))
return FAILURE;
/*
if ((pOpts->fOptSet & OPTPROC_SHORTOPT) == 0) {
res = opt_find_long(pOpts, pzArg+1, &os);
} else {
- res = opt_find_short(pOpts, (tAoUC)pzArg[1], &os);
+ res = opt_find_short(pOpts, (uint8_t)pzArg[1], &os);
}
break;
}
joinLists:
if (optsIdx > 0)
- memcpy(pOpts->origArgVect + 1, ppzOpts, optsIdx * sizeof(char*));
+ memcpy(pOpts->origArgVect + 1, ppzOpts,
+ (size_t)optsIdx * sizeof(char*));
if (opdsIdx > 0)
memcpy(pOpts->origArgVect + 1 + optsIdx, ppzOpds,
- opdsIdx * sizeof(char*));
+ (size_t)opdsIdx * sizeof(char*));
freeTemps:
free(ppzOpts);
/**
* \file stack.c
*
- * Time-stamp: "2012-08-11 08:35:28 bkorb"
- *
* This is a special option processing routine that will save the
* argument to an option in a FIFO queue.
*
* The base structure contains space for MIN_ARG_ALLOC_CT
* pointers. We subtract it off to find our augment size.
*/
- sz += sizeof(char*) * (pAL->allocCt - MIN_ARG_ALLOC_CT);
+ sz += sizeof(char*) * ((size_t)pAL->allocCt - MIN_ARG_ALLOC_CT);
pAL = (tArgList*)AGREALOC((void*)pAL, sz, "expanded opt arg stack");
if (pAL == NULL)
return;
/**
* \file streqvcmp.c
*
- * Time-stamp: "2012-03-31 13:17:39 bkorb"
- *
* String Equivalence Comparison
*
* These routines allow any character to be mapped to any other
strequate(char const* s)
{
if ((s != NULL) && (*s != NUL)) {
- unsigned char equiv = (unsigned)*s;
+ unsigned char equiv = (unsigned char)*s;
while (*s != NUL)
charmap[ (unsigned)*(s++) ] = equiv;
}
*
* Map a text file, ensuring the text always has an ending NUL byte.
*
- * Time-stamp: "2012-01-29 09:40:21 bkorb"
- *
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
* AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
mapinfo->txt_errno = 0;
#else /* HAVE mmap */
- size_t const pgsz = GETPAGESIZE();
+ size_t const pgsz = (size_t)GETPAGESIZE();
void * map_addr = NULL;
(void)pzFile;
return;
}
- mapinfo->txt_size = sb.st_size;
+ mapinfo->txt_size = (size_t)sb.st_size;
}
/*
/**
* \file time.c
*
- * Time-stamp: "2012-08-11 08:34:17 bkorb"
- *
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
* AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
pOD->fOptState &= ~OPTST_ALLOC_ARG;
}
- pOD->optArg.argInt = (unsigned long)val;
+ pOD->optArg.argInt = (long)val;
}
/*=export_func optionTimeDate
}
return;
-default_action:
+ default_action:
#endif
optionTimeVal(pOpts, pOD);
if (pOD->optArg.argInt != BAD_TIME)
- pOD->optArg.argInt += (unsigned long)time(NULL);
+ pOD->optArg.argInt += (long)time(NULL);
}
/*
* Local Variables:
/*
* This file defines the string_tokenize interface
- * Time-stamp: "2012-03-04 13:23:50 bkorb"
- *
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
* AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
pz = SPN_WHITESPACE_CHARS(pz);
} while (*pz != NUL);
- res = malloc(sizeof(*res) + (pz - str)
- + (max_token_ct * sizeof(ch_t*)));
+ res = malloc(sizeof(*res) + (size_t)(pz - str)
+ + ((size_t)max_token_ct * sizeof(ch_t*)));
}
if (res == NULL)
/*
* \file usage.c
*
- * Time-stamp: "2012-03-31 19:19:26 bkorb"
- *
* This module implements the default usage procedure for
* Automated Options. It may be overridden, of course.
*
char const * pOptTitle);
static void
-prt_ini_list(char const * const * papz, bool * pInitIntro,
- char const * pzRc, char const * pzPN);
+prt_ini_list(char const * const * papz, bool * need_intro,
+ char const * ini_file, char const * path_nm);
static void
-prt_preamble(tOptions * pOptions, tOptDesc * pOD, arg_types_t * pAT);
+prt_preamble(tOptions * opts, tOptDesc * od, arg_types_t * at);
static void
-prt_one_usage(tOptions * pOptions, tOptDesc * pOD, arg_types_t * pAT);
+prt_one_usage(tOptions * opts, tOptDesc * od, arg_types_t * at);
static void
-prt_opt_usage(tOptions * pOpts, int ex_code, char const * pOptTitle);
+prt_opt_usage(tOptions * opts, int ex_code, char const * title);
static void
-prt_prog_detail(tOptions* pOptions);
+prt_prog_detail(tOptions * opts);
static int
-setGnuOptFmts(tOptions* pOpts, tCC** ppT);
+setGnuOptFmts(tOptions * opts, char const ** ptxt);
static int
-setStdOptFmts(tOptions* pOpts, tCC** ppT);
+setStdOptFmts(tOptions * opts, char const ** ptxt);
/* = = = END-STATIC-FORWARD = = = */
/*
ao_flag_names_t const * fnt = fn_table;
for (;;) {
- if (strneqvcmp(flg_txt, fnt->fnm_name, fnt->fnm_len) == 0)
+ if (strneqvcmp(flg_txt, fnt->fnm_name, (int)fnt->fnm_len) == 0)
break;
if (++ix >= AOUF_COUNT)
return;
if (! IS_END_LIST_ENTRY_CHAR(flg_txt[fnt->fnm_len]))
return;
- flg |= 1 << ix;
+ flg |= 1U << ix;
flg_txt = SPN_WHITESPACE_CHARS(flg_txt + fnt->fnm_len);
if (*flg_txt == NUL)
return;
-bogus_desc:
+ bogus_desc:
fprintf(stderr, zInvalOptDesc, pOD->pz_Name);
exit(EX_SOFTWARE);
}
* squishy, but important to tell users how to find these files.
*/
static void
-prt_ini_list(char const * const * papz, bool * pInitIntro,
- char const * pzRc, char const * pzPN)
+prt_ini_list(char const * const * papz, bool * need_intro,
+ char const * ini_file, char const * path_nm)
{
- char zPath[AG_PATH_MAX+1];
+ char pth_buf[AG_PATH_MAX+1];
if (papz == NULL)
return;
fputs(zPresetIntro, option_usage_fp);
- *pInitIntro = false;
+ *need_intro = false;
for (;;) {
- char const * pzPath = *(papz++);
- char const * pzReal = zPath;
+ char const * path = *(papz++);
+ char const * nm_buf = pth_buf;
- if (pzPath == NULL)
+ if (path == NULL)
break;
/*
* Ignore any invalid paths
*/
- if (! optionMakePath(zPath, (int)sizeof(zPath), pzPath, pzPN))
- pzReal = pzPath;
+ if (! optionMakePath(pth_buf, (int)sizeof(pth_buf), path, path_nm))
+ nm_buf = path;
/*
* Expand paths that are relative to the executable or installation
* directories. Leave alone paths that use environment variables.
*/
- else if ((*pzPath == '$')
- && ((pzPath[1] == '$') || (pzPath[1] == '@')))
- pzPath = pzReal;
+ else if ((*path == '$')
+ && ((path[1] == '$') || (path[1] == '@')))
+ path = nm_buf;
/*
* Print the name of the "homerc" file. If the "rcfile" name is
* not empty, we may or may not print that, too...
*/
- fprintf(option_usage_fp, zPathFmt, pzPath);
- if (*pzRc != NUL) {
+ fprintf(option_usage_fp, zPathFmt, path);
+ if (*ini_file != NUL) {
struct stat sb;
/*
* IF the "homerc" file is a directory,
* then append the "rcfile" name.
*/
- if ((stat(pzReal, &sb) == 0) && S_ISDIR(sb.st_mode)) {
- fputc(DIRCH, option_usage_fp);
- fputs(pzRc, option_usage_fp);
+ if ((stat(nm_buf, &sb) == 0) && S_ISDIR(sb.st_mode)) {
+ fputc(DIRCH, option_usage_fp);
+ fputs(ini_file, option_usage_fp);
}
}
static void
-prt_preamble(tOptions * pOptions, tOptDesc * pOD, arg_types_t * pAT)
+prt_preamble(tOptions * opts, tOptDesc * od, arg_types_t * at)
{
/*
* Flag prefix: IF no flags at all, then omit it. If not printable
* Follow it with a comma if we are doing GNU usage and long
* opts are to be printed too.
*/
- if ((pOptions->fOptSet & OPTPROC_SHORTOPT) == 0)
- fputs(pAT->pzSpc, option_usage_fp);
+ if ((opts->fOptSet & OPTPROC_SHORTOPT) == 0)
+ fputs(at->pzSpc, option_usage_fp);
- else if (! IS_GRAPHIC_CHAR(pOD->optValue)) {
- if ( (pOptions->fOptSet & (OPTPROC_GNUUSAGE|OPTPROC_LONGOPT))
+ else if (! IS_GRAPHIC_CHAR(od->optValue)) {
+ if ( (opts->fOptSet & (OPTPROC_GNUUSAGE|OPTPROC_LONGOPT))
== (OPTPROC_GNUUSAGE|OPTPROC_LONGOPT))
fputc(' ', option_usage_fp);
- fputs(pAT->pzNoF, option_usage_fp);
+ fputs(at->pzNoF, option_usage_fp);
} else {
- fprintf(option_usage_fp, " -%c", pOD->optValue);
- if ( (pOptions->fOptSet & (OPTPROC_GNUUSAGE|OPTPROC_LONGOPT))
+ fprintf(option_usage_fp, " -%c", od->optValue);
+ if ( (opts->fOptSet & (OPTPROC_GNUUSAGE|OPTPROC_LONGOPT))
== (OPTPROC_GNUUSAGE|OPTPROC_LONGOPT))
fputs(", ", option_usage_fp);
}
/**
* Print the usage information for a single option.
*
- * @param pOpts the program option descriptor
- * @param pOD the option descriptor
- * @param pAT names of the option argument types
+ * @param opts the program option descriptor
+ * @param od the option descriptor
+ * @param at names of the option argument types
*/
static void
-prt_one_usage(tOptions * pOptions, tOptDesc * pOD, arg_types_t * pAT)
+prt_one_usage(tOptions * opts, tOptDesc * od, arg_types_t * at)
{
- prt_preamble(pOptions, pOD, pAT);
+ prt_preamble(opts, od, at);
{
- char z[ 80 ];
- char const * pzArgType;
+ char z[80];
+ char const * atyp;
/*
* Determine the argument type string first on its usage, then,
* when the option argument is required, base the type string on the
* argument type.
*/
- if (pOD->fOptState & OPTST_ARG_OPTIONAL) {
- pzArgType = pAT->pzOpt;
-
- } else switch (OPTST_GET_ARGTYPE(pOD->fOptState)) {
- case OPARG_TYPE_NONE: pzArgType = pAT->pzNo; break;
- case OPARG_TYPE_ENUMERATION: pzArgType = pAT->pzKey; break;
- case OPARG_TYPE_FILE: pzArgType = pAT->pzFile; break;
- case OPARG_TYPE_MEMBERSHIP: pzArgType = pAT->pzKeyL; break;
- case OPARG_TYPE_BOOLEAN: pzArgType = pAT->pzBool; break;
- case OPARG_TYPE_NUMERIC: pzArgType = pAT->pzNum; break;
- case OPARG_TYPE_HIERARCHY: pzArgType = pAT->pzNest; break;
- case OPARG_TYPE_STRING: pzArgType = pAT->pzStr; break;
- case OPARG_TYPE_TIME: pzArgType = pAT->pzTime; break;
+ if (od->fOptState & OPTST_ARG_OPTIONAL) {
+ atyp = at->pzOpt;
+
+ } else switch (OPTST_GET_ARGTYPE(od->fOptState)) {
+ case OPARG_TYPE_NONE: atyp = at->pzNo; break;
+ case OPARG_TYPE_ENUMERATION: atyp = at->pzKey; break;
+ case OPARG_TYPE_FILE: atyp = at->pzFile; break;
+ case OPARG_TYPE_MEMBERSHIP: atyp = at->pzKeyL; break;
+ case OPARG_TYPE_BOOLEAN: atyp = at->pzBool; break;
+ case OPARG_TYPE_NUMERIC: atyp = at->pzNum; break;
+ case OPARG_TYPE_HIERARCHY: atyp = at->pzNest; break;
+ case OPARG_TYPE_STRING: atyp = at->pzStr; break;
+ case OPARG_TYPE_TIME: atyp = at->pzTime; break;
default: goto bogus_desc;
}
- snprintf(z, sizeof(z), pAT->pzOptFmt, pzArgType, pOD->pz_Name,
- (pOD->optMinCt != 0) ? pAT->pzReq : pAT->pzOpt);
+#ifdef _WIN32
+ if (at->pzOptFmt == zGnuOptFmt)
+ snprintf(z, sizeof(z), "--%s%s", od->pz_Name, atyp);
+ else if (at->pzOptFmt == zGnuOptFmt + 2)
+ snprintf(z, sizeof(z), "%s%s", od->pz_Name, atyp);
+ else
+#endif
+ snprintf(z, sizeof(z), at->pzOptFmt, atyp, od->pz_Name,
+ (od->optMinCt != 0) ? at->pzReq : at->pzOpt);
- fprintf(option_usage_fp, line_fmt_buf, z, pOD->pzText);
+ fprintf(option_usage_fp, line_fmt_buf, z, od->pzText);
- switch (OPTST_GET_ARGTYPE(pOD->fOptState)) {
+ switch (OPTST_GET_ARGTYPE(od->fOptState)) {
case OPARG_TYPE_ENUMERATION:
case OPARG_TYPE_MEMBERSHIP:
- displayEnum = (pOD->pOptProc != NULL) ? true : displayEnum;
+ displayEnum = (od->pOptProc != NULL) ? true : displayEnum;
}
}
return;
-bogus_desc:
- fprintf(stderr, zInvalOptDesc, pOD->pz_Name);
+ bogus_desc:
+ fprintf(stderr, zInvalOptDesc, od->pz_Name);
exit(EX_SOFTWARE);
}
* Print out the usage information for just the options.
*/
static void
-prt_opt_usage(tOptions * pOpts, int ex_code, char const * pOptTitle)
+prt_opt_usage(tOptions * opts, int ex_code, char const * title)
{
- int ct = pOpts->optCt;
+ int ct = opts->optCt;
int optNo = 0;
- tOptDesc * pOD = pOpts->pOptDesc;
+ tOptDesc * od = opts->pOptDesc;
int docCt = 0;
do {
* deprecated -- strongly discouraged (OPTST_DEPRECATED), or
* compiled out of current object code (OPTST_OMITTED)
*/
- if ((pOD->fOptState & OPTST_NO_USAGE_MASK) != 0) {
+ if ((od->fOptState & OPTST_NO_USAGE_MASK) != 0) {
/*
* IF this is a compiled-out option
* *AND* this is NOT abbreviated usage
* THEN display this option.
*/
- if ( (pOD->fOptState == (OPTST_OMITTED | OPTST_NO_INIT))
- && (pOD->pz_Name != NULL)
+ if ( (od->fOptState == (OPTST_OMITTED | OPTST_NO_INIT))
+ && (od->pz_Name != NULL)
&& (ex_code == EXIT_SUCCESS)) {
char const * why_pz =
- (pOD->pzText == NULL) ? zDisabledWhy : pOD->pzText;
- prt_preamble(pOpts, pOD, &argTypes);
- fprintf(option_usage_fp, zDisabledOpt, pOD->pz_Name, why_pz);
+ (od->pzText == NULL) ? zDisabledWhy : od->pzText;
+ prt_preamble(opts, od, &argTypes);
+ fprintf(option_usage_fp, zDisabledOpt, od->pz_Name, why_pz);
}
continue;
}
- if ((pOD->fOptState & OPTST_DOCUMENT) != 0) {
+ if ((od->fOptState & OPTST_DOCUMENT) != 0) {
if (ex_code == EXIT_SUCCESS) {
- fprintf(option_usage_fp, argTypes.pzBrk, pOD->pzText,
- pOptTitle);
+ fprintf(option_usage_fp, argTypes.pzBrk, od->pzText,
+ title);
docCt++;
}
}
/* Skip name only options when we have a vendor option */
- if ( ((pOpts->fOptSet & OPTPROC_VENDOR_OPT) != 0)
- && (! IS_GRAPHIC_CHAR(pOD->optValue)))
+ if ( ((opts->fOptSet & OPTPROC_VENDOR_OPT) != 0)
+ && (! IS_GRAPHIC_CHAR(od->optValue)))
continue;
/*
* THEN document that the remaining options are not user opts
*/
if ((docCt > 0) && (ex_code == EXIT_SUCCESS)) {
- if (pOpts->presetOptCt == optNo) {
- if ((pOD[-1].fOptState & OPTST_DOCUMENT) == 0)
- fprintf(option_usage_fp, argTypes.pzBrk, zAuto, pOptTitle);
+ if (opts->presetOptCt == optNo) {
+ if ((od[-1].fOptState & OPTST_DOCUMENT) == 0)
+ fprintf(option_usage_fp, argTypes.pzBrk, zAuto, title);
} else if ((ct == 1) &&
- (pOpts->fOptSet & OPTPROC_VENDOR_OPT))
- fprintf(option_usage_fp, argTypes.pzBrk, zVendIntro, pOptTitle);
+ (opts->fOptSet & OPTPROC_VENDOR_OPT))
+ fprintf(option_usage_fp, argTypes.pzBrk, zVendIntro, title);
}
- prt_one_usage(pOpts, pOD, &argTypes);
+ prt_one_usage(opts, od, &argTypes);
/*
* IF we were invoked because of the --help option,
* THEN print all the extra info
*/
if (ex_code == EXIT_SUCCESS)
- prt_extd_usage(pOpts, pOD, pOptTitle);
+ prt_extd_usage(opts, od, title);
- } while (pOD++, optNo++, (--ct > 0));
+ } while (od++, optNo++, (--ct > 0));
fputc(NL, option_usage_fp);
}
* PROGRAM DETAILS
*/
static void
-prt_prog_detail(tOptions* pOptions)
+prt_prog_detail(tOptions * opts)
{
- bool initIntro = true;
+ bool need_intro = true;
/*
* Display all the places we look for config files
*/
- prt_ini_list(pOptions->papzHomeList, &initIntro,
- pOptions->pzRcName, pOptions->pzProgPath);
+ prt_ini_list(opts->papzHomeList, &need_intro,
+ opts->pzRcName, opts->pzProgPath);
/*
* Let the user know about environment variable settings
*/
- if ((pOptions->fOptSet & OPTPROC_ENVIRON) != 0) {
- if (initIntro)
+ if ((opts->fOptSet & OPTPROC_ENVIRON) != 0) {
+ if (need_intro)
fputs(zPresetIntro, option_usage_fp);
- fprintf(option_usage_fp, zExamineFmt, pOptions->pzPROGNAME);
+ fprintf(option_usage_fp, zExamineFmt, opts->pzPROGNAME);
}
/*
* option struct pointer. That tells it to display the keywords.
*/
if (displayEnum) {
- int ct = pOptions->optCt;
+ int ct = opts->optCt;
int optNo = 0;
- tOptDesc* pOD = pOptions->pOptDesc;
+ tOptDesc * od = opts->pOptDesc;
fputc(NL, option_usage_fp);
fflush(option_usage_fp);
do {
- switch (OPTST_GET_ARGTYPE(pOD->fOptState)) {
+ switch (OPTST_GET_ARGTYPE(od->fOptState)) {
case OPARG_TYPE_ENUMERATION:
case OPARG_TYPE_MEMBERSHIP:
- (*(pOD->pOptProc))(OPTPROC_EMIT_USAGE, pOD);
+ (*(od->pOptProc))(OPTPROC_EMIT_USAGE, od);
}
- } while (pOD++, optNo++, (--ct > 0));
+ } while (od++, optNo++, (--ct > 0));
}
/*
* If there is a detail string, now is the time for that.
*/
- if (pOptions->pzDetail != NULL)
- fputs(pOptions->pzDetail, option_usage_fp);
+ if (opts->pzDetail != NULL)
+ fputs(opts->pzDetail, option_usage_fp);
}
* Set up the formatting for GNU-style output
*/
static int
-setGnuOptFmts(tOptions* pOpts, tCC** ppT)
+setGnuOptFmts(tOptions * opts, char const ** ptxt)
{
static char const zOneSpace[] = " ";
int flen = 22;
- *ppT = zNoRq_ShrtTtl;
+ *ptxt = zNoRq_ShrtTtl;
argTypes.pzStr = zGnuStrArg;
argTypes.pzReq = zOneSpace;
argTypes.pzNoF = zSixSpaces;
argTypes.pzSpc = zThreeSpaces;
- switch (pOpts->fOptSet & OPTPROC_L_N_S) {
+ switch (opts->fOptSet & OPTPROC_L_N_S) {
case OPTPROC_L_N_S: argTypes.pzOptFmt = zGnuOptFmt; break;
case OPTPROC_LONGOPT: argTypes.pzOptFmt = zGnuOptFmt; break;
case 0: argTypes.pzOptFmt = zGnuOptFmt + 2; break;
* Standard (AutoOpts normal) option line formatting
*/
static int
-setStdOptFmts(tOptions* pOpts, tCC** ppT)
+setStdOptFmts(tOptions * opts, char const ** ptxt)
{
int flen = 0;
argTypes.pzNoF = zFiveSpaces;
argTypes.pzSpc = zTwoSpaces;
- switch (pOpts->fOptSet & (OPTPROC_NO_REQ_OPT | OPTPROC_SHORTOPT)) {
+ switch (opts->fOptSet & (OPTPROC_NO_REQ_OPT | OPTPROC_SHORTOPT)) {
case (OPTPROC_NO_REQ_OPT | OPTPROC_SHORTOPT):
- *ppT = zNoRq_ShrtTtl;
+ *ptxt = zNoRq_ShrtTtl;
argTypes.pzOptFmt = zNrmOptFmt;
flen = 19;
break;
case OPTPROC_NO_REQ_OPT:
- *ppT = zNoRq_NoShrtTtl;
+ *ptxt = zNoRq_NoShrtTtl;
argTypes.pzOptFmt = zNrmOptFmt;
flen = 19;
break;
case OPTPROC_SHORTOPT:
- *ppT = zReq_ShrtTtl;
+ *ptxt = zReq_ShrtTtl;
argTypes.pzOptFmt = zReqOptFmt;
flen = 24;
break;
case 0:
- *ppT = zReq_NoShrtTtl;
+ *ptxt = zReq_NoShrtTtl;
argTypes.pzOptFmt = zReqOptFmt;
flen = 24;
}
+++ /dev/null
-/* ANSI-C code produced by gperf version 3.0.4 */
-
-
-#if 0 /* gperf build options: */
-// %struct-type
-// %language=ANSI-C
-// %includes
-// %global-table
-// %omit-struct-type
-// %readonly-tables
-// %compare-strncmp
-//
-// %define slot-name vtp_name
-// %define hash-function-name value_type_hash
-// %define lookup-function-name find_value_type_name
-// %define word-array-name value_type_table
-// %define initializer-suffix ,VTP_COUNT_KWD
-#endif /* gperf build options: */
-
-#include "value-type.h"
-
-typedef struct {
- char const * vtp_name;
- value_type_enum_t vtp_id;
-} value_type_map_t;
-#include <string.h>
-
-/* maximum key range = 20, duplicates = 0 */
-
-#ifdef __GNUC__
-#else
-#ifdef __cplusplus
-#endif
-#endif
-inline static unsigned int
-value_type_hash (register const char *str, register unsigned int len)
-{
- static const unsigned char asso_values[] =
- {
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 10, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 5, 23, 23, 5, 0, 0, 23, 15, 23,
- 23, 10, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23
- };
- return len + asso_values[(unsigned char)str[2]];
-}
-
-static const value_type_map_t value_type_table[] =
- {
- {"",VTP_COUNT_KWD}, {"",VTP_COUNT_KWD},
- {"",VTP_COUNT_KWD},
- {"set", VTP_KWD_SET},
- {"",VTP_COUNT_KWD}, {"",VTP_COUNT_KWD},
- {"nested", VTP_KWD_NESTED},
- {"integer", VTP_KWD_INTEGER},
- {"",VTP_COUNT_KWD},
- {"bool", VTP_KWD_BOOL},
- {"",VTP_COUNT_KWD},
- {"string", VTP_KWD_STRING},
- {"boolean", VTP_KWD_BOOLEAN},
- {"",VTP_COUNT_KWD},
- {"set-membership", VTP_KWD_SET_MEMBERSHIP},
- {"",VTP_COUNT_KWD}, {"",VTP_COUNT_KWD},
- {"keyword", VTP_KWD_KEYWORD},
- {"",VTP_COUNT_KWD},
- {"hierarchy", VTP_KWD_HIERARCHY},
- {"",VTP_COUNT_KWD}, {"",VTP_COUNT_KWD},
- {"invalid", VTP_KWD_INVALID}
- };
-
-#ifdef __GNUC__
-#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
-__attribute__ ((__gnu_inline__))
-#endif
-#endif
-static inline const value_type_map_t *
-find_value_type_name (register const char *str, register unsigned int len)
-{
- if (len <= 14 && len >= 3)
- {
- register int key = value_type_hash (str, len);
-
- if (key <= 22 && key >= 0)
- {
- register const char *s = value_type_table[key].vtp_name;
-
- if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
- return &value_type_table[key];
- }
- }
- return 0;
-}
-
-
-value_type_enum_t
-find_value_type_id(char const * str, unsigned int len)
-{
- const value_type_map_t * p =
- find_value_type_name(str, len);
- return (p == 0) ? VTP_KWD_INVALID : p->vtp_id;
-}
+++ /dev/null
-/*
- * Generated header for gperf generated source Sat Aug 11 09:41:14 PDT 2012
- * This file enumerates the list of names and declares the
- * procedure for mapping string names to the enum value.
- */
-#ifndef AUTOOPTS_VALUE_TYPE_H_GUARD
-#define AUTOOPTS_VALUE_TYPE_H_GUARD 1
-
-typedef enum {
- VTP_KWD_INVALID,
- VTP_KWD_STRING,
- VTP_KWD_INTEGER,
- VTP_KWD_BOOLEAN,
- VTP_KWD_BOOL,
- VTP_KWD_KEYWORD,
- VTP_KWD_SET,
- VTP_KWD_SET_MEMBERSHIP,
- VTP_KWD_NESTED,
- VTP_KWD_HIERARCHY,
- VTP_COUNT_KWD
-} value_type_enum_t;
-
-extern value_type_enum_t
-find_value_type_id(char const * str, unsigned int len);
-#endif /* AUTOOPTS_VALUE_TYPE_H_GUARD */
/*
- * Time-stamp: "2012-08-11 08:41:53 bkorb"
- *
* This module implements the default usage procedure for
* Automated Options. It may be overridden, of course.
*/
char const * pe = strchr(opts->pzCopyright, NL);
if (pe == NULL)
pe = opts->pzCopyright + strlen(opts->pzCopyright);
- fwrite(opts->pzCopyright, 1, pe - opts->pzCopyright, fp);
+ fwrite(opts->pzCopyright, 1, (size_t)(pe - opts->pzCopyright), fp);
}
/*
char const * pe = strchr(opts->pzUsageTitle, NL);
if (pe == NULL)
pe = opts->pzUsageTitle + strlen(opts->pzUsageTitle);
- fwrite(opts->pzUsageTitle, 1, pe - opts->pzUsageTitle, fp);
+ fwrite(opts->pzUsageTitle, 1, (size_t)(pe - opts->pzUsageTitle), fp);
}
fputc(NL, fp);
}
char const * pe = strchr(opts->pzUsageTitle, NL);
if (pe == NULL)
pe = opts->pzUsageTitle + strlen(opts->pzUsageTitle);
- fwrite(opts->pzUsageTitle, 1, pe - opts->pzCopyright, fp);
+ fwrite(opts->pzUsageTitle, 1, (size_t)(pe - opts->pzCopyright), fp);
}
fputc(NL, fp);
+++ /dev/null
-/* ANSI-C code produced by gperf version 3.0.4 */
-
-
-#if 0 /* gperf build options: */
-// %struct-type
-// %language=ANSI-C
-// %includes
-// %global-table
-// %omit-struct-type
-// %readonly-tables
-// %compare-strncmp
-//
-// %define slot-name xat_name
-// %define hash-function-name xat_attribute_hash
-// %define lookup-function-name find_xat_attribute_name
-// %define word-array-name xat_attribute_table
-// %define initializer-suffix ,XAT_COUNT_KWD
-#endif /* gperf build options: */
-
-#include "xat-attribute.h"
-
-typedef struct {
- char const * xat_name;
- xat_attribute_enum_t xat_id;
-} xat_attribute_map_t;
-#include <string.h>
-
-/* maximum key range = 9, duplicates = 0 */
-
-#ifdef __GNUC__
-#else
-#ifdef __cplusplus
-#endif
-#endif
-inline static unsigned int
-xat_attribute_hash (register const char *str, register unsigned int len)
-{
- static const unsigned char asso_values[] =
- {
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 0,
- 13, 13, 13, 13, 13, 5, 13, 5, 13, 0,
- 13, 13, 13, 13, 13, 13, 0, 0, 13, 0,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13
- };
- return len + asso_values[(unsigned char)str[0]];
-}
-
-static const xat_attribute_map_t xat_attribute_table[] =
- {
- {"",XAT_COUNT_KWD}, {"",XAT_COUNT_KWD},
- {"",XAT_COUNT_KWD}, {"",XAT_COUNT_KWD},
- {"type", XAT_KWD_TYPE},
- {"words", XAT_KWD_WORDS},
- {"cooked", XAT_KWD_COOKED},
- {"members", XAT_KWD_MEMBERS},
- {"uncooked", XAT_KWD_UNCOOKED},
- {"keep", XAT_KWD_KEEP},
- {"",XAT_COUNT_KWD}, {"",XAT_COUNT_KWD},
- {"invalid", XAT_KWD_INVALID}
- };
-
-#ifdef __GNUC__
-#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
-__attribute__ ((__gnu_inline__))
-#endif
-#endif
-static inline const xat_attribute_map_t *
-find_xat_attribute_name (register const char *str, register unsigned int len)
-{
- if (len <= 8 && len >= 4)
- {
- register int key = xat_attribute_hash (str, len);
-
- if (key <= 12 && key >= 0)
- {
- register const char *s = xat_attribute_table[key].xat_name;
-
- if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
- return &xat_attribute_table[key];
- }
- }
- return 0;
-}
-
-
-xat_attribute_enum_t
-find_xat_attribute_id(char const * str, unsigned int len)
-{
- const xat_attribute_map_t * p =
- find_xat_attribute_name(str, len);
- return (p == 0) ? XAT_KWD_INVALID : p->xat_id;
-}
+++ /dev/null
-/*
- * Generated header for gperf generated source Sat Aug 11 09:41:14 PDT 2012
- * This file enumerates the list of names and declares the
- * procedure for mapping string names to the enum value.
- */
-#ifndef AUTOOPTS_XAT_ATTRIBUTE_H_GUARD
-#define AUTOOPTS_XAT_ATTRIBUTE_H_GUARD 1
-
-typedef enum {
- XAT_KWD_INVALID,
- XAT_KWD_TYPE,
- XAT_KWD_WORDS,
- XAT_KWD_MEMBERS,
- XAT_KWD_COOKED,
- XAT_KWD_UNCOOKED,
- XAT_KWD_KEEP,
- XAT_COUNT_KWD
-} xat_attribute_enum_t;
-
-extern xat_attribute_enum_t
-find_xat_attribute_id(char const * str, unsigned int len);
-#endif /* AUTOOPTS_XAT_ATTRIBUTE_H_GUARD */