/contrib/ntp/sntp/sntp-opts.c

https://bitbucket.org/freebsd/freebsd-head/ · C · 691 lines · 459 code · 54 blank · 178 comment · 11 complexity · 650f9f4969f707fcc4e1e5e0ebf54a04 MD5 · raw file

  1. /*
  2. * EDIT THIS FILE WITH CAUTION (sntp-opts.c)
  3. *
  4. * It has been AutoGen-ed Tuesday December 8, 2009 at 08:14:49 AM EST
  5. * From the definitions sntp-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. * sntp 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. * sntp copyright 1970-2006 ntp.org - all rights reserved
  22. *
  23. * General Public Licence for the software known as MSNTP
  24. * ------------------------------------------------------
  25. *
  26. * (c) Copyright, N.M. Maclaren, 1996, 1997, 2000
  27. * (c) Copyright, University of Cambridge, 1996, 1997, 2000
  28. *
  29. *
  30. *
  31. * Free use of MSNTP in source and binary forms is permitted, provided that this
  32. * entire licence is duplicated in all copies, and that any documentation,
  33. * announcements, and other materials related to use acknowledge that the software
  34. * was developed by N.M. Maclaren (hereafter refered to as the Author) at the
  35. * University of Cambridge. Neither the name of the Author nor the University of
  36. * Cambridge may be used to endorse or promote products derived from this material
  37. * without specific prior written permission.
  38. *
  39. * The Author and the University of Cambridge retain the copyright and all other
  40. * legal rights to the software and make it available non-exclusively. All users
  41. * must ensure that the software in all its derivations carries a copyright notice
  42. * in the form:
  43. * (c) Copyright N.M. Maclaren,
  44. * (c) Copyright University of Cambridge.
  45. *
  46. *
  47. *
  48. * NO WARRANTY
  49. *
  50. * Because the MSNTP software is licensed free of charge, the Author and the
  51. * University of Cambridge provide absolutely no warranty, either expressed or
  52. * implied, including, but not limited to, the implied warranties of
  53. * merchantability and fitness for a particular purpose. The entire risk as to
  54. * the quality and performance of the MSNTP software is with you. Should MSNTP
  55. * prove defective, you assume the cost of all necessary servicing or repair.
  56. *
  57. * In no event, unless required by law, will the Author or the University of
  58. * Cambridge, or any other party who may modify and redistribute this software as
  59. * permitted in accordance with the provisions below, be liable for damages for
  60. * any losses whatsoever, including but not limited to lost profits, lost monies,
  61. * lost or corrupted data, or other special, incidental or consequential losses
  62. * that may arise out of the use or inability to use the MSNTP software.
  63. *
  64. *
  65. *
  66. * COPYING POLICY
  67. *
  68. * Permission is hereby granted for copying and distribution of copies of the
  69. * MSNTP source and binary files, and of any part thereof, subject to the
  70. * following licence conditions:
  71. *
  72. * 1. You may distribute MSNTP or components of MSNTP, with or without additions
  73. * developed by you or by others. No charge, other than an "at-cost" distribution
  74. * fee, may be charged for copies, derivations, or distributions of this material
  75. * without the express written consent of the copyright holders.
  76. *
  77. * 2. You may also distribute MSNTP along with any other product for sale,
  78. * provided that the cost of the bundled package is the same regardless of whether
  79. * MSNTP is included or not, and provided that those interested only in MSNTP must
  80. * be notified that it is a product freely available from the University of
  81. * Cambridge.
  82. *
  83. * 3. If you distribute MSNTP software or parts of MSNTP, with or without
  84. * additions developed by you or others, then you must either make available the
  85. * source to all portions of the MSNTP system (exclusive of any additions made by
  86. * you or by others) upon request, or instead you may notify anyone requesting
  87. * source that it is freely available from the University of Cambridge.
  88. *
  89. * 4. You may not omit any of the copyright notices on either the source files,
  90. * the executable files, or the documentation.
  91. *
  92. * 5. You may not omit transmission of this License agreement with whatever
  93. * portions of MSNTP that are distributed.
  94. *
  95. * 6. Any users of this software must be notified that it is without warranty or
  96. * guarantee of any nature, express or implied, nor is there any fitness for use
  97. * represented.
  98. *
  99. *
  100. * October 1996
  101. * April 1997
  102. * October 2000
  103. */
  104. #include <limits.h>
  105. #define OPTION_CODE_COMPILE 1
  106. #include "sntp-opts.h"
  107. #ifdef __cplusplus
  108. extern "C" {
  109. #endif
  110. tSCC zCopyright[] =
  111. "sntp copyright (c) 1970-2006 ntp.org, all rights reserved";
  112. tSCC zCopyrightNotice[] =
  113. /* extracted from sntp-opts.def near line 12 */
  114. " General Public Licence for the software known as MSNTP\n\
  115. ------------------------------------------------------\n\n\
  116. \t (c) Copyright, N.M. Maclaren, 1996, 1997, 2000\n\
  117. \t (c) Copyright, University of Cambridge, 1996, 1997, 2000\n\n\n\n\
  118. Free use of MSNTP in source and binary forms is permitted, provided that this\n\
  119. entire licence is duplicated in all copies, and that any documentation,\n\
  120. announcements, and other materials related to use acknowledge that the software\n\
  121. was developed by N.M. Maclaren (hereafter refered to as the Author) at the\n\
  122. University of Cambridge. Neither the name of the Author nor the University of\n\
  123. Cambridge may be used to endorse or promote products derived from this material\n\
  124. without specific prior written permission.\n\n\
  125. The Author and the University of Cambridge retain the copyright and all other\n\
  126. legal rights to the software and make it available non-exclusively. All users\n\
  127. must ensure that the software in all its derivations carries a copyright notice\n\
  128. in the form:\n\
  129. \t (c) Copyright N.M. Maclaren,\n\
  130. \t (c) Copyright University of Cambridge.\n\n\n\n\
  131. NO WARRANTY\n\n\
  132. Because the MSNTP software is licensed free of charge, the Author and the\n\
  133. University of Cambridge provide absolutely no warranty, either expressed or\n\
  134. implied, including, but not limited to, the implied warranties of\n\
  135. merchantability and fitness for a particular purpose. The entire risk as to\n\
  136. the quality and performance of the MSNTP software is with you. Should MSNTP\n\
  137. prove defective, you assume the cost of all necessary servicing or repair.\n\n\
  138. In no event, unless required by law, will the Author or the University of\n\
  139. Cambridge, or any other party who may modify and redistribute this software as\n\
  140. permitted in accordance with the provisions below, be liable for damages for\n\
  141. any losses whatsoever, including but not limited to lost profits, lost monies,\n\
  142. lost or corrupted data, or other special, incidental or consequential losses\n\
  143. that may arise out of the use or inability to use the MSNTP software.\n\n\n\n\
  144. COPYING POLICY\n\n\
  145. Permission is hereby granted for copying and distribution of copies of the\n\
  146. MSNTP source and binary files, and of any part thereof, subject to the\n\
  147. following licence conditions:\n\n\
  148. 1. You may distribute MSNTP or components of MSNTP, with or without additions\n\
  149. developed by you or by others. No charge, other than an \"at-cost\" distribution\n\
  150. fee, may be charged for copies, derivations, or distributions of this material\n\
  151. without the express written consent of the copyright holders.\n\n\
  152. 2. You may also distribute MSNTP along with any other product for sale,\n\
  153. provided that the cost of the bundled package is the same regardless of whether\n\
  154. MSNTP is included or not, and provided that those interested only in MSNTP must\n\
  155. be notified that it is a product freely available from the University of\n\
  156. Cambridge.\n\n\
  157. 3. If you distribute MSNTP software or parts of MSNTP, with or without\n\
  158. additions developed by you or others, then you must either make available the\n\
  159. source to all portions of the MSNTP system (exclusive of any additions made by\n\
  160. you or by others) upon request, or instead you may notify anyone requesting\n\
  161. source that it is freely available from the University of Cambridge.\n\n\
  162. 4. You may not omit any of the copyright notices on either the source files,\n\
  163. the executable files, or the documentation.\n\n\
  164. 5. You may not omit transmission of this License agreement with whatever\n\
  165. portions of MSNTP that are distributed.\n\n\
  166. 6. Any users of this software must be notified that it is without warranty or\n\
  167. guarantee of any nature, express or implied, nor is there any fitness for use\n\
  168. represented.\n\n\n\
  169. October 1996\n\
  170. April 1997\n\
  171. October 2000";
  172. extern tUsageProc optionUsage;
  173. #ifndef NULL
  174. # define NULL 0
  175. #endif
  176. #ifndef EXIT_SUCCESS
  177. # define EXIT_SUCCESS 0
  178. #endif
  179. #ifndef EXIT_FAILURE
  180. # define EXIT_FAILURE 1
  181. #endif
  182. /*
  183. * Ipv4 option description:
  184. */
  185. tSCC zIpv4Text[] =
  186. "Force IPv4 DNS name resolution";
  187. tSCC zIpv4_NAME[] = "IPV4";
  188. tSCC zIpv4_Name[] = "ipv4";
  189. #define IPV4_FLAGS (OPTST_DISABLED)
  190. /*
  191. * Ipv6 option description:
  192. */
  193. tSCC zIpv6Text[] =
  194. "Force IPv6 DNS name resolution";
  195. tSCC zIpv6_NAME[] = "IPV6";
  196. tSCC zIpv6_Name[] = "ipv6";
  197. #define IPV6_FLAGS (OPTST_DISABLED)
  198. /*
  199. * Unprivport option description:
  200. */
  201. tSCC zUnprivportText[] =
  202. "Use an unprivileged port";
  203. tSCC zUnprivport_NAME[] = "UNPRIVPORT";
  204. tSCC zUnprivport_Name[] = "unprivport";
  205. #define UNPRIVPORT_FLAGS (OPTST_DISABLED)
  206. /*
  207. * Normalverbose option description with
  208. * "Must also have options" and "Incompatible options":
  209. */
  210. tSCC zNormalverboseText[] =
  211. "Slightly verbose";
  212. tSCC zNormalverbose_NAME[] = "NORMALVERBOSE";
  213. tSCC zNormalverbose_Name[] = "normalverbose";
  214. static const int
  215. aNormalverboseCantList[] = {
  216. INDEX_OPT_EXTRAVERBOSE,
  217. INDEX_OPT_MEGAVERBOSE, NO_EQUIVALENT };
  218. #define NORMALVERBOSE_FLAGS (OPTST_DISABLED)
  219. /*
  220. * Extraverbose option description with
  221. * "Must also have options" and "Incompatible options":
  222. */
  223. tSCC zExtraverboseText[] =
  224. "Extra verbose";
  225. tSCC zExtraverbose_NAME[] = "EXTRAVERBOSE";
  226. tSCC zExtraverbose_Name[] = "extraverbose";
  227. static const int
  228. aExtraverboseCantList[] = {
  229. INDEX_OPT_NORMALVERBOSE,
  230. INDEX_OPT_MEGAVERBOSE, NO_EQUIVALENT };
  231. #define EXTRAVERBOSE_FLAGS (OPTST_DISABLED)
  232. /*
  233. * Megaverbose option description with
  234. * "Must also have options" and "Incompatible options":
  235. */
  236. tSCC zMegaverboseText[] =
  237. "Mega verbose";
  238. tSCC zMegaverbose_NAME[] = "MEGAVERBOSE";
  239. tSCC zMegaverbose_Name[] = "megaverbose";
  240. static const int
  241. aMegaverboseCantList[] = {
  242. INDEX_OPT_NORMALVERBOSE,
  243. INDEX_OPT_EXTRAVERBOSE, NO_EQUIVALENT };
  244. #define MEGAVERBOSE_FLAGS (OPTST_DISABLED)
  245. /*
  246. * Settimeofday option description with
  247. * "Must also have options" and "Incompatible options":
  248. */
  249. tSCC zSettimeofdayText[] =
  250. "Set (step) the time with settimeofday()";
  251. tSCC zSettimeofday_NAME[] = "SETTIMEOFDAY";
  252. tSCC zSettimeofday_Name[] = "settimeofday";
  253. static const int
  254. aSettimeofdayCantList[] = {
  255. INDEX_OPT_ADJTIME, NO_EQUIVALENT };
  256. #define SETTIMEOFDAY_FLAGS (OPTST_DISABLED)
  257. /*
  258. * Adjtime option description with
  259. * "Must also have options" and "Incompatible options":
  260. */
  261. tSCC zAdjtimeText[] =
  262. "Set (slew) the time with adjtime()";
  263. tSCC zAdjtime_NAME[] = "ADJTIME";
  264. tSCC zAdjtime_Name[] = "adjtime";
  265. static const int
  266. aAdjtimeCantList[] = {
  267. INDEX_OPT_SETTIMEOFDAY, NO_EQUIVALENT };
  268. #define ADJTIME_FLAGS (OPTST_DISABLED)
  269. /*
  270. * Help/More_Help/Version option descriptions:
  271. */
  272. tSCC zHelpText[] = "Display usage information and exit";
  273. tSCC zHelp_Name[] = "help";
  274. tSCC zMore_HelpText[] = "Extended usage information passed thru pager";
  275. tSCC zMore_Help_Name[] = "more-help";
  276. tSCC zVersionText[] = "Output version information and exit";
  277. tSCC zVersion_Name[] = "version";
  278. /*
  279. * Save/Load_Opts option description:
  280. */
  281. tSCC zSave_OptsText[] = "Save the option state to a config file";
  282. tSCC zSave_Opts_Name[] = "save-opts";
  283. tSCC zLoad_OptsText[] = "Load options from a config file";
  284. tSCC zLoad_Opts_NAME[] = "LOAD_OPTS";
  285. tSCC zNotLoad_Opts_Name[] = "no-load-opts";
  286. tSCC zNotLoad_Opts_Pfx[] = "no";
  287. #define zLoad_Opts_Name (zNotLoad_Opts_Name + 3)
  288. /*
  289. * Declare option callback procedures
  290. */
  291. #if defined(TEST_SNTP_OPTS)
  292. /*
  293. * Under test, omit argument processing, or call optionStackArg,
  294. * if multiple copies are allowed.
  295. */
  296. extern tOptProc
  297. optionPagedUsage, optionVersionStderr;
  298. static tOptProc
  299. doUsageOpt;
  300. #else /* NOT defined TEST_SNTP_OPTS */
  301. /*
  302. * When not under test, there are different procs to use
  303. */
  304. extern tOptProc
  305. optionPagedUsage, optionPrintVersion;
  306. static tOptProc
  307. doUsageOpt;
  308. #endif /* defined(TEST_SNTP_OPTS) */
  309. #ifdef TEST_SNTP_OPTS
  310. # define DOVERPROC optionVersionStderr
  311. #else
  312. # define DOVERPROC optionPrintVersion
  313. #endif /* TEST_SNTP_OPTS */
  314. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  315. *
  316. * Define the Sntp Option Descriptions.
  317. */
  318. static tOptDesc optDesc[ OPTION_CT ] = {
  319. { /* entry idx, value */ 0, VALUE_OPT_IPV4,
  320. /* equiv idx, value */ NO_EQUIVALENT, 0,
  321. /* equivalenced to */ NO_EQUIVALENT,
  322. /* min, max, act ct */ 0, 1, 0,
  323. /* opt state flags */ IPV4_FLAGS, 0,
  324. /* last opt argumnt */ { NULL },
  325. /* arg list/cookie */ NULL,
  326. /* must/cannot opts */ NULL, NULL,
  327. /* option proc */ NULL,
  328. /* desc, NAME, name */ zIpv4Text, zIpv4_NAME, zIpv4_Name,
  329. /* disablement strs */ NULL, NULL },
  330. { /* entry idx, value */ 1, VALUE_OPT_IPV6,
  331. /* equiv idx, value */ NOLIMIT, NOLIMIT,
  332. /* equivalenced to */ INDEX_OPT_IPV4,
  333. /* min, max, act ct */ 0, 1, 0,
  334. /* opt state flags */ IPV6_FLAGS, 0,
  335. /* last opt argumnt */ { NULL },
  336. /* arg list/cookie */ NULL,
  337. /* must/cannot opts */ NULL, NULL,
  338. /* option proc */ NULL,
  339. /* desc, NAME, name */ zIpv6Text, zIpv6_NAME, zIpv6_Name,
  340. /* disablement strs */ NULL, NULL },
  341. { /* entry idx, value */ 2, VALUE_OPT_UNPRIVPORT,
  342. /* equiv idx, value */ 2, VALUE_OPT_UNPRIVPORT,
  343. /* equivalenced to */ NO_EQUIVALENT,
  344. /* min, max, act ct */ 0, 1, 0,
  345. /* opt state flags */ UNPRIVPORT_FLAGS, 0,
  346. /* last opt argumnt */ { NULL },
  347. /* arg list/cookie */ NULL,
  348. /* must/cannot opts */ NULL, NULL,
  349. /* option proc */ NULL,
  350. /* desc, NAME, name */ zUnprivportText, zUnprivport_NAME, zUnprivport_Name,
  351. /* disablement strs */ NULL, NULL },
  352. { /* entry idx, value */ 3, VALUE_OPT_NORMALVERBOSE,
  353. /* equiv idx, value */ 3, VALUE_OPT_NORMALVERBOSE,
  354. /* equivalenced to */ NO_EQUIVALENT,
  355. /* min, max, act ct */ 0, 1, 0,
  356. /* opt state flags */ NORMALVERBOSE_FLAGS, 0,
  357. /* last opt argumnt */ { NULL },
  358. /* arg list/cookie */ NULL,
  359. /* must/cannot opts */ NULL, aNormalverboseCantList,
  360. /* option proc */ NULL,
  361. /* desc, NAME, name */ zNormalverboseText, zNormalverbose_NAME, zNormalverbose_Name,
  362. /* disablement strs */ NULL, NULL },
  363. { /* entry idx, value */ 4, VALUE_OPT_EXTRAVERBOSE,
  364. /* equiv idx, value */ 4, VALUE_OPT_EXTRAVERBOSE,
  365. /* equivalenced to */ NO_EQUIVALENT,
  366. /* min, max, act ct */ 0, 1, 0,
  367. /* opt state flags */ EXTRAVERBOSE_FLAGS, 0,
  368. /* last opt argumnt */ { NULL },
  369. /* arg list/cookie */ NULL,
  370. /* must/cannot opts */ NULL, aExtraverboseCantList,
  371. /* option proc */ NULL,
  372. /* desc, NAME, name */ zExtraverboseText, zExtraverbose_NAME, zExtraverbose_Name,
  373. /* disablement strs */ NULL, NULL },
  374. { /* entry idx, value */ 5, VALUE_OPT_MEGAVERBOSE,
  375. /* equiv idx, value */ 5, VALUE_OPT_MEGAVERBOSE,
  376. /* equivalenced to */ NO_EQUIVALENT,
  377. /* min, max, act ct */ 0, 1, 0,
  378. /* opt state flags */ MEGAVERBOSE_FLAGS, 0,
  379. /* last opt argumnt */ { NULL },
  380. /* arg list/cookie */ NULL,
  381. /* must/cannot opts */ NULL, aMegaverboseCantList,
  382. /* option proc */ NULL,
  383. /* desc, NAME, name */ zMegaverboseText, zMegaverbose_NAME, zMegaverbose_Name,
  384. /* disablement strs */ NULL, NULL },
  385. { /* entry idx, value */ 6, VALUE_OPT_SETTIMEOFDAY,
  386. /* equiv idx, value */ 6, VALUE_OPT_SETTIMEOFDAY,
  387. /* equivalenced to */ NO_EQUIVALENT,
  388. /* min, max, act ct */ 0, 1, 0,
  389. /* opt state flags */ SETTIMEOFDAY_FLAGS, 0,
  390. /* last opt argumnt */ { NULL },
  391. /* arg list/cookie */ NULL,
  392. /* must/cannot opts */ NULL, aSettimeofdayCantList,
  393. /* option proc */ NULL,
  394. /* desc, NAME, name */ zSettimeofdayText, zSettimeofday_NAME, zSettimeofday_Name,
  395. /* disablement strs */ NULL, NULL },
  396. { /* entry idx, value */ 7, VALUE_OPT_ADJTIME,
  397. /* equiv idx, value */ 7, VALUE_OPT_ADJTIME,
  398. /* equivalenced to */ NO_EQUIVALENT,
  399. /* min, max, act ct */ 0, 1, 0,
  400. /* opt state flags */ ADJTIME_FLAGS, 0,
  401. /* last opt argumnt */ { NULL },
  402. /* arg list/cookie */ NULL,
  403. /* must/cannot opts */ NULL, aAdjtimeCantList,
  404. /* option proc */ NULL,
  405. /* desc, NAME, name */ zAdjtimeText, zAdjtime_NAME, zAdjtime_Name,
  406. /* disablement strs */ NULL, NULL },
  407. #ifdef NO_OPTIONAL_OPT_ARGS
  408. # define VERSION_OPT_FLAGS OPTST_IMM | OPTST_NO_INIT
  409. #else
  410. # define VERSION_OPT_FLAGS OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
  411. OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT
  412. #endif
  413. { /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
  414. /* equiv idx value */ NO_EQUIVALENT, 0,
  415. /* equivalenced to */ NO_EQUIVALENT,
  416. /* min, max, act ct */ 0, 1, 0,
  417. /* opt state flags */ VERSION_OPT_FLAGS, 0,
  418. /* last opt argumnt */ { NULL },
  419. /* arg list/cookie */ NULL,
  420. /* must/cannot opts */ NULL, NULL,
  421. /* option proc */ DOVERPROC,
  422. /* desc, NAME, name */ zVersionText, NULL, zVersion_Name,
  423. /* disablement strs */ NULL, NULL },
  424. #undef VERSION_OPT_FLAGS
  425. { /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
  426. /* equiv idx value */ NO_EQUIVALENT, 0,
  427. /* equivalenced to */ NO_EQUIVALENT,
  428. /* min, max, act ct */ 0, 1, 0,
  429. /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0,
  430. /* last opt argumnt */ { NULL },
  431. /* arg list/cookie */ NULL,
  432. /* must/cannot opts */ NULL, NULL,
  433. /* option proc */ doUsageOpt,
  434. /* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
  435. /* disablement strs */ NULL, NULL },
  436. { /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
  437. /* equiv idx value */ NO_EQUIVALENT, 0,
  438. /* equivalenced to */ NO_EQUIVALENT,
  439. /* min, max, act ct */ 0, 1, 0,
  440. /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0,
  441. /* last opt argumnt */ { NULL },
  442. /* arg list/cookie */ NULL,
  443. /* must/cannot opts */ NULL, NULL,
  444. /* option proc */ optionPagedUsage,
  445. /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name,
  446. /* disablement strs */ NULL, NULL },
  447. { /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS,
  448. /* equiv idx value */ NO_EQUIVALENT, 0,
  449. /* equivalenced to */ NO_EQUIVALENT,
  450. /* min, max, act ct */ 0, 1, 0,
  451. /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
  452. | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0,
  453. /* last opt argumnt */ { NULL },
  454. /* arg list/cookie */ NULL,
  455. /* must/cannot opts */ NULL, NULL,
  456. /* option proc */ NULL,
  457. /* desc, NAME, name */ zSave_OptsText, NULL, zSave_Opts_Name,
  458. /* disablement strs */ NULL, NULL },
  459. { /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS,
  460. /* equiv idx value */ NO_EQUIVALENT, 0,
  461. /* equivalenced to */ NO_EQUIVALENT,
  462. /* min, max, act ct */ 0, NOLIMIT, 0,
  463. /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) \
  464. | OPTST_DISABLE_IMM, 0,
  465. /* last opt argumnt */ { NULL },
  466. /* arg list/cookie */ NULL,
  467. /* must/cannot opts */ NULL, NULL,
  468. /* option proc */ optionLoadOpt,
  469. /* desc, NAME, name */ zLoad_OptsText, zLoad_Opts_NAME, zLoad_Opts_Name,
  470. /* disablement strs */ zNotLoad_Opts_Name, zNotLoad_Opts_Pfx }
  471. };
  472. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  473. *
  474. * Define the Sntp Option Environment
  475. */
  476. tSCC zPROGNAME[] = "SNTP";
  477. tSCC zUsageTitle[] =
  478. "sntp - standard SNTP program - Ver. 4.2.4p8\n\
  479. USAGE: %s [ -<flag> | --<name> ]...\n";
  480. tSCC zRcName[] = ".ntprc";
  481. tSCC* apzHomeList[] = {
  482. "$HOME",
  483. ".",
  484. NULL };
  485. tSCC zBugsAddr[] = "http://bugs.ntp.org, bugs@ntp.org";
  486. #define zExplain NULL
  487. tSCC zDetail[] = "\n\
  488. .I sntp\n\
  489. can be used as a SNTP client to query a NTP or SNTP server and either display\n\
  490. the time or set the local system's time (given suitable privilege). It can be\n\
  491. run as an interactive command or in a\n\
  492. .I cron\n\
  493. job.\n\
  494. NTP is the Network Time Protocol (RFC 1305) and SNTP is the\n\
  495. Simple Network Time Protocol (RFC 2030, which supersedes RFC 1769).\n";
  496. tSCC zFullVersion[] = SNTP_FULL_VERSION;
  497. /* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optcode.tpl near line 408 */
  498. #if defined(ENABLE_NLS)
  499. # define OPTPROC_BASE OPTPROC_TRANSLATE
  500. static tOptionXlateProc translate_option_strings;
  501. #else
  502. # define OPTPROC_BASE OPTPROC_NONE
  503. # define translate_option_strings NULL
  504. #endif /* ENABLE_NLS */
  505. tOptions sntpOptions = {
  506. OPTIONS_STRUCT_VERSION,
  507. 0, NULL, /* original argc + argv */
  508. ( OPTPROC_BASE
  509. + OPTPROC_ERRSTOP
  510. + OPTPROC_SHORTOPT
  511. + OPTPROC_LONGOPT
  512. + OPTPROC_NO_REQ_OPT
  513. + OPTPROC_ENVIRON
  514. + OPTPROC_NO_ARGS
  515. + OPTPROC_HAS_IMMED ),
  516. 0, NULL, /* current option index, current option */
  517. NULL, NULL, zPROGNAME,
  518. zRcName, zCopyright, zCopyrightNotice,
  519. zFullVersion, apzHomeList, zUsageTitle,
  520. zExplain, zDetail, optDesc,
  521. zBugsAddr, /* address to send bugs to */
  522. NULL, NULL, /* extensions/saved state */
  523. optionUsage, /* usage procedure */
  524. translate_option_strings, /* translation procedure */
  525. /*
  526. * Indexes to special options
  527. */
  528. { INDEX_OPT_MORE_HELP,
  529. INDEX_OPT_SAVE_OPTS,
  530. NO_EQUIVALENT /* index of '-#' option */,
  531. NO_EQUIVALENT /* index of default opt */
  532. },
  533. 13 /* full option count */, 8 /* user option count */
  534. };
  535. /*
  536. * Create the static procedure(s) declared above.
  537. */
  538. static void
  539. doUsageOpt(
  540. tOptions* pOptions,
  541. tOptDesc* pOptDesc )
  542. {
  543. USAGE( EXIT_SUCCESS );
  544. }
  545. /* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optmain.tpl near line 92 */
  546. #if defined(TEST_SNTP_OPTS) /* TEST MAIN PROCEDURE: */
  547. int
  548. main( int argc, char** argv )
  549. {
  550. int res = EXIT_SUCCESS;
  551. (void)optionProcess( &sntpOptions, argc, argv );
  552. {
  553. void optionPutShell( tOptions* );
  554. optionPutShell( &sntpOptions );
  555. }
  556. return res;
  557. }
  558. #endif /* defined TEST_SNTP_OPTS */
  559. /* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optcode.tpl near line 514 */
  560. #if ENABLE_NLS
  561. #include <stdio.h>
  562. #include <stdlib.h>
  563. #include <string.h>
  564. #include <unistd.h>
  565. #include <autoopts/usage-txt.h>
  566. static char* AO_gettext( char const* pz );
  567. static void coerce_it(void** s);
  568. static char*
  569. AO_gettext( char const* pz )
  570. {
  571. char* pzRes;
  572. if (pz == NULL)
  573. return NULL;
  574. pzRes = _(pz);
  575. if (pzRes == pz)
  576. return pzRes;
  577. pzRes = strdup( pzRes );
  578. if (pzRes == NULL) {
  579. fputs( _("No memory for duping translated strings\n"), stderr );
  580. exit( EXIT_FAILURE );
  581. }
  582. return pzRes;
  583. }
  584. static void coerce_it(void** s) { *s = AO_gettext(*s); }
  585. #define COERSION(_f) \
  586. coerce_it((void*)&(sntpOptions._f))
  587. /*
  588. * This invokes the translation code (e.g. gettext(3)).
  589. */
  590. static void
  591. translate_option_strings( void )
  592. {
  593. /*
  594. * Guard against re-translation. It won't work. The strings will have
  595. * been changed by the first pass through this code. One shot only.
  596. */
  597. if (option_usage_text.field_ct == 0)
  598. return;
  599. /*
  600. * Do the translations. The first pointer follows the field count field.
  601. * The field count field is the size of a pointer.
  602. */
  603. {
  604. char** ppz = (char**)(void*)&(option_usage_text);
  605. int ix = option_usage_text.field_ct;
  606. do {
  607. ppz++;
  608. *ppz = AO_gettext(*ppz);
  609. } while (--ix > 0);
  610. }
  611. option_usage_text.field_ct = 0;
  612. {
  613. tOptDesc* pOD = sntpOptions.pOptDesc;
  614. int ix = sntpOptions.optCt;
  615. for (;;) {
  616. pOD->pzText = AO_gettext(pOD->pzText);
  617. pOD->pz_NAME = AO_gettext(pOD->pz_NAME);
  618. pOD->pz_Name = AO_gettext(pOD->pz_Name);
  619. pOD->pz_DisableName = AO_gettext(pOD->pz_DisableName);
  620. pOD->pz_DisablePfx = AO_gettext(pOD->pz_DisablePfx);
  621. if (--ix <= 0)
  622. break;
  623. pOD++;
  624. }
  625. }
  626. COERSION(pzCopyright);
  627. COERSION(pzCopyNotice);
  628. COERSION(pzFullVersion);
  629. COERSION(pzUsageTitle);
  630. COERSION(pzExplain);
  631. COERSION(pzDetail);
  632. }
  633. #endif /* ENABLE_NLS */
  634. #ifdef __cplusplus
  635. }
  636. #endif
  637. /* sntp-opts.c ends here */