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