/contrib/ntp/ntpdc/ntpdc-opts.c

https://bitbucket.org/freebsd/freebsd-head/ · C · 667 lines · 480 code · 69 blank · 118 comment · 11 complexity · 0a1d648ca9fe6ac779580e48838f537d MD5 · raw file

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