123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351 |
- /* -*- buffer-read-only: t -*- vi: set ro:
- *
- * DO NOT EDIT THIS FILE (genshell.c)
- *
- * It has been AutoGen-ed Saturday July 28, 2007 at 01:01:44 PM PDT
- * From the definitions genshell.def
- * and the template file options
- *
- * Generated from AutoOpts 30:0:5 templates.
- */
- /*
- * This file was produced by an AutoOpts template. AutoOpts is a
- * copyrighted work. This source file is not encumbered by AutoOpts
- * licensing, but is provided under the licensing terms chosen by the
- * genshellopt author or copyright holder. AutoOpts is licensed under
- * the terms of the LGPL. The redistributable library (``libopts'') is
- * licensed under the terms of either the LGPL or, at the users discretion,
- * the BSD license. See the AutoOpts and/or libopts sources for details.
- *
- * This source file is copyrighted and licensed under the following terms:
- *
- * genshellopt copyright 1999-2007 Bruce Korb - all rights reserved
- *
- * genshellopt is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * genshellopt 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- #include <limits.h>
- #define OPTION_CODE_COMPILE 1
- #include "genshell.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- tSCC zCopyright[] =
- "genshellopt copyright (c) 1999-2007 Bruce Korb, all rights reserved";
- tSCC zCopyrightNotice[] =
- "genshellopt is free software: you can redistribute it and/or modify it\n\
- under the terms of the GNU General Public License as published by the\n\
- Free Software Foundation, either version 3 of the License, or\n\
- (at your option) any later version.\n\n\
- genshellopt is distributed in the hope that it will be useful, but\n\
- WITHOUT ANY WARRANTY; without even the implied warranty of\n\
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
- See the GNU General Public License for more details.\n\n\
- You should have received a copy of the GNU General Public License along\n\
- with this program. If not, see <http://www.gnu.org/licenses/>.";
- extern tUsageProc genshelloptUsage;
- #ifndef NULL
- # define NULL 0
- #endif
- #ifndef EXIT_SUCCESS
- # define EXIT_SUCCESS 0
- #endif
- #ifndef EXIT_FAILURE
- # define EXIT_FAILURE 1
- #endif
- /*
- * Script option description:
- */
- tSCC zScriptText[] =
- "Output Script File";
- tSCC zScript_NAME[] = "SCRIPT";
- tSCC zScript_Name[] = "script";
- #define SCRIPT_FLAGS (OPTST_DISABLED \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
- /*
- * Shell option description:
- */
- tSCC zShellText[] =
- "Shell name (follows \"#!\" magic)";
- tSCC zShell_NAME[] = "SHELL";
- tSCC zNotShell_Name[] = "no-shell";
- tSCC zNotShell_Pfx[] = "no";
- #define zShell_Name (zNotShell_Name + 3)
- #define SHELL_FLAGS (OPTST_INITENABLED \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
- /*
- * Help/More_Help/Version option descriptions:
- */
- tSCC zHelpText[] = "Display usage information and exit";
- tSCC zHelp_Name[] = "help";
- tSCC zMore_HelpText[] = "Extended usage information passed thru pager";
- tSCC zMore_Help_Name[] = "more-help";
- tSCC zVersionText[] = "Output version information and exit";
- tSCC zVersion_Name[] = "version";
- /*
- * Declare option callback procedures
- */
- extern tOptProc
- optionPagedUsage, optionPrintVersion;
- static tOptProc
- doUsageOpt;
- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *
- * Define the Genshellopt Option Descriptions.
- */
- static tOptDesc optDesc[ OPTION_CT ] = {
- { /* entry idx, value */ 0, VALUE_OPT_SCRIPT,
- /* equiv idx, value */ 0, VALUE_OPT_SCRIPT,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ SCRIPT_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ NULL,
- /* desc, NAME, name */ zScriptText, zScript_NAME, zScript_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 1, VALUE_OPT_SHELL,
- /* equiv idx, value */ 1, VALUE_OPT_SHELL,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ SHELL_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ NULL,
- /* desc, NAME, name */ zShellText, zShell_NAME, zShell_Name,
- /* disablement strs */ zNotShell_Name, zNotShell_Pfx },
- #ifdef NO_OPTIONAL_OPT_ARGS
- # define VERSION_OPT_FLAGS OPTST_IMM | OPTST_NO_INIT
- #else
- # define VERSION_OPT_FLAGS OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
- OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT
- #endif
- { /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
- /* equiv idx value */ NO_EQUIVALENT, 0,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ VERSION_OPT_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ optionPrintVersion,
- /* desc, NAME, name */ zVersionText, NULL, zVersion_Name,
- /* disablement strs */ NULL, NULL },
- #undef VERSION_OPT_FLAGS
- { /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
- /* equiv idx value */ NO_EQUIVALENT, 0,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ doUsageOpt,
- /* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
- /* equiv idx value */ NO_EQUIVALENT, 0,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ optionPagedUsage,
- /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name,
- /* disablement strs */ NULL, NULL }
- };
- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *
- * Define the Genshellopt Option Environment
- */
- tSCC zPROGNAME[] = "GENSHELLOPT";
- tSCC zUsageTitle[] =
- "genshellopt - Generate Shell Option Processing Script - Ver. 1\n\
- USAGE: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n";
- #define zRcName NULL
- #define apzHomeList NULL
- tSCC zBugsAddr[] = "autogen-users@lists.sourceforge.net";
- tSCC zExplain[] = "\n\
- Note that `shell' is only useful if the output file does not already\n\
- exist. If it does, then the shell name and optional first argument\n\
- will be extracted from the script file.\n";
- tSCC zDetail[] = "\n\
- If the script file already exists and contains Automated Option Processing\n\
- text, the second line of the file through the ending tag will be replaced\n\
- by the newly generated text. The first `#!' line will be regenerated.\n";
- tSCC zFullVersion[] = GENSHELLOPT_FULL_VERSION;
- /* extracted from optcode.tpl near line 428 */
- #if defined(ENABLE_NLS)
- # define OPTPROC_BASE OPTPROC_TRANSLATE
- static tOptionXlateProc translate_option_strings;
- #else
- # define OPTPROC_BASE OPTPROC_NONE
- # define translate_option_strings NULL
- #endif /* ENABLE_NLS */
- #define genshellopt_full_usage NULL
- #define genshellopt_short_usage NULL
- tOptions genshelloptOptions = {
- OPTIONS_STRUCT_VERSION,
- 0, NULL, /* original argc + argv */
- ( OPTPROC_BASE
- + OPTPROC_ERRSTOP
- + OPTPROC_SHORTOPT
- + OPTPROC_LONGOPT
- + OPTPROC_NO_REQ_OPT
- + OPTPROC_NEGATIONS
- + OPTPROC_NO_ARGS ),
- 0, NULL, /* current option index, current option */
- NULL, NULL, zPROGNAME,
- zRcName, zCopyright, zCopyrightNotice,
- zFullVersion, apzHomeList, zUsageTitle,
- zExplain, zDetail, optDesc,
- zBugsAddr, /* address to send bugs to */
- NULL, NULL, /* extensions/saved state */
- genshelloptUsage, /* usage procedure */
- translate_option_strings, /* translation procedure */
- /*
- * Indexes to special options
- */
- { INDEX_OPT_MORE_HELP,
- 0 /* no option state saving */,
- NO_EQUIVALENT /* index of '-#' option */,
- NO_EQUIVALENT /* index of default opt */
- },
- 5 /* full option count */, 2 /* user option count */,
- genshellopt_full_usage, genshellopt_short_usage
- };
- /*
- * Create the static procedure(s) declared above.
- */
- static void
- doUsageOpt(
- tOptions* pOptions,
- tOptDesc* pOptDesc )
- {
- USAGE( EXIT_SUCCESS );
- }
- /* extracted from optcode.tpl near line 537 */
- #if ENABLE_NLS
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <unistd.h>
- #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 )
- {
- char* pzRes;
- if (pz == NULL)
- return NULL;
- pzRes = _(pz);
- if (pzRes == pz)
- return pzRes;
- pzRes = strdup( pzRes );
- if (pzRes == NULL) {
- fputs( _("No memory for duping translated strings\n"), stderr );
- exit( EXIT_FAILURE );
- }
- return pzRes;
- }
- static void coerce_it(void** s) { *s = AO_gettext(*s); }
- #define COERSION(_f) \
- coerce_it((void*)&(genshelloptOptions._f))
- /*
- * This invokes the translation code (e.g. gettext(3)).
- */
- static void
- translate_option_strings( void )
- {
- /*
- * 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)
- return;
- /*
- * Do the translations. The first pointer follows the field count field.
- * The field count field is the size of a pointer.
- */
- {
- char** ppz = (char**)(void*)&(option_usage_text);
- int ix = option_usage_text.field_ct;
- do {
- ppz++;
- *ppz = AO_gettext(*ppz);
- } while (--ix > 0);
- }
- option_usage_text.field_ct = 0;
- {
- tOptDesc* pOD = genshelloptOptions.pOptDesc;
- int ix = genshelloptOptions.optCt;
- for (;;) {
- pOD->pzText = AO_gettext(pOD->pzText);
- pOD->pz_NAME = AO_gettext(pOD->pz_NAME);
- pOD->pz_Name = AO_gettext(pOD->pz_Name);
- pOD->pz_DisableName = AO_gettext(pOD->pz_DisableName);
- pOD->pz_DisablePfx = AO_gettext(pOD->pz_DisablePfx);
- if (--ix <= 0)
- break;
- pOD++;
- }
- }
- COERSION(pzCopyright);
- COERSION(pzCopyNotice);
- COERSION(pzFullVersion);
- COERSION(pzUsageTitle);
- COERSION(pzExplain);
- COERSION(pzDetail);
- }
- #endif /* ENABLE_NLS */
- #ifdef __cplusplus
- }
- #endif
- /* genshell.c ends here */
|