1/*
2 *  EDIT THIS FILE WITH CAUTION  (sntp-opts.c)
3 *
4 *  It has been AutoGen-ed  December 10, 2009 at 05:07:30 AM by AutoGen 5.10
5 *  From the definitions    sntp-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 *  sntp 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 * sntp 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 "sntp-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       "sntp 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#ifndef NULL
51#  define NULL 0
52#endif
53#ifndef EXIT_SUCCESS
54#  define  EXIT_SUCCESS 0
55#endif
56#ifndef EXIT_FAILURE
57#  define  EXIT_FAILURE 1
58#endif
59
60/*
61 *  Ipv4 option description with
62 *  "Must also have options" and "Incompatible options":
63 */
64tSCC    zIpv4Text[] =
65        "Force IPv4 DNS name resolution";
66tSCC    zIpv4_NAME[]               = "IPV4";
67tSCC    zIpv4_Name[]               = "ipv4";
68static const int
69    aIpv4CantList[] = {
70    INDEX_OPT_IPV6, NO_EQUIVALENT };
71#define IPV4_FLAGS       (OPTST_DISABLED)
72
73/*
74 *  Ipv6 option description with
75 *  "Must also have options" and "Incompatible options":
76 */
77tSCC    zIpv6Text[] =
78        "Force IPv6 DNS name resolution";
79tSCC    zIpv6_NAME[]               = "IPV6";
80tSCC    zIpv6_Name[]               = "ipv6";
81static const int
82    aIpv6CantList[] = {
83    INDEX_OPT_IPV4, NO_EQUIVALENT };
84#define IPV6_FLAGS       (OPTST_DISABLED)
85
86/*
87 *  Normalverbose option description:
88 */
89tSCC    zNormalverboseText[] =
90        "Normal verbose";
91tSCC    zNormalverbose_NAME[]      = "NORMALVERBOSE";
92tSCC    zNormalverbose_Name[]      = "normalverbose";
93#define NORMALVERBOSE_FLAGS       (OPTST_DISABLED)
94
95/*
96 *  Kod option description:
97 */
98tSCC    zKodText[] =
99        "KoD history filename";
100tSCC    zKod_NAME[]                = "KOD";
101tSCC    zKod_Name[]                = "kod";
102#define KOD_FLAGS       (OPTST_DISABLED \
103        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
104
105/*
106 *  Syslog option description with
107 *  "Must also have options" and "Incompatible options":
108 */
109tSCC    zSyslogText[] =
110        "Logging with syslog";
111tSCC    zSyslog_NAME[]             = "SYSLOG";
112tSCC    zSyslog_Name[]             = "syslog";
113static const int
114    aSyslogCantList[] = {
115    INDEX_OPT_FILELOG, NO_EQUIVALENT };
116#define SYSLOG_FLAGS       (OPTST_DISABLED)
117
118/*
119 *  Filelog option description with
120 *  "Must also have options" and "Incompatible options":
121 */
122tSCC    zFilelogText[] =
123        "Log to specified logfile";
124tSCC    zFilelog_NAME[]            = "FILELOG";
125tSCC    zFilelog_Name[]            = "filelog";
126static const int
127    aFilelogCantList[] = {
128    INDEX_OPT_SYSLOG, NO_EQUIVALENT };
129#define FILELOG_FLAGS       (OPTST_DISABLED \
130        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
131
132/*
133 *  Settod option description with
134 *  "Must also have options" and "Incompatible options":
135 */
136tSCC    zSettodText[] =
137        "Set (step) the time with settimeofday()";
138tSCC    zSettod_NAME[]             = "SETTOD";
139tSCC    zSettod_Name[]             = "settod";
140static const int
141    aSettodCantList[] = {
142    INDEX_OPT_ADJTIME, NO_EQUIVALENT };
143#define SETTOD_FLAGS       (OPTST_DISABLED)
144
145/*
146 *  Adjtime option description with
147 *  "Must also have options" and "Incompatible options":
148 */
149tSCC    zAdjtimeText[] =
150        "Set (slew) the time with adjtime()";
151tSCC    zAdjtime_NAME[]            = "ADJTIME";
152tSCC    zAdjtime_Name[]            = "adjtime";
153static const int
154    aAdjtimeCantList[] = {
155    INDEX_OPT_SETTOD, NO_EQUIVALENT };
156#define ADJTIME_FLAGS       (OPTST_DISABLED)
157
158/*
159 *  Broadcast option description:
160 */
161tSCC    zBroadcastText[] =
162        "Use broadcasts to the address specified for synchronisation";
163tSCC    zBroadcast_NAME[]          = "BROADCAST";
164tSCC    zBroadcast_Name[]          = "broadcast";
165#define BROADCAST_FLAGS       (OPTST_DISABLED \
166        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
167
168/*
169 *  Timeout option description:
170 */
171tSCC    zTimeoutText[] =
172        "Specify the number of seconds to wait for broadcasts";
173tSCC    zTimeout_NAME[]            = "TIMEOUT";
174tSCC    zTimeout_Name[]            = "timeout";
175#define zTimeoutDefaultArg           ((char const*)68)
176#define TIMEOUT_FLAGS       (OPTST_DISABLED \
177        | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
178
179/*
180 *  Authentication option description:
181 */
182tSCC    zAuthenticationText[] =
183        "Enable authentication with the key auth-keynumber";
184tSCC    zAuthentication_NAME[]     = "AUTHENTICATION";
185tSCC    zAuthentication_Name[]     = "authentication";
186#define AUTHENTICATION_FLAGS       (OPTST_DISABLED \
187        | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
188
189/*
190 *  Keyfile option description:
191 */
192tSCC    zKeyfileText[] =
193        "Specify a keyfile. SNTP will look in this file for the key specified with -a";
194tSCC    zKeyfile_NAME[]            = "KEYFILE";
195tSCC    zKeyfile_Name[]            = "keyfile";
196#define KEYFILE_FLAGS       (OPTST_DISABLED \
197        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
198
199/*
200 *  Help/More_Help/Version option descriptions:
201 */
202tSCC zHelpText[]          = "Display extended usage information and exit";
203tSCC zHelp_Name[]         = "help";
204#ifdef HAVE_WORKING_FORK
205#define OPTST_MORE_HELP_FLAGS   (OPTST_IMM | OPTST_NO_INIT)
206tSCC zMore_Help_Name[]    = "more-help";
207tSCC zMore_HelpText[]     = "Extended usage information passed thru pager";
208#else
209#define OPTST_MORE_HELP_FLAGS   (OPTST_OMITTED | OPTST_NO_INIT)
210#define zMore_Help_Name   NULL
211#define zMore_HelpText    NULL
212#endif
213#ifdef NO_OPTIONAL_OPT_ARGS
214#  define OPTST_VERSION_FLAGS   OPTST_IMM | OPTST_NO_INIT
215#else
216#  define OPTST_VERSION_FLAGS   OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
217                                OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT
218#endif
219
220tSCC zVersionText[]       = "Output version information and exit";
221tSCC zVersion_Name[]      = "version";
222tSCC zSave_OptsText[]     = "Save the option state to a config file";
223tSCC zSave_Opts_Name[]    = "save-opts";
224tSCC zLoad_OptsText[]     = "Load options from a config file";
225tSCC zLoad_Opts_NAME[]    = "LOAD_OPTS";
226tSCC zNotLoad_Opts_Name[] = "no-load-opts";
227tSCC zNotLoad_Opts_Pfx[]  = "no";
228#define zLoad_Opts_Name   (zNotLoad_Opts_Name + 3)
229/*
230 *  Declare option callback procedures
231 */
232#if defined(TEST_SNTP_OPTS)
233/*
234 *  Under test, omit argument processing, or call optionStackArg,
235 *  if multiple copies are allowed.
236 */
237extern tOptProc
238    optionNumericVal, optionPagedUsage, optionVersionStderr;
239static tOptProc
240    doUsageOpt;
241
242#else /* NOT defined TEST_SNTP_OPTS */
243/*
244 *  When not under test, there are different procs to use
245 */
246extern tOptProc
247    optionNumericVal, optionPagedUsage, optionPrintVersion;
248static tOptProc
249    doUsageOpt;
250#endif /* defined(TEST_SNTP_OPTS) */
251#ifdef TEST_SNTP_OPTS
252# define DOVERPROC optionVersionStderr
253#else
254# define DOVERPROC optionPrintVersion
255#endif /* TEST_SNTP_OPTS */
256
257/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
258 *
259 *  Define the Sntp Option Descriptions.
260 */
261static tOptDesc optDesc[ OPTION_CT ] = {
262  {  /* entry idx, value */ 0, VALUE_OPT_IPV4,
263     /* equiv idx, value */ 0, VALUE_OPT_IPV4,
264     /* equivalenced to  */ NO_EQUIVALENT,
265     /* min, max, act ct */ 0, 1, 0,
266     /* opt state flags  */ IPV4_FLAGS, 0,
267     /* last opt argumnt */ { NULL },
268     /* arg list/cookie  */ NULL,
269     /* must/cannot opts */ NULL, aIpv4CantList,
270     /* option proc      */ NULL,
271     /* desc, NAME, name */ zIpv4Text, zIpv4_NAME, zIpv4_Name,
272     /* disablement strs */ NULL, NULL },
273
274  {  /* entry idx, value */ 1, VALUE_OPT_IPV6,
275     /* equiv idx, value */ 1, VALUE_OPT_IPV6,
276     /* equivalenced to  */ NO_EQUIVALENT,
277     /* min, max, act ct */ 0, 1, 0,
278     /* opt state flags  */ IPV6_FLAGS, 0,
279     /* last opt argumnt */ { NULL },
280     /* arg list/cookie  */ NULL,
281     /* must/cannot opts */ NULL, aIpv6CantList,
282     /* option proc      */ NULL,
283     /* desc, NAME, name */ zIpv6Text, zIpv6_NAME, zIpv6_Name,
284     /* disablement strs */ NULL, NULL },
285
286  {  /* entry idx, value */ 2, VALUE_OPT_NORMALVERBOSE,
287     /* equiv idx, value */ 2, VALUE_OPT_NORMALVERBOSE,
288     /* equivalenced to  */ NO_EQUIVALENT,
289     /* min, max, act ct */ 0, 1, 0,
290     /* opt state flags  */ NORMALVERBOSE_FLAGS, 0,
291     /* last opt argumnt */ { NULL },
292     /* arg list/cookie  */ NULL,
293     /* must/cannot opts */ NULL, NULL,
294     /* option proc      */ NULL,
295     /* desc, NAME, name */ zNormalverboseText, zNormalverbose_NAME, zNormalverbose_Name,
296     /* disablement strs */ NULL, NULL },
297
298  {  /* entry idx, value */ 3, VALUE_OPT_KOD,
299     /* equiv idx, value */ 3, VALUE_OPT_KOD,
300     /* equivalenced to  */ NO_EQUIVALENT,
301     /* min, max, act ct */ 0, 1, 0,
302     /* opt state flags  */ KOD_FLAGS, 0,
303     /* last opt argumnt */ { NULL },
304     /* arg list/cookie  */ NULL,
305     /* must/cannot opts */ NULL, NULL,
306     /* option proc      */ NULL,
307     /* desc, NAME, name */ zKodText, zKod_NAME, zKod_Name,
308     /* disablement strs */ NULL, NULL },
309
310  {  /* entry idx, value */ 4, VALUE_OPT_SYSLOG,
311     /* equiv idx, value */ 4, VALUE_OPT_SYSLOG,
312     /* equivalenced to  */ NO_EQUIVALENT,
313     /* min, max, act ct */ 0, 1, 0,
314     /* opt state flags  */ SYSLOG_FLAGS, 0,
315     /* last opt argumnt */ { NULL },
316     /* arg list/cookie  */ NULL,
317     /* must/cannot opts */ NULL, aSyslogCantList,
318     /* option proc      */ NULL,
319     /* desc, NAME, name */ zSyslogText, zSyslog_NAME, zSyslog_Name,
320     /* disablement strs */ NULL, NULL },
321
322  {  /* entry idx, value */ 5, VALUE_OPT_FILELOG,
323     /* equiv idx, value */ 5, VALUE_OPT_FILELOG,
324     /* equivalenced to  */ NO_EQUIVALENT,
325     /* min, max, act ct */ 0, 1, 0,
326     /* opt state flags  */ FILELOG_FLAGS, 0,
327     /* last opt argumnt */ { NULL },
328     /* arg list/cookie  */ NULL,
329     /* must/cannot opts */ NULL, aFilelogCantList,
330     /* option proc      */ NULL,
331     /* desc, NAME, name */ zFilelogText, zFilelog_NAME, zFilelog_Name,
332     /* disablement strs */ NULL, NULL },
333
334  {  /* entry idx, value */ 6, VALUE_OPT_SETTOD,
335     /* equiv idx, value */ 6, VALUE_OPT_SETTOD,
336     /* equivalenced to  */ NO_EQUIVALENT,
337     /* min, max, act ct */ 0, 1, 0,
338     /* opt state flags  */ SETTOD_FLAGS, 0,
339     /* last opt argumnt */ { NULL },
340     /* arg list/cookie  */ NULL,
341     /* must/cannot opts */ NULL, aSettodCantList,
342     /* option proc      */ NULL,
343     /* desc, NAME, name */ zSettodText, zSettod_NAME, zSettod_Name,
344     /* disablement strs */ NULL, NULL },
345
346  {  /* entry idx, value */ 7, VALUE_OPT_ADJTIME,
347     /* equiv idx, value */ 7, VALUE_OPT_ADJTIME,
348     /* equivalenced to  */ NO_EQUIVALENT,
349     /* min, max, act ct */ 0, 1, 0,
350     /* opt state flags  */ ADJTIME_FLAGS, 0,
351     /* last opt argumnt */ { NULL },
352     /* arg list/cookie  */ NULL,
353     /* must/cannot opts */ NULL, aAdjtimeCantList,
354     /* option proc      */ NULL,
355     /* desc, NAME, name */ zAdjtimeText, zAdjtime_NAME, zAdjtime_Name,
356     /* disablement strs */ NULL, NULL },
357
358  {  /* entry idx, value */ 8, VALUE_OPT_BROADCAST,
359     /* equiv idx, value */ 8, VALUE_OPT_BROADCAST,
360     /* equivalenced to  */ NO_EQUIVALENT,
361     /* min, max, act ct */ 0, 1, 0,
362     /* opt state flags  */ BROADCAST_FLAGS, 0,
363     /* last opt argumnt */ { NULL },
364     /* arg list/cookie  */ NULL,
365     /* must/cannot opts */ NULL, NULL,
366     /* option proc      */ NULL,
367     /* desc, NAME, name */ zBroadcastText, zBroadcast_NAME, zBroadcast_Name,
368     /* disablement strs */ NULL, NULL },
369
370  {  /* entry idx, value */ 9, VALUE_OPT_TIMEOUT,
371     /* equiv idx, value */ 9, VALUE_OPT_TIMEOUT,
372     /* equivalenced to  */ NO_EQUIVALENT,
373     /* min, max, act ct */ 0, 1, 0,
374     /* opt state flags  */ TIMEOUT_FLAGS, 0,
375     /* last opt argumnt */ { zTimeoutDefaultArg },
376     /* arg list/cookie  */ NULL,
377     /* must/cannot opts */ NULL, NULL,
378     /* option proc      */ optionNumericVal,
379     /* desc, NAME, name */ zTimeoutText, zTimeout_NAME, zTimeout_Name,
380     /* disablement strs */ NULL, NULL },
381
382  {  /* entry idx, value */ 10, VALUE_OPT_AUTHENTICATION,
383     /* equiv idx, value */ 10, VALUE_OPT_AUTHENTICATION,
384     /* equivalenced to  */ NO_EQUIVALENT,
385     /* min, max, act ct */ 0, 1, 0,
386     /* opt state flags  */ AUTHENTICATION_FLAGS, 0,
387     /* last opt argumnt */ { NULL },
388     /* arg list/cookie  */ NULL,
389     /* must/cannot opts */ NULL, NULL,
390     /* option proc      */ optionNumericVal,
391     /* desc, NAME, name */ zAuthenticationText, zAuthentication_NAME, zAuthentication_Name,
392     /* disablement strs */ NULL, NULL },
393
394  {  /* entry idx, value */ 11, VALUE_OPT_KEYFILE,
395     /* equiv idx, value */ 11, VALUE_OPT_KEYFILE,
396     /* equivalenced to  */ NO_EQUIVALENT,
397     /* min, max, act ct */ 0, 1, 0,
398     /* opt state flags  */ KEYFILE_FLAGS, 0,
399     /* last opt argumnt */ { NULL },
400     /* arg list/cookie  */ NULL,
401     /* must/cannot opts */ NULL, NULL,
402     /* option proc      */ NULL,
403     /* desc, NAME, name */ zKeyfileText, zKeyfile_NAME, zKeyfile_Name,
404     /* disablement strs */ NULL, NULL },
405
406  {  /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
407     /* equiv idx value  */ NO_EQUIVALENT, 0,
408     /* equivalenced to  */ NO_EQUIVALENT,
409     /* min, max, act ct */ 0, 1, 0,
410     /* opt state flags  */ OPTST_VERSION_FLAGS, 0,
411     /* last opt argumnt */ { NULL },
412     /* arg list/cookie  */ NULL,
413     /* must/cannot opts */ NULL, NULL,
414     /* option proc      */ DOVERPROC,
415     /* desc, NAME, name */ zVersionText, NULL, zVersion_Name,
416     /* disablement strs */ NULL, NULL },
417
418
419
420  {  /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
421     /* equiv idx value  */ NO_EQUIVALENT, 0,
422     /* equivalenced to  */ NO_EQUIVALENT,
423     /* min, max, act ct */ 0, 1, 0,
424     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
425     /* last opt argumnt */ { NULL },
426     /* arg list/cookie  */ NULL,
427     /* must/cannot opts */ NULL, NULL,
428     /* option proc      */ doUsageOpt,
429     /* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
430     /* disablement strs */ NULL, NULL },
431
432  {  /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
433     /* equiv idx value  */ NO_EQUIVALENT, 0,
434     /* equivalenced to  */ NO_EQUIVALENT,
435     /* min, max, act ct */ 0, 1, 0,
436     /* opt state flags  */ OPTST_MORE_HELP_FLAGS, 0,
437     /* last opt argumnt */ { NULL },
438     /* arg list/cookie  */ NULL,
439     /* must/cannot opts */ NULL,  NULL,
440     /* option proc      */ optionPagedUsage,
441     /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name,
442     /* disablement strs */ NULL, NULL },
443
444  {  /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS,
445     /* equiv idx value  */ NO_EQUIVALENT, 0,
446     /* equivalenced to  */ NO_EQUIVALENT,
447     /* min, max, act ct */ 0, 1, 0,
448     /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
449                          | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0,
450     /* last opt argumnt */ { NULL },
451     /* arg list/cookie  */ NULL,
452     /* must/cannot opts */ NULL,  NULL,
453     /* option proc      */ NULL,
454     /* desc, NAME, name */ zSave_OptsText, NULL, zSave_Opts_Name,
455     /* disablement strs */ NULL, NULL },
456
457  {  /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS,
458     /* equiv idx value  */ NO_EQUIVALENT, 0,
459     /* equivalenced to  */ NO_EQUIVALENT,
460     /* min, max, act ct */ 0, NOLIMIT, 0,
461     /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
462			  | OPTST_DISABLE_IMM, 0,
463     /* last opt argumnt */ { NULL },
464     /* arg list/cookie  */ NULL,
465     /* must/cannot opts */ NULL, NULL,
466     /* option proc      */ optionLoadOpt,
467     /* desc, NAME, name */ zLoad_OptsText, zLoad_Opts_NAME, zLoad_Opts_Name,
468     /* disablement strs */ zNotLoad_Opts_Name, zNotLoad_Opts_Pfx }
469};
470
471/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
472 *
473 *  Define the Sntp Option Environment
474 */
475tSCC   zPROGNAME[]   = "SNTP";
476tSCC   zUsageTitle[] =
477"sntp - standard SNTP program - Ver. 4.2.6\n\
478USAGE:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... hostname-or-IP ...\n";
479tSCC   zRcName[]     = ".ntprc";
480tSCC*  apzHomeList[] = {
481       "$HOME",
482       ".",
483       NULL };
484
485tSCC   zBugsAddr[]    = "http://bugs.ntp.org, bugs@ntp.org";
486#define zExplain NULL
487tSCC    zDetail[]     = "\n\
488.I sntp\n\
489implements the Simple Network Time Protocol, and is used\n\
490to query an NTP or SNTP server and either\n\
491display the time\n\
492or\n\
493set the local system's time (given suitable privilege).\n\n\
494It can be\n\
495run interactively from the command line or as a\n\
496.I cron\n\
497job.\n\n\
498NTP and SNTP are defined by draft-ietf-ntp-ntpv4-proto-13, which\n\
499obsoletes RFC 4330 and RFC 1305.\n";
500tSCC    zFullVersion[] = SNTP_FULL_VERSION;
501/* extracted from /usr/local/gnu/share/autogen/optcode.tpl near line 495 */
502
503#if defined(ENABLE_NLS)
504# define OPTPROC_BASE OPTPROC_TRANSLATE
505  static tOptionXlateProc translate_option_strings;
506#else
507# define OPTPROC_BASE OPTPROC_NONE
508# define translate_option_strings NULL
509#endif /* ENABLE_NLS */
510
511
512#define sntp_full_usage NULL
513#define sntp_short_usage NULL
514tOptions sntpOptions = {
515    OPTIONS_STRUCT_VERSION,
516    0, NULL,                    /* original argc + argv    */
517    ( OPTPROC_BASE
518    + OPTPROC_ERRSTOP
519    + OPTPROC_SHORTOPT
520    + OPTPROC_LONGOPT
521    + OPTPROC_NO_REQ_OPT
522    + OPTPROC_ENVIRON
523    + OPTPROC_ARGS_REQ ),
524    0, NULL,                    /* current option index, current option */
525    NULL,         NULL,         zPROGNAME,
526    zRcName,      zCopyright,   zCopyrightNotice,
527    zFullVersion, apzHomeList,  zUsageTitle,
528    zExplain,     zDetail,      optDesc,
529    zBugsAddr,                  /* address to send bugs to */
530    NULL, NULL,                 /* extensions/saved state  */
531    optionUsage,       /* usage procedure */
532    translate_option_strings,   /* translation procedure */
533    /*
534     *  Indexes to special options
535     */
536    { INDEX_OPT_MORE_HELP, /* more-help option index */
537      INDEX_OPT_SAVE_OPTS, /* save option index */
538      NO_EQUIVALENT, /* '-#' option index */
539      NO_EQUIVALENT /* index of default opt */
540    },
541    17 /* full option count */, 12 /* user option count */,
542    sntp_full_usage, sntp_short_usage,
543    NULL, NULL
544};
545
546/*
547 *  Create the static procedure(s) declared above.
548 */
549static void
550doUsageOpt(
551    tOptions*   pOptions,
552    tOptDesc*   pOptDesc )
553{
554    (void)pOptions;
555    USAGE( EXIT_SUCCESS );
556}
557/* extracted from /usr/local/gnu/share/autogen/optmain.tpl near line 109 */
558
559#if defined(TEST_SNTP_OPTS) /* TEST MAIN PROCEDURE: */
560
561extern void optionPutShell( tOptions* );
562
563int
564main(int argc, char** argv)
565{
566    int res = EXIT_SUCCESS;
567    (void)optionProcess( &sntpOptions, argc, argv );
568    optionPutShell( &sntpOptions );
569    return res;
570}
571#endif  /* defined TEST_SNTP_OPTS */
572/* extracted from /usr/local/gnu/share/autogen/optcode.tpl near line 627 */
573
574#if ENABLE_NLS
575#include <stdio.h>
576#include <stdlib.h>
577#include <string.h>
578#include <unistd.h>
579#include <autoopts/usage-txt.h>
580
581static char* AO_gettext( char const* pz );
582static void  coerce_it(void** s);
583
584static char*
585AO_gettext( char const* pz )
586{
587    char* pzRes;
588    if (pz == NULL)
589        return NULL;
590    pzRes = _(pz);
591    if (pzRes == pz)
592        return pzRes;
593    pzRes = strdup( pzRes );
594    if (pzRes == NULL) {
595        fputs( _("No memory for duping translated strings\n"), stderr );
596        exit( EXIT_FAILURE );
597    }
598    return pzRes;
599}
600
601static void coerce_it(void** s) { *s = AO_gettext(*s); }
602#define COERSION(_f) \
603  coerce_it((void*)&(sntpOptions._f))
604
605/*
606 *  This invokes the translation code (e.g. gettext(3)).
607 */
608static void
609translate_option_strings( void )
610{
611    /*
612     *  Guard against re-translation.  It won't work.  The strings will have
613     *  been changed by the first pass through this code.  One shot only.
614     */
615    if (option_usage_text.field_ct != 0) {
616
617        /*
618         *  Do the translations.  The first pointer follows the field count
619         *  field.  The field count field is the size of a pointer.
620         */
621        tOptDesc* pOD = sntpOptions.pOptDesc;
622        char**    ppz = (char**)(void*)&(option_usage_text);
623        int       ix  = option_usage_text.field_ct;
624
625        do {
626            ppz++;
627            *ppz = AO_gettext(*ppz);
628        } while (--ix > 0);
629
630        COERSION(pzCopyright);
631        COERSION(pzCopyNotice);
632        COERSION(pzFullVersion);
633        COERSION(pzUsageTitle);
634        COERSION(pzExplain);
635        COERSION(pzDetail);
636        option_usage_text.field_ct = 0;
637
638        for (ix = sntpOptions.optCt; ix > 0; ix--, pOD++)
639            coerce_it((void*)&(pOD->pzText));
640    }
641
642    if ((sntpOptions.fOptSet & OPTPROC_NXLAT_OPT_CFG) == 0) {
643        tOptDesc* pOD = sntpOptions.pOptDesc;
644        int       ix;
645
646        for (ix = sntpOptions.optCt; ix > 0; ix--, pOD++) {
647            coerce_it((void*)&(pOD->pz_Name));
648            coerce_it((void*)&(pOD->pz_DisableName));
649            coerce_it((void*)&(pOD->pz_DisablePfx));
650        }
651        /* prevent re-translation */
652        sntpOptions.fOptSet |= OPTPROC_NXLAT_OPT_CFG | OPTPROC_NXLAT_OPT;
653    }
654}
655
656#endif /* ENABLE_NLS */
657
658#ifdef  __cplusplus
659}
660#endif
661/* sntp-opts.c ends here */
662