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