sntp-opts.c revision 293896
1/*
2 *  EDIT THIS FILE WITH CAUTION  (sntp-opts.c)
3 *
4 *  It has been AutoGen-ed  January  7, 2016 at 11:22:49 PM by AutoGen 5.18.5
5 *  From the definitions    sntp-opts.def
6 *  and the template file   options
7 *
8 * Generated from AutoOpts 41:0:16 templates.
9 *
10 *  AutoOpts is a copyrighted work.  This source file is not encumbered
11 *  by AutoOpts licensing, but is provided under the licensing terms chosen
12 *  by the sntp author or copyright holder.  AutoOpts is
13 *  licensed under the terms of the LGPL.  The redistributable library
14 *  (``libopts'') is licensed under the terms of either the LGPL or, at the
15 *  users discretion, the BSD license.  See the AutoOpts and/or libopts sources
16 *  for details.
17 *
18 * The sntp program is copyrighted and licensed
19 * under the following terms:
20 *
21 *  Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.
22 *  This is free software. It is licensed for use, modification and
23 *  redistribution under the terms of the NTP License, copies of which
24 *  can be seen at:
25 *    <http://ntp.org/license>
26 *    <http://opensource.org/licenses/ntp-license.php>
27 *
28 *  Permission to use, copy, modify, and distribute this software and its
29 *  documentation for any purpose with or without fee is hereby granted,
30 *  provided that the above copyright notice appears in all copies and that
31 *  both the copyright notice and this permission notice appear in
32 *  supporting documentation, and that the name The University of Delaware not be used in
33 *  advertising or publicity pertaining to distribution of the software
34 *  without specific, written prior permission. The University of Delaware and Network Time Foundation makes no
35 *  representations about the suitability this software for any purpose. It
36 *  is provided "as is" without express or implied warranty.
37 */
38
39#ifndef __doxygen__
40#define OPTION_CODE_COMPILE 1
41#include "sntp-opts.h"
42#include <sys/types.h>
43
44#include <limits.h>
45#include <stdio.h>
46#include <stdlib.h>
47#include <errno.h>
48
49#ifdef  __cplusplus
50extern "C" {
51#endif
52extern FILE * option_usage_fp;
53#define zCopyright      (sntp_opt_strs+0)
54#define zLicenseDescrip (sntp_opt_strs+340)
55
56/*
57 *  global included definitions
58 */
59#ifdef __windows
60  extern int atoi(const char*);
61#else
62# include <stdlib.h>
63#endif
64
65#ifndef NULL
66#  define NULL 0
67#endif
68
69/**
70 *  static const strings for sntp options
71 */
72static char const sntp_opt_strs[2549] =
73/*     0 */ "sntp 4.2.8p5\n"
74            "Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n"
75            "This is free software. It is licensed for use, modification and\n"
76            "redistribution under the terms of the NTP License, copies of which\n"
77            "can be seen at:\n"
78            "  <http://ntp.org/license>\n"
79            "  <http://opensource.org/licenses/ntp-license.php>\n\0"
80/*   340 */ "Permission to use, copy, modify, and distribute this software and its\n"
81            "documentation for any purpose with or without fee is hereby granted,\n"
82            "provided that the above copyright notice appears in all copies and that\n"
83            "both the copyright notice and this permission notice appear in supporting\n"
84            "documentation, and that the name The University of Delaware not be used in\n"
85            "advertising or publicity pertaining to distribution of the software without\n"
86            "specific, written prior permission.  The University of Delaware and Network\n"
87            "Time Foundation makes no representations about the suitability this\n"
88            "software for any purpose.  It is provided \"as is\" without express or\n"
89            "implied warranty.\n\0"
90/*  1008 */ "Force IPv4 DNS name resolution\0"
91/*  1039 */ "IPV4\0"
92/*  1044 */ "ipv4\0"
93/*  1049 */ "Force IPv6 DNS name resolution\0"
94/*  1080 */ "IPV6\0"
95/*  1085 */ "ipv6\0"
96/*  1090 */ "Enable authentication with the key auth-keynumber\0"
97/*  1140 */ "AUTHENTICATION\0"
98/*  1155 */ "authentication\0"
99/*  1170 */ "Listen to the address specified for broadcast time sync\0"
100/*  1226 */ "BROADCAST\0"
101/*  1236 */ "broadcast\0"
102/*  1246 */ "Concurrently query all IPs returned for host-name\0"
103/*  1296 */ "CONCURRENT\0"
104/*  1307 */ "concurrent\0"
105/*  1318 */ "Increase debug verbosity level\0"
106/*  1349 */ "DEBUG_LEVEL\0"
107/*  1361 */ "debug-level\0"
108/*  1373 */ "Set the debug verbosity level\0"
109/*  1403 */ "SET_DEBUG_LEVEL\0"
110/*  1419 */ "set-debug-level\0"
111/*  1435 */ "The gap (in milliseconds) between time requests\0"
112/*  1483 */ "GAP\0"
113/*  1487 */ "gap\0"
114/*  1491 */ "KoD history filename\0"
115/*  1512 */ "KOD\0"
116/*  1516 */ "kod\0"
117/*  1520 */ "/var/db/ntp-kod\0"
118/*  1536 */ "Look in this file for the key specified with -a\0"
119/*  1584 */ "KEYFILE\0"
120/*  1592 */ "keyfile\0"
121/*  1600 */ "Log to specified logfile\0"
122/*  1625 */ "LOGFILE\0"
123/*  1633 */ "logfile\0"
124/*  1641 */ "Adjustments less than steplimit msec will be slewed\0"
125/*  1693 */ "STEPLIMIT\0"
126/*  1703 */ "steplimit\0"
127/*  1713 */ "Send int as our NTP protocol version\0"
128/*  1750 */ "NTPVERSION\0"
129/*  1761 */ "ntpversion\0"
130/*  1772 */ "Use the NTP Reserved Port (port 123)\0"
131/*  1809 */ "USERESERVEDPORT\0"
132/*  1825 */ "usereservedport\0"
133/*  1841 */ "OK to 'step' the time with settimeofday(2)\0"
134/*  1884 */ "STEP\0"
135/*  1889 */ "step\0"
136/*  1894 */ "OK to 'slew' the time with adjtime(2)\0"
137/*  1932 */ "SLEW\0"
138/*  1937 */ "slew\0"
139/*  1942 */ "The number of seconds to wait for responses\0"
140/*  1986 */ "TIMEOUT\0"
141/*  1994 */ "timeout\0"
142/*  2002 */ "Wait for pending replies (if not setting the time)\0"
143/*  2053 */ "WAIT\0"
144/*  2058 */ "no-wait\0"
145/*  2066 */ "no\0"
146/*  2069 */ "display extended usage information and exit\0"
147/*  2113 */ "help\0"
148/*  2118 */ "extended usage information passed thru pager\0"
149/*  2163 */ "more-help\0"
150/*  2173 */ "output version information and exit\0"
151/*  2209 */ "version\0"
152/*  2217 */ "save the option state to a config file\0"
153/*  2256 */ "save-opts\0"
154/*  2266 */ "load options from a config file\0"
155/*  2298 */ "LOAD_OPTS\0"
156/*  2308 */ "no-load-opts\0"
157/*  2321 */ "SNTP\0"
158/*  2326 */ "sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p5\n"
159            "Usage:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n"
160            "\t\t[ hostname-or-IP ...]\n\0"
161/*  2485 */ "$HOME\0"
162/*  2491 */ ".\0"
163/*  2493 */ ".ntprc\0"
164/*  2500 */ "http://bugs.ntp.org, bugs@ntp.org\0"
165/*  2534 */ "\n\0"
166/*  2536 */ "sntp 4.2.8p5";
167
168/**
169 *  ipv4 option description with
170 *  "Must also have options" and "Incompatible options":
171 */
172/** Descriptive text for the ipv4 option */
173#define IPV4_DESC      (sntp_opt_strs+1008)
174/** Upper-cased name for the ipv4 option */
175#define IPV4_NAME      (sntp_opt_strs+1039)
176/** Name string for the ipv4 option */
177#define IPV4_name      (sntp_opt_strs+1044)
178/** Other options that appear in conjunction with the ipv4 option */
179static int const aIpv4CantList[] = {
180    INDEX_OPT_IPV6, NO_EQUIVALENT };
181/** Compiled in flag settings for the ipv4 option */
182#define IPV4_FLAGS     (OPTST_DISABLED)
183
184/**
185 *  ipv6 option description with
186 *  "Must also have options" and "Incompatible options":
187 */
188/** Descriptive text for the ipv6 option */
189#define IPV6_DESC      (sntp_opt_strs+1049)
190/** Upper-cased name for the ipv6 option */
191#define IPV6_NAME      (sntp_opt_strs+1080)
192/** Name string for the ipv6 option */
193#define IPV6_name      (sntp_opt_strs+1085)
194/** Other options that appear in conjunction with the ipv6 option */
195static int const aIpv6CantList[] = {
196    INDEX_OPT_IPV4, NO_EQUIVALENT };
197/** Compiled in flag settings for the ipv6 option */
198#define IPV6_FLAGS     (OPTST_DISABLED)
199
200/**
201 *  authentication option description:
202 */
203/** Descriptive text for the authentication option */
204#define AUTHENTICATION_DESC      (sntp_opt_strs+1090)
205/** Upper-cased name for the authentication option */
206#define AUTHENTICATION_NAME      (sntp_opt_strs+1140)
207/** Name string for the authentication option */
208#define AUTHENTICATION_name      (sntp_opt_strs+1155)
209/** Compiled in flag settings for the authentication option */
210#define AUTHENTICATION_FLAGS     (OPTST_DISABLED \
211        | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
212
213/**
214 *  broadcast option description:
215 */
216/** Descriptive text for the broadcast option */
217#define BROADCAST_DESC      (sntp_opt_strs+1170)
218/** Upper-cased name for the broadcast option */
219#define BROADCAST_NAME      (sntp_opt_strs+1226)
220/** Name string for the broadcast option */
221#define BROADCAST_name      (sntp_opt_strs+1236)
222/** Compiled in flag settings for the broadcast option */
223#define BROADCAST_FLAGS     (OPTST_DISABLED | OPTST_STACKED \
224        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
225
226/**
227 *  concurrent option description:
228 */
229/** Descriptive text for the concurrent option */
230#define CONCURRENT_DESC      (sntp_opt_strs+1246)
231/** Upper-cased name for the concurrent option */
232#define CONCURRENT_NAME      (sntp_opt_strs+1296)
233/** Name string for the concurrent option */
234#define CONCURRENT_name      (sntp_opt_strs+1307)
235/** Compiled in flag settings for the concurrent option */
236#define CONCURRENT_FLAGS     (OPTST_DISABLED | OPTST_STACKED \
237        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
238
239/**
240 *  debug-level option description:
241 */
242/** Descriptive text for the debug-level option */
243#define DEBUG_LEVEL_DESC      (sntp_opt_strs+1318)
244/** Upper-cased name for the debug-level option */
245#define DEBUG_LEVEL_NAME      (sntp_opt_strs+1349)
246/** Name string for the debug-level option */
247#define DEBUG_LEVEL_name      (sntp_opt_strs+1361)
248/** Compiled in flag settings for the debug-level option */
249#define DEBUG_LEVEL_FLAGS     (OPTST_DISABLED)
250
251/**
252 *  set-debug-level option description:
253 */
254/** Descriptive text for the set-debug-level option */
255#define SET_DEBUG_LEVEL_DESC      (sntp_opt_strs+1373)
256/** Upper-cased name for the set-debug-level option */
257#define SET_DEBUG_LEVEL_NAME      (sntp_opt_strs+1403)
258/** Name string for the set-debug-level option */
259#define SET_DEBUG_LEVEL_name      (sntp_opt_strs+1419)
260/** Compiled in flag settings for the set-debug-level option */
261#define SET_DEBUG_LEVEL_FLAGS     (OPTST_DISABLED \
262        | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
263
264/**
265 *  gap option description:
266 */
267/** Descriptive text for the gap option */
268#define GAP_DESC      (sntp_opt_strs+1435)
269/** Upper-cased name for the gap option */
270#define GAP_NAME      (sntp_opt_strs+1483)
271/** Name string for the gap option */
272#define GAP_name      (sntp_opt_strs+1487)
273/** The compiled in default value for the gap option argument */
274#define GAP_DFT_ARG   ((char const*)50)
275/** Compiled in flag settings for the gap option */
276#define GAP_FLAGS     (OPTST_DISABLED \
277        | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
278
279/**
280 *  kod option description:
281 */
282/** Descriptive text for the kod option */
283#define KOD_DESC      (sntp_opt_strs+1491)
284/** Upper-cased name for the kod option */
285#define KOD_NAME      (sntp_opt_strs+1512)
286/** Name string for the kod option */
287#define KOD_name      (sntp_opt_strs+1516)
288/** The compiled in default value for the kod option argument */
289#define KOD_DFT_ARG   (sntp_opt_strs+1520)
290/** Compiled in flag settings for the kod option */
291#define KOD_FLAGS     (OPTST_DISABLED \
292        | OPTST_SET_ARGTYPE(OPARG_TYPE_FILE))
293
294/**
295 *  keyfile option description:
296 */
297/** Descriptive text for the keyfile option */
298#define KEYFILE_DESC      (sntp_opt_strs+1536)
299/** Upper-cased name for the keyfile option */
300#define KEYFILE_NAME      (sntp_opt_strs+1584)
301/** Name string for the keyfile option */
302#define KEYFILE_name      (sntp_opt_strs+1592)
303/** Compiled in flag settings for the keyfile option */
304#define KEYFILE_FLAGS     (OPTST_DISABLED \
305        | OPTST_SET_ARGTYPE(OPARG_TYPE_FILE))
306
307/**
308 *  logfile option description:
309 */
310/** Descriptive text for the logfile option */
311#define LOGFILE_DESC      (sntp_opt_strs+1600)
312/** Upper-cased name for the logfile option */
313#define LOGFILE_NAME      (sntp_opt_strs+1625)
314/** Name string for the logfile option */
315#define LOGFILE_name      (sntp_opt_strs+1633)
316/** Compiled in flag settings for the logfile option */
317#define LOGFILE_FLAGS     (OPTST_DISABLED \
318        | OPTST_SET_ARGTYPE(OPARG_TYPE_FILE))
319
320/**
321 *  steplimit option description:
322 */
323/** Descriptive text for the steplimit option */
324#define STEPLIMIT_DESC      (sntp_opt_strs+1641)
325/** Upper-cased name for the steplimit option */
326#define STEPLIMIT_NAME      (sntp_opt_strs+1693)
327/** Name string for the steplimit option */
328#define STEPLIMIT_name      (sntp_opt_strs+1703)
329/** Compiled in flag settings for the steplimit option */
330#define STEPLIMIT_FLAGS     (OPTST_DISABLED \
331        | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
332
333/**
334 *  ntpversion option description:
335 */
336/** Descriptive text for the ntpversion option */
337#define NTPVERSION_DESC      (sntp_opt_strs+1713)
338/** Upper-cased name for the ntpversion option */
339#define NTPVERSION_NAME      (sntp_opt_strs+1750)
340/** Name string for the ntpversion option */
341#define NTPVERSION_name      (sntp_opt_strs+1761)
342/** The compiled in default value for the ntpversion option argument */
343#define NTPVERSION_DFT_ARG   ((char const*)4)
344/** Compiled in flag settings for the ntpversion option */
345#define NTPVERSION_FLAGS     (OPTST_DISABLED \
346        | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
347
348/**
349 *  usereservedport option description:
350 */
351/** Descriptive text for the usereservedport option */
352#define USERESERVEDPORT_DESC      (sntp_opt_strs+1772)
353/** Upper-cased name for the usereservedport option */
354#define USERESERVEDPORT_NAME      (sntp_opt_strs+1809)
355/** Name string for the usereservedport option */
356#define USERESERVEDPORT_name      (sntp_opt_strs+1825)
357/** Compiled in flag settings for the usereservedport option */
358#define USERESERVEDPORT_FLAGS     (OPTST_DISABLED)
359
360/**
361 *  step option description:
362 */
363/** Descriptive text for the step option */
364#define STEP_DESC      (sntp_opt_strs+1841)
365/** Upper-cased name for the step option */
366#define STEP_NAME      (sntp_opt_strs+1884)
367/** Name string for the step option */
368#define STEP_name      (sntp_opt_strs+1889)
369/** Compiled in flag settings for the step option */
370#define STEP_FLAGS     (OPTST_DISABLED)
371
372/**
373 *  slew option description:
374 */
375/** Descriptive text for the slew option */
376#define SLEW_DESC      (sntp_opt_strs+1894)
377/** Upper-cased name for the slew option */
378#define SLEW_NAME      (sntp_opt_strs+1932)
379/** Name string for the slew option */
380#define SLEW_name      (sntp_opt_strs+1937)
381/** Compiled in flag settings for the slew option */
382#define SLEW_FLAGS     (OPTST_DISABLED)
383
384/**
385 *  timeout option description:
386 */
387/** Descriptive text for the timeout option */
388#define TIMEOUT_DESC      (sntp_opt_strs+1942)
389/** Upper-cased name for the timeout option */
390#define TIMEOUT_NAME      (sntp_opt_strs+1986)
391/** Name string for the timeout option */
392#define TIMEOUT_name      (sntp_opt_strs+1994)
393/** The compiled in default value for the timeout option argument */
394#define TIMEOUT_DFT_ARG   ((char const*)5)
395/** Compiled in flag settings for the timeout option */
396#define TIMEOUT_FLAGS     (OPTST_DISABLED \
397        | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
398
399/**
400 *  wait option description:
401 */
402/** Descriptive text for the wait option */
403#define WAIT_DESC      (sntp_opt_strs+2002)
404/** Upper-cased name for the wait option */
405#define WAIT_NAME      (sntp_opt_strs+2053)
406/** disablement name for the wait option */
407#define NOT_WAIT_name  (sntp_opt_strs+2058)
408/** disablement prefix for the wait option */
409#define NOT_WAIT_PFX   (sntp_opt_strs+2066)
410/** Name string for the wait option */
411#define WAIT_name      (NOT_WAIT_name + 3)
412/** Compiled in flag settings for the wait option */
413#define WAIT_FLAGS     (OPTST_INITENABLED)
414
415/*
416 *  Help/More_Help/Version option descriptions:
417 */
418#define HELP_DESC       (sntp_opt_strs+2069)
419#define HELP_name       (sntp_opt_strs+2113)
420#ifdef HAVE_WORKING_FORK
421#define MORE_HELP_DESC  (sntp_opt_strs+2118)
422#define MORE_HELP_name  (sntp_opt_strs+2163)
423#define MORE_HELP_FLAGS (OPTST_IMM | OPTST_NO_INIT)
424#else
425#define MORE_HELP_DESC  HELP_DESC
426#define MORE_HELP_name  HELP_name
427#define MORE_HELP_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
428#endif
429#ifdef NO_OPTIONAL_OPT_ARGS
430#  define VER_FLAGS     (OPTST_IMM | OPTST_NO_INIT)
431#else
432#  define VER_FLAGS     (OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
433                         OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT)
434#endif
435#define VER_DESC        (sntp_opt_strs+2173)
436#define VER_name        (sntp_opt_strs+2209)
437#define SAVE_OPTS_DESC  (sntp_opt_strs+2217)
438#define SAVE_OPTS_name  (sntp_opt_strs+2256)
439#define LOAD_OPTS_DESC     (sntp_opt_strs+2266)
440#define LOAD_OPTS_NAME     (sntp_opt_strs+2298)
441#define NO_LOAD_OPTS_name  (sntp_opt_strs+2308)
442#define LOAD_OPTS_pfx      (sntp_opt_strs+2066)
443#define LOAD_OPTS_name     (NO_LOAD_OPTS_name + 3)
444/**
445 *  Declare option callback procedures
446 */
447extern tOptProc
448    ntpOptionPrintVersion, optionBooleanVal,      optionNestedVal,
449    optionNumericVal,      optionPagedUsage,      optionResetOpt,
450    optionStackArg,        optionTimeDate,        optionTimeVal,
451    optionUnstackArg,      optionVendorOption;
452static tOptProc
453    doOptDebug_Level, doOptKeyfile,     doOptKod,         doOptLogfile,
454    doOptNtpversion,  doOptSteplimit,   doUsageOpt;
455#define VER_PROC        ntpOptionPrintVersion
456
457/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
458/**
459 *  Define the sntp Option Descriptions.
460 * This is an array of OPTION_CT entries, one for each
461 * option that the sntp program responds to.
462 */
463static tOptDesc optDesc[OPTION_CT] = {
464  {  /* entry idx, value */ 0, VALUE_OPT_IPV4,
465     /* equiv idx, value */ 0, VALUE_OPT_IPV4,
466     /* equivalenced to  */ NO_EQUIVALENT,
467     /* min, max, act ct */ 0, 1, 0,
468     /* opt state flags  */ IPV4_FLAGS, 0,
469     /* last opt argumnt */ { NULL }, /* --ipv4 */
470     /* arg list/cookie  */ NULL,
471     /* must/cannot opts */ NULL, aIpv4CantList,
472     /* option proc      */ NULL,
473     /* desc, NAME, name */ IPV4_DESC, IPV4_NAME, IPV4_name,
474     /* disablement strs */ NULL, NULL },
475
476  {  /* entry idx, value */ 1, VALUE_OPT_IPV6,
477     /* equiv idx, value */ 1, VALUE_OPT_IPV6,
478     /* equivalenced to  */ NO_EQUIVALENT,
479     /* min, max, act ct */ 0, 1, 0,
480     /* opt state flags  */ IPV6_FLAGS, 0,
481     /* last opt argumnt */ { NULL }, /* --ipv6 */
482     /* arg list/cookie  */ NULL,
483     /* must/cannot opts */ NULL, aIpv6CantList,
484     /* option proc      */ NULL,
485     /* desc, NAME, name */ IPV6_DESC, IPV6_NAME, IPV6_name,
486     /* disablement strs */ NULL, NULL },
487
488  {  /* entry idx, value */ 2, VALUE_OPT_AUTHENTICATION,
489     /* equiv idx, value */ 2, VALUE_OPT_AUTHENTICATION,
490     /* equivalenced to  */ NO_EQUIVALENT,
491     /* min, max, act ct */ 0, 1, 0,
492     /* opt state flags  */ AUTHENTICATION_FLAGS, 0,
493     /* last opt argumnt */ { NULL }, /* --authentication */
494     /* arg list/cookie  */ NULL,
495     /* must/cannot opts */ NULL, NULL,
496     /* option proc      */ optionNumericVal,
497     /* desc, NAME, name */ AUTHENTICATION_DESC, AUTHENTICATION_NAME, AUTHENTICATION_name,
498     /* disablement strs */ NULL, NULL },
499
500  {  /* entry idx, value */ 3, VALUE_OPT_BROADCAST,
501     /* equiv idx, value */ 3, VALUE_OPT_BROADCAST,
502     /* equivalenced to  */ NO_EQUIVALENT,
503     /* min, max, act ct */ 0, NOLIMIT, 0,
504     /* opt state flags  */ BROADCAST_FLAGS, 0,
505     /* last opt argumnt */ { NULL }, /* --broadcast */
506     /* arg list/cookie  */ NULL,
507     /* must/cannot opts */ NULL, NULL,
508     /* option proc      */ optionStackArg,
509     /* desc, NAME, name */ BROADCAST_DESC, BROADCAST_NAME, BROADCAST_name,
510     /* disablement strs */ NULL, NULL },
511
512  {  /* entry idx, value */ 4, VALUE_OPT_CONCURRENT,
513     /* equiv idx, value */ 4, VALUE_OPT_CONCURRENT,
514     /* equivalenced to  */ NO_EQUIVALENT,
515     /* min, max, act ct */ 0, NOLIMIT, 0,
516     /* opt state flags  */ CONCURRENT_FLAGS, 0,
517     /* last opt argumnt */ { NULL }, /* --concurrent */
518     /* arg list/cookie  */ NULL,
519     /* must/cannot opts */ NULL, NULL,
520     /* option proc      */ optionStackArg,
521     /* desc, NAME, name */ CONCURRENT_DESC, CONCURRENT_NAME, CONCURRENT_name,
522     /* disablement strs */ NULL, NULL },
523
524  {  /* entry idx, value */ 5, VALUE_OPT_DEBUG_LEVEL,
525     /* equiv idx, value */ 5, VALUE_OPT_DEBUG_LEVEL,
526     /* equivalenced to  */ NO_EQUIVALENT,
527     /* min, max, act ct */ 0, NOLIMIT, 0,
528     /* opt state flags  */ DEBUG_LEVEL_FLAGS, 0,
529     /* last opt argumnt */ { NULL }, /* --debug-level */
530     /* arg list/cookie  */ NULL,
531     /* must/cannot opts */ NULL, NULL,
532     /* option proc      */ doOptDebug_Level,
533     /* desc, NAME, name */ DEBUG_LEVEL_DESC, DEBUG_LEVEL_NAME, DEBUG_LEVEL_name,
534     /* disablement strs */ NULL, NULL },
535
536  {  /* entry idx, value */ 6, VALUE_OPT_SET_DEBUG_LEVEL,
537     /* equiv idx, value */ 6, VALUE_OPT_SET_DEBUG_LEVEL,
538     /* equivalenced to  */ NO_EQUIVALENT,
539     /* min, max, act ct */ 0, NOLIMIT, 0,
540     /* opt state flags  */ SET_DEBUG_LEVEL_FLAGS, 0,
541     /* last opt argumnt */ { NULL }, /* --set-debug-level */
542     /* arg list/cookie  */ NULL,
543     /* must/cannot opts */ NULL, NULL,
544     /* option proc      */ optionNumericVal,
545     /* desc, NAME, name */ SET_DEBUG_LEVEL_DESC, SET_DEBUG_LEVEL_NAME, SET_DEBUG_LEVEL_name,
546     /* disablement strs */ NULL, NULL },
547
548  {  /* entry idx, value */ 7, VALUE_OPT_GAP,
549     /* equiv idx, value */ 7, VALUE_OPT_GAP,
550     /* equivalenced to  */ NO_EQUIVALENT,
551     /* min, max, act ct */ 0, 1, 0,
552     /* opt state flags  */ GAP_FLAGS, 0,
553     /* last opt argumnt */ { GAP_DFT_ARG },
554     /* arg list/cookie  */ NULL,
555     /* must/cannot opts */ NULL, NULL,
556     /* option proc      */ optionNumericVal,
557     /* desc, NAME, name */ GAP_DESC, GAP_NAME, GAP_name,
558     /* disablement strs */ NULL, NULL },
559
560  {  /* entry idx, value */ 8, VALUE_OPT_KOD,
561     /* equiv idx, value */ 8, VALUE_OPT_KOD,
562     /* equivalenced to  */ NO_EQUIVALENT,
563     /* min, max, act ct */ 0, 1, 0,
564     /* opt state flags  */ KOD_FLAGS, 0,
565     /* last opt argumnt */ { KOD_DFT_ARG },
566     /* arg list/cookie  */ NULL,
567     /* must/cannot opts */ NULL, NULL,
568     /* option proc      */ doOptKod,
569     /* desc, NAME, name */ KOD_DESC, KOD_NAME, KOD_name,
570     /* disablement strs */ NULL, NULL },
571
572  {  /* entry idx, value */ 9, VALUE_OPT_KEYFILE,
573     /* equiv idx, value */ 9, VALUE_OPT_KEYFILE,
574     /* equivalenced to  */ NO_EQUIVALENT,
575     /* min, max, act ct */ 0, 1, 0,
576     /* opt state flags  */ KEYFILE_FLAGS, 0,
577     /* last opt argumnt */ { NULL }, /* --keyfile */
578     /* arg list/cookie  */ NULL,
579     /* must/cannot opts */ NULL, NULL,
580     /* option proc      */ doOptKeyfile,
581     /* desc, NAME, name */ KEYFILE_DESC, KEYFILE_NAME, KEYFILE_name,
582     /* disablement strs */ NULL, NULL },
583
584  {  /* entry idx, value */ 10, VALUE_OPT_LOGFILE,
585     /* equiv idx, value */ 10, VALUE_OPT_LOGFILE,
586     /* equivalenced to  */ NO_EQUIVALENT,
587     /* min, max, act ct */ 0, 1, 0,
588     /* opt state flags  */ LOGFILE_FLAGS, 0,
589     /* last opt argumnt */ { NULL }, /* --logfile */
590     /* arg list/cookie  */ NULL,
591     /* must/cannot opts */ NULL, NULL,
592     /* option proc      */ doOptLogfile,
593     /* desc, NAME, name */ LOGFILE_DESC, LOGFILE_NAME, LOGFILE_name,
594     /* disablement strs */ NULL, NULL },
595
596  {  /* entry idx, value */ 11, VALUE_OPT_STEPLIMIT,
597     /* equiv idx, value */ 11, VALUE_OPT_STEPLIMIT,
598     /* equivalenced to  */ NO_EQUIVALENT,
599     /* min, max, act ct */ 0, 1, 0,
600     /* opt state flags  */ STEPLIMIT_FLAGS, 0,
601     /* last opt argumnt */ { NULL }, /* --steplimit */
602     /* arg list/cookie  */ NULL,
603     /* must/cannot opts */ NULL, NULL,
604     /* option proc      */ doOptSteplimit,
605     /* desc, NAME, name */ STEPLIMIT_DESC, STEPLIMIT_NAME, STEPLIMIT_name,
606     /* disablement strs */ NULL, NULL },
607
608  {  /* entry idx, value */ 12, VALUE_OPT_NTPVERSION,
609     /* equiv idx, value */ 12, VALUE_OPT_NTPVERSION,
610     /* equivalenced to  */ NO_EQUIVALENT,
611     /* min, max, act ct */ 0, 1, 0,
612     /* opt state flags  */ NTPVERSION_FLAGS, 0,
613     /* last opt argumnt */ { NTPVERSION_DFT_ARG },
614     /* arg list/cookie  */ NULL,
615     /* must/cannot opts */ NULL, NULL,
616     /* option proc      */ doOptNtpversion,
617     /* desc, NAME, name */ NTPVERSION_DESC, NTPVERSION_NAME, NTPVERSION_name,
618     /* disablement strs */ NULL, NULL },
619
620  {  /* entry idx, value */ 13, VALUE_OPT_USERESERVEDPORT,
621     /* equiv idx, value */ 13, VALUE_OPT_USERESERVEDPORT,
622     /* equivalenced to  */ NO_EQUIVALENT,
623     /* min, max, act ct */ 0, 1, 0,
624     /* opt state flags  */ USERESERVEDPORT_FLAGS, 0,
625     /* last opt argumnt */ { NULL }, /* --usereservedport */
626     /* arg list/cookie  */ NULL,
627     /* must/cannot opts */ NULL, NULL,
628     /* option proc      */ NULL,
629     /* desc, NAME, name */ USERESERVEDPORT_DESC, USERESERVEDPORT_NAME, USERESERVEDPORT_name,
630     /* disablement strs */ NULL, NULL },
631
632  {  /* entry idx, value */ 14, VALUE_OPT_STEP,
633     /* equiv idx, value */ 14, VALUE_OPT_STEP,
634     /* equivalenced to  */ NO_EQUIVALENT,
635     /* min, max, act ct */ 0, 1, 0,
636     /* opt state flags  */ STEP_FLAGS, 0,
637     /* last opt argumnt */ { NULL }, /* --step */
638     /* arg list/cookie  */ NULL,
639     /* must/cannot opts */ NULL, NULL,
640     /* option proc      */ NULL,
641     /* desc, NAME, name */ STEP_DESC, STEP_NAME, STEP_name,
642     /* disablement strs */ NULL, NULL },
643
644  {  /* entry idx, value */ 15, VALUE_OPT_SLEW,
645     /* equiv idx, value */ 15, VALUE_OPT_SLEW,
646     /* equivalenced to  */ NO_EQUIVALENT,
647     /* min, max, act ct */ 0, 1, 0,
648     /* opt state flags  */ SLEW_FLAGS, 0,
649     /* last opt argumnt */ { NULL }, /* --slew */
650     /* arg list/cookie  */ NULL,
651     /* must/cannot opts */ NULL, NULL,
652     /* option proc      */ NULL,
653     /* desc, NAME, name */ SLEW_DESC, SLEW_NAME, SLEW_name,
654     /* disablement strs */ NULL, NULL },
655
656  {  /* entry idx, value */ 16, VALUE_OPT_TIMEOUT,
657     /* equiv idx, value */ 16, VALUE_OPT_TIMEOUT,
658     /* equivalenced to  */ NO_EQUIVALENT,
659     /* min, max, act ct */ 0, 1, 0,
660     /* opt state flags  */ TIMEOUT_FLAGS, 0,
661     /* last opt argumnt */ { TIMEOUT_DFT_ARG },
662     /* arg list/cookie  */ NULL,
663     /* must/cannot opts */ NULL, NULL,
664     /* option proc      */ optionNumericVal,
665     /* desc, NAME, name */ TIMEOUT_DESC, TIMEOUT_NAME, TIMEOUT_name,
666     /* disablement strs */ NULL, NULL },
667
668  {  /* entry idx, value */ 17, VALUE_OPT_WAIT,
669     /* equiv idx, value */ 17, VALUE_OPT_WAIT,
670     /* equivalenced to  */ NO_EQUIVALENT,
671     /* min, max, act ct */ 0, 1, 0,
672     /* opt state flags  */ WAIT_FLAGS, 0,
673     /* last opt argumnt */ { NULL }, /* --wait */
674     /* arg list/cookie  */ NULL,
675     /* must/cannot opts */ NULL, NULL,
676     /* option proc      */ NULL,
677     /* desc, NAME, name */ WAIT_DESC, WAIT_NAME, WAIT_name,
678     /* disablement strs */ NOT_WAIT_name, NOT_WAIT_PFX },
679
680  {  /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
681     /* equiv idx value  */ NO_EQUIVALENT, VALUE_OPT_VERSION,
682     /* equivalenced to  */ NO_EQUIVALENT,
683     /* min, max, act ct */ 0, 1, 0,
684     /* opt state flags  */ VER_FLAGS, AOUSE_VERSION,
685     /* last opt argumnt */ { NULL },
686     /* arg list/cookie  */ NULL,
687     /* must/cannot opts */ NULL, NULL,
688     /* option proc      */ VER_PROC,
689     /* desc, NAME, name */ VER_DESC, NULL, VER_name,
690     /* disablement strs */ NULL, NULL },
691
692
693
694  {  /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
695     /* equiv idx value  */ NO_EQUIVALENT, VALUE_OPT_HELP,
696     /* equivalenced to  */ NO_EQUIVALENT,
697     /* min, max, act ct */ 0, 1, 0,
698     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, AOUSE_HELP,
699     /* last opt argumnt */ { NULL },
700     /* arg list/cookie  */ NULL,
701     /* must/cannot opts */ NULL, NULL,
702     /* option proc      */ doUsageOpt,
703     /* desc, NAME, name */ HELP_DESC, NULL, HELP_name,
704     /* disablement strs */ NULL, NULL },
705
706  {  /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
707     /* equiv idx value  */ NO_EQUIVALENT, VALUE_OPT_MORE_HELP,
708     /* equivalenced to  */ NO_EQUIVALENT,
709     /* min, max, act ct */ 0, 1, 0,
710     /* opt state flags  */ MORE_HELP_FLAGS, AOUSE_MORE_HELP,
711     /* last opt argumnt */ { NULL },
712     /* arg list/cookie  */ NULL,
713     /* must/cannot opts */ NULL,  NULL,
714     /* option proc      */ optionPagedUsage,
715     /* desc, NAME, name */ MORE_HELP_DESC, NULL, MORE_HELP_name,
716     /* disablement strs */ NULL, NULL },
717
718  {  /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS,
719     /* equiv idx value  */ NO_EQUIVALENT, VALUE_OPT_SAVE_OPTS,
720     /* equivalenced to  */ NO_EQUIVALENT,
721     /* min, max, act ct */ 0, 1, 0,
722     /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
723                       | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, AOUSE_SAVE_OPTS,
724     /* last opt argumnt */ { NULL },
725     /* arg list/cookie  */ NULL,
726     /* must/cannot opts */ NULL,  NULL,
727     /* option proc      */ NULL,
728     /* desc, NAME, name */ SAVE_OPTS_DESC, NULL, SAVE_OPTS_name,
729     /* disablement strs */ NULL, NULL },
730
731  {  /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS,
732     /* equiv idx value  */ NO_EQUIVALENT, VALUE_OPT_LOAD_OPTS,
733     /* equivalenced to  */ NO_EQUIVALENT,
734     /* min, max, act ct */ 0, NOLIMIT, 0,
735     /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
736			  | OPTST_DISABLE_IMM, AOUSE_LOAD_OPTS,
737     /* last opt argumnt */ { NULL },
738     /* arg list/cookie  */ NULL,
739     /* must/cannot opts */ NULL, NULL,
740     /* option proc      */ optionLoadOpt,
741     /* desc, NAME, name */ LOAD_OPTS_DESC, LOAD_OPTS_NAME, LOAD_OPTS_name,
742     /* disablement strs */ NO_LOAD_OPTS_name, LOAD_OPTS_pfx }
743};
744
745
746/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
747/** Reference to the upper cased version of sntp. */
748#define zPROGNAME       (sntp_opt_strs+2321)
749/** Reference to the title line for sntp usage. */
750#define zUsageTitle     (sntp_opt_strs+2326)
751/** sntp configuration file name. */
752#define zRcName         (sntp_opt_strs+2493)
753/** Directories to search for sntp config files. */
754static char const * const apzHomeList[3] = {
755    sntp_opt_strs+2485,
756    sntp_opt_strs+2491,
757    NULL };
758/** The sntp program bug email address. */
759#define zBugsAddr       (sntp_opt_strs+2500)
760/** Clarification/explanation of what sntp does. */
761#define zExplain        (sntp_opt_strs+2534)
762/** Extra detail explaining what sntp does. */
763#define zDetail         (NULL)
764/** The full version string for sntp. */
765#define zFullVersion    (sntp_opt_strs+2536)
766/* extracted from optcode.tlib near line 364 */
767
768#if defined(ENABLE_NLS)
769# define OPTPROC_BASE OPTPROC_TRANSLATE
770  static tOptionXlateProc translate_option_strings;
771#else
772# define OPTPROC_BASE OPTPROC_NONE
773# define translate_option_strings NULL
774#endif /* ENABLE_NLS */
775
776#define sntp_full_usage (NULL)
777#define sntp_short_usage (NULL)
778
779#endif /* not defined __doxygen__ */
780
781/*
782 *  Create the static procedure(s) declared above.
783 */
784/**
785 * The callout function that invokes the optionUsage function.
786 *
787 * @param[in] opts the AutoOpts option description structure
788 * @param[in] od   the descriptor for the "help" (usage) option.
789 * @noreturn
790 */
791static void
792doUsageOpt(tOptions * opts, tOptDesc * od)
793{
794    int ex_code;
795    ex_code = SNTP_EXIT_SUCCESS;
796    optionUsage(&sntpOptions, ex_code);
797    /* NOTREACHED */
798    exit(1);
799    (void)opts;
800    (void)od;
801}
802
803/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
804/**
805 * Code to handle the debug-level option.
806 *
807 * @param[in] pOptions the sntp options data structure
808 * @param[in,out] pOptDesc the option descriptor for this option.
809 */
810static void
811doOptDebug_Level(tOptions* pOptions, tOptDesc* pOptDesc)
812{
813    /*
814     * Be sure the flag-code[0] handles special values for the options pointer
815     * viz. (poptions <= OPTPROC_EMIT_LIMIT) *and also* the special flag bit
816     * ((poptdesc->fOptState & OPTST_RESET) != 0) telling the option to
817     * reset its state.
818     */
819    /* extracted from debug-opt.def, line 15 */
820OPT_VALUE_SET_DEBUG_LEVEL++;
821    (void)pOptDesc;
822    (void)pOptions;
823}
824
825/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
826/**
827 * Code to handle the kod option.
828 * Specifies the filename to be used for the persistent history of KoD
829 * responses received from servers.  If the file does not exist, a
830 * warning message will be displayed.  The file will not be created.
831 * @param[in] pOptions the sntp options data structure
832 * @param[in,out] pOptDesc the option descriptor for this option.
833 */
834static void
835doOptKod(tOptions* pOptions, tOptDesc* pOptDesc)
836{
837    static teOptFileType const  type =
838        FTYPE_MODE_MAY_EXIST + FTYPE_MODE_NO_OPEN;
839    static tuFileMode           mode;
840#ifndef O_CLOEXEC
841#  define O_CLOEXEC 0
842#endif
843    mode.file_flags = O_CLOEXEC;
844
845    /*
846     * This function handles special invalid values for "pOptions"
847     */
848    optionFileCheck(pOptions, pOptDesc, type, mode);
849}
850
851/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
852/**
853 * Code to handle the keyfile option.
854 * This option specifies the keyfile.
855 * @code{sntp} will search for the key specified with @option{-a}
856 * @file{keyno} in this file.  See @command{ntp.keys(5)} for more
857 * information.
858 * @param[in] pOptions the sntp options data structure
859 * @param[in,out] pOptDesc the option descriptor for this option.
860 */
861static void
862doOptKeyfile(tOptions* pOptions, tOptDesc* pOptDesc)
863{
864    static teOptFileType const  type =
865        FTYPE_MODE_MAY_EXIST + FTYPE_MODE_NO_OPEN;
866    static tuFileMode           mode;
867#ifndef O_CLOEXEC
868#  define O_CLOEXEC 0
869#endif
870    mode.file_flags = O_CLOEXEC;
871
872    /*
873     * This function handles special invalid values for "pOptions"
874     */
875    optionFileCheck(pOptions, pOptDesc, type, mode);
876}
877
878/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
879/**
880 * Code to handle the logfile option.
881 * This option causes the client to write log messages to the specified
882 * @file{logfile}.
883 * @param[in] pOptions the sntp options data structure
884 * @param[in,out] pOptDesc the option descriptor for this option.
885 */
886static void
887doOptLogfile(tOptions* pOptions, tOptDesc* pOptDesc)
888{
889    static teOptFileType const  type =
890        FTYPE_MODE_MAY_EXIST + FTYPE_MODE_NO_OPEN;
891    static tuFileMode           mode;
892#ifndef O_CLOEXEC
893#  define O_CLOEXEC 0
894#endif
895    mode.file_flags = O_CLOEXEC;
896
897    /*
898     * This function handles special invalid values for "pOptions"
899     */
900    optionFileCheck(pOptions, pOptDesc, type, mode);
901}
902
903/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
904/**
905 * Code to handle the steplimit option.
906 * If the time adjustment is less than @file{steplimit} milliseconds,
907 * slew the amount using @command{adjtime(2)}.  Otherwise, step the
908 * correction using @command{settimeofday(2)}.  The default value is 0,
909 * which means all adjustments will be stepped.  This is a feature, as
910 * different situations demand different values.
911 * @param[in] pOptions the sntp options data structure
912 * @param[in,out] pOptDesc the option descriptor for this option.
913 */
914static void
915doOptSteplimit(tOptions* pOptions, tOptDesc* pOptDesc)
916{
917    static struct {long rmin, rmax;} const rng[1] = {
918        { 0, LONG_MAX } };
919    int  ix;
920
921    if (pOptions <= OPTPROC_EMIT_LIMIT)
922        goto emit_ranges;
923    optionNumericVal(pOptions, pOptDesc);
924
925    for (ix = 0; ix < 1; ix++) {
926        if (pOptDesc->optArg.argInt < rng[ix].rmin)
927            continue;  /* ranges need not be ordered. */
928        if (pOptDesc->optArg.argInt == rng[ix].rmin)
929            return;
930        if (rng[ix].rmax == LONG_MIN)
931            continue;
932        if (pOptDesc->optArg.argInt <= rng[ix].rmax)
933            return;
934    }
935
936    option_usage_fp = stderr;
937
938 emit_ranges:
939optionShowRange(pOptions, pOptDesc, VOIDP(rng), 1);
940}
941
942/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
943/**
944 * Code to handle the ntpversion option.
945 * When sending requests to a remote server, tell them we are running
946 * NTP protocol version @file{ntpversion} .
947 * @param[in] pOptions the sntp options data structure
948 * @param[in,out] pOptDesc the option descriptor for this option.
949 */
950static void
951doOptNtpversion(tOptions* pOptions, tOptDesc* pOptDesc)
952{
953    static struct {long rmin, rmax;} const rng[1] = {
954        { 0, 7 } };
955    int  ix;
956
957    if (pOptions <= OPTPROC_EMIT_LIMIT)
958        goto emit_ranges;
959    optionNumericVal(pOptions, pOptDesc);
960
961    for (ix = 0; ix < 1; ix++) {
962        if (pOptDesc->optArg.argInt < rng[ix].rmin)
963            continue;  /* ranges need not be ordered. */
964        if (pOptDesc->optArg.argInt == rng[ix].rmin)
965            return;
966        if (rng[ix].rmax == LONG_MIN)
967            continue;
968        if (pOptDesc->optArg.argInt <= rng[ix].rmax)
969            return;
970    }
971
972    option_usage_fp = stderr;
973
974 emit_ranges:
975optionShowRange(pOptions, pOptDesc, VOIDP(rng), 1);
976}
977/* extracted from optmain.tlib near line 1250 */
978
979/**
980 * The directory containing the data associated with sntp.
981 */
982#ifndef  PKGDATADIR
983# define PKGDATADIR ""
984#endif
985
986/**
987 * Information about the person or institution that packaged sntp
988 * for the current distribution.
989 */
990#ifndef  WITH_PACKAGER
991# define sntp_packager_info NULL
992#else
993/** Packager information for sntp. */
994static char const sntp_packager_info[] =
995    "Packaged by " WITH_PACKAGER
996
997# ifdef WITH_PACKAGER_VERSION
998        " ("WITH_PACKAGER_VERSION")"
999# endif
1000
1001# ifdef WITH_PACKAGER_BUG_REPORTS
1002    "\nReport sntp bugs to " WITH_PACKAGER_BUG_REPORTS
1003# endif
1004    "\n";
1005#endif
1006#ifndef __doxygen__
1007
1008#endif /* __doxygen__ */
1009/**
1010 * The option definitions for sntp.  The one structure that
1011 * binds them all.
1012 */
1013tOptions sntpOptions = {
1014    OPTIONS_STRUCT_VERSION,
1015    0, NULL,                    /* original argc + argv    */
1016    ( OPTPROC_BASE
1017    + OPTPROC_ERRSTOP
1018    + OPTPROC_SHORTOPT
1019    + OPTPROC_LONGOPT
1020    + OPTPROC_NO_REQ_OPT
1021    + OPTPROC_NEGATIONS
1022    + OPTPROC_ENVIRON
1023    + OPTPROC_MISUSE ),
1024    0, NULL,                    /* current option index, current option */
1025    NULL,         NULL,         zPROGNAME,
1026    zRcName,      zCopyright,   zLicenseDescrip,
1027    zFullVersion, apzHomeList,  zUsageTitle,
1028    zExplain,     zDetail,      optDesc,
1029    zBugsAddr,                  /* address to send bugs to */
1030    NULL, NULL,                 /* extensions/saved state  */
1031    optionUsage, /* usage procedure */
1032    translate_option_strings,   /* translation procedure */
1033    /*
1034     *  Indexes to special options
1035     */
1036    { INDEX_OPT_MORE_HELP, /* more-help option index */
1037      INDEX_OPT_SAVE_OPTS, /* save option index */
1038      NO_EQUIVALENT, /* '-#' option index */
1039      NO_EQUIVALENT /* index of default opt */
1040    },
1041    23 /* full option count */, 18 /* user option count */,
1042    sntp_full_usage, sntp_short_usage,
1043    NULL, NULL,
1044    PKGDATADIR, sntp_packager_info
1045};
1046
1047#if ENABLE_NLS
1048/**
1049 * This code is designed to translate translatable option text for the
1050 * sntp program.  These translations happen upon entry
1051 * to optionProcess().
1052 */
1053#include <stdio.h>
1054#include <stdlib.h>
1055#include <string.h>
1056#include <unistd.h>
1057#ifdef HAVE_DCGETTEXT
1058# include <gettext.h>
1059#endif
1060#include <autoopts/usage-txt.h>
1061
1062static char * AO_gettext(char const * pz);
1063static void   coerce_it(void ** s);
1064
1065/**
1066 * AutoGen specific wrapper function for gettext.  It relies on the macro _()
1067 * to convert from English to the target language, then strdup-duplicates the
1068 * result string.  It tries the "libopts" domain first, then whatever has been
1069 * set via the \a textdomain(3) call.
1070 *
1071 * @param[in] pz the input text used as a lookup key.
1072 * @returns the translated text (if there is one),
1073 *   or the original text (if not).
1074 */
1075static char *
1076AO_gettext(char const * pz)
1077{
1078    char * res;
1079    if (pz == NULL)
1080        return NULL;
1081#ifdef HAVE_DCGETTEXT
1082    /*
1083     * While processing the option_xlateable_txt data, try to use the
1084     * "libopts" domain.  Once we switch to the option descriptor data,
1085     * do *not* use that domain.
1086     */
1087    if (option_xlateable_txt.field_ct != 0) {
1088        res = dgettext("libopts", pz);
1089        if (res == pz)
1090            res = (char *)VOIDP(_(pz));
1091    } else
1092        res = (char *)VOIDP(_(pz));
1093#else
1094    res = (char *)VOIDP(_(pz));
1095#endif
1096    if (res == pz)
1097        return res;
1098    res = strdup(res);
1099    if (res == NULL) {
1100        fputs(_("No memory for duping translated strings\n"), stderr);
1101        exit(SNTP_EXIT_FAILURE);
1102    }
1103    return res;
1104}
1105
1106/**
1107 * All the pointers we use are marked "* const", but they are stored in
1108 * writable memory.  Coerce the mutability and set the pointer.
1109 */
1110static void coerce_it(void ** s) { *s = AO_gettext(*s);
1111}
1112
1113/**
1114 * Translate all the translatable strings in the sntpOptions
1115 * structure defined above.  This is done only once.
1116 */
1117static void
1118translate_option_strings(void)
1119{
1120    tOptions * const opts = &sntpOptions;
1121
1122    /*
1123     *  Guard against re-translation.  It won't work.  The strings will have
1124     *  been changed by the first pass through this code.  One shot only.
1125     */
1126    if (option_xlateable_txt.field_ct != 0) {
1127        /*
1128         *  Do the translations.  The first pointer follows the field count
1129         *  field.  The field count field is the size of a pointer.
1130         */
1131        char ** ppz = (char**)VOIDP(&(option_xlateable_txt));
1132        int     ix  = option_xlateable_txt.field_ct;
1133
1134        do {
1135            ppz++; /* skip over field_ct */
1136            *ppz = AO_gettext(*ppz);
1137        } while (--ix > 0);
1138        /* prevent re-translation and disable "libopts" domain lookup */
1139        option_xlateable_txt.field_ct = 0;
1140
1141        coerce_it(VOIDP(&(opts->pzCopyright)));
1142        coerce_it(VOIDP(&(opts->pzCopyNotice)));
1143        coerce_it(VOIDP(&(opts->pzFullVersion)));
1144        coerce_it(VOIDP(&(opts->pzUsageTitle)));
1145        coerce_it(VOIDP(&(opts->pzExplain)));
1146        coerce_it(VOIDP(&(opts->pzDetail)));
1147        {
1148            tOptDesc * od = opts->pOptDesc;
1149            for (ix = opts->optCt; ix > 0; ix--, od++)
1150                coerce_it(VOIDP(&(od->pzText)));
1151        }
1152    }
1153}
1154#endif /* ENABLE_NLS */
1155
1156#ifdef DO_NOT_COMPILE_THIS_CODE_IT_IS_FOR_GETTEXT
1157/** I18N function strictly for xgettext.  Do not compile. */
1158static void bogus_function(void) {
1159  /* TRANSLATORS:
1160
1161     The following dummy function was crated solely so that xgettext can
1162     extract the correct strings.  These strings are actually referenced
1163     by a field name in the sntpOptions structure noted in the
1164     comments below.  The literal text is defined in sntp_opt_strs.
1165
1166     NOTE: the strings below are segmented with respect to the source string
1167     sntp_opt_strs.  The strings above are handed off for translation
1168     at run time a paragraph at a time.  Consequently, they are presented here
1169     for translation a paragraph at a time.
1170
1171     ALSO: often the description for an option will reference another option
1172     by name.  These are set off with apostrophe quotes (I hope).  Do not
1173     translate option names.
1174   */
1175  /* referenced via sntpOptions.pzCopyright */
1176  puts(_("sntp 4.2.8p5\n\
1177Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n\
1178This is free software. It is licensed for use, modification and\n\
1179redistribution under the terms of the NTP License, copies of which\n\
1180can be seen at:\n"));
1181  puts(_("  <http://ntp.org/license>\n\
1182  <http://opensource.org/licenses/ntp-license.php>\n"));
1183
1184  /* referenced via sntpOptions.pzCopyNotice */
1185  puts(_("Permission to use, copy, modify, and distribute this software and its\n\
1186documentation for any purpose with or without fee is hereby granted,\n\
1187provided that the above copyright notice appears in all copies and that\n\
1188both the copyright notice and this permission notice appear in supporting\n\
1189documentation, and that the name The University of Delaware not be used in\n\
1190advertising or publicity pertaining to distribution of the software without\n\
1191specific, written prior permission.  The University of Delaware and Network\n\
1192Time Foundation makes no representations about the suitability this\n\
1193software for any purpose.  It is provided \"as is\" without express or\n\
1194implied warranty.\n"));
1195
1196  /* referenced via sntpOptions.pOptDesc->pzText */
1197  puts(_("Force IPv4 DNS name resolution"));
1198
1199  /* referenced via sntpOptions.pOptDesc->pzText */
1200  puts(_("Force IPv6 DNS name resolution"));
1201
1202  /* referenced via sntpOptions.pOptDesc->pzText */
1203  puts(_("Enable authentication with the key auth-keynumber"));
1204
1205  /* referenced via sntpOptions.pOptDesc->pzText */
1206  puts(_("Listen to the address specified for broadcast time sync"));
1207
1208  /* referenced via sntpOptions.pOptDesc->pzText */
1209  puts(_("Concurrently query all IPs returned for host-name"));
1210
1211  /* referenced via sntpOptions.pOptDesc->pzText */
1212  puts(_("Increase debug verbosity level"));
1213
1214  /* referenced via sntpOptions.pOptDesc->pzText */
1215  puts(_("Set the debug verbosity level"));
1216
1217  /* referenced via sntpOptions.pOptDesc->pzText */
1218  puts(_("The gap (in milliseconds) between time requests"));
1219
1220  /* referenced via sntpOptions.pOptDesc->pzText */
1221  puts(_("KoD history filename"));
1222
1223  /* referenced via sntpOptions.pOptDesc->pzText */
1224  puts(_("Look in this file for the key specified with -a"));
1225
1226  /* referenced via sntpOptions.pOptDesc->pzText */
1227  puts(_("Log to specified logfile"));
1228
1229  /* referenced via sntpOptions.pOptDesc->pzText */
1230  puts(_("Adjustments less than steplimit msec will be slewed"));
1231
1232  /* referenced via sntpOptions.pOptDesc->pzText */
1233  puts(_("Send int as our NTP protocol version"));
1234
1235  /* referenced via sntpOptions.pOptDesc->pzText */
1236  puts(_("Use the NTP Reserved Port (port 123)"));
1237
1238  /* referenced via sntpOptions.pOptDesc->pzText */
1239  puts(_("OK to 'step' the time with settimeofday(2)"));
1240
1241  /* referenced via sntpOptions.pOptDesc->pzText */
1242  puts(_("OK to 'slew' the time with adjtime(2)"));
1243
1244  /* referenced via sntpOptions.pOptDesc->pzText */
1245  puts(_("The number of seconds to wait for responses"));
1246
1247  /* referenced via sntpOptions.pOptDesc->pzText */
1248  puts(_("Wait for pending replies (if not setting the time)"));
1249
1250  /* referenced via sntpOptions.pOptDesc->pzText */
1251  puts(_("display extended usage information and exit"));
1252
1253  /* referenced via sntpOptions.pOptDesc->pzText */
1254  puts(_("extended usage information passed thru pager"));
1255
1256  /* referenced via sntpOptions.pOptDesc->pzText */
1257  puts(_("output version information and exit"));
1258
1259  /* referenced via sntpOptions.pOptDesc->pzText */
1260  puts(_("save the option state to a config file"));
1261
1262  /* referenced via sntpOptions.pOptDesc->pzText */
1263  puts(_("load options from a config file"));
1264
1265  /* referenced via sntpOptions.pzUsageTitle */
1266  puts(_("sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p5\n\
1267Usage:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\
1268\t\t[ hostname-or-IP ...]\n"));
1269
1270  /* referenced via sntpOptions.pzExplain */
1271  puts(_("\n"));
1272
1273  /* referenced via sntpOptions.pzFullVersion */
1274  puts(_("sntp 4.2.8p5"));
1275
1276  /* referenced via sntpOptions.pzFullUsage */
1277  puts(_("<<<NOT-FOUND>>>"));
1278
1279  /* referenced via sntpOptions.pzShortUsage */
1280  puts(_("<<<NOT-FOUND>>>"));
1281  /* LIBOPTS-MESSAGES: */
1282#line 67 "../autoopts.c"
1283  puts(_("allocation of %d bytes failed\n"));
1284#line 93 "../autoopts.c"
1285  puts(_("allocation of %d bytes failed\n"));
1286#line 53 "../init.c"
1287  puts(_("AutoOpts function called without option descriptor\n"));
1288#line 86 "../init.c"
1289  puts(_("\tThis exceeds the compiled library version:  "));
1290#line 84 "../init.c"
1291  puts(_("Automated Options Processing Error!\n"
1292       "\t%s called AutoOpts function with structure version %d:%d:%d.\n"));
1293#line 80 "../autoopts.c"
1294  puts(_("realloc of %d bytes at 0x%p failed\n"));
1295#line 88 "../init.c"
1296  puts(_("\tThis is less than the minimum library version:  "));
1297#line 121 "../version.c"
1298  puts(_("Automated Options version %s\n"
1299       "\tCopyright (C) 1999-2014 by Bruce Korb - all rights reserved\n"));
1300#line 87 "../makeshell.c"
1301  puts(_("(AutoOpts bug):  %s.\n"));
1302#line 90 "../reset.c"
1303  puts(_("optionResetOpt() called, but reset-option not configured"));
1304#line 292 "../usage.c"
1305  puts(_("could not locate the 'help' option"));
1306#line 336 "../autoopts.c"
1307  puts(_("optionProcess() was called with invalid data"));
1308#line 748 "../usage.c"
1309  puts(_("invalid argument type specified"));
1310#line 598 "../find.c"
1311  puts(_("defaulted to option with optional arg"));
1312#line 76 "../alias.c"
1313  puts(_("aliasing option is out of range."));
1314#line 234 "../enum.c"
1315  puts(_("%s error:  the keyword '%s' is ambiguous for %s\n"));
1316#line 108 "../find.c"
1317  puts(_("  The following options match:\n"));
1318#line 293 "../find.c"
1319  puts(_("%s: ambiguous option name: %s (matches %d options)\n"));
1320#line 161 "../check.c"
1321  puts(_("%s: Command line arguments required\n"));
1322#line 43 "../alias.c"
1323  puts(_("%d %s%s options allowed\n"));
1324#line 94 "../makeshell.c"
1325  puts(_("%s error %d (%s) calling %s for '%s'\n"));
1326#line 306 "../makeshell.c"
1327  puts(_("interprocess pipe"));
1328#line 168 "../version.c"
1329  puts(_("error: version option argument '%c' invalid.  Use:\n"
1330       "\t'v' - version only\n"
1331       "\t'c' - version and copyright\n"
1332       "\t'n' - version and full copyright notice\n"));
1333#line 58 "../check.c"
1334  puts(_("%s error:  the '%s' and '%s' options conflict\n"));
1335#line 217 "../find.c"
1336  puts(_("%s: The '%s' option has been disabled."));
1337#line 430 "../find.c"
1338  puts(_("%s: The '%s' option has been disabled."));
1339#line 38 "../alias.c"
1340  puts(_("-equivalence"));
1341#line 469 "../find.c"
1342  puts(_("%s: illegal option -- %c\n"));
1343#line 110 "../reset.c"
1344  puts(_("%s: illegal option -- %c\n"));
1345#line 271 "../find.c"
1346  puts(_("%s: illegal option -- %s\n"));
1347#line 755 "../find.c"
1348  puts(_("%s: illegal option -- %s\n"));
1349#line 118 "../reset.c"
1350  puts(_("%s: illegal option -- %s\n"));
1351#line 335 "../find.c"
1352  puts(_("%s: unknown vendor extension option -- %s\n"));
1353#line 159 "../enum.c"
1354  puts(_("  or an integer from %d through %d\n"));
1355#line 169 "../enum.c"
1356  puts(_("  or an integer from %d through %d\n"));
1357#line 747 "../usage.c"
1358  puts(_("%s error:  invalid option descriptor for %s\n"));
1359#line 1081 "../usage.c"
1360  puts(_("%s error:  invalid option descriptor for %s\n"));
1361#line 385 "../find.c"
1362  puts(_("%s: invalid option name: %s\n"));
1363#line 527 "../find.c"
1364  puts(_("%s: The '%s' option requires an argument.\n"));
1365#line 156 "../autoopts.c"
1366  puts(_("(AutoOpts bug):  Equivalenced option '%s' was equivalenced to both\n"
1367       "\t'%s' and '%s'."));
1368#line 94 "../check.c"
1369  puts(_("%s error:  The %s option is required\n"));
1370#line 632 "../find.c"
1371  puts(_("%s: The '%s' option cannot have an argument.\n"));
1372#line 151 "../check.c"
1373  puts(_("%s: Command line arguments are not allowed.\n"));
1374#line 535 "../save.c"
1375  puts(_("error %d (%s) creating %s\n"));
1376#line 234 "../enum.c"
1377  puts(_("%s error:  '%s' does not match any %s keywords.\n"));
1378#line 93 "../reset.c"
1379  puts(_("%s error: The '%s' option requires an argument.\n"));
1380#line 184 "../save.c"
1381  puts(_("error %d (%s) stat-ing %s\n"));
1382#line 238 "../save.c"
1383  puts(_("error %d (%s) stat-ing %s\n"));
1384#line 143 "../restore.c"
1385  puts(_("%s error: no saved option state\n"));
1386#line 231 "../autoopts.c"
1387  puts(_("'%s' is not a command line option.\n"));
1388#line 111 "../time.c"
1389  puts(_("%s error:  '%s' is not a recognizable date/time.\n"));
1390#line 132 "../save.c"
1391  puts(_("'%s' not defined\n"));
1392#line 50 "../time.c"
1393  puts(_("%s error:  '%s' is not a recognizable time duration.\n"));
1394#line 92 "../check.c"
1395  puts(_("%s error:  The %s option must appear %d times.\n"));
1396#line 164 "../numeric.c"
1397  puts(_("%s error:  '%s' is not a recognizable number.\n"));
1398#line 200 "../enum.c"
1399  puts(_("%s error:  %s exceeds %s keyword count\n"));
1400#line 330 "../usage.c"
1401  puts(_("Try '%s %s' for more information.\n"));
1402#line 45 "../alias.c"
1403  puts(_("one %s%s option allowed\n"));
1404#line 208 "../makeshell.c"
1405  puts(_("standard output"));
1406#line 943 "../makeshell.c"
1407  puts(_("standard output"));
1408#line 274 "../usage.c"
1409  puts(_("standard output"));
1410#line 415 "../usage.c"
1411  puts(_("standard output"));
1412#line 625 "../usage.c"
1413  puts(_("standard output"));
1414#line 175 "../version.c"
1415  puts(_("standard output"));
1416#line 274 "../usage.c"
1417  puts(_("standard error"));
1418#line 415 "../usage.c"
1419  puts(_("standard error"));
1420#line 625 "../usage.c"
1421  puts(_("standard error"));
1422#line 175 "../version.c"
1423  puts(_("standard error"));
1424#line 208 "../makeshell.c"
1425  puts(_("write"));
1426#line 943 "../makeshell.c"
1427  puts(_("write"));
1428#line 273 "../usage.c"
1429  puts(_("write"));
1430#line 414 "../usage.c"
1431  puts(_("write"));
1432#line 624 "../usage.c"
1433  puts(_("write"));
1434#line 174 "../version.c"
1435  puts(_("write"));
1436#line 60 "../numeric.c"
1437  puts(_("%s error:  %s option value %ld is out of range.\n"));
1438#line 44 "../check.c"
1439  puts(_("%s error:  %s option requires the %s option\n"));
1440#line 131 "../save.c"
1441  puts(_("%s warning:  cannot save options - %s not regular file\n"));
1442#line 183 "../save.c"
1443  puts(_("%s warning:  cannot save options - %s not regular file\n"));
1444#line 237 "../save.c"
1445  puts(_("%s warning:  cannot save options - %s not regular file\n"));
1446#line 256 "../save.c"
1447  puts(_("%s warning:  cannot save options - %s not regular file\n"));
1448#line 534 "../save.c"
1449  puts(_("%s warning:  cannot save options - %s not regular file\n"));
1450  /* END-LIBOPTS-MESSAGES */
1451
1452  /* USAGE-TEXT: */
1453#line 873 "../usage.c"
1454  puts(_("\t\t\t\t- an alternate for '%s'\n"));
1455#line 1148 "../usage.c"
1456  puts(_("Version, usage and configuration options:"));
1457#line 924 "../usage.c"
1458  puts(_("\t\t\t\t- default option for unnamed options\n"));
1459#line 837 "../usage.c"
1460  puts(_("\t\t\t\t- disabled as '--%s'\n"));
1461#line 1117 "../usage.c"
1462  puts(_(" --- %-14s %s\n"));
1463#line 1115 "../usage.c"
1464  puts(_("This option has been disabled"));
1465#line 864 "../usage.c"
1466  puts(_("\t\t\t\t- enabled by default\n"));
1467#line 40 "../alias.c"
1468  puts(_("%s error:  only "));
1469#line 1194 "../usage.c"
1470  puts(_(" - examining environment variables named %s_*\n"));
1471#line 168 "../file.c"
1472  puts(_("\t\t\t\t- file must not pre-exist\n"));
1473#line 172 "../file.c"
1474  puts(_("\t\t\t\t- file must pre-exist\n"));
1475#line 380 "../usage.c"
1476  puts(_("Options are specified by doubled hyphens and their name or by a single\n"
1477       "hyphen and the flag character.\n"));
1478#line 921 "../makeshell.c"
1479  puts(_("\n"
1480       "= = = = = = = =\n\n"
1481       "This incarnation of genshell will produce\n"
1482       "a shell script to parse the options for %s:\n\n"));
1483#line 166 "../enum.c"
1484  puts(_("  or an integer mask with any of the lower %d bits set\n"));
1485#line 897 "../usage.c"
1486  puts(_("\t\t\t\t- is a set membership option\n"));
1487#line 918 "../usage.c"
1488  puts(_("\t\t\t\t- must appear between %d and %d times\n"));
1489#line 382 "../usage.c"
1490  puts(_("Options are specified by single or double hyphens and their name.\n"));
1491#line 904 "../usage.c"
1492  puts(_("\t\t\t\t- may appear multiple times\n"));
1493#line 891 "../usage.c"
1494  puts(_("\t\t\t\t- may not be preset\n"));
1495#line 1309 "../usage.c"
1496  puts(_("   Arg Option-Name    Description\n"));
1497#line 1245 "../usage.c"
1498  puts(_("  Flg Arg Option-Name    Description\n"));
1499#line 1303 "../usage.c"
1500  puts(_("  Flg Arg Option-Name    Description\n"));
1501#line 1304 "../usage.c"
1502  puts(_(" %3s %s"));
1503#line 1310 "../usage.c"
1504  puts(_(" %3s %s"));
1505#line 387 "../usage.c"
1506  puts(_("The '-#<number>' option may omit the hash char\n"));
1507#line 383 "../usage.c"
1508  puts(_("All arguments are named options.\n"));
1509#line 971 "../usage.c"
1510  puts(_(" - reading file %s"));
1511#line 409 "../usage.c"
1512  puts(_("\n"
1513       "Please send bug reports to:  <%s>\n"));
1514#line 100 "../version.c"
1515  puts(_("\n"
1516       "Please send bug reports to:  <%s>\n"));
1517#line 129 "../version.c"
1518  puts(_("\n"
1519       "Please send bug reports to:  <%s>\n"));
1520#line 903 "../usage.c"
1521  puts(_("\t\t\t\t- may NOT appear - preset only\n"));
1522#line 944 "../usage.c"
1523  puts(_("\n"
1524       "The following option preset mechanisms are supported:\n"));
1525#line 1192 "../usage.c"
1526  puts(_("\n"
1527       "The following option preset mechanisms are supported:\n"));
1528#line 682 "../usage.c"
1529  puts(_("prohibits these options:\n"));
1530#line 677 "../usage.c"
1531  puts(_("prohibits the option '%s'\n"));
1532#line 81 "../numeric.c"
1533  puts(_("%s%ld to %ld"));
1534#line 79 "../numeric.c"
1535  puts(_("%sgreater than or equal to %ld"));
1536#line 75 "../numeric.c"
1537  puts(_("%s%ld exactly"));
1538#line 68 "../numeric.c"
1539  puts(_("%sit must lie in one of the ranges:\n"));
1540#line 68 "../numeric.c"
1541  puts(_("%sit must be in the range:\n"));
1542#line 88 "../numeric.c"
1543  puts(_(", or\n"));
1544#line 66 "../numeric.c"
1545  puts(_("%sis scalable with a suffix: k/K/m/M/g/G/t/T\n"));
1546#line 77 "../numeric.c"
1547  puts(_("%sless than or equal to %ld"));
1548#line 390 "../usage.c"
1549  puts(_("Operands and options may be intermixed.  They will be reordered.\n"));
1550#line 652 "../usage.c"
1551  puts(_("requires the option '%s'\n"));
1552#line 655 "../usage.c"
1553  puts(_("requires these options:\n"));
1554#line 1321 "../usage.c"
1555  puts(_("   Arg Option-Name   Req?  Description\n"));
1556#line 1315 "../usage.c"
1557  puts(_("  Flg Arg Option-Name   Req?  Description\n"));
1558#line 167 "../enum.c"
1559  puts(_("or you may use a numeric representation.  Preceding these with a '!'\n"
1560       "will clear the bits, specifying 'none' will clear all bits, and 'all'\n"
1561       "will set them all.  Multiple entries may be passed as an option\n"
1562       "argument list.\n"));
1563#line 910 "../usage.c"
1564  puts(_("\t\t\t\t- may appear up to %d times\n"));
1565#line 77 "../enum.c"
1566  puts(_("The valid \"%s\" option keywords are:\n"));
1567#line 1152 "../usage.c"
1568  puts(_("The next option supports vendor supported extra options:"));
1569#line 773 "../usage.c"
1570  puts(_("These additional options are:"));
1571  /* END-USAGE-TEXT */
1572}
1573#endif /* uncompilable code */
1574#ifdef  __cplusplus
1575}
1576#endif
1577/* sntp-opts.c ends here */
1578