4 * EDIT THIS FILE WITH CAUTION (ntpsnmpd-opts.c)
6 * It has been AutoGen-ed December 10, 2009 at 05:03:45 AM by AutoGen 5.10
7 * From the definitions ntpsnmpd-opts.def
8 * and the template file options
10 * Generated from AutoOpts 33:0:8 templates.
14 * This file was produced by an AutoOpts template. AutoOpts is a
15 * copyrighted work. This source file is not encumbered by AutoOpts
16 * licensing, but is provided under the licensing terms chosen by the
17 * ntpsnmpd author or copyright holder. AutoOpts is licensed under
18 * the terms of the LGPL. The redistributable library (``libopts'') is
19 * licensed under the terms of either the LGPL or, at the users discretion,
20 * the BSD license. See the AutoOpts and/or libopts sources for details.
22 * This source file is copyrighted and licensed under the following terms:
24 * ntpsnmpd copyright (c) 1970-2009 David L. Mills and/or others - all rights reserved
26 * see html/copyright.html
29 #include <sys/types.h>
34 #define OPTION_CODE_COMPILE 1
35 #include "ntpsnmpd-opts.h"
41 /* TRANSLATORS: choose the translation for option names wisely because you
42 cannot ever change your mind. */
44 "ntpsnmpd copyright (c) 1970-2009 David L. Mills and/or others, all rights reserved"
45 /* extracted from ../include/copyright.def near line 8 */
47 tSCC zCopyrightNotice
[24] =
48 "see html/copyright.html";
50 extern tUsageProc optionUsage
;
56 # define EXIT_SUCCESS 0
59 # define EXIT_FAILURE 1
63 * Nofork option description:
67 tSCC zNofork_NAME
[] = "NOFORK";
68 tSCC zNofork_Name
[] = "nofork";
69 #define NOFORK_FLAGS (OPTST_DISABLED)
72 * Syslog option description:
76 tSCC zSyslog_NAME
[] = "SYSLOG";
77 tSCC zSyslog_Name
[] = "syslog";
78 #define SYSLOG_FLAGS (OPTST_DISABLED)
81 * Help/More_Help/Version option descriptions:
83 tSCC zHelpText
[] = "Display extended usage information and exit";
84 tSCC zHelp_Name
[] = "help";
85 #ifdef HAVE_WORKING_FORK
86 #define OPTST_MORE_HELP_FLAGS (OPTST_IMM | OPTST_NO_INIT)
87 tSCC zMore_Help_Name
[] = "more-help";
88 tSCC zMore_HelpText
[] = "Extended usage information passed thru pager";
90 #define OPTST_MORE_HELP_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
91 #define zMore_Help_Name NULL
92 #define zMore_HelpText NULL
94 #ifdef NO_OPTIONAL_OPT_ARGS
95 # define OPTST_VERSION_FLAGS OPTST_IMM | OPTST_NO_INIT
97 # define OPTST_VERSION_FLAGS OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
98 OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT
101 tSCC zVersionText
[] = "Output version information and exit";
102 tSCC zVersion_Name
[] = "version";
103 tSCC zSave_OptsText
[] = "Save the option state to a config file";
104 tSCC zSave_Opts_Name
[] = "save-opts";
105 tSCC zLoad_OptsText
[] = "Load options from a config file";
106 tSCC zLoad_Opts_NAME
[] = "LOAD_OPTS";
107 tSCC zNotLoad_Opts_Name
[] = "no-load-opts";
108 tSCC zNotLoad_Opts_Pfx
[] = "no";
109 #define zLoad_Opts_Name (zNotLoad_Opts_Name + 3)
111 * Declare option callback procedures
113 #if defined(TEST_NTPSNMPD_OPTS)
115 * Under test, omit argument processing, or call optionStackArg,
116 * if multiple copies are allowed.
119 optionPagedUsage
, optionVersionStderr
;
123 #else /* NOT defined TEST_NTPSNMPD_OPTS */
125 * When not under test, there are different procs to use
128 optionPagedUsage
, optionPrintVersion
;
131 #endif /* defined(TEST_NTPSNMPD_OPTS) */
132 #ifdef TEST_NTPSNMPD_OPTS
133 # define DOVERPROC optionVersionStderr
135 # define DOVERPROC optionPrintVersion
136 #endif /* TEST_NTPSNMPD_OPTS */
138 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
140 * Define the Ntpsnmpd Option Descriptions.
142 static tOptDesc optDesc
[ OPTION_CT
] = {
143 { /* entry idx, value */ 0, VALUE_OPT_NOFORK
,
144 /* equiv idx, value */ 0, VALUE_OPT_NOFORK
,
145 /* equivalenced to */ NO_EQUIVALENT
,
146 /* min, max, act ct */ 0, 1, 0,
147 /* opt state flags */ NOFORK_FLAGS
, 0,
148 /* last opt argumnt */ { NULL
},
149 /* arg list/cookie */ NULL
,
150 /* must/cannot opts */ NULL
, NULL
,
151 /* option proc */ NULL
,
152 /* desc, NAME, name */ zNoforkText
, zNofork_NAME
, zNofork_Name
,
153 /* disablement strs */ NULL
, NULL
},
155 { /* entry idx, value */ 1, VALUE_OPT_SYSLOG
,
156 /* equiv idx, value */ 1, VALUE_OPT_SYSLOG
,
157 /* equivalenced to */ NO_EQUIVALENT
,
158 /* min, max, act ct */ 0, 1, 0,
159 /* opt state flags */ SYSLOG_FLAGS
, 0,
160 /* last opt argumnt */ { NULL
},
161 /* arg list/cookie */ NULL
,
162 /* must/cannot opts */ NULL
, NULL
,
163 /* option proc */ NULL
,
164 /* desc, NAME, name */ zSyslogText
, zSyslog_NAME
, zSyslog_Name
,
165 /* disablement strs */ NULL
, NULL
},
167 { /* entry idx, value */ INDEX_OPT_VERSION
, VALUE_OPT_VERSION
,
168 /* equiv idx value */ NO_EQUIVALENT
, 0,
169 /* equivalenced to */ NO_EQUIVALENT
,
170 /* min, max, act ct */ 0, 1, 0,
171 /* opt state flags */ OPTST_VERSION_FLAGS
, 0,
172 /* last opt argumnt */ { NULL
},
173 /* arg list/cookie */ NULL
,
174 /* must/cannot opts */ NULL
, NULL
,
175 /* option proc */ DOVERPROC
,
176 /* desc, NAME, name */ zVersionText
, NULL
, zVersion_Name
,
177 /* disablement strs */ NULL
, NULL
},
181 { /* entry idx, value */ INDEX_OPT_HELP
, VALUE_OPT_HELP
,
182 /* equiv idx value */ NO_EQUIVALENT
, 0,
183 /* equivalenced to */ NO_EQUIVALENT
,
184 /* min, max, act ct */ 0, 1, 0,
185 /* opt state flags */ OPTST_IMM
| OPTST_NO_INIT
, 0,
186 /* last opt argumnt */ { NULL
},
187 /* arg list/cookie */ NULL
,
188 /* must/cannot opts */ NULL
, NULL
,
189 /* option proc */ doUsageOpt
,
190 /* desc, NAME, name */ zHelpText
, NULL
, zHelp_Name
,
191 /* disablement strs */ NULL
, NULL
},
193 { /* entry idx, value */ INDEX_OPT_MORE_HELP
, VALUE_OPT_MORE_HELP
,
194 /* equiv idx value */ NO_EQUIVALENT
, 0,
195 /* equivalenced to */ NO_EQUIVALENT
,
196 /* min, max, act ct */ 0, 1, 0,
197 /* opt state flags */ OPTST_MORE_HELP_FLAGS
, 0,
198 /* last opt argumnt */ { NULL
},
199 /* arg list/cookie */ NULL
,
200 /* must/cannot opts */ NULL
, NULL
,
201 /* option proc */ optionPagedUsage
,
202 /* desc, NAME, name */ zMore_HelpText
, NULL
, zMore_Help_Name
,
203 /* disablement strs */ NULL
, NULL
},
205 { /* entry idx, value */ INDEX_OPT_SAVE_OPTS
, VALUE_OPT_SAVE_OPTS
,
206 /* equiv idx value */ NO_EQUIVALENT
, 0,
207 /* equivalenced to */ NO_EQUIVALENT
,
208 /* min, max, act ct */ 0, 1, 0,
209 /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING
)
210 | OPTST_ARG_OPTIONAL
| OPTST_NO_INIT
, 0,
211 /* last opt argumnt */ { NULL
},
212 /* arg list/cookie */ NULL
,
213 /* must/cannot opts */ NULL
, NULL
,
214 /* option proc */ NULL
,
215 /* desc, NAME, name */ zSave_OptsText
, NULL
, zSave_Opts_Name
,
216 /* disablement strs */ NULL
, NULL
},
218 { /* entry idx, value */ INDEX_OPT_LOAD_OPTS
, VALUE_OPT_LOAD_OPTS
,
219 /* equiv idx value */ NO_EQUIVALENT
, 0,
220 /* equivalenced to */ NO_EQUIVALENT
,
221 /* min, max, act ct */ 0, NOLIMIT
, 0,
222 /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING
)
223 | OPTST_DISABLE_IMM
, 0,
224 /* last opt argumnt */ { NULL
},
225 /* arg list/cookie */ NULL
,
226 /* must/cannot opts */ NULL
, NULL
,
227 /* option proc */ optionLoadOpt
,
228 /* desc, NAME, name */ zLoad_OptsText
, zLoad_Opts_NAME
, zLoad_Opts_Name
,
229 /* disablement strs */ zNotLoad_Opts_Name
, zNotLoad_Opts_Pfx
}
232 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
234 * Define the Ntpsnmpd Option Environment
236 tSCC zPROGNAME
[] = "NTPSNMPD";
238 "ntpsnmpd - NTP SNMP MIB agent - Ver. 4.2.6\n\
239 USAGE: %s [ -<flag> | --<name> ]...\n";
240 tSCC zRcName
[] = ".ntprc";
241 tSCC
* apzHomeList
[] = {
246 tSCC zBugsAddr
[] = "http://bugs.ntp.org, bugs@ntp.org";
247 #define zExplain NULL
249 tSCC zFullVersion
[] = NTPSNMPD_FULL_VERSION
;
250 /* extracted from /usr/local/gnu/share/autogen/optcode.tpl near line 495 */
252 #if defined(ENABLE_NLS)
253 # define OPTPROC_BASE OPTPROC_TRANSLATE
254 static tOptionXlateProc translate_option_strings
;
256 # define OPTPROC_BASE OPTPROC_NONE
257 # define translate_option_strings NULL
258 #endif /* ENABLE_NLS */
261 #define ntpsnmpd_full_usage NULL
262 #define ntpsnmpd_short_usage NULL
263 tOptions ntpsnmpdOptions
= {
264 OPTIONS_STRUCT_VERSION
,
265 0, NULL
, /* original argc + argv */
273 0, NULL
, /* current option index, current option */
274 NULL
, NULL
, zPROGNAME
,
275 zRcName
, zCopyright
, zCopyrightNotice
,
276 zFullVersion
, apzHomeList
, zUsageTitle
,
277 zExplain
, zDetail
, optDesc
,
278 zBugsAddr
, /* address to send bugs to */
279 NULL
, NULL
, /* extensions/saved state */
280 optionUsage
, /* usage procedure */
281 translate_option_strings
, /* translation procedure */
283 * Indexes to special options
285 { INDEX_OPT_MORE_HELP
, /* more-help option index */
286 INDEX_OPT_SAVE_OPTS
, /* save option index */
287 NO_EQUIVALENT
, /* '-#' option index */
288 NO_EQUIVALENT
/* index of default opt */
290 7 /* full option count */, 2 /* user option count */,
291 ntpsnmpd_full_usage
, ntpsnmpd_short_usage
,
296 * Create the static procedure(s) declared above.
304 USAGE( EXIT_SUCCESS
);
306 /* extracted from /usr/local/gnu/share/autogen/optmain.tpl near line 109 */
308 #if defined(TEST_NTPSNMPD_OPTS) /* TEST MAIN PROCEDURE: */
310 extern void optionPutShell( tOptions
* );
313 main(int argc
, char** argv
)
315 int res
= EXIT_SUCCESS
;
316 (void)optionProcess( &ntpsnmpdOptions
, argc
, argv
);
317 optionPutShell( &ntpsnmpdOptions
);
320 #endif /* defined TEST_NTPSNMPD_OPTS */
321 /* extracted from /usr/local/gnu/share/autogen/optcode.tpl near line 627 */
328 #include <autoopts/usage-txt.h>
330 static char* AO_gettext( char const* pz
);
331 static void coerce_it(void** s
);
334 AO_gettext( char const* pz
)
342 pzRes
= strdup( pzRes
);
344 fputs( _("No memory for duping translated strings\n"), stderr
);
345 exit( EXIT_FAILURE
);
350 static void coerce_it(void** s
) { *s
= AO_gettext(*s
); }
351 #define COERSION(_f) \
352 coerce_it((void*)&(ntpsnmpdOptions._f))
355 * This invokes the translation code (e.g. gettext(3)).
358 translate_option_strings( void )
361 * Guard against re-translation. It won't work. The strings will have
362 * been changed by the first pass through this code. One shot only.
364 if (option_usage_text
.field_ct
!= 0) {
367 * Do the translations. The first pointer follows the field count
368 * field. The field count field is the size of a pointer.
370 tOptDesc
* pOD
= ntpsnmpdOptions
.pOptDesc
;
371 char** ppz
= (char**)(void*)&(option_usage_text
);
372 int ix
= option_usage_text
.field_ct
;
376 *ppz
= AO_gettext(*ppz
);
379 COERSION(pzCopyright
);
380 COERSION(pzCopyNotice
);
381 COERSION(pzFullVersion
);
382 COERSION(pzUsageTitle
);
385 option_usage_text
.field_ct
= 0;
387 for (ix
= ntpsnmpdOptions
.optCt
; ix
> 0; ix
--, pOD
++)
388 coerce_it((void*)&(pOD
->pzText
));
391 if ((ntpsnmpdOptions
.fOptSet
& OPTPROC_NXLAT_OPT_CFG
) == 0) {
392 tOptDesc
* pOD
= ntpsnmpdOptions
.pOptDesc
;
395 for (ix
= ntpsnmpdOptions
.optCt
; ix
> 0; ix
--, pOD
++) {
396 coerce_it((void*)&(pOD
->pz_Name
));
397 coerce_it((void*)&(pOD
->pz_DisableName
));
398 coerce_it((void*)&(pOD
->pz_DisablePfx
));
400 /* prevent re-translation */
401 ntpsnmpdOptions
.fOptSet
|= OPTPROC_NXLAT_OPT_CFG
| OPTPROC_NXLAT_OPT
;
405 #endif /* ENABLE_NLS */
410 /* ntpsnmpd-opts.c ends here */