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