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