xref: /netbsd-src/external/bsd/ntp/dist/ntpq/ntpq-opts.c (revision a5847cc334d9a7029f6352b847e9e8d71a0f9e0c)
1 /*	$NetBSD: ntpq-opts.c,v 1.1.1.1 2009/12/13 16:56:31 kardel Exp $	*/
2 
3 /*
4  *  EDIT THIS FILE WITH CAUTION  (ntpq-opts.c)
5  *
6  *  It has been AutoGen-ed  December 10, 2009 at 05:03:03 AM by AutoGen 5.10
7  *  From the definitions    ntpq-opts.def
8  *  and the template file   options
9  *
10  * Generated from AutoOpts 33:0:8 templates.
11  */
12 
13 /*
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.
21  *
22  * This source file is copyrighted and licensed under the following terms:
23  *
24  * ntpq copyright (c) 1970-2009 David L. Mills and/or others - all rights reserved
25  *
26  * see html/copyright.html
27  */
28 
29 #include <sys/types.h>
30 #include <limits.h>
31 #include <stdio.h>
32 #include <stdlib.h>
33 
34 #define OPTION_CODE_COMPILE 1
35 #include "ntpq-opts.h"
36 
37 #ifdef  __cplusplus
38 extern "C" {
39 #endif
40 
41 /* TRANSLATORS: choose the translation for option names wisely because you
42                 cannot ever change your mind. */
43 tSCC zCopyright[] =
44        "ntpq copyright (c) 1970-2009 David L. Mills and/or others, all rights reserved"
45 /* extracted from ../include/copyright.def near line 8 */
46 ;
47 tSCC zCopyrightNotice[24] =
48 "see html/copyright.html";
49 
50 extern tUsageProc optionUsage;
51 
52 /*
53  *  global included definitions
54  */
55 #ifdef __windows
56   extern int atoi(const char*);
57 #else
58 # include <stdlib.h>
59 #endif
60 
61 #ifndef NULL
62 #  define NULL 0
63 #endif
64 #ifndef EXIT_SUCCESS
65 #  define  EXIT_SUCCESS 0
66 #endif
67 #ifndef EXIT_FAILURE
68 #  define  EXIT_FAILURE 1
69 #endif
70 
71 /*
72  *  Ipv4 option description with
73  *  "Must also have options" and "Incompatible options":
74  */
75 tSCC    zIpv4Text[] =
76         "Force IPv4 DNS name resolution";
77 tSCC    zIpv4_NAME[]               = "IPV4";
78 tSCC    zIpv4_Name[]               = "ipv4";
79 static const int
80     aIpv4CantList[] = {
81     INDEX_OPT_IPV6, NO_EQUIVALENT };
82 #define IPV4_FLAGS       (OPTST_DISABLED)
83 
84 /*
85  *  Ipv6 option description with
86  *  "Must also have options" and "Incompatible options":
87  */
88 tSCC    zIpv6Text[] =
89         "Force IPv6 DNS name resolution";
90 tSCC    zIpv6_NAME[]               = "IPV6";
91 tSCC    zIpv6_Name[]               = "ipv6";
92 static const int
93     aIpv6CantList[] = {
94     INDEX_OPT_IPV4, NO_EQUIVALENT };
95 #define IPV6_FLAGS       (OPTST_DISABLED)
96 
97 /*
98  *  Command option description:
99  */
100 tSCC    zCommandText[] =
101         "run a command and exit";
102 tSCC    zCommand_NAME[]            = "COMMAND";
103 tSCC    zCommand_Name[]            = "command";
104 #define COMMAND_FLAGS       (OPTST_DISABLED \
105         | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
106 
107 /*
108  *  Debug_Level option description:
109  */
110 tSCC    zDebug_LevelText[] =
111         "Increase output debug message level";
112 tSCC    zDebug_Level_NAME[]        = "DEBUG_LEVEL";
113 tSCC    zDebug_Level_Name[]        = "debug-level";
114 #define DEBUG_LEVEL_FLAGS       (OPTST_DISABLED)
115 
116 /*
117  *  Set_Debug_Level option description:
118  */
119 tSCC    zSet_Debug_LevelText[] =
120         "Set the output debug message level";
121 tSCC    zSet_Debug_Level_NAME[]    = "SET_DEBUG_LEVEL";
122 tSCC    zSet_Debug_Level_Name[]    = "set-debug-level";
123 #define SET_DEBUG_LEVEL_FLAGS       (OPTST_DISABLED \
124         | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
125 
126 /*
127  *  Peers option description with
128  *  "Must also have options" and "Incompatible options":
129  */
130 tSCC    zPeersText[] =
131         "Print a list of the peers";
132 tSCC    zPeers_NAME[]              = "PEERS";
133 tSCC    zPeers_Name[]              = "peers";
134 static const int
135     aPeersCantList[] = {
136     INDEX_OPT_INTERACTIVE, NO_EQUIVALENT };
137 #define PEERS_FLAGS       (OPTST_DISABLED)
138 
139 /*
140  *  Interactive option description with
141  *  "Must also have options" and "Incompatible options":
142  */
143 tSCC    zInteractiveText[] =
144         "Force ntpq to operate in interactive mode";
145 tSCC    zInteractive_NAME[]        = "INTERACTIVE";
146 tSCC    zInteractive_Name[]        = "interactive";
147 static const int
148     aInteractiveCantList[] = {
149     INDEX_OPT_COMMAND,
150     INDEX_OPT_PEERS, NO_EQUIVALENT };
151 #define INTERACTIVE_FLAGS       (OPTST_DISABLED)
152 
153 /*
154  *  Numeric option description:
155  */
156 tSCC    zNumericText[] =
157         "numeric host addresses";
158 tSCC    zNumeric_NAME[]            = "NUMERIC";
159 tSCC    zNumeric_Name[]            = "numeric";
160 #define NUMERIC_FLAGS       (OPTST_DISABLED)
161 
162 /*
163  *  Old_Rv option description:
164  */
165 tSCC    zOld_RvText[] =
166         "Always output status line with readvar";
167 tSCC    zOld_Rv_NAME[]             = "OLD_RV";
168 tSCC    zOld_Rv_Name[]             = "old-rv";
169 #define OLD_RV_FLAGS       (OPTST_DISABLED)
170 
171 /*
172  *  Help/More_Help/Version option descriptions:
173  */
174 tSCC zHelpText[]          = "Display extended usage information and exit";
175 tSCC zHelp_Name[]         = "help";
176 #ifdef HAVE_WORKING_FORK
177 #define OPTST_MORE_HELP_FLAGS   (OPTST_IMM | OPTST_NO_INIT)
178 tSCC zMore_Help_Name[]    = "more-help";
179 tSCC zMore_HelpText[]     = "Extended usage information passed thru pager";
180 #else
181 #define OPTST_MORE_HELP_FLAGS   (OPTST_OMITTED | OPTST_NO_INIT)
182 #define zMore_Help_Name   NULL
183 #define zMore_HelpText    NULL
184 #endif
185 #ifdef NO_OPTIONAL_OPT_ARGS
186 #  define OPTST_VERSION_FLAGS   OPTST_IMM | OPTST_NO_INIT
187 #else
188 #  define OPTST_VERSION_FLAGS   OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
189                                 OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT
190 #endif
191 
192 tSCC zVersionText[]       = "Output version information and exit";
193 tSCC zVersion_Name[]      = "version";
194 tSCC zSave_OptsText[]     = "Save the option state to a config file";
195 tSCC zSave_Opts_Name[]    = "save-opts";
196 tSCC zLoad_OptsText[]     = "Load options from a config file";
197 tSCC zLoad_Opts_NAME[]    = "LOAD_OPTS";
198 tSCC zNotLoad_Opts_Name[] = "no-load-opts";
199 tSCC zNotLoad_Opts_Pfx[]  = "no";
200 #define zLoad_Opts_Name   (zNotLoad_Opts_Name + 3)
201 /*
202  *  Declare option callback procedures
203  */
204 #if defined(TEST_NTPQ_OPTS)
205 /*
206  *  Under test, omit argument processing, or call optionStackArg,
207  *  if multiple copies are allowed.
208  */
209 extern tOptProc
210     optionPagedUsage, optionStackArg, optionVersionStderr;
211 static tOptProc
212     doUsageOpt;
213 
214 /*
215  *  #define map the "normal" callout procs to the test ones...
216  */
217 #define COMMAND_OPT_PROC optionStackArg
218 #define SET_DEBUG_LEVEL_OPT_PROC optionStackArg
219 #define PEERS_OPT_PROC optionStackArg
220 
221 
222 #else /* NOT defined TEST_NTPQ_OPTS */
223 /*
224  *  When not under test, there are different procs to use
225  */
226 extern tOptProc
227     ntpq_custom_opt_handler, optionPagedUsage, optionPrintVersion;
228 static tOptProc
229     doOptSet_Debug_Level, doUsageOpt;
230 
231 /*
232  *  #define map the "normal" callout procs
233  */
234 #define COMMAND_OPT_PROC ntpq_custom_opt_handler
235 #define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level
236 #define PEERS_OPT_PROC ntpq_custom_opt_handler
237 
238 #define COMMAND_OPT_PROC ntpq_custom_opt_handler
239 #define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level
240 #define PEERS_OPT_PROC ntpq_custom_opt_handler
241 #endif /* defined(TEST_NTPQ_OPTS) */
242 #ifdef TEST_NTPQ_OPTS
243 # define DOVERPROC optionVersionStderr
244 #else
245 # define DOVERPROC optionPrintVersion
246 #endif /* TEST_NTPQ_OPTS */
247 
248 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
249  *
250  *  Define the Ntpq Option Descriptions.
251  */
252 static tOptDesc optDesc[ OPTION_CT ] = {
253   {  /* entry idx, value */ 0, VALUE_OPT_IPV4,
254      /* equiv idx, value */ 0, VALUE_OPT_IPV4,
255      /* equivalenced to  */ NO_EQUIVALENT,
256      /* min, max, act ct */ 0, 1, 0,
257      /* opt state flags  */ IPV4_FLAGS, 0,
258      /* last opt argumnt */ { NULL },
259      /* arg list/cookie  */ NULL,
260      /* must/cannot opts */ NULL, aIpv4CantList,
261      /* option proc      */ NULL,
262      /* desc, NAME, name */ zIpv4Text, zIpv4_NAME, zIpv4_Name,
263      /* disablement strs */ NULL, NULL },
264 
265   {  /* entry idx, value */ 1, VALUE_OPT_IPV6,
266      /* equiv idx, value */ 1, VALUE_OPT_IPV6,
267      /* equivalenced to  */ NO_EQUIVALENT,
268      /* min, max, act ct */ 0, 1, 0,
269      /* opt state flags  */ IPV6_FLAGS, 0,
270      /* last opt argumnt */ { NULL },
271      /* arg list/cookie  */ NULL,
272      /* must/cannot opts */ NULL, aIpv6CantList,
273      /* option proc      */ NULL,
274      /* desc, NAME, name */ zIpv6Text, zIpv6_NAME, zIpv6_Name,
275      /* disablement strs */ NULL, NULL },
276 
277   {  /* entry idx, value */ 2, VALUE_OPT_COMMAND,
278      /* equiv idx, value */ 2, VALUE_OPT_COMMAND,
279      /* equivalenced to  */ NO_EQUIVALENT,
280      /* min, max, act ct */ 0, NOLIMIT, 0,
281      /* opt state flags  */ COMMAND_FLAGS, 0,
282      /* last opt argumnt */ { NULL },
283      /* arg list/cookie  */ NULL,
284      /* must/cannot opts */ NULL, NULL,
285      /* option proc      */ COMMAND_OPT_PROC,
286      /* desc, NAME, name */ zCommandText, zCommand_NAME, zCommand_Name,
287      /* disablement strs */ NULL, NULL },
288 
289   {  /* entry idx, value */ 3, VALUE_OPT_DEBUG_LEVEL,
290      /* equiv idx, value */ 3, VALUE_OPT_DEBUG_LEVEL,
291      /* equivalenced to  */ NO_EQUIVALENT,
292      /* min, max, act ct */ 0, NOLIMIT, 0,
293      /* opt state flags  */ DEBUG_LEVEL_FLAGS, 0,
294      /* last opt argumnt */ { NULL },
295      /* arg list/cookie  */ NULL,
296      /* must/cannot opts */ NULL, NULL,
297      /* option proc      */ NULL,
298      /* desc, NAME, name */ zDebug_LevelText, zDebug_Level_NAME, zDebug_Level_Name,
299      /* disablement strs */ NULL, NULL },
300 
301   {  /* entry idx, value */ 4, VALUE_OPT_SET_DEBUG_LEVEL,
302      /* equiv idx, value */ 4, VALUE_OPT_SET_DEBUG_LEVEL,
303      /* equivalenced to  */ NO_EQUIVALENT,
304      /* min, max, act ct */ 0, NOLIMIT, 0,
305      /* opt state flags  */ SET_DEBUG_LEVEL_FLAGS, 0,
306      /* last opt argumnt */ { NULL },
307      /* arg list/cookie  */ NULL,
308      /* must/cannot opts */ NULL, NULL,
309      /* option proc      */ SET_DEBUG_LEVEL_OPT_PROC,
310      /* desc, NAME, name */ zSet_Debug_LevelText, zSet_Debug_Level_NAME, zSet_Debug_Level_Name,
311      /* disablement strs */ NULL, NULL },
312 
313   {  /* entry idx, value */ 5, VALUE_OPT_PEERS,
314      /* equiv idx, value */ 5, VALUE_OPT_PEERS,
315      /* equivalenced to  */ NO_EQUIVALENT,
316      /* min, max, act ct */ 0, 1, 0,
317      /* opt state flags  */ PEERS_FLAGS, 0,
318      /* last opt argumnt */ { NULL },
319      /* arg list/cookie  */ NULL,
320      /* must/cannot opts */ NULL, aPeersCantList,
321      /* option proc      */ PEERS_OPT_PROC,
322      /* desc, NAME, name */ zPeersText, zPeers_NAME, zPeers_Name,
323      /* disablement strs */ NULL, NULL },
324 
325   {  /* entry idx, value */ 6, VALUE_OPT_INTERACTIVE,
326      /* equiv idx, value */ 6, VALUE_OPT_INTERACTIVE,
327      /* equivalenced to  */ NO_EQUIVALENT,
328      /* min, max, act ct */ 0, 1, 0,
329      /* opt state flags  */ INTERACTIVE_FLAGS, 0,
330      /* last opt argumnt */ { NULL },
331      /* arg list/cookie  */ NULL,
332      /* must/cannot opts */ NULL, aInteractiveCantList,
333      /* option proc      */ NULL,
334      /* desc, NAME, name */ zInteractiveText, zInteractive_NAME, zInteractive_Name,
335      /* disablement strs */ NULL, NULL },
336 
337   {  /* entry idx, value */ 7, VALUE_OPT_NUMERIC,
338      /* equiv idx, value */ 7, VALUE_OPT_NUMERIC,
339      /* equivalenced to  */ NO_EQUIVALENT,
340      /* min, max, act ct */ 0, 1, 0,
341      /* opt state flags  */ NUMERIC_FLAGS, 0,
342      /* last opt argumnt */ { NULL },
343      /* arg list/cookie  */ NULL,
344      /* must/cannot opts */ NULL, NULL,
345      /* option proc      */ NULL,
346      /* desc, NAME, name */ zNumericText, zNumeric_NAME, zNumeric_Name,
347      /* disablement strs */ NULL, NULL },
348 
349   {  /* entry idx, value */ 8, VALUE_OPT_OLD_RV,
350      /* equiv idx, value */ 8, VALUE_OPT_OLD_RV,
351      /* equivalenced to  */ NO_EQUIVALENT,
352      /* min, max, act ct */ 0, 1, 0,
353      /* opt state flags  */ OLD_RV_FLAGS, 0,
354      /* last opt argumnt */ { NULL },
355      /* arg list/cookie  */ NULL,
356      /* must/cannot opts */ NULL, NULL,
357      /* option proc      */ NULL,
358      /* desc, NAME, name */ zOld_RvText, zOld_Rv_NAME, zOld_Rv_Name,
359      /* disablement strs */ NULL, NULL },
360 
361   {  /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
362      /* equiv idx value  */ NO_EQUIVALENT, 0,
363      /* equivalenced to  */ NO_EQUIVALENT,
364      /* min, max, act ct */ 0, 1, 0,
365      /* opt state flags  */ OPTST_VERSION_FLAGS, 0,
366      /* last opt argumnt */ { NULL },
367      /* arg list/cookie  */ NULL,
368      /* must/cannot opts */ NULL, NULL,
369      /* option proc      */ DOVERPROC,
370      /* desc, NAME, name */ zVersionText, NULL, zVersion_Name,
371      /* disablement strs */ NULL, NULL },
372 
373 
374 
375   {  /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
376      /* equiv idx value  */ NO_EQUIVALENT, 0,
377      /* equivalenced to  */ NO_EQUIVALENT,
378      /* min, max, act ct */ 0, 1, 0,
379      /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
380      /* last opt argumnt */ { NULL },
381      /* arg list/cookie  */ NULL,
382      /* must/cannot opts */ NULL, NULL,
383      /* option proc      */ doUsageOpt,
384      /* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
385      /* disablement strs */ NULL, NULL },
386 
387   {  /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
388      /* equiv idx value  */ NO_EQUIVALENT, 0,
389      /* equivalenced to  */ NO_EQUIVALENT,
390      /* min, max, act ct */ 0, 1, 0,
391      /* opt state flags  */ OPTST_MORE_HELP_FLAGS, 0,
392      /* last opt argumnt */ { NULL },
393      /* arg list/cookie  */ NULL,
394      /* must/cannot opts */ NULL,  NULL,
395      /* option proc      */ optionPagedUsage,
396      /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name,
397      /* disablement strs */ NULL, NULL },
398 
399   {  /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS,
400      /* equiv idx value  */ NO_EQUIVALENT, 0,
401      /* equivalenced to  */ NO_EQUIVALENT,
402      /* min, max, act ct */ 0, 1, 0,
403      /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
404                           | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0,
405      /* last opt argumnt */ { NULL },
406      /* arg list/cookie  */ NULL,
407      /* must/cannot opts */ NULL,  NULL,
408      /* option proc      */ NULL,
409      /* desc, NAME, name */ zSave_OptsText, NULL, zSave_Opts_Name,
410      /* disablement strs */ NULL, NULL },
411 
412   {  /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS,
413      /* equiv idx value  */ NO_EQUIVALENT, 0,
414      /* equivalenced to  */ NO_EQUIVALENT,
415      /* min, max, act ct */ 0, NOLIMIT, 0,
416      /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
417 			  | OPTST_DISABLE_IMM, 0,
418      /* last opt argumnt */ { NULL },
419      /* arg list/cookie  */ NULL,
420      /* must/cannot opts */ NULL, NULL,
421      /* option proc      */ optionLoadOpt,
422      /* desc, NAME, name */ zLoad_OptsText, zLoad_Opts_NAME, zLoad_Opts_Name,
423      /* disablement strs */ zNotLoad_Opts_Name, zNotLoad_Opts_Pfx }
424 };
425 
426 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
427  *
428  *  Define the Ntpq Option Environment
429  */
430 tSCC   zPROGNAME[]   = "NTPQ";
431 tSCC   zUsageTitle[] =
432 "ntpq - standard NTP query program - Ver. 4.2.6\n\
433 USAGE:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [ host ...]\n";
434 tSCC   zRcName[]     = ".ntprc";
435 tSCC*  apzHomeList[] = {
436        "$HOME",
437        ".",
438        NULL };
439 
440 tSCC   zBugsAddr[]    = "http://bugs.ntp.org, bugs@ntp.org";
441 #define zExplain NULL
442 tSCC    zDetail[]     = "\n\
443 The\n\
444 [= prog-name =]\n\
445 utility program is used to query NTP servers which\n\
446 implement the standard NTP mode 6 control message formats defined\n\
447 in Appendix B of the NTPv3 specification RFC1305, requesting\n\
448 information about current state and/or changes in that state.\n\
449 The same formats are used in NTPv4, although some of the\n\
450 variables have changed and new ones added.\n";
451 tSCC    zFullVersion[] = NTPQ_FULL_VERSION;
452 /* extracted from /usr/local/gnu/share/autogen/optcode.tpl near line 495 */
453 
454 #if defined(ENABLE_NLS)
455 # define OPTPROC_BASE OPTPROC_TRANSLATE
456   static tOptionXlateProc translate_option_strings;
457 #else
458 # define OPTPROC_BASE OPTPROC_NONE
459 # define translate_option_strings NULL
460 #endif /* ENABLE_NLS */
461 
462 
463 #define ntpq_full_usage NULL
464 #define ntpq_short_usage NULL
465 tOptions ntpqOptions = {
466     OPTIONS_STRUCT_VERSION,
467     0, NULL,                    /* original argc + argv    */
468     ( OPTPROC_BASE
469     + OPTPROC_ERRSTOP
470     + OPTPROC_SHORTOPT
471     + OPTPROC_LONGOPT
472     + OPTPROC_NO_REQ_OPT
473     + OPTPROC_ENVIRON ),
474     0, NULL,                    /* current option index, current option */
475     NULL,         NULL,         zPROGNAME,
476     zRcName,      zCopyright,   zCopyrightNotice,
477     zFullVersion, apzHomeList,  zUsageTitle,
478     zExplain,     zDetail,      optDesc,
479     zBugsAddr,                  /* address to send bugs to */
480     NULL, NULL,                 /* extensions/saved state  */
481     optionUsage,       /* usage procedure */
482     translate_option_strings,   /* translation procedure */
483     /*
484      *  Indexes to special options
485      */
486     { INDEX_OPT_MORE_HELP, /* more-help option index */
487       INDEX_OPT_SAVE_OPTS, /* save option index */
488       NO_EQUIVALENT, /* '-#' option index */
489       NO_EQUIVALENT /* index of default opt */
490     },
491     14 /* full option count */, 9 /* user option count */,
492     ntpq_full_usage, ntpq_short_usage,
493     NULL, NULL
494 };
495 
496 /*
497  *  Create the static procedure(s) declared above.
498  */
499 static void
500 doUsageOpt(
501     tOptions*   pOptions,
502     tOptDesc*   pOptDesc )
503 {
504     (void)pOptions;
505     USAGE( EXIT_SUCCESS );
506 }
507 
508 #if ! defined(TEST_NTPQ_OPTS)
509 
510 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
511  *
512  *   For the set-debug-level option.
513  */
514 static void
515 doOptSet_Debug_Level(tOptions* pOptions, tOptDesc* pOptDesc)
516 {
517     /* extracted from ../include/debug-opt.def, line 27 */
518 DESC(DEBUG_LEVEL).optOccCt = atoi( pOptDesc->pzLastArg );
519 }
520 #endif /* defined(TEST_NTPQ_OPTS) */
521 /* extracted from /usr/local/gnu/share/autogen/optmain.tpl near line 109 */
522 
523 #if defined(TEST_NTPQ_OPTS) /* TEST MAIN PROCEDURE: */
524 
525 extern void optionPutShell( tOptions* );
526 
527 int
528 main(int argc, char** argv)
529 {
530     int res = EXIT_SUCCESS;
531     (void)optionProcess( &ntpqOptions, argc, argv );
532     optionPutShell( &ntpqOptions );
533     return res;
534 }
535 #endif  /* defined TEST_NTPQ_OPTS */
536 /* extracted from /usr/local/gnu/share/autogen/optcode.tpl near line 627 */
537 
538 #if ENABLE_NLS
539 #include <stdio.h>
540 #include <stdlib.h>
541 #include <string.h>
542 #include <unistd.h>
543 #include <autoopts/usage-txt.h>
544 
545 static char* AO_gettext( char const* pz );
546 static void  coerce_it(void** s);
547 
548 static char*
549 AO_gettext( char const* pz )
550 {
551     char* pzRes;
552     if (pz == NULL)
553         return NULL;
554     pzRes = _(pz);
555     if (pzRes == pz)
556         return pzRes;
557     pzRes = strdup( pzRes );
558     if (pzRes == NULL) {
559         fputs( _("No memory for duping translated strings\n"), stderr );
560         exit( EXIT_FAILURE );
561     }
562     return pzRes;
563 }
564 
565 static void coerce_it(void** s) { *s = AO_gettext(*s); }
566 #define COERSION(_f) \
567   coerce_it((void*)&(ntpqOptions._f))
568 
569 /*
570  *  This invokes the translation code (e.g. gettext(3)).
571  */
572 static void
573 translate_option_strings( void )
574 {
575     /*
576      *  Guard against re-translation.  It won't work.  The strings will have
577      *  been changed by the first pass through this code.  One shot only.
578      */
579     if (option_usage_text.field_ct != 0) {
580 
581         /*
582          *  Do the translations.  The first pointer follows the field count
583          *  field.  The field count field is the size of a pointer.
584          */
585         tOptDesc* pOD = ntpqOptions.pOptDesc;
586         char**    ppz = (char**)(void*)&(option_usage_text);
587         int       ix  = option_usage_text.field_ct;
588 
589         do {
590             ppz++;
591             *ppz = AO_gettext(*ppz);
592         } while (--ix > 0);
593 
594         COERSION(pzCopyright);
595         COERSION(pzCopyNotice);
596         COERSION(pzFullVersion);
597         COERSION(pzUsageTitle);
598         COERSION(pzExplain);
599         COERSION(pzDetail);
600         option_usage_text.field_ct = 0;
601 
602         for (ix = ntpqOptions.optCt; ix > 0; ix--, pOD++)
603             coerce_it((void*)&(pOD->pzText));
604     }
605 
606     if ((ntpqOptions.fOptSet & OPTPROC_NXLAT_OPT_CFG) == 0) {
607         tOptDesc* pOD = ntpqOptions.pOptDesc;
608         int       ix;
609 
610         for (ix = ntpqOptions.optCt; ix > 0; ix--, pOD++) {
611             coerce_it((void*)&(pOD->pz_Name));
612             coerce_it((void*)&(pOD->pz_DisableName));
613             coerce_it((void*)&(pOD->pz_DisablePfx));
614         }
615         /* prevent re-translation */
616         ntpqOptions.fOptSet |= OPTPROC_NXLAT_OPT_CFG | OPTPROC_NXLAT_OPT;
617     }
618 }
619 
620 #endif /* ENABLE_NLS */
621 
622 #ifdef  __cplusplus
623 }
624 #endif
625 /* ntpq-opts.c ends here */
626