4 * EDIT THIS FILE WITH CAUTION (ntpq-opts.c)
6 * It has been AutoGen-ed Tuesday December 8, 2009 at 08:14:26 AM EST
7 * From the definitions ntpq-opts.def
8 * and the template file options
10 * Generated from AutoOpts 29:0:4 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 * ntpq 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 * ntpq copyright 1970-2009 David L. Mills and/or others - all rights reserved
26 * see html/copyright.html
32 #define OPTION_CODE_COMPILE 1
33 #include "ntpq-opts.h"
39 "ntpq copyright (c) 1970-2009 David L. Mills and/or others, all rights reserved";
40 tSCC zCopyrightNotice
[] =
42 /* extracted from ../include/copyright.def near line 8 */
43 "see html/copyright.html";
44 extern tUsageProc optionUsage
;
47 * global included definitions
50 extern int atoi(const char*);
59 # define EXIT_SUCCESS 0
62 # define EXIT_FAILURE 1
65 * Ipv4 option description:
68 "Force IPv4 DNS name resolution";
69 tSCC zIpv4_NAME
[] = "IPV4";
70 tSCC zIpv4_Name
[] = "ipv4";
71 #define IPV4_FLAGS (OPTST_DISABLED)
74 * Ipv6 option description:
77 "Force IPv6 DNS name resolution";
78 tSCC zIpv6_NAME
[] = "IPV6";
79 tSCC zIpv6_Name
[] = "ipv6";
80 #define IPV6_FLAGS (OPTST_DISABLED)
83 * Command option description:
86 "run a command and exit";
87 tSCC zCommand_NAME
[] = "COMMAND";
88 tSCC zCommand_Name
[] = "command";
89 #define COMMAND_FLAGS (OPTST_DISABLED | OPTST_STACKED \
90 | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
93 * Debug_Level option description:
96 tSCC zDebug_LevelText
[] =
97 "Increase output debug message level";
98 tSCC zDebug_Level_NAME
[] = "DEBUG_LEVEL";
99 tSCC zDebug_Level_Name
[] = "debug-level";
100 #define DEBUG_LEVEL_FLAGS (OPTST_DISABLED)
102 #else /* disable Debug_Level */
103 #define VALUE_OPT_DEBUG_LEVEL NO_EQUIVALENT
104 #define DEBUG_LEVEL_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
105 #define zDebug_LevelText NULL
106 #define zDebug_Level_NAME NULL
107 #define zDebug_Level_Name NULL
111 * Set_Debug_Level option description:
114 tSCC zSet_Debug_LevelText
[] =
115 "Set the output debug message level";
116 tSCC zSet_Debug_Level_NAME
[] = "SET_DEBUG_LEVEL";
117 tSCC zSet_Debug_Level_Name
[] = "set-debug-level";
118 #define SET_DEBUG_LEVEL_FLAGS (OPTST_DISABLED \
119 | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
121 #else /* disable Set_Debug_Level */
122 #define VALUE_OPT_SET_DEBUG_LEVEL NO_EQUIVALENT
123 #define SET_DEBUG_LEVEL_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
124 #define zSet_Debug_LevelText NULL
125 #define zSet_Debug_Level_NAME NULL
126 #define zSet_Debug_Level_Name NULL
130 * Peers option description with
131 * "Must also have options" and "Incompatible options":
134 "Print a list of the peers";
135 tSCC zPeers_NAME
[] = "PEERS";
136 tSCC zPeers_Name
[] = "peers";
139 INDEX_OPT_INTERACTIVE
, NO_EQUIVALENT
};
140 #define PEERS_FLAGS (OPTST_DISABLED)
143 * Interactive option description with
144 * "Must also have options" and "Incompatible options":
146 tSCC zInteractiveText
[] =
147 "Force ntpq to operate in interactive mode";
148 tSCC zInteractive_NAME
[] = "INTERACTIVE";
149 tSCC zInteractive_Name
[] = "interactive";
151 aInteractiveCantList
[] = {
153 INDEX_OPT_PEERS
, NO_EQUIVALENT
};
154 #define INTERACTIVE_FLAGS (OPTST_DISABLED)
157 * Numeric option description:
159 tSCC zNumericText
[] =
160 "numeric host addresses";
161 tSCC zNumeric_NAME
[] = "NUMERIC";
162 tSCC zNumeric_Name
[] = "numeric";
163 #define NUMERIC_FLAGS (OPTST_DISABLED)
166 * Help/More_Help/Version option descriptions:
168 tSCC zHelpText
[] = "Display usage information and exit";
169 tSCC zHelp_Name
[] = "help";
171 tSCC zMore_HelpText
[] = "Extended usage information passed thru pager";
172 tSCC zMore_Help_Name
[] = "more-help";
174 tSCC zVersionText
[] = "Output version information and exit";
175 tSCC zVersion_Name
[] = "version";
178 * Save/Load_Opts option description:
180 tSCC zSave_OptsText
[] = "Save the option state to a config file";
181 tSCC zSave_Opts_Name
[] = "save-opts";
183 tSCC zLoad_OptsText
[] = "Load options from a config file";
184 tSCC zLoad_Opts_NAME
[] = "LOAD_OPTS";
186 tSCC zNotLoad_Opts_Name
[] = "no-load-opts";
187 tSCC zNotLoad_Opts_Pfx
[] = "no";
188 #define zLoad_Opts_Name (zNotLoad_Opts_Name + 3)
190 * Declare option callback procedures
193 static tOptProc doOptSet_Debug_Level
;
194 #else /* not DEBUG */
195 # define doOptSet_Debug_Level NULL
196 #endif /* def/not DEBUG */
197 #if defined(TEST_NTPQ_OPTS)
199 * Under test, omit argument processing, or call optionStackArg,
200 * if multiple copies are allowed.
203 optionPagedUsage
, optionStackArg
, optionVersionStderr
;
208 * #define map the "normal" callout procs to the test ones...
210 #define SET_DEBUG_LEVEL_OPT_PROC optionStackArg
213 #else /* NOT defined TEST_NTPQ_OPTS */
215 * When not under test, there are different procs to use
218 optionPagedUsage
, optionPrintVersion
, optionStackArg
;
223 * #define map the "normal" callout procs
225 #define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level
227 #define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level
228 #endif /* defined(TEST_NTPQ_OPTS) */
229 #ifdef TEST_NTPQ_OPTS
230 # define DOVERPROC optionVersionStderr
232 # define DOVERPROC optionPrintVersion
233 #endif /* TEST_NTPQ_OPTS */
235 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
237 * Define the Ntpq Option Descriptions.
239 static tOptDesc optDesc
[ OPTION_CT
] = {
240 { /* entry idx, value */ 0, VALUE_OPT_IPV4
,
241 /* equiv idx, value */ NO_EQUIVALENT
, 0,
242 /* equivalenced to */ NO_EQUIVALENT
,
243 /* min, max, act ct */ 0, 1, 0,
244 /* opt state flags */ IPV4_FLAGS
, 0,
245 /* last opt argumnt */ { NULL
},
246 /* arg list/cookie */ NULL
,
247 /* must/cannot opts */ NULL
, NULL
,
248 /* option proc */ NULL
,
249 /* desc, NAME, name */ zIpv4Text
, zIpv4_NAME
, zIpv4_Name
,
250 /* disablement strs */ NULL
, NULL
},
252 { /* entry idx, value */ 1, VALUE_OPT_IPV6
,
253 /* equiv idx, value */ NOLIMIT
, NOLIMIT
,
254 /* equivalenced to */ INDEX_OPT_IPV4
,
255 /* min, max, act ct */ 0, 1, 0,
256 /* opt state flags */ IPV6_FLAGS
, 0,
257 /* last opt argumnt */ { NULL
},
258 /* arg list/cookie */ NULL
,
259 /* must/cannot opts */ NULL
, NULL
,
260 /* option proc */ NULL
,
261 /* desc, NAME, name */ zIpv6Text
, zIpv6_NAME
, zIpv6_Name
,
262 /* disablement strs */ NULL
, NULL
},
264 { /* entry idx, value */ 2, VALUE_OPT_COMMAND
,
265 /* equiv idx, value */ 2, VALUE_OPT_COMMAND
,
266 /* equivalenced to */ NO_EQUIVALENT
,
267 /* min, max, act ct */ 0, NOLIMIT
, 0,
268 /* opt state flags */ COMMAND_FLAGS
, 0,
269 /* last opt argumnt */ { NULL
},
270 /* arg list/cookie */ NULL
,
271 /* must/cannot opts */ NULL
, NULL
,
272 /* option proc */ optionStackArg
,
273 /* desc, NAME, name */ zCommandText
, zCommand_NAME
, zCommand_Name
,
274 /* disablement strs */ NULL
, NULL
},
276 { /* entry idx, value */ 3, VALUE_OPT_DEBUG_LEVEL
,
277 /* equiv idx, value */ 3, VALUE_OPT_DEBUG_LEVEL
,
278 /* equivalenced to */ NO_EQUIVALENT
,
279 /* min, max, act ct */ 0, NOLIMIT
, 0,
280 /* opt state flags */ DEBUG_LEVEL_FLAGS
, 0,
281 /* last opt argumnt */ { NULL
},
282 /* arg list/cookie */ NULL
,
283 /* must/cannot opts */ NULL
, NULL
,
284 /* option proc */ NULL
,
285 /* desc, NAME, name */ zDebug_LevelText
, zDebug_Level_NAME
, zDebug_Level_Name
,
286 /* disablement strs */ NULL
, NULL
},
288 { /* entry idx, value */ 4, VALUE_OPT_SET_DEBUG_LEVEL
,
289 /* equiv idx, value */ 4, VALUE_OPT_SET_DEBUG_LEVEL
,
290 /* equivalenced to */ NO_EQUIVALENT
,
291 /* min, max, act ct */ 0, NOLIMIT
, 0,
292 /* opt state flags */ SET_DEBUG_LEVEL_FLAGS
, 0,
293 /* last opt argumnt */ { NULL
},
294 /* arg list/cookie */ NULL
,
295 /* must/cannot opts */ NULL
, NULL
,
296 /* option proc */ SET_DEBUG_LEVEL_OPT_PROC
,
297 /* desc, NAME, name */ zSet_Debug_LevelText
, zSet_Debug_Level_NAME
, zSet_Debug_Level_Name
,
298 /* disablement strs */ NULL
, NULL
},
300 { /* entry idx, value */ 5, VALUE_OPT_PEERS
,
301 /* equiv idx, value */ 5, VALUE_OPT_PEERS
,
302 /* equivalenced to */ NO_EQUIVALENT
,
303 /* min, max, act ct */ 0, 1, 0,
304 /* opt state flags */ PEERS_FLAGS
, 0,
305 /* last opt argumnt */ { NULL
},
306 /* arg list/cookie */ NULL
,
307 /* must/cannot opts */ NULL
, aPeersCantList
,
308 /* option proc */ NULL
,
309 /* desc, NAME, name */ zPeersText
, zPeers_NAME
, zPeers_Name
,
310 /* disablement strs */ NULL
, NULL
},
312 { /* entry idx, value */ 6, VALUE_OPT_INTERACTIVE
,
313 /* equiv idx, value */ 6, VALUE_OPT_INTERACTIVE
,
314 /* equivalenced to */ NO_EQUIVALENT
,
315 /* min, max, act ct */ 0, 1, 0,
316 /* opt state flags */ INTERACTIVE_FLAGS
, 0,
317 /* last opt argumnt */ { NULL
},
318 /* arg list/cookie */ NULL
,
319 /* must/cannot opts */ NULL
, aInteractiveCantList
,
320 /* option proc */ NULL
,
321 /* desc, NAME, name */ zInteractiveText
, zInteractive_NAME
, zInteractive_Name
,
322 /* disablement strs */ NULL
, NULL
},
324 { /* entry idx, value */ 7, VALUE_OPT_NUMERIC
,
325 /* equiv idx, value */ 7, VALUE_OPT_NUMERIC
,
326 /* equivalenced to */ NO_EQUIVALENT
,
327 /* min, max, act ct */ 0, 1, 0,
328 /* opt state flags */ NUMERIC_FLAGS
, 0,
329 /* last opt argumnt */ { NULL
},
330 /* arg list/cookie */ NULL
,
331 /* must/cannot opts */ NULL
, NULL
,
332 /* option proc */ NULL
,
333 /* desc, NAME, name */ zNumericText
, zNumeric_NAME
, zNumeric_Name
,
334 /* disablement strs */ NULL
, NULL
},
336 #ifdef NO_OPTIONAL_OPT_ARGS
337 # define VERSION_OPT_FLAGS OPTST_IMM | OPTST_NO_INIT
339 # define VERSION_OPT_FLAGS OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
340 OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT
343 { /* entry idx, value */ INDEX_OPT_VERSION
, VALUE_OPT_VERSION
,
344 /* equiv idx value */ NO_EQUIVALENT
, 0,
345 /* equivalenced to */ NO_EQUIVALENT
,
346 /* min, max, act ct */ 0, 1, 0,
347 /* opt state flags */ VERSION_OPT_FLAGS
, 0,
348 /* last opt argumnt */ { NULL
},
349 /* arg list/cookie */ NULL
,
350 /* must/cannot opts */ NULL
, NULL
,
351 /* option proc */ DOVERPROC
,
352 /* desc, NAME, name */ zVersionText
, NULL
, zVersion_Name
,
353 /* disablement strs */ NULL
, NULL
},
355 #undef VERSION_OPT_FLAGS
358 { /* entry idx, value */ INDEX_OPT_HELP
, VALUE_OPT_HELP
,
359 /* equiv idx value */ NO_EQUIVALENT
, 0,
360 /* equivalenced to */ NO_EQUIVALENT
,
361 /* min, max, act ct */ 0, 1, 0,
362 /* opt state flags */ OPTST_IMM
| OPTST_NO_INIT
, 0,
363 /* last opt argumnt */ { NULL
},
364 /* arg list/cookie */ NULL
,
365 /* must/cannot opts */ NULL
, NULL
,
366 /* option proc */ doUsageOpt
,
367 /* desc, NAME, name */ zHelpText
, NULL
, zHelp_Name
,
368 /* disablement strs */ NULL
, NULL
},
370 { /* entry idx, value */ INDEX_OPT_MORE_HELP
, VALUE_OPT_MORE_HELP
,
371 /* equiv idx value */ NO_EQUIVALENT
, 0,
372 /* equivalenced to */ NO_EQUIVALENT
,
373 /* min, max, act ct */ 0, 1, 0,
374 /* opt state flags */ OPTST_IMM
| OPTST_NO_INIT
, 0,
375 /* last opt argumnt */ { NULL
},
376 /* arg list/cookie */ NULL
,
377 /* must/cannot opts */ NULL
, NULL
,
378 /* option proc */ optionPagedUsage
,
379 /* desc, NAME, name */ zMore_HelpText
, NULL
, zMore_Help_Name
,
380 /* disablement strs */ NULL
, NULL
},
382 { /* entry idx, value */ INDEX_OPT_SAVE_OPTS
, VALUE_OPT_SAVE_OPTS
,
383 /* equiv idx value */ NO_EQUIVALENT
, 0,
384 /* equivalenced to */ NO_EQUIVALENT
,
385 /* min, max, act ct */ 0, 1, 0,
386 /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING
)
387 | OPTST_ARG_OPTIONAL
| OPTST_NO_INIT
, 0,
388 /* last opt argumnt */ { NULL
},
389 /* arg list/cookie */ NULL
,
390 /* must/cannot opts */ NULL
, NULL
,
391 /* option proc */ NULL
,
392 /* desc, NAME, name */ zSave_OptsText
, NULL
, zSave_Opts_Name
,
393 /* disablement strs */ NULL
, NULL
},
395 { /* entry idx, value */ INDEX_OPT_LOAD_OPTS
, VALUE_OPT_LOAD_OPTS
,
396 /* equiv idx value */ NO_EQUIVALENT
, 0,
397 /* equivalenced to */ NO_EQUIVALENT
,
398 /* min, max, act ct */ 0, NOLIMIT
, 0,
399 /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING
) \
400 | OPTST_DISABLE_IMM
, 0,
401 /* last opt argumnt */ { NULL
},
402 /* arg list/cookie */ NULL
,
403 /* must/cannot opts */ NULL
, NULL
,
404 /* option proc */ optionLoadOpt
,
405 /* desc, NAME, name */ zLoad_OptsText
, zLoad_Opts_NAME
, zLoad_Opts_Name
,
406 /* disablement strs */ zNotLoad_Opts_Name
, zNotLoad_Opts_Pfx
}
409 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
411 * Define the Ntpq Option Environment
413 tSCC zPROGNAME
[] = "NTPQ";
415 "ntpq - standard NTP query program - Ver. 4.2.4p8\n\
416 USAGE: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [ host ...]\n";
417 tSCC zRcName
[] = ".ntprc";
418 tSCC
* apzHomeList
[] = {
423 tSCC zBugsAddr
[] = "http://bugs.ntp.org, bugs@ntp.org";
424 #define zExplain NULL
425 tSCC zDetail
[] = "\n\
428 utility program is used to query NTP servers which\n\
429 implement the standard NTP mode 6 control message formats defined\n\
430 in Appendix B of the NTPv3 specification RFC1305, requesting\n\
431 information about current state and/or changes in that state.\n\
432 The same formats are used in NTPv4, although some of the\n\
433 variables have changed and new ones added.\n";
434 tSCC zFullVersion
[] = NTPQ_FULL_VERSION
;
435 /* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optcode.tpl near line 408 */
437 #if defined(ENABLE_NLS)
438 # define OPTPROC_BASE OPTPROC_TRANSLATE
439 static tOptionXlateProc translate_option_strings
;
441 # define OPTPROC_BASE OPTPROC_NONE
442 # define translate_option_strings NULL
443 #endif /* ENABLE_NLS */
445 tOptions ntpqOptions
= {
446 OPTIONS_STRUCT_VERSION
,
447 0, NULL
, /* original argc + argv */
454 + OPTPROC_HAS_IMMED
),
455 0, NULL
, /* current option index, current option */
456 NULL
, NULL
, zPROGNAME
,
457 zRcName
, zCopyright
, zCopyrightNotice
,
458 zFullVersion
, apzHomeList
, zUsageTitle
,
459 zExplain
, zDetail
, optDesc
,
460 zBugsAddr
, /* address to send bugs to */
461 NULL
, NULL
, /* extensions/saved state */
462 optionUsage
, /* usage procedure */
463 translate_option_strings
, /* translation procedure */
465 * Indexes to special options
467 { INDEX_OPT_MORE_HELP
,
469 NO_EQUIVALENT
/* index of '-#' option */,
470 NO_EQUIVALENT
/* index of default opt */
472 13 /* full option count */, 8 /* user option count */
476 * Create the static procedure(s) declared above.
483 USAGE( EXIT_SUCCESS
);
486 #if ! defined(TEST_NTPQ_OPTS)
490 * For the set-debug-level option, when DEBUG is #define-d.
494 doOptSet_Debug_Level(
498 /* extracted from ../include/debug-opt.def, line 29 */
499 DESC(DEBUG_LEVEL
).optOccCt
= atoi( pOptDesc
->pzLastArg
);
501 #endif /* defined DEBUG */
503 #endif /* defined(TEST_NTPQ_OPTS) */
505 /* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optmain.tpl near line 92 */
507 #if defined(TEST_NTPQ_OPTS) /* TEST MAIN PROCEDURE: */
510 main( int argc
, char** argv
)
512 int res
= EXIT_SUCCESS
;
513 (void)optionProcess( &ntpqOptions
, argc
, argv
);
515 void optionPutShell( tOptions
* );
516 optionPutShell( &ntpqOptions
);
520 #endif /* defined TEST_NTPQ_OPTS */
521 /* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optcode.tpl near line 514 */
528 #include <autoopts/usage-txt.h>
530 static char* AO_gettext( char const* pz
);
531 static void coerce_it(void** s
);
534 AO_gettext( char const* pz
)
542 pzRes
= strdup( pzRes
);
544 fputs( _("No memory for duping translated strings\n"), stderr
);
545 exit( EXIT_FAILURE
);
550 static void coerce_it(void** s
) { *s
= AO_gettext(*s
); }
551 #define COERSION(_f) \
552 coerce_it((void*)&(ntpqOptions._f))
555 * This invokes the translation code (e.g. gettext(3)).
558 translate_option_strings( void )
561 * Guard against re-translation. It won't work. The strings will have
562 * been changed by the first pass through this code. One shot only.
564 if (option_usage_text
.field_ct
== 0)
567 * Do the translations. The first pointer follows the field count field.
568 * The field count field is the size of a pointer.
571 char** ppz
= (char**)(void*)&(option_usage_text
);
572 int ix
= option_usage_text
.field_ct
;
576 *ppz
= AO_gettext(*ppz
);
579 option_usage_text
.field_ct
= 0;
582 tOptDesc
* pOD
= ntpqOptions
.pOptDesc
;
583 int ix
= ntpqOptions
.optCt
;
586 pOD
->pzText
= AO_gettext(pOD
->pzText
);
587 pOD
->pz_NAME
= AO_gettext(pOD
->pz_NAME
);
588 pOD
->pz_Name
= AO_gettext(pOD
->pz_Name
);
589 pOD
->pz_DisableName
= AO_gettext(pOD
->pz_DisableName
);
590 pOD
->pz_DisablePfx
= AO_gettext(pOD
->pz_DisablePfx
);
596 COERSION(pzCopyright
);
597 COERSION(pzCopyNotice
);
598 COERSION(pzFullVersion
);
599 COERSION(pzUsageTitle
);
604 #endif /* ENABLE_NLS */
609 /* ntpq-opts.c ends here */