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