2 * EDIT THIS FILE WITH CAUTION (ntpq-opts.c)
4 * It has been AutoGen-ed Sunday August 17, 2008 at 05:26:55 AM EDT
5 * From the definitions ntpq-opts.def
6 * and the template file options
8 * Generated from AutoOpts 29:0:4 templates.
12 * This file was produced by an AutoOpts template. AutoOpts is a
13 * copyrighted work. This source file is not encumbered by AutoOpts
14 * licensing, but is provided under the licensing terms chosen by the
15 * ntpq author or copyright holder. AutoOpts is licensed under
16 * the terms of the LGPL. The redistributable library (``libopts'') is
17 * licensed under the terms of either the LGPL or, at the users discretion,
18 * the BSD license. See the AutoOpts and/or libopts sources for details.
20 * This source file is copyrighted and licensed under the following terms:
22 * ntpq copyright 1970-2008 David L. Mills and/or others - all rights reserved
24 * see html/copyright.html
30 #define OPTION_CODE_COMPILE 1
31 #include "ntpq-opts.h"
37 "ntpq copyright (c) 1970-2008 David L. Mills and/or others, all rights reserved";
38 tSCC zCopyrightNotice[] =
40 /* extracted from ../include/copyright.def near line 8 */
41 "see html/copyright.html";
42 extern tUsageProc optionUsage;
45 * global included definitions
48 extern int atoi(const char*);
57 # define EXIT_SUCCESS 0
60 # define EXIT_FAILURE 1
63 * Ipv4 option description:
66 "Force IPv4 DNS name resolution";
67 tSCC zIpv4_NAME[] = "IPV4";
68 tSCC zIpv4_Name[] = "ipv4";
69 #define IPV4_FLAGS (OPTST_DISABLED)
72 * Ipv6 option description:
75 "Force IPv6 DNS name resolution";
76 tSCC zIpv6_NAME[] = "IPV6";
77 tSCC zIpv6_Name[] = "ipv6";
78 #define IPV6_FLAGS (OPTST_DISABLED)
81 * Command option description:
84 "run a command and exit";
85 tSCC zCommand_NAME[] = "COMMAND";
86 tSCC zCommand_Name[] = "command";
87 #define COMMAND_FLAGS (OPTST_DISABLED | OPTST_STACKED \
88 | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
91 * Debug_Level option description:
94 tSCC zDebug_LevelText[] =
95 "Increase output debug message level";
96 tSCC zDebug_Level_NAME[] = "DEBUG_LEVEL";
97 tSCC zDebug_Level_Name[] = "debug-level";
98 #define DEBUG_LEVEL_FLAGS (OPTST_DISABLED)
100 #else /* disable Debug_Level */
101 #define VALUE_OPT_DEBUG_LEVEL NO_EQUIVALENT
102 #define DEBUG_LEVEL_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
103 #define zDebug_LevelText NULL
104 #define zDebug_Level_NAME NULL
105 #define zDebug_Level_Name NULL
109 * Set_Debug_Level option description:
112 tSCC zSet_Debug_LevelText[] =
113 "Set the output debug message level";
114 tSCC zSet_Debug_Level_NAME[] = "SET_DEBUG_LEVEL";
115 tSCC zSet_Debug_Level_Name[] = "set-debug-level";
116 #define SET_DEBUG_LEVEL_FLAGS (OPTST_DISABLED \
117 | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
119 #else /* disable Set_Debug_Level */
120 #define VALUE_OPT_SET_DEBUG_LEVEL NO_EQUIVALENT
121 #define SET_DEBUG_LEVEL_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
122 #define zSet_Debug_LevelText NULL
123 #define zSet_Debug_Level_NAME NULL
124 #define zSet_Debug_Level_Name NULL
128 * Peers option description with
129 * "Must also have options" and "Incompatible options":
132 "Print a list of the peers";
133 tSCC zPeers_NAME[] = "PEERS";
134 tSCC zPeers_Name[] = "peers";
137 INDEX_OPT_INTERACTIVE, NO_EQUIVALENT };
138 #define PEERS_FLAGS (OPTST_DISABLED)
141 * Interactive option description with
142 * "Must also have options" and "Incompatible options":
144 tSCC zInteractiveText[] =
145 "Force ntpq to operate in interactive mode";
146 tSCC zInteractive_NAME[] = "INTERACTIVE";
147 tSCC zInteractive_Name[] = "interactive";
149 aInteractiveCantList[] = {
151 INDEX_OPT_PEERS, NO_EQUIVALENT };
152 #define INTERACTIVE_FLAGS (OPTST_DISABLED)
155 * Numeric option description:
157 tSCC zNumericText[] =
158 "numeric host addresses";
159 tSCC zNumeric_NAME[] = "NUMERIC";
160 tSCC zNumeric_Name[] = "numeric";
161 #define NUMERIC_FLAGS (OPTST_DISABLED)
164 * Help/More_Help/Version option descriptions:
166 tSCC zHelpText[] = "Display usage information and exit";
167 tSCC zHelp_Name[] = "help";
169 tSCC zMore_HelpText[] = "Extended usage information passed thru pager";
170 tSCC zMore_Help_Name[] = "more-help";
172 tSCC zVersionText[] = "Output version information and exit";
173 tSCC zVersion_Name[] = "version";
176 * Save/Load_Opts option description:
178 tSCC zSave_OptsText[] = "Save the option state to a config file";
179 tSCC zSave_Opts_Name[] = "save-opts";
181 tSCC zLoad_OptsText[] = "Load options from a config file";
182 tSCC zLoad_Opts_NAME[] = "LOAD_OPTS";
184 tSCC zNotLoad_Opts_Name[] = "no-load-opts";
185 tSCC zNotLoad_Opts_Pfx[] = "no";
186 #define zLoad_Opts_Name (zNotLoad_Opts_Name + 3)
188 * Declare option callback procedures
191 static tOptProc doOptSet_Debug_Level;
192 #else /* not DEBUG */
193 # define doOptSet_Debug_Level NULL
194 #endif /* def/not DEBUG */
195 #if defined(TEST_NTPQ_OPTS)
197 * Under test, omit argument processing, or call optionStackArg,
198 * if multiple copies are allowed.
201 optionPagedUsage, optionStackArg, optionVersionStderr;
206 * #define map the "normal" callout procs to the test ones...
208 #define SET_DEBUG_LEVEL_OPT_PROC optionStackArg
211 #else /* NOT defined TEST_NTPQ_OPTS */
213 * When not under test, there are different procs to use
216 optionPagedUsage, optionPrintVersion, optionStackArg;
221 * #define map the "normal" callout procs
223 #define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level
225 #define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level
226 #endif /* defined(TEST_NTPQ_OPTS) */
227 #ifdef TEST_NTPQ_OPTS
228 # define DOVERPROC optionVersionStderr
230 # define DOVERPROC optionPrintVersion
231 #endif /* TEST_NTPQ_OPTS */
233 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
235 * Define the Ntpq Option Descriptions.
237 static tOptDesc optDesc[ OPTION_CT ] = {
238 { /* entry idx, value */ 0, VALUE_OPT_IPV4,
239 /* equiv idx, value */ NO_EQUIVALENT, 0,
240 /* equivalenced to */ NO_EQUIVALENT,
241 /* min, max, act ct */ 0, 1, 0,
242 /* opt state flags */ IPV4_FLAGS, 0,
243 /* last opt argumnt */ { NULL },
244 /* arg list/cookie */ NULL,
245 /* must/cannot opts */ NULL, NULL,
246 /* option proc */ NULL,
247 /* desc, NAME, name */ zIpv4Text, zIpv4_NAME, zIpv4_Name,
248 /* disablement strs */ NULL, NULL },
250 { /* entry idx, value */ 1, VALUE_OPT_IPV6,
251 /* equiv idx, value */ NOLIMIT, NOLIMIT,
252 /* equivalenced to */ INDEX_OPT_IPV4,
253 /* min, max, act ct */ 0, 1, 0,
254 /* opt state flags */ IPV6_FLAGS, 0,
255 /* last opt argumnt */ { NULL },
256 /* arg list/cookie */ NULL,
257 /* must/cannot opts */ NULL, NULL,
258 /* option proc */ NULL,
259 /* desc, NAME, name */ zIpv6Text, zIpv6_NAME, zIpv6_Name,
260 /* disablement strs */ NULL, NULL },
262 { /* entry idx, value */ 2, VALUE_OPT_COMMAND,
263 /* equiv idx, value */ 2, VALUE_OPT_COMMAND,
264 /* equivalenced to */ NO_EQUIVALENT,
265 /* min, max, act ct */ 0, NOLIMIT, 0,
266 /* opt state flags */ COMMAND_FLAGS, 0,
267 /* last opt argumnt */ { NULL },
268 /* arg list/cookie */ NULL,
269 /* must/cannot opts */ NULL, NULL,
270 /* option proc */ optionStackArg,
271 /* desc, NAME, name */ zCommandText, zCommand_NAME, zCommand_Name,
272 /* disablement strs */ NULL, NULL },
274 { /* entry idx, value */ 3, VALUE_OPT_DEBUG_LEVEL,
275 /* equiv idx, value */ 3, VALUE_OPT_DEBUG_LEVEL,
276 /* equivalenced to */ NO_EQUIVALENT,
277 /* min, max, act ct */ 0, NOLIMIT, 0,
278 /* opt state flags */ DEBUG_LEVEL_FLAGS, 0,
279 /* last opt argumnt */ { NULL },
280 /* arg list/cookie */ NULL,
281 /* must/cannot opts */ NULL, NULL,
282 /* option proc */ NULL,
283 /* desc, NAME, name */ zDebug_LevelText, zDebug_Level_NAME, zDebug_Level_Name,
284 /* disablement strs */ NULL, NULL },
286 { /* entry idx, value */ 4, VALUE_OPT_SET_DEBUG_LEVEL,
287 /* equiv idx, value */ 4, VALUE_OPT_SET_DEBUG_LEVEL,
288 /* equivalenced to */ NO_EQUIVALENT,
289 /* min, max, act ct */ 0, NOLIMIT, 0,
290 /* opt state flags */ SET_DEBUG_LEVEL_FLAGS, 0,
291 /* last opt argumnt */ { NULL },
292 /* arg list/cookie */ NULL,
293 /* must/cannot opts */ NULL, NULL,
294 /* option proc */ SET_DEBUG_LEVEL_OPT_PROC,
295 /* desc, NAME, name */ zSet_Debug_LevelText, zSet_Debug_Level_NAME, zSet_Debug_Level_Name,
296 /* disablement strs */ NULL, NULL },
298 { /* entry idx, value */ 5, VALUE_OPT_PEERS,
299 /* equiv idx, value */ 5, VALUE_OPT_PEERS,
300 /* equivalenced to */ NO_EQUIVALENT,
301 /* min, max, act ct */ 0, 1, 0,
302 /* opt state flags */ PEERS_FLAGS, 0,
303 /* last opt argumnt */ { NULL },
304 /* arg list/cookie */ NULL,
305 /* must/cannot opts */ NULL, aPeersCantList,
306 /* option proc */ NULL,
307 /* desc, NAME, name */ zPeersText, zPeers_NAME, zPeers_Name,
308 /* disablement strs */ NULL, NULL },
310 { /* entry idx, value */ 6, VALUE_OPT_INTERACTIVE,
311 /* equiv idx, value */ 6, VALUE_OPT_INTERACTIVE,
312 /* equivalenced to */ NO_EQUIVALENT,
313 /* min, max, act ct */ 0, 1, 0,
314 /* opt state flags */ INTERACTIVE_FLAGS, 0,
315 /* last opt argumnt */ { NULL },
316 /* arg list/cookie */ NULL,
317 /* must/cannot opts */ NULL, aInteractiveCantList,
318 /* option proc */ NULL,
319 /* desc, NAME, name */ zInteractiveText, zInteractive_NAME, zInteractive_Name,
320 /* disablement strs */ NULL, NULL },
322 { /* entry idx, value */ 7, VALUE_OPT_NUMERIC,
323 /* equiv idx, value */ 7, VALUE_OPT_NUMERIC,
324 /* equivalenced to */ NO_EQUIVALENT,
325 /* min, max, act ct */ 0, 1, 0,
326 /* opt state flags */ NUMERIC_FLAGS, 0,
327 /* last opt argumnt */ { NULL },
328 /* arg list/cookie */ NULL,
329 /* must/cannot opts */ NULL, NULL,
330 /* option proc */ NULL,
331 /* desc, NAME, name */ zNumericText, zNumeric_NAME, zNumeric_Name,
332 /* disablement strs */ NULL, NULL },
334 #ifdef NO_OPTIONAL_OPT_ARGS
335 # define VERSION_OPT_FLAGS OPTST_IMM | OPTST_NO_INIT
337 # define VERSION_OPT_FLAGS OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
338 OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT
341 { /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
342 /* equiv idx value */ NO_EQUIVALENT, 0,
343 /* equivalenced to */ NO_EQUIVALENT,
344 /* min, max, act ct */ 0, 1, 0,
345 /* opt state flags */ VERSION_OPT_FLAGS, 0,
346 /* last opt argumnt */ { NULL },
347 /* arg list/cookie */ NULL,
348 /* must/cannot opts */ NULL, NULL,
349 /* option proc */ DOVERPROC,
350 /* desc, NAME, name */ zVersionText, NULL, zVersion_Name,
351 /* disablement strs */ NULL, NULL },
353 #undef VERSION_OPT_FLAGS
356 { /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
357 /* equiv idx value */ NO_EQUIVALENT, 0,
358 /* equivalenced to */ NO_EQUIVALENT,
359 /* min, max, act ct */ 0, 1, 0,
360 /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0,
361 /* last opt argumnt */ { NULL },
362 /* arg list/cookie */ NULL,
363 /* must/cannot opts */ NULL, NULL,
364 /* option proc */ doUsageOpt,
365 /* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
366 /* disablement strs */ NULL, NULL },
368 { /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
369 /* equiv idx value */ NO_EQUIVALENT, 0,
370 /* equivalenced to */ NO_EQUIVALENT,
371 /* min, max, act ct */ 0, 1, 0,
372 /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0,
373 /* last opt argumnt */ { NULL },
374 /* arg list/cookie */ NULL,
375 /* must/cannot opts */ NULL, NULL,
376 /* option proc */ optionPagedUsage,
377 /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name,
378 /* disablement strs */ NULL, NULL },
380 { /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS,
381 /* equiv idx value */ NO_EQUIVALENT, 0,
382 /* equivalenced to */ NO_EQUIVALENT,
383 /* min, max, act ct */ 0, 1, 0,
384 /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
385 | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0,
386 /* last opt argumnt */ { NULL },
387 /* arg list/cookie */ NULL,
388 /* must/cannot opts */ NULL, NULL,
389 /* option proc */ NULL,
390 /* desc, NAME, name */ zSave_OptsText, NULL, zSave_Opts_Name,
391 /* disablement strs */ NULL, NULL },
393 { /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS,
394 /* equiv idx value */ NO_EQUIVALENT, 0,
395 /* equivalenced to */ NO_EQUIVALENT,
396 /* min, max, act ct */ 0, NOLIMIT, 0,
397 /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) \
398 | OPTST_DISABLE_IMM, 0,
399 /* last opt argumnt */ { NULL },
400 /* arg list/cookie */ NULL,
401 /* must/cannot opts */ NULL, NULL,
402 /* option proc */ optionLoadOpt,
403 /* desc, NAME, name */ zLoad_OptsText, zLoad_Opts_NAME, zLoad_Opts_Name,
404 /* disablement strs */ zNotLoad_Opts_Name, zNotLoad_Opts_Pfx }
407 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
409 * Define the Ntpq Option Environment
411 tSCC zPROGNAME[] = "NTPQ";
413 "ntpq - standard NTP query program - Ver. 4.2.4p5\n\
414 USAGE: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [ host ...]\n";
415 tSCC zRcName[] = ".ntprc";
416 tSCC* apzHomeList[] = {
421 tSCC zBugsAddr[] = "http://bugs.ntp.isc.org, bugs@ntp.org";
422 #define zExplain NULL
423 tSCC zDetail[] = "\n\
426 utility program is used to query NTP servers which\n\
427 implement the standard NTP mode 6 control message formats defined\n\
428 in Appendix B of the NTPv3 specification RFC1305, requesting\n\
429 information about current state and/or changes in that state.\n\
430 The same formats are used in NTPv4, although some of the\n\
431 variables have changed and new ones added.\n";
432 tSCC zFullVersion[] = NTPQ_FULL_VERSION;
433 /* extracted from /usr/local/gnu/share/autogen/optcode.tpl near line 408 */
435 #if defined(ENABLE_NLS)
436 # define OPTPROC_BASE OPTPROC_TRANSLATE
437 static tOptionXlateProc translate_option_strings;
439 # define OPTPROC_BASE OPTPROC_NONE
440 # define translate_option_strings NULL
441 #endif /* ENABLE_NLS */
443 tOptions ntpqOptions = {
444 OPTIONS_STRUCT_VERSION,
445 0, NULL, /* original argc + argv */
452 + OPTPROC_HAS_IMMED ),
453 0, NULL, /* current option index, current option */
454 NULL, NULL, zPROGNAME,
455 zRcName, zCopyright, zCopyrightNotice,
456 zFullVersion, apzHomeList, zUsageTitle,
457 zExplain, zDetail, optDesc,
458 zBugsAddr, /* address to send bugs to */
459 NULL, NULL, /* extensions/saved state */
460 optionUsage, /* usage procedure */
461 translate_option_strings, /* translation procedure */
463 * Indexes to special options
465 { INDEX_OPT_MORE_HELP,
467 NO_EQUIVALENT /* index of '-#' option */,
468 NO_EQUIVALENT /* index of default opt */
470 13 /* full option count */, 8 /* user option count */
474 * Create the static procedure(s) declared above.
481 USAGE( EXIT_SUCCESS );
484 #if ! defined(TEST_NTPQ_OPTS)
488 * For the set-debug-level option, when DEBUG is #define-d.
492 doOptSet_Debug_Level(
496 /* extracted from ../include/debug-opt.def, line 29 */
497 DESC(DEBUG_LEVEL).optOccCt = atoi( pOptDesc->pzLastArg );
499 #endif /* defined DEBUG */
501 #endif /* defined(TEST_NTPQ_OPTS) */
503 /* extracted from /usr/local/gnu/share/autogen/optmain.tpl near line 92 */
505 #if defined(TEST_NTPQ_OPTS) /* TEST MAIN PROCEDURE: */
508 main( int argc, char** argv )
510 int res = EXIT_SUCCESS;
511 (void)optionProcess( &ntpqOptions, argc, argv );
513 void optionPutShell( tOptions* );
514 optionPutShell( &ntpqOptions );
518 #endif /* defined TEST_NTPQ_OPTS */
519 /* extracted from /usr/local/gnu/share/autogen/optcode.tpl near line 514 */
526 #include <autoopts/usage-txt.h>
528 static char* AO_gettext( char const* pz );
529 static void coerce_it(void** s);
532 AO_gettext( char const* pz )
540 pzRes = strdup( pzRes );
542 fputs( _("No memory for duping translated strings\n"), stderr );
543 exit( EXIT_FAILURE );
548 static void coerce_it(void** s) { *s = AO_gettext(*s); }
549 #define COERSION(_f) \
550 coerce_it((void*)&(ntpqOptions._f))
553 * This invokes the translation code (e.g. gettext(3)).
556 translate_option_strings( void )
559 * Guard against re-translation. It won't work. The strings will have
560 * been changed by the first pass through this code. One shot only.
562 if (option_usage_text.field_ct == 0)
565 * Do the translations. The first pointer follows the field count field.
566 * The field count field is the size of a pointer.
569 char** ppz = (char**)(void*)&(option_usage_text);
570 int ix = option_usage_text.field_ct;
574 *ppz = AO_gettext(*ppz);
577 option_usage_text.field_ct = 0;
580 tOptDesc* pOD = ntpqOptions.pOptDesc;
581 int ix = ntpqOptions.optCt;
584 pOD->pzText = AO_gettext(pOD->pzText);
585 pOD->pz_NAME = AO_gettext(pOD->pz_NAME);
586 pOD->pz_Name = AO_gettext(pOD->pz_Name);
587 pOD->pz_DisableName = AO_gettext(pOD->pz_DisableName);
588 pOD->pz_DisablePfx = AO_gettext(pOD->pz_DisablePfx);
594 COERSION(pzCopyright);
595 COERSION(pzCopyNotice);
596 COERSION(pzFullVersion);
597 COERSION(pzUsageTitle);
602 #endif /* ENABLE_NLS */
607 /* ntpq-opts.c ends here */