1 /* $NetBSD: ntpdc-opts.c,v 1.1.1.1 2009/12/13 16:56:26 kardel Exp $ */ 2 3 /* 4 * EDIT THIS FILE WITH CAUTION (ntpdc-opts.c) 5 * 6 * It has been AutoGen-ed December 10, 2009 at 05:02:36 AM by AutoGen 5.10 7 * From the definitions ntpdc-opts.def 8 * and the template file options 9 * 10 * Generated from AutoOpts 33:0:8 templates. 11 */ 12 13 /* 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 * ntpdc 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. 21 * 22 * This source file is copyrighted and licensed under the following terms: 23 * 24 * ntpdc copyright (c) 1970-2009 David L. Mills and/or others - all rights reserved 25 * 26 * see html/copyright.html 27 */ 28 29 #include <sys/types.h> 30 #include <limits.h> 31 #include <stdio.h> 32 #include <stdlib.h> 33 34 #define OPTION_CODE_COMPILE 1 35 #include "ntpdc-opts.h" 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 /* TRANSLATORS: choose the translation for option names wisely because you 42 cannot ever change your mind. */ 43 tSCC zCopyright[] = 44 "ntpdc copyright (c) 1970-2009 David L. Mills and/or others, all rights reserved" 45 /* extracted from ../include/copyright.def near line 8 */ 46 ; 47 tSCC zCopyrightNotice[24] = 48 "see html/copyright.html"; 49 50 extern tUsageProc optionUsage; 51 52 /* 53 * global included definitions 54 */ 55 #ifdef __windows 56 extern int atoi(const char*); 57 #else 58 # include <stdlib.h> 59 #endif 60 61 #ifndef NULL 62 # define NULL 0 63 #endif 64 #ifndef EXIT_SUCCESS 65 # define EXIT_SUCCESS 0 66 #endif 67 #ifndef EXIT_FAILURE 68 # define EXIT_FAILURE 1 69 #endif 70 71 /* 72 * Ipv4 option description with 73 * "Must also have options" and "Incompatible options": 74 */ 75 tSCC zIpv4Text[] = 76 "Force IPv4 DNS name resolution"; 77 tSCC zIpv4_NAME[] = "IPV4"; 78 tSCC zIpv4_Name[] = "ipv4"; 79 static const int 80 aIpv4CantList[] = { 81 INDEX_OPT_IPV6, NO_EQUIVALENT }; 82 #define IPV4_FLAGS (OPTST_DISABLED) 83 84 /* 85 * Ipv6 option description with 86 * "Must also have options" and "Incompatible options": 87 */ 88 tSCC zIpv6Text[] = 89 "Force IPv6 DNS name resolution"; 90 tSCC zIpv6_NAME[] = "IPV6"; 91 tSCC zIpv6_Name[] = "ipv6"; 92 static const int 93 aIpv6CantList[] = { 94 INDEX_OPT_IPV4, NO_EQUIVALENT }; 95 #define IPV6_FLAGS (OPTST_DISABLED) 96 97 /* 98 * Command option description: 99 */ 100 tSCC zCommandText[] = 101 "run a command and exit"; 102 tSCC zCommand_NAME[] = "COMMAND"; 103 tSCC zCommand_Name[] = "command"; 104 #define COMMAND_FLAGS (OPTST_DISABLED | OPTST_STACKED \ 105 | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) 106 107 /* 108 * Listpeers option description with 109 * "Must also have options" and "Incompatible options": 110 */ 111 tSCC zListpeersText[] = 112 "Print a list of the peers"; 113 tSCC zListpeers_NAME[] = "LISTPEERS"; 114 tSCC zListpeers_Name[] = "listpeers"; 115 static const int 116 aListpeersCantList[] = { 117 INDEX_OPT_COMMAND, NO_EQUIVALENT }; 118 #define LISTPEERS_FLAGS (OPTST_DISABLED) 119 120 /* 121 * Peers option description with 122 * "Must also have options" and "Incompatible options": 123 */ 124 tSCC zPeersText[] = 125 "Print a list of the peers"; 126 tSCC zPeers_NAME[] = "PEERS"; 127 tSCC zPeers_Name[] = "peers"; 128 static const int 129 aPeersCantList[] = { 130 INDEX_OPT_COMMAND, NO_EQUIVALENT }; 131 #define PEERS_FLAGS (OPTST_DISABLED) 132 133 /* 134 * Showpeers option description with 135 * "Must also have options" and "Incompatible options": 136 */ 137 tSCC zShowpeersText[] = 138 "Show a list of the peers"; 139 tSCC zShowpeers_NAME[] = "SHOWPEERS"; 140 tSCC zShowpeers_Name[] = "showpeers"; 141 static const int 142 aShowpeersCantList[] = { 143 INDEX_OPT_COMMAND, NO_EQUIVALENT }; 144 #define SHOWPEERS_FLAGS (OPTST_DISABLED) 145 146 /* 147 * Interactive option description with 148 * "Must also have options" and "Incompatible options": 149 */ 150 tSCC zInteractiveText[] = 151 "Force ntpq to operate in interactive mode"; 152 tSCC zInteractive_NAME[] = "INTERACTIVE"; 153 tSCC zInteractive_Name[] = "interactive"; 154 static const int 155 aInteractiveCantList[] = { 156 INDEX_OPT_COMMAND, 157 INDEX_OPT_LISTPEERS, 158 INDEX_OPT_PEERS, 159 INDEX_OPT_SHOWPEERS, NO_EQUIVALENT }; 160 #define INTERACTIVE_FLAGS (OPTST_DISABLED) 161 162 /* 163 * Debug_Level option description: 164 */ 165 tSCC zDebug_LevelText[] = 166 "Increase output debug message level"; 167 tSCC zDebug_Level_NAME[] = "DEBUG_LEVEL"; 168 tSCC zDebug_Level_Name[] = "debug-level"; 169 #define DEBUG_LEVEL_FLAGS (OPTST_DISABLED) 170 171 /* 172 * Set_Debug_Level option description: 173 */ 174 tSCC zSet_Debug_LevelText[] = 175 "Set the output debug message level"; 176 tSCC zSet_Debug_Level_NAME[] = "SET_DEBUG_LEVEL"; 177 tSCC zSet_Debug_Level_Name[] = "set-debug-level"; 178 #define SET_DEBUG_LEVEL_FLAGS (OPTST_DISABLED \ 179 | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) 180 181 /* 182 * Numeric option description: 183 */ 184 tSCC zNumericText[] = 185 "numeric host addresses"; 186 tSCC zNumeric_NAME[] = "NUMERIC"; 187 tSCC zNumeric_Name[] = "numeric"; 188 #define NUMERIC_FLAGS (OPTST_DISABLED) 189 190 /* 191 * Help/More_Help/Version option descriptions: 192 */ 193 tSCC zHelpText[] = "Display extended usage information and exit"; 194 tSCC zHelp_Name[] = "help"; 195 #ifdef HAVE_WORKING_FORK 196 #define OPTST_MORE_HELP_FLAGS (OPTST_IMM | OPTST_NO_INIT) 197 tSCC zMore_Help_Name[] = "more-help"; 198 tSCC zMore_HelpText[] = "Extended usage information passed thru pager"; 199 #else 200 #define OPTST_MORE_HELP_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) 201 #define zMore_Help_Name NULL 202 #define zMore_HelpText NULL 203 #endif 204 #ifdef NO_OPTIONAL_OPT_ARGS 205 # define OPTST_VERSION_FLAGS OPTST_IMM | OPTST_NO_INIT 206 #else 207 # define OPTST_VERSION_FLAGS OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \ 208 OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT 209 #endif 210 211 tSCC zVersionText[] = "Output version information and exit"; 212 tSCC zVersion_Name[] = "version"; 213 tSCC zSave_OptsText[] = "Save the option state to a config file"; 214 tSCC zSave_Opts_Name[] = "save-opts"; 215 tSCC zLoad_OptsText[] = "Load options from a config file"; 216 tSCC zLoad_Opts_NAME[] = "LOAD_OPTS"; 217 tSCC zNotLoad_Opts_Name[] = "no-load-opts"; 218 tSCC zNotLoad_Opts_Pfx[] = "no"; 219 #define zLoad_Opts_Name (zNotLoad_Opts_Name + 3) 220 /* 221 * Declare option callback procedures 222 */ 223 #if defined(TEST_NTPDC_OPTS) 224 /* 225 * Under test, omit argument processing, or call optionStackArg, 226 * if multiple copies are allowed. 227 */ 228 extern tOptProc 229 optionPagedUsage, optionStackArg, optionVersionStderr; 230 static tOptProc 231 doUsageOpt; 232 233 /* 234 * #define map the "normal" callout procs to the test ones... 235 */ 236 #define SET_DEBUG_LEVEL_OPT_PROC optionStackArg 237 238 239 #else /* NOT defined TEST_NTPDC_OPTS */ 240 /* 241 * When not under test, there are different procs to use 242 */ 243 extern tOptProc 244 optionPagedUsage, optionPrintVersion, optionStackArg; 245 static tOptProc 246 doOptSet_Debug_Level, doUsageOpt; 247 248 /* 249 * #define map the "normal" callout procs 250 */ 251 #define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level 252 253 #define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level 254 #endif /* defined(TEST_NTPDC_OPTS) */ 255 #ifdef TEST_NTPDC_OPTS 256 # define DOVERPROC optionVersionStderr 257 #else 258 # define DOVERPROC optionPrintVersion 259 #endif /* TEST_NTPDC_OPTS */ 260 261 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 262 * 263 * Define the Ntpdc Option Descriptions. 264 */ 265 static tOptDesc optDesc[ OPTION_CT ] = { 266 { /* entry idx, value */ 0, VALUE_OPT_IPV4, 267 /* equiv idx, value */ 0, VALUE_OPT_IPV4, 268 /* equivalenced to */ NO_EQUIVALENT, 269 /* min, max, act ct */ 0, 1, 0, 270 /* opt state flags */ IPV4_FLAGS, 0, 271 /* last opt argumnt */ { NULL }, 272 /* arg list/cookie */ NULL, 273 /* must/cannot opts */ NULL, aIpv4CantList, 274 /* option proc */ NULL, 275 /* desc, NAME, name */ zIpv4Text, zIpv4_NAME, zIpv4_Name, 276 /* disablement strs */ NULL, NULL }, 277 278 { /* entry idx, value */ 1, VALUE_OPT_IPV6, 279 /* equiv idx, value */ 1, VALUE_OPT_IPV6, 280 /* equivalenced to */ NO_EQUIVALENT, 281 /* min, max, act ct */ 0, 1, 0, 282 /* opt state flags */ IPV6_FLAGS, 0, 283 /* last opt argumnt */ { NULL }, 284 /* arg list/cookie */ NULL, 285 /* must/cannot opts */ NULL, aIpv6CantList, 286 /* option proc */ NULL, 287 /* desc, NAME, name */ zIpv6Text, zIpv6_NAME, zIpv6_Name, 288 /* disablement strs */ NULL, NULL }, 289 290 { /* entry idx, value */ 2, VALUE_OPT_COMMAND, 291 /* equiv idx, value */ 2, VALUE_OPT_COMMAND, 292 /* equivalenced to */ NO_EQUIVALENT, 293 /* min, max, act ct */ 0, NOLIMIT, 0, 294 /* opt state flags */ COMMAND_FLAGS, 0, 295 /* last opt argumnt */ { NULL }, 296 /* arg list/cookie */ NULL, 297 /* must/cannot opts */ NULL, NULL, 298 /* option proc */ optionStackArg, 299 /* desc, NAME, name */ zCommandText, zCommand_NAME, zCommand_Name, 300 /* disablement strs */ NULL, NULL }, 301 302 { /* entry idx, value */ 3, VALUE_OPT_LISTPEERS, 303 /* equiv idx, value */ 3, VALUE_OPT_LISTPEERS, 304 /* equivalenced to */ NO_EQUIVALENT, 305 /* min, max, act ct */ 0, 1, 0, 306 /* opt state flags */ LISTPEERS_FLAGS, 0, 307 /* last opt argumnt */ { NULL }, 308 /* arg list/cookie */ NULL, 309 /* must/cannot opts */ NULL, aListpeersCantList, 310 /* option proc */ NULL, 311 /* desc, NAME, name */ zListpeersText, zListpeers_NAME, zListpeers_Name, 312 /* disablement strs */ NULL, NULL }, 313 314 { /* entry idx, value */ 4, VALUE_OPT_PEERS, 315 /* equiv idx, value */ 4, VALUE_OPT_PEERS, 316 /* equivalenced to */ NO_EQUIVALENT, 317 /* min, max, act ct */ 0, 1, 0, 318 /* opt state flags */ PEERS_FLAGS, 0, 319 /* last opt argumnt */ { NULL }, 320 /* arg list/cookie */ NULL, 321 /* must/cannot opts */ NULL, aPeersCantList, 322 /* option proc */ NULL, 323 /* desc, NAME, name */ zPeersText, zPeers_NAME, zPeers_Name, 324 /* disablement strs */ NULL, NULL }, 325 326 { /* entry idx, value */ 5, VALUE_OPT_SHOWPEERS, 327 /* equiv idx, value */ 5, VALUE_OPT_SHOWPEERS, 328 /* equivalenced to */ NO_EQUIVALENT, 329 /* min, max, act ct */ 0, 1, 0, 330 /* opt state flags */ SHOWPEERS_FLAGS, 0, 331 /* last opt argumnt */ { NULL }, 332 /* arg list/cookie */ NULL, 333 /* must/cannot opts */ NULL, aShowpeersCantList, 334 /* option proc */ NULL, 335 /* desc, NAME, name */ zShowpeersText, zShowpeers_NAME, zShowpeers_Name, 336 /* disablement strs */ NULL, NULL }, 337 338 { /* entry idx, value */ 6, VALUE_OPT_INTERACTIVE, 339 /* equiv idx, value */ 6, VALUE_OPT_INTERACTIVE, 340 /* equivalenced to */ NO_EQUIVALENT, 341 /* min, max, act ct */ 0, 1, 0, 342 /* opt state flags */ INTERACTIVE_FLAGS, 0, 343 /* last opt argumnt */ { NULL }, 344 /* arg list/cookie */ NULL, 345 /* must/cannot opts */ NULL, aInteractiveCantList, 346 /* option proc */ NULL, 347 /* desc, NAME, name */ zInteractiveText, zInteractive_NAME, zInteractive_Name, 348 /* disablement strs */ NULL, NULL }, 349 350 { /* entry idx, value */ 7, VALUE_OPT_DEBUG_LEVEL, 351 /* equiv idx, value */ 7, VALUE_OPT_DEBUG_LEVEL, 352 /* equivalenced to */ NO_EQUIVALENT, 353 /* min, max, act ct */ 0, NOLIMIT, 0, 354 /* opt state flags */ DEBUG_LEVEL_FLAGS, 0, 355 /* last opt argumnt */ { NULL }, 356 /* arg list/cookie */ NULL, 357 /* must/cannot opts */ NULL, NULL, 358 /* option proc */ NULL, 359 /* desc, NAME, name */ zDebug_LevelText, zDebug_Level_NAME, zDebug_Level_Name, 360 /* disablement strs */ NULL, NULL }, 361 362 { /* entry idx, value */ 8, VALUE_OPT_SET_DEBUG_LEVEL, 363 /* equiv idx, value */ 8, VALUE_OPT_SET_DEBUG_LEVEL, 364 /* equivalenced to */ NO_EQUIVALENT, 365 /* min, max, act ct */ 0, NOLIMIT, 0, 366 /* opt state flags */ SET_DEBUG_LEVEL_FLAGS, 0, 367 /* last opt argumnt */ { NULL }, 368 /* arg list/cookie */ NULL, 369 /* must/cannot opts */ NULL, NULL, 370 /* option proc */ SET_DEBUG_LEVEL_OPT_PROC, 371 /* desc, NAME, name */ zSet_Debug_LevelText, zSet_Debug_Level_NAME, zSet_Debug_Level_Name, 372 /* disablement strs */ NULL, NULL }, 373 374 { /* entry idx, value */ 9, VALUE_OPT_NUMERIC, 375 /* equiv idx, value */ 9, VALUE_OPT_NUMERIC, 376 /* equivalenced to */ NO_EQUIVALENT, 377 /* min, max, act ct */ 0, 1, 0, 378 /* opt state flags */ NUMERIC_FLAGS, 0, 379 /* last opt argumnt */ { NULL }, 380 /* arg list/cookie */ NULL, 381 /* must/cannot opts */ NULL, NULL, 382 /* option proc */ NULL, 383 /* desc, NAME, name */ zNumericText, zNumeric_NAME, zNumeric_Name, 384 /* disablement strs */ NULL, NULL }, 385 386 { /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION, 387 /* equiv idx value */ NO_EQUIVALENT, 0, 388 /* equivalenced to */ NO_EQUIVALENT, 389 /* min, max, act ct */ 0, 1, 0, 390 /* opt state flags */ OPTST_VERSION_FLAGS, 0, 391 /* last opt argumnt */ { NULL }, 392 /* arg list/cookie */ NULL, 393 /* must/cannot opts */ NULL, NULL, 394 /* option proc */ DOVERPROC, 395 /* desc, NAME, name */ zVersionText, NULL, zVersion_Name, 396 /* disablement strs */ NULL, NULL }, 397 398 399 400 { /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP, 401 /* equiv idx value */ NO_EQUIVALENT, 0, 402 /* equivalenced to */ NO_EQUIVALENT, 403 /* min, max, act ct */ 0, 1, 0, 404 /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0, 405 /* last opt argumnt */ { NULL }, 406 /* arg list/cookie */ NULL, 407 /* must/cannot opts */ NULL, NULL, 408 /* option proc */ doUsageOpt, 409 /* desc, NAME, name */ zHelpText, NULL, zHelp_Name, 410 /* disablement strs */ NULL, NULL }, 411 412 { /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP, 413 /* equiv idx value */ NO_EQUIVALENT, 0, 414 /* equivalenced to */ NO_EQUIVALENT, 415 /* min, max, act ct */ 0, 1, 0, 416 /* opt state flags */ OPTST_MORE_HELP_FLAGS, 0, 417 /* last opt argumnt */ { NULL }, 418 /* arg list/cookie */ NULL, 419 /* must/cannot opts */ NULL, NULL, 420 /* option proc */ optionPagedUsage, 421 /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name, 422 /* disablement strs */ NULL, NULL }, 423 424 { /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS, 425 /* equiv idx value */ NO_EQUIVALENT, 0, 426 /* equivalenced to */ NO_EQUIVALENT, 427 /* min, max, act ct */ 0, 1, 0, 428 /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) 429 | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0, 430 /* last opt argumnt */ { NULL }, 431 /* arg list/cookie */ NULL, 432 /* must/cannot opts */ NULL, NULL, 433 /* option proc */ NULL, 434 /* desc, NAME, name */ zSave_OptsText, NULL, zSave_Opts_Name, 435 /* disablement strs */ NULL, NULL }, 436 437 { /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS, 438 /* equiv idx value */ NO_EQUIVALENT, 0, 439 /* equivalenced to */ NO_EQUIVALENT, 440 /* min, max, act ct */ 0, NOLIMIT, 0, 441 /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) 442 | OPTST_DISABLE_IMM, 0, 443 /* last opt argumnt */ { NULL }, 444 /* arg list/cookie */ NULL, 445 /* must/cannot opts */ NULL, NULL, 446 /* option proc */ optionLoadOpt, 447 /* desc, NAME, name */ zLoad_OptsText, zLoad_Opts_NAME, zLoad_Opts_Name, 448 /* disablement strs */ zNotLoad_Opts_Name, zNotLoad_Opts_Pfx } 449 }; 450 451 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 452 * 453 * Define the Ntpdc Option Environment 454 */ 455 tSCC zPROGNAME[] = "NTPDC"; 456 tSCC zUsageTitle[] = 457 "ntpdc - vendor-specific NTP query program - Ver. 4.2.6\n\ 458 USAGE: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [ host ...]\n"; 459 tSCC zRcName[] = ".ntprc"; 460 tSCC* apzHomeList[] = { 461 "$HOME", 462 ".", 463 NULL }; 464 465 tSCC zBugsAddr[] = "http://bugs.ntp.org, bugs@ntp.org"; 466 #define zExplain NULL 467 tSCC zDetail[] = "\n\ 468 The\n\ 469 [= prog-name =]\n\ 470 utility program is used to query an NTP daemon about its\n\ 471 current state and to request changes in that state.\n\ 472 It uses NTP mode 7 control message formats described in the source code.\n\ 473 The program may\n\ 474 be run either in interactive mode or controlled using command line\n\ 475 arguments.\n\ 476 Extensive state and statistics information is available\n\ 477 through the\n\ 478 [= prog-name =]\n\ 479 interface.\n\ 480 In addition, nearly all the\n\ 481 configuration options which can be specified at startup using\n\ 482 ntpd's configuration file may also be specified at run time using\n\ 483 [= prog-name =] .\n"; 484 tSCC zFullVersion[] = NTPDC_FULL_VERSION; 485 /* extracted from /usr/local/gnu/share/autogen/optcode.tpl near line 495 */ 486 487 #if defined(ENABLE_NLS) 488 # define OPTPROC_BASE OPTPROC_TRANSLATE 489 static tOptionXlateProc translate_option_strings; 490 #else 491 # define OPTPROC_BASE OPTPROC_NONE 492 # define translate_option_strings NULL 493 #endif /* ENABLE_NLS */ 494 495 496 #define ntpdc_full_usage NULL 497 #define ntpdc_short_usage NULL 498 tOptions ntpdcOptions = { 499 OPTIONS_STRUCT_VERSION, 500 0, NULL, /* original argc + argv */ 501 ( OPTPROC_BASE 502 + OPTPROC_ERRSTOP 503 + OPTPROC_SHORTOPT 504 + OPTPROC_LONGOPT 505 + OPTPROC_NO_REQ_OPT 506 + OPTPROC_ENVIRON ), 507 0, NULL, /* current option index, current option */ 508 NULL, NULL, zPROGNAME, 509 zRcName, zCopyright, zCopyrightNotice, 510 zFullVersion, apzHomeList, zUsageTitle, 511 zExplain, zDetail, optDesc, 512 zBugsAddr, /* address to send bugs to */ 513 NULL, NULL, /* extensions/saved state */ 514 optionUsage, /* usage procedure */ 515 translate_option_strings, /* translation procedure */ 516 /* 517 * Indexes to special options 518 */ 519 { INDEX_OPT_MORE_HELP, /* more-help option index */ 520 INDEX_OPT_SAVE_OPTS, /* save option index */ 521 NO_EQUIVALENT, /* '-#' option index */ 522 NO_EQUIVALENT /* index of default opt */ 523 }, 524 15 /* full option count */, 10 /* user option count */, 525 ntpdc_full_usage, ntpdc_short_usage, 526 NULL, NULL 527 }; 528 529 /* 530 * Create the static procedure(s) declared above. 531 */ 532 static void 533 doUsageOpt( 534 tOptions* pOptions, 535 tOptDesc* pOptDesc ) 536 { 537 (void)pOptions; 538 USAGE( EXIT_SUCCESS ); 539 } 540 541 #if ! defined(TEST_NTPDC_OPTS) 542 543 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 544 * 545 * For the set-debug-level option. 546 */ 547 static void 548 doOptSet_Debug_Level(tOptions* pOptions, tOptDesc* pOptDesc) 549 { 550 /* extracted from ../include/debug-opt.def, line 27 */ 551 DESC(DEBUG_LEVEL).optOccCt = atoi( pOptDesc->pzLastArg ); 552 } 553 #endif /* defined(TEST_NTPDC_OPTS) */ 554 /* extracted from /usr/local/gnu/share/autogen/optmain.tpl near line 109 */ 555 556 #if defined(TEST_NTPDC_OPTS) /* TEST MAIN PROCEDURE: */ 557 558 extern void optionPutShell( tOptions* ); 559 560 int 561 main(int argc, char** argv) 562 { 563 int res = EXIT_SUCCESS; 564 (void)optionProcess( &ntpdcOptions, argc, argv ); 565 optionPutShell( &ntpdcOptions ); 566 return res; 567 } 568 #endif /* defined TEST_NTPDC_OPTS */ 569 /* extracted from /usr/local/gnu/share/autogen/optcode.tpl near line 627 */ 570 571 #if ENABLE_NLS 572 #include <stdio.h> 573 #include <stdlib.h> 574 #include <string.h> 575 #include <unistd.h> 576 #include <autoopts/usage-txt.h> 577 578 static char* AO_gettext( char const* pz ); 579 static void coerce_it(void** s); 580 581 static char* 582 AO_gettext( char const* pz ) 583 { 584 char* pzRes; 585 if (pz == NULL) 586 return NULL; 587 pzRes = _(pz); 588 if (pzRes == pz) 589 return pzRes; 590 pzRes = strdup( pzRes ); 591 if (pzRes == NULL) { 592 fputs( _("No memory for duping translated strings\n"), stderr ); 593 exit( EXIT_FAILURE ); 594 } 595 return pzRes; 596 } 597 598 static void coerce_it(void** s) { *s = AO_gettext(*s); } 599 #define COERSION(_f) \ 600 coerce_it((void*)&(ntpdcOptions._f)) 601 602 /* 603 * This invokes the translation code (e.g. gettext(3)). 604 */ 605 static void 606 translate_option_strings( void ) 607 { 608 /* 609 * Guard against re-translation. It won't work. The strings will have 610 * been changed by the first pass through this code. One shot only. 611 */ 612 if (option_usage_text.field_ct != 0) { 613 614 /* 615 * Do the translations. The first pointer follows the field count 616 * field. The field count field is the size of a pointer. 617 */ 618 tOptDesc* pOD = ntpdcOptions.pOptDesc; 619 char** ppz = (char**)(void*)&(option_usage_text); 620 int ix = option_usage_text.field_ct; 621 622 do { 623 ppz++; 624 *ppz = AO_gettext(*ppz); 625 } while (--ix > 0); 626 627 COERSION(pzCopyright); 628 COERSION(pzCopyNotice); 629 COERSION(pzFullVersion); 630 COERSION(pzUsageTitle); 631 COERSION(pzExplain); 632 COERSION(pzDetail); 633 option_usage_text.field_ct = 0; 634 635 for (ix = ntpdcOptions.optCt; ix > 0; ix--, pOD++) 636 coerce_it((void*)&(pOD->pzText)); 637 } 638 639 if ((ntpdcOptions.fOptSet & OPTPROC_NXLAT_OPT_CFG) == 0) { 640 tOptDesc* pOD = ntpdcOptions.pOptDesc; 641 int ix; 642 643 for (ix = ntpdcOptions.optCt; ix > 0; ix--, pOD++) { 644 coerce_it((void*)&(pOD->pz_Name)); 645 coerce_it((void*)&(pOD->pz_DisableName)); 646 coerce_it((void*)&(pOD->pz_DisablePfx)); 647 } 648 /* prevent re-translation */ 649 ntpdcOptions.fOptSet |= OPTPROC_NXLAT_OPT_CFG | OPTPROC_NXLAT_OPT; 650 } 651 } 652 653 #endif /* ENABLE_NLS */ 654 655 #ifdef __cplusplus 656 } 657 #endif 658 /* ntpdc-opts.c ends here */ 659