]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/ntp/ntpq/ntpq-opts.c
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / ntp / ntpq / ntpq-opts.c
1 /*  
2  *  EDIT THIS FILE WITH CAUTION  (ntpq-opts.c)
3  *  
4  *  It has been AutoGen-ed  Tuesday December  8, 2009 at 08:14:26 AM EST
5  *  From the definitions    ntpq-opts.def
6  *  and the template file   options
7  *
8  * Generated from AutoOpts 29:0:4 templates.
9  */
10
11 /*
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.
19  *
20  * This source file is copyrighted and licensed under the following terms:
21  *
22  * ntpq copyright 1970-2009 David L. Mills and/or others - all rights reserved
23  *
24  * see html/copyright.html
25  */
26
27
28 #include <limits.h>
29
30 #define OPTION_CODE_COMPILE 1
31 #include "ntpq-opts.h"
32
33 #ifdef  __cplusplus
34 extern "C" {
35 #endif
36 tSCC zCopyright[] =
37        "ntpq copyright (c) 1970-2009 David L. Mills and/or others, all rights reserved";
38 tSCC zCopyrightNotice[] =
39        
40 /* extracted from ../include/copyright.def near line 8 */
41 "see html/copyright.html";
42 extern tUsageProc optionUsage;
43
44 /*
45  *  global included definitions
46  */
47 #ifdef __windows
48   extern int atoi(const char*);
49 #else
50 # include <stdlib.h>
51 #endif
52
53 #ifndef NULL
54 #  define NULL 0
55 #endif
56 #ifndef EXIT_SUCCESS
57 #  define  EXIT_SUCCESS 0
58 #endif
59 #ifndef EXIT_FAILURE
60 #  define  EXIT_FAILURE 1
61 #endif
62 /*
63  *  Ipv4 option description:
64  */
65 tSCC    zIpv4Text[] =
66         "Force IPv4 DNS name resolution";
67 tSCC    zIpv4_NAME[]               = "IPV4";
68 tSCC    zIpv4_Name[]               = "ipv4";
69 #define IPV4_FLAGS       (OPTST_DISABLED)
70
71 /*
72  *  Ipv6 option description:
73  */
74 tSCC    zIpv6Text[] =
75         "Force IPv6 DNS name resolution";
76 tSCC    zIpv6_NAME[]               = "IPV6";
77 tSCC    zIpv6_Name[]               = "ipv6";
78 #define IPV6_FLAGS       (OPTST_DISABLED)
79
80 /*
81  *  Command option description:
82  */
83 tSCC    zCommandText[] =
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))
89
90 /*
91  *  Debug_Level option description:
92  */
93 #ifdef DEBUG
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)
99
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
106 #endif  /* DEBUG */
107
108 /*
109  *  Set_Debug_Level option description:
110  */
111 #ifdef DEBUG
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))
118
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
125 #endif  /* DEBUG */
126
127 /*
128  *  Peers option description with
129  *  "Must also have options" and "Incompatible options":
130  */
131 tSCC    zPeersText[] =
132         "Print a list of the peers";
133 tSCC    zPeers_NAME[]              = "PEERS";
134 tSCC    zPeers_Name[]              = "peers";
135 static const int
136     aPeersCantList[] = {
137     INDEX_OPT_INTERACTIVE, NO_EQUIVALENT };
138 #define PEERS_FLAGS       (OPTST_DISABLED)
139
140 /*
141  *  Interactive option description with
142  *  "Must also have options" and "Incompatible options":
143  */
144 tSCC    zInteractiveText[] =
145         "Force ntpq to operate in interactive mode";
146 tSCC    zInteractive_NAME[]        = "INTERACTIVE";
147 tSCC    zInteractive_Name[]        = "interactive";
148 static const int
149     aInteractiveCantList[] = {
150     INDEX_OPT_COMMAND,
151     INDEX_OPT_PEERS, NO_EQUIVALENT };
152 #define INTERACTIVE_FLAGS       (OPTST_DISABLED)
153
154 /*
155  *  Numeric option description:
156  */
157 tSCC    zNumericText[] =
158         "numeric host addresses";
159 tSCC    zNumeric_NAME[]            = "NUMERIC";
160 tSCC    zNumeric_Name[]            = "numeric";
161 #define NUMERIC_FLAGS       (OPTST_DISABLED)
162
163 /*
164  *  Help/More_Help/Version option descriptions:
165  */
166 tSCC zHelpText[]       = "Display usage information and exit";
167 tSCC zHelp_Name[]      = "help";
168
169 tSCC zMore_HelpText[]  = "Extended usage information passed thru pager";
170 tSCC zMore_Help_Name[] = "more-help";
171
172 tSCC zVersionText[]    = "Output version information and exit";
173 tSCC zVersion_Name[]   = "version";
174
175 /*
176  *  Save/Load_Opts option description:
177  */
178 tSCC zSave_OptsText[]     = "Save the option state to a config file";
179 tSCC zSave_Opts_Name[]    = "save-opts";
180
181 tSCC zLoad_OptsText[]     = "Load options from a config file";
182 tSCC zLoad_Opts_NAME[]    = "LOAD_OPTS";
183
184 tSCC zNotLoad_Opts_Name[] = "no-load-opts";
185 tSCC zNotLoad_Opts_Pfx[]  = "no";
186 #define zLoad_Opts_Name   (zNotLoad_Opts_Name + 3)
187 /*
188  *  Declare option callback procedures
189  */
190 #ifdef DEBUG
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)
196 /*
197  *  Under test, omit argument processing, or call optionStackArg,
198  *  if multiple copies are allowed.
199  */
200 extern tOptProc
201     optionPagedUsage, optionStackArg, optionVersionStderr;
202 static tOptProc
203     doUsageOpt;
204
205 /*
206  *  #define map the "normal" callout procs to the test ones...
207  */
208 #define SET_DEBUG_LEVEL_OPT_PROC optionStackArg
209
210
211 #else /* NOT defined TEST_NTPQ_OPTS */
212 /*
213  *  When not under test, there are different procs to use
214  */
215 extern tOptProc
216     optionPagedUsage, optionPrintVersion, optionStackArg;
217 static tOptProc
218     doUsageOpt;
219
220 /*
221  *  #define map the "normal" callout procs
222  */
223 #define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level
224
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
229 #else
230 # define DOVERPROC optionPrintVersion
231 #endif /* TEST_NTPQ_OPTS */
232
233 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
234  *
235  *  Define the Ntpq Option Descriptions.
236  */
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 },
249
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 },
261
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 },
273
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 },
285
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 },
297
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 },
309
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 },
321
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 },
333
334 #ifdef NO_OPTIONAL_OPT_ARGS
335 #  define VERSION_OPT_FLAGS     OPTST_IMM | OPTST_NO_INIT
336 #else
337 #  define VERSION_OPT_FLAGS     OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
338                                 OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT
339 #endif
340
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 },
352
353 #undef VERSION_OPT_FLAGS
354
355
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 },
367
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 },
379
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 },
392
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 }
405 };
406
407 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
408  *
409  *  Define the Ntpq Option Environment
410  */
411 tSCC   zPROGNAME[]   = "NTPQ";
412 tSCC   zUsageTitle[] =
413 "ntpq - standard NTP query program - Ver. 4.2.4p8\n\
414 USAGE:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [ host ...]\n";
415 tSCC   zRcName[]     = ".ntprc";
416 tSCC*  apzHomeList[] = {
417        "$HOME",
418        ".",
419        NULL };
420
421 tSCC   zBugsAddr[]    = "http://bugs.ntp.org, bugs@ntp.org";
422 #define zExplain NULL
423 tSCC    zDetail[]     = "\n\
424 The\n\
425 [= prog-name =]\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/autogen-5.9.1/share/autogen/optcode.tpl near line 408 */
434
435 #if defined(ENABLE_NLS)
436 # define OPTPROC_BASE OPTPROC_TRANSLATE
437   static tOptionXlateProc translate_option_strings;
438 #else
439 # define OPTPROC_BASE OPTPROC_NONE
440 # define translate_option_strings NULL
441 #endif /* ENABLE_NLS */
442
443 tOptions ntpqOptions = {
444     OPTIONS_STRUCT_VERSION,
445     0, NULL,                    /* original argc + argv    */
446     ( OPTPROC_BASE
447     + OPTPROC_ERRSTOP
448     + OPTPROC_SHORTOPT
449     + OPTPROC_LONGOPT
450     + OPTPROC_NO_REQ_OPT
451     + OPTPROC_ENVIRON
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 */
462     /*
463      *  Indexes to special options
464      */
465     { INDEX_OPT_MORE_HELP,
466       INDEX_OPT_SAVE_OPTS,
467       NO_EQUIVALENT /* index of '-#' option */,
468       NO_EQUIVALENT /* index of default opt */
469     },
470     13 /* full option count */, 8 /* user option count */
471 };
472
473 /*
474  *  Create the static procedure(s) declared above.
475  */
476 static void
477 doUsageOpt(
478     tOptions*   pOptions,
479     tOptDesc*   pOptDesc )
480 {
481     USAGE( EXIT_SUCCESS );
482 }
483
484 #if ! defined(TEST_NTPQ_OPTS)
485
486 /* * * * * * *
487  *
488  *   For the set-debug-level option, when DEBUG is #define-d.
489  */
490 #ifdef DEBUG
491 static void
492 doOptSet_Debug_Level(
493     tOptions*   pOptions,
494     tOptDesc*   pOptDesc )
495 {
496     /* extracted from ../include/debug-opt.def, line 29 */
497 DESC(DEBUG_LEVEL).optOccCt = atoi( pOptDesc->pzLastArg );
498 }
499 #endif /* defined DEBUG */
500
501 #endif /* defined(TEST_NTPQ_OPTS) */
502
503 /* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optmain.tpl near line 92 */
504
505 #if defined(TEST_NTPQ_OPTS) /* TEST MAIN PROCEDURE: */
506
507 int
508 main( int argc, char** argv )
509 {
510     int res = EXIT_SUCCESS;
511     (void)optionProcess( &ntpqOptions, argc, argv );
512     {
513         void optionPutShell( tOptions* );
514         optionPutShell( &ntpqOptions );
515     }
516     return res;
517 }
518 #endif  /* defined TEST_NTPQ_OPTS */
519 /* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optcode.tpl near line 514 */
520
521 #if ENABLE_NLS
522 #include <stdio.h>
523 #include <stdlib.h>
524 #include <string.h>
525 #include <unistd.h>
526 #include <autoopts/usage-txt.h>
527
528 static char* AO_gettext( char const* pz );
529 static void  coerce_it(void** s);
530
531 static char*
532 AO_gettext( char const* pz )
533 {
534     char* pzRes;
535     if (pz == NULL)
536         return NULL;
537     pzRes = _(pz);
538     if (pzRes == pz)
539         return pzRes;
540     pzRes = strdup( pzRes );
541     if (pzRes == NULL) {
542         fputs( _("No memory for duping translated strings\n"), stderr );
543         exit( EXIT_FAILURE );
544     }
545     return pzRes;
546 }
547
548 static void coerce_it(void** s) { *s = AO_gettext(*s); }
549 #define COERSION(_f) \
550   coerce_it((void*)&(ntpqOptions._f))
551
552 /*
553  *  This invokes the translation code (e.g. gettext(3)).
554  */
555 static void
556 translate_option_strings( void )
557 {
558     /*
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.
561      */
562     if (option_usage_text.field_ct == 0)
563         return;
564     /*
565      *  Do the translations.  The first pointer follows the field count field.
566      *  The field count field is the size of a pointer.
567      */
568     {
569         char** ppz = (char**)(void*)&(option_usage_text);
570         int    ix  = option_usage_text.field_ct;
571
572         do {
573             ppz++;
574             *ppz = AO_gettext(*ppz);
575         } while (--ix > 0);
576     }
577     option_usage_text.field_ct = 0;
578
579     {
580         tOptDesc* pOD = ntpqOptions.pOptDesc;
581         int       ix  = ntpqOptions.optCt;
582
583         for (;;) {
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);
589             if (--ix <= 0)
590                 break;
591             pOD++;
592         }
593     }
594     COERSION(pzCopyright);
595     COERSION(pzCopyNotice);
596     COERSION(pzFullVersion);
597     COERSION(pzUsageTitle);
598     COERSION(pzExplain);
599     COERSION(pzDetail);
600 }
601
602 #endif /* ENABLE_NLS */
603
604 #ifdef  __cplusplus
605 }
606 #endif
607 /* ntpq-opts.c ends here */