1
/* -*- buffer-read-only: t -*- vi: set ro:
3
* DO NOT EDIT THIS FILE (genshell.c)
5
* It has been AutoGen-ed Saturday May 5, 2007 at 12:02:35 PM PDT
6
* From the definitions genshell.def
7
* and the template file options
9
* Generated from AutoOpts 29:0:4 templates.
13
* This file was produced by an AutoOpts template. AutoOpts is a
14
* copyrighted work. This source file is not encumbered by AutoOpts
15
* licensing, but is provided under the licensing terms chosen by the
16
* genshellopt author or copyright holder. AutoOpts is licensed under
17
* the terms of the LGPL. The redistributable library (``libopts'') is
18
* licensed under the terms of either the LGPL or, at the users discretion,
19
* the BSD license. See the AutoOpts and/or libopts sources for details.
21
* This source file is copyrighted and licensed under the following terms:
23
* genshellopt copyright 1999-2007 Bruce Korb - all rights reserved
25
* genshellopt is free software; you can redistribute it and/or
26
* modify it under the terms of the GNU Lesser General Public
27
* License as published by the Free Software Foundation; either
28
* version 2.1 of the License, or (at your option) any later version.
30
* genshellopt is distributed in the hope that it will be useful,
31
* but WITHOUT ANY WARRANTY; without even the implied warranty of
32
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
33
* Lesser General Public License for more details.
35
* You should have received a copy of the GNU Lesser General Public
36
* License along with genshellopt. If not, write to:
37
* The Free Software Foundation, Inc.,
38
* 51 Franklin Street, Fifth Floor
39
* Boston, MA 02110-1301, USA.
45
#define OPTION_CODE_COMPILE 1
52
"genshellopt copyright (c) 1999-2007 Bruce Korb, all rights reserved";
53
tSCC zCopyrightNotice[] =
54
"genshellopt is free software; you can redistribute it and/or\n\
55
modify it under the terms of the GNU Lesser General Public\n\
56
License as published by the Free Software Foundation; either\n\
57
version 2.1 of the License, or (at your option) any later version.\n\n\
58
genshellopt is distributed in the hope that it will be useful,\n\
59
but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
60
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n\
61
Lesser General Public License for more details.\n\n\
62
You should have received a copy of the GNU Lesser General Public\n\
63
License along with genshellopt. If not, write to:\n\
64
\tThe Free Software Foundation, Inc.,\n\
65
\t51 Franklin Street, Fifth Floor\n\
66
\tBoston, MA 02110-1301, USA.";
67
extern tUsageProc genshelloptUsage;
73
# define EXIT_SUCCESS 0
76
# define EXIT_FAILURE 1
79
* Script option description:
83
tSCC zScript_NAME[] = "SCRIPT";
84
tSCC zScript_Name[] = "script";
85
#define SCRIPT_FLAGS (OPTST_DISABLED \
86
| OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
89
* Shell option description:
92
"Shell name (follows \"#!\" magic)";
93
tSCC zShell_NAME[] = "SHELL";
94
tSCC zNotShell_Name[] = "no-shell";
95
tSCC zNotShell_Pfx[] = "no";
96
#define zShell_Name (zNotShell_Name + 3)
97
#define SHELL_FLAGS (OPTST_INITENABLED \
98
| OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
101
* Help/More_Help/Version option descriptions:
103
tSCC zHelpText[] = "Display usage information and exit";
104
tSCC zHelp_Name[] = "help";
106
tSCC zMore_HelpText[] = "Extended usage information passed thru pager";
107
tSCC zMore_Help_Name[] = "more-help";
109
tSCC zVersionText[] = "Output version information and exit";
110
tSCC zVersion_Name[] = "version";
112
* Declare option callback procedures
115
optionPagedUsage, optionPrintVersion;
119
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
121
* Define the Genshellopt Option Descriptions.
123
static tOptDesc optDesc[ OPTION_CT ] = {
124
{ /* entry idx, value */ 0, VALUE_OPT_SCRIPT,
125
/* equiv idx, value */ 0, VALUE_OPT_SCRIPT,
126
/* equivalenced to */ NO_EQUIVALENT,
127
/* min, max, act ct */ 0, 1, 0,
128
/* opt state flags */ SCRIPT_FLAGS, 0,
129
/* last opt argumnt */ { NULL },
130
/* arg list/cookie */ NULL,
131
/* must/cannot opts */ NULL, NULL,
132
/* option proc */ NULL,
133
/* desc, NAME, name */ zScriptText, zScript_NAME, zScript_Name,
134
/* disablement strs */ NULL, NULL },
136
{ /* entry idx, value */ 1, VALUE_OPT_SHELL,
137
/* equiv idx, value */ 1, VALUE_OPT_SHELL,
138
/* equivalenced to */ NO_EQUIVALENT,
139
/* min, max, act ct */ 0, 1, 0,
140
/* opt state flags */ SHELL_FLAGS, 0,
141
/* last opt argumnt */ { NULL },
142
/* arg list/cookie */ NULL,
143
/* must/cannot opts */ NULL, NULL,
144
/* option proc */ NULL,
145
/* desc, NAME, name */ zShellText, zShell_NAME, zShell_Name,
146
/* disablement strs */ zNotShell_Name, zNotShell_Pfx },
148
#ifdef NO_OPTIONAL_OPT_ARGS
149
# define VERSION_OPT_FLAGS OPTST_IMM | OPTST_NO_INIT
151
# define VERSION_OPT_FLAGS OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
152
OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT
155
{ /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
156
/* equiv idx value */ NO_EQUIVALENT, 0,
157
/* equivalenced to */ NO_EQUIVALENT,
158
/* min, max, act ct */ 0, 1, 0,
159
/* opt state flags */ VERSION_OPT_FLAGS, 0,
160
/* last opt argumnt */ { NULL },
161
/* arg list/cookie */ NULL,
162
/* must/cannot opts */ NULL, NULL,
163
/* option proc */ optionPrintVersion,
164
/* desc, NAME, name */ zVersionText, NULL, zVersion_Name,
165
/* disablement strs */ NULL, NULL },
167
#undef VERSION_OPT_FLAGS
170
{ /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
171
/* equiv idx value */ NO_EQUIVALENT, 0,
172
/* equivalenced to */ NO_EQUIVALENT,
173
/* min, max, act ct */ 0, 1, 0,
174
/* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0,
175
/* last opt argumnt */ { NULL },
176
/* arg list/cookie */ NULL,
177
/* must/cannot opts */ NULL, NULL,
178
/* option proc */ doUsageOpt,
179
/* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
180
/* disablement strs */ NULL, NULL },
182
{ /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
183
/* equiv idx value */ NO_EQUIVALENT, 0,
184
/* equivalenced to */ NO_EQUIVALENT,
185
/* min, max, act ct */ 0, 1, 0,
186
/* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0,
187
/* last opt argumnt */ { NULL },
188
/* arg list/cookie */ NULL,
189
/* must/cannot opts */ NULL, NULL,
190
/* option proc */ optionPagedUsage,
191
/* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name,
192
/* disablement strs */ NULL, NULL }
195
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
197
* Define the Genshellopt Option Environment
199
tSCC zPROGNAME[] = "GENSHELLOPT";
201
"genshellopt - Generate Shell Option Processing Script - Ver. 1\n\
202
USAGE: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n";
204
#define apzHomeList NULL
206
tSCC zBugsAddr[] = "autogen-users@lists.sourceforge.net";
207
tSCC zExplain[] = "\n\
208
Note that `shell' is only useful if the output file does not already\n\
209
exist. If it does, then the shell name and optional first argument\n\
210
will be extracted from the script file.\n";
211
tSCC zDetail[] = "\n\
212
If the script file already exists and contains Automated Option Processing\n\
213
text, the second line of the file through the ending tag will be replaced\n\
214
by the newly generated text. The first `#!' line will be regenerated.\n";
215
tSCC zFullVersion[] = GENSHELLOPT_FULL_VERSION;
216
/* extracted from optcode.tpl near line 408 */
218
#if defined(ENABLE_NLS)
219
# define OPTPROC_BASE OPTPROC_TRANSLATE
220
static tOptionXlateProc translate_option_strings;
222
# define OPTPROC_BASE OPTPROC_NONE
223
# define translate_option_strings NULL
224
#endif /* ENABLE_NLS */
226
tOptions genshelloptOptions = {
227
OPTIONS_STRUCT_VERSION,
228
0, NULL, /* original argc + argv */
236
0, NULL, /* current option index, current option */
237
NULL, NULL, zPROGNAME,
238
zRcName, zCopyright, zCopyrightNotice,
239
zFullVersion, apzHomeList, zUsageTitle,
240
zExplain, zDetail, optDesc,
241
zBugsAddr, /* address to send bugs to */
242
NULL, NULL, /* extensions/saved state */
243
genshelloptUsage, /* usage procedure */
244
translate_option_strings, /* translation procedure */
246
* Indexes to special options
248
{ INDEX_OPT_MORE_HELP,
249
0 /* no option state saving */,
250
NO_EQUIVALENT /* index of '-#' option */,
251
NO_EQUIVALENT /* index of default opt */
253
5 /* full option count */, 2 /* user option count */
257
* Create the static procedure(s) declared above.
264
USAGE( EXIT_SUCCESS );
266
/* extracted from optcode.tpl near line 514 */
273
#include <autoopts/usage-txt.h>
275
static char* AO_gettext( char const* pz );
276
static void coerce_it(void** s);
279
AO_gettext( char const* pz )
287
pzRes = strdup( pzRes );
289
fputs( _("No memory for duping translated strings\n"), stderr );
290
exit( EXIT_FAILURE );
295
static void coerce_it(void** s) { *s = AO_gettext(*s); }
296
#define COERSION(_f) \
297
coerce_it((void*)&(genshelloptOptions._f))
300
* This invokes the translation code (e.g. gettext(3)).
303
translate_option_strings( void )
306
* Guard against re-translation. It won't work. The strings will have
307
* been changed by the first pass through this code. One shot only.
309
if (option_usage_text.field_ct == 0)
312
* Do the translations. The first pointer follows the field count field.
313
* The field count field is the size of a pointer.
316
char** ppz = (char**)(void*)&(option_usage_text);
317
int ix = option_usage_text.field_ct;
321
*ppz = AO_gettext(*ppz);
324
option_usage_text.field_ct = 0;
327
tOptDesc* pOD = genshelloptOptions.pOptDesc;
328
int ix = genshelloptOptions.optCt;
331
pOD->pzText = AO_gettext(pOD->pzText);
332
pOD->pz_NAME = AO_gettext(pOD->pz_NAME);
333
pOD->pz_Name = AO_gettext(pOD->pz_Name);
334
pOD->pz_DisableName = AO_gettext(pOD->pz_DisableName);
335
pOD->pz_DisablePfx = AO_gettext(pOD->pz_DisablePfx);
341
COERSION(pzCopyright);
342
COERSION(pzCopyNotice);
343
COERSION(pzFullVersion);
344
COERSION(pzUsageTitle);
349
#endif /* ENABLE_NLS */
354
/* genshell.c ends here */