1
/* -*- buffer-read-only: t -*- vi: set ro:
3
* DO NOT EDIT THIS FILE (genshell.c)
5
* It has been AutoGen-ed Thursday October 12, 2006 at 05:44:47 PM PDT
6
* From the definitions genshell.def
7
* and the template file options
9
* Generated from AutoOpts 27:5:3 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-2006 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-2006 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
{ /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
149
/* equiv idx value */ NO_EQUIVALENT, 0,
150
/* equivalenced to */ NO_EQUIVALENT,
151
/* min, max, act ct */ 0, 1, 0,
152
/* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
153
| OPTST_ARG_OPTIONAL, 0,
154
/* last opt argumnt */ { NULL },
155
/* arg list/cookie */ NULL,
156
/* must/cannot opts */ NULL, NULL,
157
/* option proc */ optionPrintVersion,
158
/* desc, NAME, name */ zVersionText, NULL, zVersion_Name,
159
/* disablement strs */ NULL, NULL },
161
{ /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
162
/* equiv idx value */ NO_EQUIVALENT, 0,
163
/* equivalenced to */ NO_EQUIVALENT,
164
/* min, max, act ct */ 0, 1, 0,
165
/* opt state flags */ OPTST_IMM, 0,
166
/* last opt argumnt */ { NULL },
167
/* arg list/cookie */ NULL,
168
/* must/cannot opts */ NULL, NULL,
169
/* option proc */ doUsageOpt,
170
/* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
171
/* disablement strs */ NULL, NULL },
173
{ /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
174
/* equiv idx value */ NO_EQUIVALENT, 0,
175
/* equivalenced to */ NO_EQUIVALENT,
176
/* min, max, act ct */ 0, 1, 0,
177
/* opt state flags */ OPTST_IMM, 0,
178
/* last opt argumnt */ { NULL },
179
/* arg list/cookie */ NULL,
180
/* must/cannot opts */ NULL, NULL,
181
/* option proc */ optionPagedUsage,
182
/* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name,
183
/* disablement strs */ NULL, NULL }
186
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
188
* Define the Genshellopt Option Environment
190
tSCC zPROGNAME[] = "GENSHELLOPT";
192
"genshellopt - Generate Shell Option Processing Script - Ver. 1\n\
193
USAGE: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n";
195
#define apzHomeList NULL
197
tSCC zBugsAddr[] = "autogen-users@lists.sourceforge.net";
198
tSCC zExplain[] = "\n\
199
Note that `shell' is only useful if the output file does not already\n\
200
exist. If it does, then the shell name and optional first argument\n\
201
will be extracted from the script file.\n";
202
tSCC zDetail[] = "\n\
203
If the script file already exists and contains Automated Option Processing\n\
204
text, the second line of the file through the ending tag will be replaced\n\
205
by the newly generated text. The first `#!' line will be regenerated.\n";
206
tSCC zFullVersion[] = GENSHELLOPT_FULL_VERSION;
207
/* extracted from optcode near line 368 */
209
#if defined(ENABLE_NLS)
210
# define OPTPROC_BASE OPTPROC_TRANSLATE
211
static tOptionXlateProc translate_option_strings;
213
# define OPTPROC_BASE OPTPROC_NONE
214
# define translate_option_strings NULL
215
#endif /* ENABLE_NLS */
217
tOptions genshelloptOptions = {
218
OPTIONS_STRUCT_VERSION,
219
0, NULL, /* original argc + argv */
227
0, NULL, /* current option index, current option */
228
NULL, NULL, zPROGNAME,
229
zRcName, zCopyright, zCopyrightNotice,
230
zFullVersion, apzHomeList, zUsageTitle,
231
zExplain, zDetail, optDesc,
232
zBugsAddr, /* address to send bugs to */
233
NULL, NULL, /* extensions/saved state */
234
genshelloptUsage, /* usage procedure */
235
translate_option_strings, /* translation procedure */
237
* Indexes to special options
239
{ INDEX_OPT_MORE_HELP,
240
0 /* no option state saving */,
241
NO_EQUIVALENT /* index of '-#' option */,
242
NO_EQUIVALENT /* index of default opt */
244
OPTION_CT, 2 /* user option count */
248
* Create the static procedure(s) declared above.
255
USAGE( EXIT_SUCCESS );
257
/* extracted from optcode near line 465 */
264
#include <autoopts/usage-txt.h>
266
static char* AO_gettext( char const* pz );
267
static void coerce_it(void** s);
270
AO_gettext( char const* pz )
278
pzRes = strdup( pzRes );
280
fputs( _("No memory for duping translated strings\n"), stderr );
281
exit( EXIT_FAILURE );
286
static void coerce_it(void** s) { *s = AO_gettext(*s); }
287
#define COERSION(_f) \
288
coerce_it((void*)&(genshelloptOptions._f))
291
* This invokes the translation code (e.g. gettext(3)).
294
translate_option_strings( void )
297
* Guard against re-translation. It won't work. The strings will have
298
* been changed by the first pass through this code. One shot only.
300
if (option_usage_text.field_ct == 0)
303
* Do the translations. The first pointer follows the field count field.
304
* The field count field is the size of a pointer.
307
char** ppz = (char**)(void*)&(option_usage_text);
308
int ix = option_usage_text.field_ct;
312
*ppz = AO_gettext(*ppz);
315
option_usage_text.field_ct = 0;
318
tOptDesc* pOD = genshelloptOptions.pOptDesc;
319
int ix = genshelloptOptions.optCt;
322
pOD->pzText = AO_gettext(pOD->pzText);
323
pOD->pz_NAME = AO_gettext(pOD->pz_NAME);
324
pOD->pz_Name = AO_gettext(pOD->pz_Name);
325
pOD->pz_DisableName = AO_gettext(pOD->pz_DisableName);
326
pOD->pz_DisablePfx = AO_gettext(pOD->pz_DisablePfx);
332
COERSION(pzCopyright);
333
COERSION(pzCopyNotice);
334
COERSION(pzFullVersion);
335
COERSION(pzUsageTitle);
340
#endif /* ENABLE_NLS */