PageRenderTime 42ms CodeModel.GetById 12ms app.highlight 24ms RepoModel.GetById 2ms app.codeStats 0ms

/contrib/ntp/sntp/sntp-opts.c

https://bitbucket.org/freebsd/freebsd-head/
C | 691 lines | 459 code | 54 blank | 178 comment | 11 complexity | 650f9f4969f707fcc4e1e5e0ebf54a04 MD5 | raw file
  1/*  
  2 *  EDIT THIS FILE WITH CAUTION  (sntp-opts.c)
  3 *  
  4 *  It has been AutoGen-ed  Tuesday December  8, 2009 at 08:14:49 AM EST
  5 *  From the definitions    sntp-opts.def
  6 *  and the template file   options
  7 *
  8 * Generated from AutoOpts 29:0:4 templates.
  9 */
 10
 11/*
 12 *  This file was produced by an AutoOpts template.  AutoOpts is a
 13 *  copyrighted work.  This source file is not encumbered by AutoOpts
 14 *  licensing, but is provided under the licensing terms chosen by the
 15 *  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 1970-2006 ntp.org - all rights reserved
 23 *
 24 *         General Public Licence for the software known as MSNTP
 25 *         ------------------------------------------------------
 26 * 
 27 * 	  (c) Copyright, N.M. Maclaren, 1996, 1997, 2000
 28 * 	  (c) Copyright, University of Cambridge, 1996, 1997, 2000
 29 * 
 30 * 
 31 * 
 32 * Free use of MSNTP in source and binary forms is permitted, provided that this
 33 * entire licence is duplicated in all copies, and that any documentation,
 34 * announcements, and other materials related to use acknowledge that the software
 35 * was developed by N.M. Maclaren (hereafter refered to as the Author) at the
 36 * University of Cambridge.  Neither the name of the Author nor the University of
 37 * Cambridge may be used to endorse or promote products derived from this material
 38 * without specific prior written permission.
 39 * 
 40 * The Author and the University of Cambridge retain the copyright and all other
 41 * legal rights to the software and make it available non-exclusively.  All users
 42 * must ensure that the software in all its derivations carries a copyright notice
 43 * in the form:
 44 * 	  (c) Copyright N.M. Maclaren,
 45 * 	  (c) Copyright University of Cambridge.
 46 * 
 47 * 
 48 * 
 49 *                            NO WARRANTY
 50 * 
 51 * Because the MSNTP software is licensed free of charge, the Author and the
 52 * University of Cambridge provide absolutely no warranty, either expressed or
 53 * implied, including, but not limited to, the implied warranties of
 54 * merchantability and fitness for a particular purpose.  The entire risk as to
 55 * the quality and performance of the MSNTP software is with you.  Should MSNTP
 56 * prove defective, you assume the cost of all necessary servicing or repair.
 57 * 
 58 * In no event, unless required by law, will the Author or the University of
 59 * Cambridge, or any other party who may modify and redistribute this software as
 60 * permitted in accordance with the provisions below, be liable for damages for
 61 * any losses whatsoever, including but not limited to lost profits, lost monies,
 62 * lost or corrupted data, or other special, incidental or consequential losses
 63 * that may arise out of the use or inability to use the MSNTP software.
 64 * 
 65 * 
 66 * 
 67 *                          COPYING POLICY
 68 * 
 69 * Permission is hereby granted for copying and distribution of copies of the
 70 * MSNTP source and binary files, and of any part thereof, subject to the
 71 * following licence conditions:
 72 * 
 73 * 1. You may distribute MSNTP or components of MSNTP, with or without additions
 74 * developed by you or by others.  No charge, other than an "at-cost" distribution
 75 * fee, may be charged for copies, derivations, or distributions of this material
 76 * without the express written consent of the copyright holders.
 77 * 
 78 * 2. You may also distribute MSNTP along with any other product for sale,
 79 * provided that the cost of the bundled package is the same regardless of whether
 80 * MSNTP is included or not, and provided that those interested only in MSNTP must
 81 * be notified that it is a product freely available from the University of
 82 * Cambridge.
 83 * 
 84 * 3. If you distribute MSNTP software or parts of MSNTP, with or without
 85 * additions developed by you or others, then you must either make available the
 86 * source to all portions of the MSNTP system (exclusive of any additions made by
 87 * you or by others) upon request, or instead you may notify anyone requesting
 88 * source that it is freely available from the University of Cambridge.
 89 * 
 90 * 4. You may not omit any of the copyright notices on either the source files,
 91 * the executable files, or the documentation.
 92 * 
 93 * 5. You may not omit transmission of this License agreement with whatever
 94 * portions of MSNTP that are distributed.
 95 * 
 96 * 6. Any users of this software must be notified that it is without warranty or
 97 * guarantee of any nature, express or implied, nor is there any fitness for use
 98 * represented.
 99 * 
100 * 
101 * October 1996
102 * April 1997
103 * October 2000
104 */
105
106
107#include <limits.h>
108
109#define OPTION_CODE_COMPILE 1
110#include "sntp-opts.h"
111
112#ifdef  __cplusplus
113extern "C" {
114#endif
115tSCC zCopyright[] =
116       "sntp copyright (c) 1970-2006 ntp.org, all rights reserved";
117tSCC zCopyrightNotice[] =
118       
119/* extracted from sntp-opts.def near line 12 */
120"        General Public Licence for the software known as MSNTP\n\
121        ------------------------------------------------------\n\n\
122\t  (c) Copyright, N.M. Maclaren, 1996, 1997, 2000\n\
123\t  (c) Copyright, University of Cambridge, 1996, 1997, 2000\n\n\n\n\
124Free use of MSNTP in source and binary forms is permitted, provided that this\n\
125entire licence is duplicated in all copies, and that any documentation,\n\
126announcements, and other materials related to use acknowledge that the software\n\
127was developed by N.M. Maclaren (hereafter refered to as the Author) at the\n\
128University of Cambridge.  Neither the name of the Author nor the University of\n\
129Cambridge may be used to endorse or promote products derived from this material\n\
130without specific prior written permission.\n\n\
131The Author and the University of Cambridge retain the copyright and all other\n\
132legal rights to the software and make it available non-exclusively.  All users\n\
133must ensure that the software in all its derivations carries a copyright notice\n\
134in the form:\n\
135\t  (c) Copyright N.M. Maclaren,\n\
136\t  (c) Copyright University of Cambridge.\n\n\n\n\
137                           NO WARRANTY\n\n\
138Because the MSNTP software is licensed free of charge, the Author and the\n\
139University of Cambridge provide absolutely no warranty, either expressed or\n\
140implied, including, but not limited to, the implied warranties of\n\
141merchantability and fitness for a particular purpose.  The entire risk as to\n\
142the quality and performance of the MSNTP software is with you.  Should MSNTP\n\
143prove defective, you assume the cost of all necessary servicing or repair.\n\n\
144In no event, unless required by law, will the Author or the University of\n\
145Cambridge, or any other party who may modify and redistribute this software as\n\
146permitted in accordance with the provisions below, be liable for damages for\n\
147any losses whatsoever, including but not limited to lost profits, lost monies,\n\
148lost or corrupted data, or other special, incidental or consequential losses\n\
149that may arise out of the use or inability to use the MSNTP software.\n\n\n\n\
150                         COPYING POLICY\n\n\
151Permission is hereby granted for copying and distribution of copies of the\n\
152MSNTP source and binary files, and of any part thereof, subject to the\n\
153following licence conditions:\n\n\
1541. You may distribute MSNTP or components of MSNTP, with or without additions\n\
155developed by you or by others.  No charge, other than an \"at-cost\" distribution\n\
156fee, may be charged for copies, derivations, or distributions of this material\n\
157without the express written consent of the copyright holders.\n\n\
1582. You may also distribute MSNTP along with any other product for sale,\n\
159provided that the cost of the bundled package is the same regardless of whether\n\
160MSNTP is included or not, and provided that those interested only in MSNTP must\n\
161be notified that it is a product freely available from the University of\n\
162Cambridge.\n\n\
1633. If you distribute MSNTP software or parts of MSNTP, with or without\n\
164additions developed by you or others, then you must either make available the\n\
165source to all portions of the MSNTP system (exclusive of any additions made by\n\
166you or by others) upon request, or instead you may notify anyone requesting\n\
167source that it is freely available from the University of Cambridge.\n\n\
1684. You may not omit any of the copyright notices on either the source files,\n\
169the executable files, or the documentation.\n\n\
1705. You may not omit transmission of this License agreement with whatever\n\
171portions of MSNTP that are distributed.\n\n\
1726. Any users of this software must be notified that it is without warranty or\n\
173guarantee of any nature, express or implied, nor is there any fitness for use\n\
174represented.\n\n\n\
175October 1996\n\
176April 1997\n\
177October 2000";
178extern tUsageProc optionUsage;
179
180#ifndef NULL
181#  define NULL 0
182#endif
183#ifndef EXIT_SUCCESS
184#  define  EXIT_SUCCESS 0
185#endif
186#ifndef EXIT_FAILURE
187#  define  EXIT_FAILURE 1
188#endif
189/*
190 *  Ipv4 option description:
191 */
192tSCC    zIpv4Text[] =
193        "Force IPv4 DNS name resolution";
194tSCC    zIpv4_NAME[]               = "IPV4";
195tSCC    zIpv4_Name[]               = "ipv4";
196#define IPV4_FLAGS       (OPTST_DISABLED)
197
198/*
199 *  Ipv6 option description:
200 */
201tSCC    zIpv6Text[] =
202        "Force IPv6 DNS name resolution";
203tSCC    zIpv6_NAME[]               = "IPV6";
204tSCC    zIpv6_Name[]               = "ipv6";
205#define IPV6_FLAGS       (OPTST_DISABLED)
206
207/*
208 *  Unprivport option description:
209 */
210tSCC    zUnprivportText[] =
211        "Use an unprivileged port";
212tSCC    zUnprivport_NAME[]         = "UNPRIVPORT";
213tSCC    zUnprivport_Name[]         = "unprivport";
214#define UNPRIVPORT_FLAGS       (OPTST_DISABLED)
215
216/*
217 *  Normalverbose option description with
218 *  "Must also have options" and "Incompatible options":
219 */
220tSCC    zNormalverboseText[] =
221        "Slightly verbose";
222tSCC    zNormalverbose_NAME[]      = "NORMALVERBOSE";
223tSCC    zNormalverbose_Name[]      = "normalverbose";
224static const int
225    aNormalverboseCantList[] = {
226    INDEX_OPT_EXTRAVERBOSE,
227    INDEX_OPT_MEGAVERBOSE, NO_EQUIVALENT };
228#define NORMALVERBOSE_FLAGS       (OPTST_DISABLED)
229
230/*
231 *  Extraverbose option description with
232 *  "Must also have options" and "Incompatible options":
233 */
234tSCC    zExtraverboseText[] =
235        "Extra verbose";
236tSCC    zExtraverbose_NAME[]       = "EXTRAVERBOSE";
237tSCC    zExtraverbose_Name[]       = "extraverbose";
238static const int
239    aExtraverboseCantList[] = {
240    INDEX_OPT_NORMALVERBOSE,
241    INDEX_OPT_MEGAVERBOSE, NO_EQUIVALENT };
242#define EXTRAVERBOSE_FLAGS       (OPTST_DISABLED)
243
244/*
245 *  Megaverbose option description with
246 *  "Must also have options" and "Incompatible options":
247 */
248tSCC    zMegaverboseText[] =
249        "Mega verbose";
250tSCC    zMegaverbose_NAME[]        = "MEGAVERBOSE";
251tSCC    zMegaverbose_Name[]        = "megaverbose";
252static const int
253    aMegaverboseCantList[] = {
254    INDEX_OPT_NORMALVERBOSE,
255    INDEX_OPT_EXTRAVERBOSE, NO_EQUIVALENT };
256#define MEGAVERBOSE_FLAGS       (OPTST_DISABLED)
257
258/*
259 *  Settimeofday option description with
260 *  "Must also have options" and "Incompatible options":
261 */
262tSCC    zSettimeofdayText[] =
263        "Set (step) the time with settimeofday()";
264tSCC    zSettimeofday_NAME[]       = "SETTIMEOFDAY";
265tSCC    zSettimeofday_Name[]       = "settimeofday";
266static const int
267    aSettimeofdayCantList[] = {
268    INDEX_OPT_ADJTIME, NO_EQUIVALENT };
269#define SETTIMEOFDAY_FLAGS       (OPTST_DISABLED)
270
271/*
272 *  Adjtime option description with
273 *  "Must also have options" and "Incompatible options":
274 */
275tSCC    zAdjtimeText[] =
276        "Set (slew) the time with adjtime()";
277tSCC    zAdjtime_NAME[]            = "ADJTIME";
278tSCC    zAdjtime_Name[]            = "adjtime";
279static const int
280    aAdjtimeCantList[] = {
281    INDEX_OPT_SETTIMEOFDAY, NO_EQUIVALENT };
282#define ADJTIME_FLAGS       (OPTST_DISABLED)
283
284/*
285 *  Help/More_Help/Version option descriptions:
286 */
287tSCC zHelpText[]       = "Display usage information and exit";
288tSCC zHelp_Name[]      = "help";
289
290tSCC zMore_HelpText[]  = "Extended usage information passed thru pager";
291tSCC zMore_Help_Name[] = "more-help";
292
293tSCC zVersionText[]    = "Output version information and exit";
294tSCC zVersion_Name[]   = "version";
295
296/*
297 *  Save/Load_Opts option description:
298 */
299tSCC zSave_OptsText[]     = "Save the option state to a config file";
300tSCC zSave_Opts_Name[]    = "save-opts";
301
302tSCC zLoad_OptsText[]     = "Load options from a config file";
303tSCC zLoad_Opts_NAME[]    = "LOAD_OPTS";
304
305tSCC zNotLoad_Opts_Name[] = "no-load-opts";
306tSCC zNotLoad_Opts_Pfx[]  = "no";
307#define zLoad_Opts_Name   (zNotLoad_Opts_Name + 3)
308/*
309 *  Declare option callback procedures
310 */
311#if defined(TEST_SNTP_OPTS)
312/*
313 *  Under test, omit argument processing, or call optionStackArg,
314 *  if multiple copies are allowed.
315 */
316extern tOptProc
317    optionPagedUsage, optionVersionStderr;
318static tOptProc
319    doUsageOpt;
320
321#else /* NOT defined TEST_SNTP_OPTS */
322/*
323 *  When not under test, there are different procs to use
324 */
325extern tOptProc
326    optionPagedUsage, optionPrintVersion;
327static tOptProc
328    doUsageOpt;
329#endif /* defined(TEST_SNTP_OPTS) */
330#ifdef TEST_SNTP_OPTS
331# define DOVERPROC optionVersionStderr
332#else
333# define DOVERPROC optionPrintVersion
334#endif /* TEST_SNTP_OPTS */
335
336/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
337 *
338 *  Define the Sntp Option Descriptions.
339 */
340static tOptDesc optDesc[ OPTION_CT ] = {
341  {  /* entry idx, value */ 0, VALUE_OPT_IPV4,
342     /* equiv idx, value */ NO_EQUIVALENT, 0,
343     /* equivalenced to  */ NO_EQUIVALENT,
344     /* min, max, act ct */ 0, 1, 0,
345     /* opt state flags  */ IPV4_FLAGS, 0,
346     /* last opt argumnt */ { NULL },
347     /* arg list/cookie  */ NULL,
348     /* must/cannot opts */ NULL, NULL,
349     /* option proc      */ NULL,
350     /* desc, NAME, name */ zIpv4Text, zIpv4_NAME, zIpv4_Name,
351     /* disablement strs */ NULL, NULL },
352
353  {  /* entry idx, value */ 1, VALUE_OPT_IPV6,
354     /* equiv idx, value */ NOLIMIT, NOLIMIT,
355     /* equivalenced to  */ INDEX_OPT_IPV4,
356     /* min, max, act ct */ 0, 1, 0,
357     /* opt state flags  */ IPV6_FLAGS, 0,
358     /* last opt argumnt */ { NULL },
359     /* arg list/cookie  */ NULL,
360     /* must/cannot opts */ NULL, NULL,
361     /* option proc      */ NULL,
362     /* desc, NAME, name */ zIpv6Text, zIpv6_NAME, zIpv6_Name,
363     /* disablement strs */ NULL, NULL },
364
365  {  /* entry idx, value */ 2, VALUE_OPT_UNPRIVPORT,
366     /* equiv idx, value */ 2, VALUE_OPT_UNPRIVPORT,
367     /* equivalenced to  */ NO_EQUIVALENT,
368     /* min, max, act ct */ 0, 1, 0,
369     /* opt state flags  */ UNPRIVPORT_FLAGS, 0,
370     /* last opt argumnt */ { NULL },
371     /* arg list/cookie  */ NULL,
372     /* must/cannot opts */ NULL, NULL,
373     /* option proc      */ NULL,
374     /* desc, NAME, name */ zUnprivportText, zUnprivport_NAME, zUnprivport_Name,
375     /* disablement strs */ NULL, NULL },
376
377  {  /* entry idx, value */ 3, VALUE_OPT_NORMALVERBOSE,
378     /* equiv idx, value */ 3, VALUE_OPT_NORMALVERBOSE,
379     /* equivalenced to  */ NO_EQUIVALENT,
380     /* min, max, act ct */ 0, 1, 0,
381     /* opt state flags  */ NORMALVERBOSE_FLAGS, 0,
382     /* last opt argumnt */ { NULL },
383     /* arg list/cookie  */ NULL,
384     /* must/cannot opts */ NULL, aNormalverboseCantList,
385     /* option proc      */ NULL,
386     /* desc, NAME, name */ zNormalverboseText, zNormalverbose_NAME, zNormalverbose_Name,
387     /* disablement strs */ NULL, NULL },
388
389  {  /* entry idx, value */ 4, VALUE_OPT_EXTRAVERBOSE,
390     /* equiv idx, value */ 4, VALUE_OPT_EXTRAVERBOSE,
391     /* equivalenced to  */ NO_EQUIVALENT,
392     /* min, max, act ct */ 0, 1, 0,
393     /* opt state flags  */ EXTRAVERBOSE_FLAGS, 0,
394     /* last opt argumnt */ { NULL },
395     /* arg list/cookie  */ NULL,
396     /* must/cannot opts */ NULL, aExtraverboseCantList,
397     /* option proc      */ NULL,
398     /* desc, NAME, name */ zExtraverboseText, zExtraverbose_NAME, zExtraverbose_Name,
399     /* disablement strs */ NULL, NULL },
400
401  {  /* entry idx, value */ 5, VALUE_OPT_MEGAVERBOSE,
402     /* equiv idx, value */ 5, VALUE_OPT_MEGAVERBOSE,
403     /* equivalenced to  */ NO_EQUIVALENT,
404     /* min, max, act ct */ 0, 1, 0,
405     /* opt state flags  */ MEGAVERBOSE_FLAGS, 0,
406     /* last opt argumnt */ { NULL },
407     /* arg list/cookie  */ NULL,
408     /* must/cannot opts */ NULL, aMegaverboseCantList,
409     /* option proc      */ NULL,
410     /* desc, NAME, name */ zMegaverboseText, zMegaverbose_NAME, zMegaverbose_Name,
411     /* disablement strs */ NULL, NULL },
412
413  {  /* entry idx, value */ 6, VALUE_OPT_SETTIMEOFDAY,
414     /* equiv idx, value */ 6, VALUE_OPT_SETTIMEOFDAY,
415     /* equivalenced to  */ NO_EQUIVALENT,
416     /* min, max, act ct */ 0, 1, 0,
417     /* opt state flags  */ SETTIMEOFDAY_FLAGS, 0,
418     /* last opt argumnt */ { NULL },
419     /* arg list/cookie  */ NULL,
420     /* must/cannot opts */ NULL, aSettimeofdayCantList,
421     /* option proc      */ NULL,
422     /* desc, NAME, name */ zSettimeofdayText, zSettimeofday_NAME, zSettimeofday_Name,
423     /* disablement strs */ NULL, NULL },
424
425  {  /* entry idx, value */ 7, VALUE_OPT_ADJTIME,
426     /* equiv idx, value */ 7, VALUE_OPT_ADJTIME,
427     /* equivalenced to  */ NO_EQUIVALENT,
428     /* min, max, act ct */ 0, 1, 0,
429     /* opt state flags  */ ADJTIME_FLAGS, 0,
430     /* last opt argumnt */ { NULL },
431     /* arg list/cookie  */ NULL,
432     /* must/cannot opts */ NULL, aAdjtimeCantList,
433     /* option proc      */ NULL,
434     /* desc, NAME, name */ zAdjtimeText, zAdjtime_NAME, zAdjtime_Name,
435     /* disablement strs */ NULL, NULL },
436
437#ifdef NO_OPTIONAL_OPT_ARGS
438#  define VERSION_OPT_FLAGS     OPTST_IMM | OPTST_NO_INIT
439#else
440#  define VERSION_OPT_FLAGS     OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
441                                OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT
442#endif
443
444  {  /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
445     /* equiv idx value  */ NO_EQUIVALENT, 0,
446     /* equivalenced to  */ NO_EQUIVALENT,
447     /* min, max, act ct */ 0, 1, 0,
448     /* opt state flags  */ VERSION_OPT_FLAGS, 0,
449     /* last opt argumnt */ { NULL },
450     /* arg list/cookie  */ NULL,
451     /* must/cannot opts */ NULL, NULL,
452     /* option proc      */ DOVERPROC,
453     /* desc, NAME, name */ zVersionText, NULL, zVersion_Name,
454     /* disablement strs */ NULL, NULL },
455
456#undef VERSION_OPT_FLAGS
457
458
459  {  /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
460     /* equiv idx value  */ NO_EQUIVALENT, 0,
461     /* equivalenced to  */ NO_EQUIVALENT,
462     /* min, max, act ct */ 0, 1, 0,
463     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
464     /* last opt argumnt */ { NULL },
465     /* arg list/cookie  */ NULL,
466     /* must/cannot opts */ NULL, NULL,
467     /* option proc      */ doUsageOpt,
468     /* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
469     /* disablement strs */ NULL, NULL },
470
471  {  /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
472     /* equiv idx value  */ NO_EQUIVALENT, 0,
473     /* equivalenced to  */ NO_EQUIVALENT,
474     /* min, max, act ct */ 0, 1, 0,
475     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
476     /* last opt argumnt */ { NULL },
477     /* arg list/cookie  */ NULL,
478     /* must/cannot opts */ NULL,  NULL,
479     /* option proc      */ optionPagedUsage,
480     /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name,
481     /* disablement strs */ NULL, NULL },
482
483  {  /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS,
484     /* equiv idx value  */ NO_EQUIVALENT, 0,
485     /* equivalenced to  */ NO_EQUIVALENT,
486     /* min, max, act ct */ 0, 1, 0,
487     /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
488                          | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0,
489     /* last opt argumnt */ { NULL },
490     /* arg list/cookie  */ NULL,
491     /* must/cannot opts */ NULL,  NULL,
492     /* option proc      */ NULL,
493     /* desc, NAME, name */ zSave_OptsText, NULL, zSave_Opts_Name,
494     /* disablement strs */ NULL, NULL },
495
496  {  /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS,
497     /* equiv idx value  */ NO_EQUIVALENT, 0,
498     /* equivalenced to  */ NO_EQUIVALENT,
499     /* min, max, act ct */ 0, NOLIMIT, 0,
500     /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) \
501			  | OPTST_DISABLE_IMM, 0,
502     /* last opt argumnt */ { NULL },
503     /* arg list/cookie  */ NULL,
504     /* must/cannot opts */ NULL, NULL,
505     /* option proc      */ optionLoadOpt,
506     /* desc, NAME, name */ zLoad_OptsText, zLoad_Opts_NAME, zLoad_Opts_Name,
507     /* disablement strs */ zNotLoad_Opts_Name, zNotLoad_Opts_Pfx }
508};
509
510/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
511 *
512 *  Define the Sntp Option Environment
513 */
514tSCC   zPROGNAME[]   = "SNTP";
515tSCC   zUsageTitle[] =
516"sntp - standard SNTP program - Ver. 4.2.4p8\n\
517USAGE:  %s [ -<flag> | --<name> ]...\n";
518tSCC   zRcName[]     = ".ntprc";
519tSCC*  apzHomeList[] = {
520       "$HOME",
521       ".",
522       NULL };
523
524tSCC   zBugsAddr[]    = "http://bugs.ntp.org, bugs@ntp.org";
525#define zExplain NULL
526tSCC    zDetail[]     = "\n\
527.I sntp\n\
528can be used as a SNTP client to query a NTP or SNTP server and either display\n\
529the time or set the local system's time (given suitable privilege).  It can be\n\
530run as an interactive command or in a\n\
531.I cron\n\
532job.\n\
533NTP is the Network Time Protocol (RFC 1305) and SNTP is the\n\
534Simple Network Time Protocol (RFC 2030, which supersedes RFC 1769).\n";
535tSCC    zFullVersion[] = SNTP_FULL_VERSION;
536/* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optcode.tpl near line 408 */
537
538#if defined(ENABLE_NLS)
539# define OPTPROC_BASE OPTPROC_TRANSLATE
540  static tOptionXlateProc translate_option_strings;
541#else
542# define OPTPROC_BASE OPTPROC_NONE
543# define translate_option_strings NULL
544#endif /* ENABLE_NLS */
545
546tOptions sntpOptions = {
547    OPTIONS_STRUCT_VERSION,
548    0, NULL,                    /* original argc + argv    */
549    ( OPTPROC_BASE
550    + OPTPROC_ERRSTOP
551    + OPTPROC_SHORTOPT
552    + OPTPROC_LONGOPT
553    + OPTPROC_NO_REQ_OPT
554    + OPTPROC_ENVIRON
555    + OPTPROC_NO_ARGS
556    + OPTPROC_HAS_IMMED ),
557    0, NULL,                    /* current option index, current option */
558    NULL,         NULL,         zPROGNAME,
559    zRcName,      zCopyright,   zCopyrightNotice,
560    zFullVersion, apzHomeList,  zUsageTitle,
561    zExplain,     zDetail,      optDesc,
562    zBugsAddr,                  /* address to send bugs to */
563    NULL, NULL,                 /* extensions/saved state  */
564    optionUsage,       /* usage procedure */
565    translate_option_strings,   /* translation procedure */
566    /*
567     *  Indexes to special options
568     */
569    { INDEX_OPT_MORE_HELP,
570      INDEX_OPT_SAVE_OPTS,
571      NO_EQUIVALENT /* index of '-#' option */,
572      NO_EQUIVALENT /* index of default opt */
573    },
574    13 /* full option count */, 8 /* user option count */
575};
576
577/*
578 *  Create the static procedure(s) declared above.
579 */
580static void
581doUsageOpt(
582    tOptions*   pOptions,
583    tOptDesc*   pOptDesc )
584{
585    USAGE( EXIT_SUCCESS );
586}
587/* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optmain.tpl near line 92 */
588
589#if defined(TEST_SNTP_OPTS) /* TEST MAIN PROCEDURE: */
590
591int
592main( int argc, char** argv )
593{
594    int res = EXIT_SUCCESS;
595    (void)optionProcess( &sntpOptions, argc, argv );
596    {
597        void optionPutShell( tOptions* );
598        optionPutShell( &sntpOptions );
599    }
600    return res;
601}
602#endif  /* defined TEST_SNTP_OPTS */
603/* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optcode.tpl near line 514 */
604
605#if ENABLE_NLS
606#include <stdio.h>
607#include <stdlib.h>
608#include <string.h>
609#include <unistd.h>
610#include <autoopts/usage-txt.h>
611
612static char* AO_gettext( char const* pz );
613static void  coerce_it(void** s);
614
615static char*
616AO_gettext( char const* pz )
617{
618    char* pzRes;
619    if (pz == NULL)
620        return NULL;
621    pzRes = _(pz);
622    if (pzRes == pz)
623        return pzRes;
624    pzRes = strdup( pzRes );
625    if (pzRes == NULL) {
626        fputs( _("No memory for duping translated strings\n"), stderr );
627        exit( EXIT_FAILURE );
628    }
629    return pzRes;
630}
631
632static void coerce_it(void** s) { *s = AO_gettext(*s); }
633#define COERSION(_f) \
634  coerce_it((void*)&(sntpOptions._f))
635
636/*
637 *  This invokes the translation code (e.g. gettext(3)).
638 */
639static void
640translate_option_strings( void )
641{
642    /*
643     *  Guard against re-translation.  It won't work.  The strings will have
644     *  been changed by the first pass through this code.  One shot only.
645     */
646    if (option_usage_text.field_ct == 0)
647        return;
648    /*
649     *  Do the translations.  The first pointer follows the field count field.
650     *  The field count field is the size of a pointer.
651     */
652    {
653        char** ppz = (char**)(void*)&(option_usage_text);
654        int    ix  = option_usage_text.field_ct;
655
656        do {
657            ppz++;
658            *ppz = AO_gettext(*ppz);
659        } while (--ix > 0);
660    }
661    option_usage_text.field_ct = 0;
662
663    {
664        tOptDesc* pOD = sntpOptions.pOptDesc;
665        int       ix  = sntpOptions.optCt;
666
667        for (;;) {
668            pOD->pzText           = AO_gettext(pOD->pzText);
669            pOD->pz_NAME          = AO_gettext(pOD->pz_NAME);
670            pOD->pz_Name          = AO_gettext(pOD->pz_Name);
671            pOD->pz_DisableName   = AO_gettext(pOD->pz_DisableName);
672            pOD->pz_DisablePfx    = AO_gettext(pOD->pz_DisablePfx);
673            if (--ix <= 0)
674                break;
675            pOD++;
676        }
677    }
678    COERSION(pzCopyright);
679    COERSION(pzCopyNotice);
680    COERSION(pzFullVersion);
681    COERSION(pzUsageTitle);
682    COERSION(pzExplain);
683    COERSION(pzDetail);
684}
685
686#endif /* ENABLE_NLS */
687
688#ifdef  __cplusplus
689}
690#endif
691/* sntp-opts.c ends here */