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