#include <sys/types.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#define OPTION_CODE_COMPILE 1
#include "genshell.h"
#ifdef __cplusplus
extern "C" {
#endif
tSCC zCopyright[] =
"genshellopt copyright (c) 1999-2009 Bruce Korb, all rights reserved";
tSCC zCopyrightNotice[610] =
"genshellopt is free software: you can redistribute it and/or modify it under\n\
the terms of the GNU General Public License as published by the Free Software\n\
Foundation, either version 3 of the License, or (at your option) any later\n\
version.\n\n\
genshellopt is distributed in the hope that it will be useful, but WITHOUT ANY\n\
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A\n\
PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\n\
You should have received a copy of the GNU General Public License along with\n\
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
tSCC zScriptText[] =
"Output Script File";
tSCC zScript_NAME[] = "SCRIPT";
tSCC zScript_Name[] = "script";
#define SCRIPT_FLAGS (OPTST_DISABLED \
| OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
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))
tSCC zHelpText[] = "Display extended usage information and exit";
tSCC zHelp_Name[] = "help";
#ifdef HAVE_WORKING_FORK
#define OPTST_MORE_HELP_FLAGS (OPTST_IMM | OPTST_NO_INIT)
tSCC zMore_Help_Name[] = "more-help";
tSCC zMore_HelpText[] = "Extended usage information passed thru pager";
#else
#define OPTST_MORE_HELP_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
#define zMore_Help_Name NULL
#define zMore_HelpText NULL
#endif
#ifdef NO_OPTIONAL_OPT_ARGS
# define OPTST_VERSION_FLAGS OPTST_IMM | OPTST_NO_INIT
#else
# define OPTST_VERSION_FLAGS OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT
#endif
tSCC zVersionText[] = "Output version information and exit";
tSCC zVersion_Name[] = "version";
extern tOptProc
optionPagedUsage, optionPrintVersion;
static tOptProc
doUsageOpt;
static tOptDesc optDesc[ OPTION_CT ] = {
{ 0, VALUE_OPT_SCRIPT,
0, VALUE_OPT_SCRIPT,
NO_EQUIVALENT,
0, 1, 0,
SCRIPT_FLAGS, 0,
{ NULL },
NULL,
NULL, NULL,
NULL,
zScriptText, zScript_NAME, zScript_Name,
NULL, NULL },
{ 1, VALUE_OPT_SHELL,
1, VALUE_OPT_SHELL,
NO_EQUIVALENT,
0, 1, 0,
SHELL_FLAGS, 0,
{ NULL },
NULL,
NULL, NULL,
NULL,
zShellText, zShell_NAME, zShell_Name,
zNotShell_Name, zNotShell_Pfx },
{ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
NO_EQUIVALENT, 0,
NO_EQUIVALENT,
0, 1, 0,
OPTST_VERSION_FLAGS, 0,
{ NULL },
NULL,
NULL, NULL,
optionPrintVersion,
zVersionText, NULL, zVersion_Name,
NULL, NULL },
{ INDEX_OPT_HELP, VALUE_OPT_HELP,
NO_EQUIVALENT, 0,
NO_EQUIVALENT,
0, 1, 0,
OPTST_IMM | OPTST_NO_INIT, 0,
{ NULL },
NULL,
NULL, NULL,
doUsageOpt,
zHelpText, NULL, zHelp_Name,
NULL, NULL },
{ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
NO_EQUIVALENT, 0,
NO_EQUIVALENT,
0, 1, 0,
OPTST_MORE_HELP_FLAGS, 0,
{ NULL },
NULL,
NULL, NULL,
optionPagedUsage,
zMore_HelpText, NULL, zMore_Help_Name,
NULL, NULL }
};
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;
#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
#define genshellopt_full_usage NULL
#define genshellopt_short_usage NULL
tOptions genshelloptOptions = {
OPTIONS_STRUCT_VERSION,
0, NULL,
( OPTPROC_BASE
+ OPTPROC_ERRSTOP
+ OPTPROC_SHORTOPT
+ OPTPROC_LONGOPT
+ OPTPROC_NO_REQ_OPT
+ OPTPROC_NEGATIONS
+ OPTPROC_NO_ARGS ),
0, NULL,
NULL, NULL, zPROGNAME,
zRcName, zCopyright, zCopyrightNotice,
zFullVersion, apzHomeList, zUsageTitle,
zExplain, zDetail, optDesc,
zBugsAddr,
NULL, NULL,
genshelloptUsage,
translate_option_strings,
{ INDEX_OPT_MORE_HELP,
NO_EQUIVALENT,
NO_EQUIVALENT,
NO_EQUIVALENT
},
5 , 2 ,
genshellopt_full_usage, genshellopt_short_usage,
NULL, NULL
};
static void
doUsageOpt(
tOptions* pOptions,
tOptDesc* pOptDesc )
{
(void)pOptions;
USAGE( EXIT_SUCCESS );
}
#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))
static void
translate_option_strings( void )
{
if (option_usage_text.field_ct != 0) {
tOptDesc* pOD = genshelloptOptions.pOptDesc;
char** ppz = (char**)(void*)&(option_usage_text);
int ix = option_usage_text.field_ct;
do {
ppz++;
*ppz = AO_gettext(*ppz);
} while (--ix > 0);
COERSION(pzCopyright);
COERSION(pzCopyNotice);
COERSION(pzFullVersion);
COERSION(pzUsageTitle);
COERSION(pzExplain);
COERSION(pzDetail);
option_usage_text.field_ct = 0;
for (ix = genshelloptOptions.optCt; ix > 0; ix--, pOD++)
coerce_it((void*)&(pOD->pzText));
}
if ((genshelloptOptions.fOptSet & OPTPROC_NXLAT_OPT_CFG) == 0) {
tOptDesc* pOD = genshelloptOptions.pOptDesc;
int ix;
for (ix = genshelloptOptions.optCt; ix > 0; ix--, pOD++) {
coerce_it((void*)&(pOD->pz_Name));
coerce_it((void*)&(pOD->pz_DisableName));
coerce_it((void*)&(pOD->pz_DisablePfx));
}
genshelloptOptions.fOptSet |= OPTPROC_NXLAT_OPT_CFG | OPTPROC_NXLAT_OPT;
}
}
#endif
#ifdef __cplusplus
}
#endif