Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / ntp / util / ntp-keygen-opts.c
blob1543789b0cc5639c82c7705c5f20ae9e675f6fda
1 /* $NetBSD$ */
3 /*
4 * EDIT THIS FILE WITH CAUTION (ntp-keygen-opts.c)
5 *
6 * It has been AutoGen-ed Tuesday December 8, 2009 at 08:14:56 AM EST
7 * From the definitions ntp-keygen-opts.def
8 * and the template file options
10 * Generated from AutoOpts 29:0:4 templates.
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 * ntp-keygen 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.
22 * This source file is copyrighted and licensed under the following terms:
24 * ntp-keygen copyright 1970-2009 David L. Mills and/or others - all rights reserved
26 * see html/copyright.html
30 #include <limits.h>
31 #include <stdio.h>
32 #define OPTION_CODE_COMPILE 1
33 #include "ntp-keygen-opts.h"
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 tSCC zCopyright[] =
39 "ntp-keygen copyright (c) 1970-2009 David L. Mills and/or others, all rights reserved";
40 tSCC zCopyrightNotice[] =
42 /* extracted from ../include/copyright.def near line 8 */
43 "see html/copyright.html";
44 extern tUsageProc optionUsage;
47 * global included definitions
49 #include <stdlib.h>
50 #ifdef __windows
51 extern int atoi(const char*);
52 #else
53 # include <stdlib.h>
54 #endif
56 #ifndef NULL
57 # define NULL 0
58 #endif
59 #ifndef EXIT_SUCCESS
60 # define EXIT_SUCCESS 0
61 #endif
62 #ifndef EXIT_FAILURE
63 # define EXIT_FAILURE 1
64 #endif
66 * Certificate option description:
68 #ifdef OPENSSL
69 tSCC zCertificateText[] =
70 "certificate scheme";
71 tSCC zCertificate_NAME[] = "CERTIFICATE";
72 tSCC zCertificate_Name[] = "certificate";
73 #define CERTIFICATE_FLAGS (OPTST_DISABLED \
74 | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
76 #else /* disable Certificate */
77 #define VALUE_OPT_CERTIFICATE NO_EQUIVALENT
78 #define CERTIFICATE_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
79 #define zCertificateText NULL
80 #define zCertificate_NAME NULL
81 #define zCertificate_Name NULL
82 #endif /* OPENSSL */
85 * Debug_Level option description:
87 #ifdef DEBUG
88 tSCC zDebug_LevelText[] =
89 "Increase output debug message level";
90 tSCC zDebug_Level_NAME[] = "DEBUG_LEVEL";
91 tSCC zDebug_Level_Name[] = "debug-level";
92 #define DEBUG_LEVEL_FLAGS (OPTST_DISABLED)
94 #else /* disable Debug_Level */
95 #define VALUE_OPT_DEBUG_LEVEL NO_EQUIVALENT
96 #define DEBUG_LEVEL_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
97 #define zDebug_LevelText NULL
98 #define zDebug_Level_NAME NULL
99 #define zDebug_Level_Name NULL
100 #endif /* DEBUG */
103 * Set_Debug_Level option description:
105 #ifdef DEBUG
106 tSCC zSet_Debug_LevelText[] =
107 "Set the output debug message level";
108 tSCC zSet_Debug_Level_NAME[] = "SET_DEBUG_LEVEL";
109 tSCC zSet_Debug_Level_Name[] = "set-debug-level";
110 #define SET_DEBUG_LEVEL_FLAGS (OPTST_DISABLED \
111 | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
113 #else /* disable Set_Debug_Level */
114 #define VALUE_OPT_SET_DEBUG_LEVEL NO_EQUIVALENT
115 #define SET_DEBUG_LEVEL_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
116 #define zSet_Debug_LevelText NULL
117 #define zSet_Debug_Level_NAME NULL
118 #define zSet_Debug_Level_Name NULL
119 #endif /* DEBUG */
122 * Id_Key option description:
124 #ifdef OPENSSL
125 tSCC zId_KeyText[] =
126 "Write identity keys";
127 tSCC zId_Key_NAME[] = "ID_KEY";
128 tSCC zId_Key_Name[] = "id-key";
129 #define ID_KEY_FLAGS (OPTST_DISABLED)
131 #else /* disable Id_Key */
132 #define VALUE_OPT_ID_KEY NO_EQUIVALENT
133 #define ID_KEY_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
134 #define zId_KeyText NULL
135 #define zId_Key_NAME NULL
136 #define zId_Key_Name NULL
137 #endif /* OPENSSL */
140 * Gq_Params option description:
142 #ifdef OPENSSL
143 tSCC zGq_ParamsText[] =
144 "Generate GQ parameters and keys";
145 tSCC zGq_Params_NAME[] = "GQ_PARAMS";
146 tSCC zGq_Params_Name[] = "gq-params";
147 #define GQ_PARAMS_FLAGS (OPTST_DISABLED)
149 #else /* disable Gq_Params */
150 #define VALUE_OPT_GQ_PARAMS NO_EQUIVALENT
151 #define GQ_PARAMS_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
152 #define zGq_ParamsText NULL
153 #define zGq_Params_NAME NULL
154 #define zGq_Params_Name NULL
155 #endif /* OPENSSL */
158 * Gq_Keys option description:
160 #ifdef OPENSSL
161 tSCC zGq_KeysText[] =
162 "update GQ keys";
163 tSCC zGq_Keys_NAME[] = "GQ_KEYS";
164 tSCC zGq_Keys_Name[] = "gq-keys";
165 #define GQ_KEYS_FLAGS (OPTST_DISABLED)
167 #else /* disable Gq_Keys */
168 #define VALUE_OPT_GQ_KEYS NO_EQUIVALENT
169 #define GQ_KEYS_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
170 #define zGq_KeysText NULL
171 #define zGq_Keys_NAME NULL
172 #define zGq_Keys_Name NULL
173 #endif /* OPENSSL */
176 * Host_Key option description:
178 #ifdef OPENSSL
179 tSCC zHost_KeyText[] =
180 "generate RSA host key";
181 tSCC zHost_Key_NAME[] = "HOST_KEY";
182 tSCC zHost_Key_Name[] = "host-key";
183 #define HOST_KEY_FLAGS (OPTST_DISABLED)
185 #else /* disable Host_Key */
186 #define VALUE_OPT_HOST_KEY NO_EQUIVALENT
187 #define HOST_KEY_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
188 #define zHost_KeyText NULL
189 #define zHost_Key_NAME NULL
190 #define zHost_Key_Name NULL
191 #endif /* OPENSSL */
194 * Iffkey option description:
196 #ifdef OPENSSL
197 tSCC zIffkeyText[] =
198 "generate IFF parameters";
199 tSCC zIffkey_NAME[] = "IFFKEY";
200 tSCC zIffkey_Name[] = "iffkey";
201 #define IFFKEY_FLAGS (OPTST_DISABLED)
203 #else /* disable Iffkey */
204 #define VALUE_OPT_IFFKEY NO_EQUIVALENT
205 #define IFFKEY_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
206 #define zIffkeyText NULL
207 #define zIffkey_NAME NULL
208 #define zIffkey_Name NULL
209 #endif /* OPENSSL */
212 * Issuer_Name option description:
214 #ifdef OPENSSL
215 tSCC zIssuer_NameText[] =
216 "set issuer name";
217 tSCC zIssuer_Name_NAME[] = "ISSUER_NAME";
218 tSCC zIssuer_Name_Name[] = "issuer-name";
219 #define ISSUER_NAME_FLAGS (OPTST_DISABLED)
221 #else /* disable Issuer_Name */
222 #define VALUE_OPT_ISSUER_NAME NO_EQUIVALENT
223 #define ISSUER_NAME_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
224 #define zIssuer_NameText NULL
225 #define zIssuer_Name_NAME NULL
226 #define zIssuer_Name_Name NULL
227 #endif /* OPENSSL */
230 * Md5key option description:
232 tSCC zMd5keyText[] =
233 "generate MD5 keys";
234 tSCC zMd5key_NAME[] = "MD5KEY";
235 tSCC zMd5key_Name[] = "md5key";
236 #define MD5KEY_FLAGS (OPTST_DISABLED)
239 * Modulus option description:
241 #ifdef OPENSSL
242 tSCC zModulusText[] =
243 "modulus";
244 tSCC zModulus_NAME[] = "MODULUS";
245 tSCC zModulus_Name[] = "modulus";
246 #define MODULUS_FLAGS (OPTST_DISABLED \
247 | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
249 #else /* disable Modulus */
250 #define VALUE_OPT_MODULUS NO_EQUIVALENT
251 #define MODULUS_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
252 #define zModulusText NULL
253 #define zModulus_NAME NULL
254 #define zModulus_Name NULL
255 #endif /* OPENSSL */
258 * Pvt_Cert option description:
260 #ifdef OPENSSL
261 tSCC zPvt_CertText[] =
262 "generate PC private certificate";
263 tSCC zPvt_Cert_NAME[] = "PVT_CERT";
264 tSCC zPvt_Cert_Name[] = "pvt-cert";
265 #define PVT_CERT_FLAGS (OPTST_DISABLED)
267 #else /* disable Pvt_Cert */
268 #define VALUE_OPT_PVT_CERT NO_EQUIVALENT
269 #define PVT_CERT_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
270 #define zPvt_CertText NULL
271 #define zPvt_Cert_NAME NULL
272 #define zPvt_Cert_Name NULL
273 #endif /* OPENSSL */
276 * Pvt_Passwd option description:
278 #ifdef OPENSSL
279 tSCC zPvt_PasswdText[] =
280 "output private password";
281 tSCC zPvt_Passwd_NAME[] = "PVT_PASSWD";
282 tSCC zPvt_Passwd_Name[] = "pvt-passwd";
283 #define PVT_PASSWD_FLAGS (OPTST_DISABLED \
284 | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
286 #else /* disable Pvt_Passwd */
287 #define VALUE_OPT_PVT_PASSWD NO_EQUIVALENT
288 #define PVT_PASSWD_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
289 #define zPvt_PasswdText NULL
290 #define zPvt_Passwd_NAME NULL
291 #define zPvt_Passwd_Name NULL
292 #endif /* OPENSSL */
295 * Get_Pvt_Passwd option description:
297 #ifdef OPENSSL
298 tSCC zGet_Pvt_PasswdText[] =
299 "input private password";
300 tSCC zGet_Pvt_Passwd_NAME[] = "GET_PVT_PASSWD";
301 tSCC zGet_Pvt_Passwd_Name[] = "get-pvt-passwd";
302 #define GET_PVT_PASSWD_FLAGS (OPTST_DISABLED \
303 | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
305 #else /* disable Get_Pvt_Passwd */
306 #define VALUE_OPT_GET_PVT_PASSWD NO_EQUIVALENT
307 #define GET_PVT_PASSWD_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
308 #define zGet_Pvt_PasswdText NULL
309 #define zGet_Pvt_Passwd_NAME NULL
310 #define zGet_Pvt_Passwd_Name NULL
311 #endif /* OPENSSL */
314 * Sign_Key option description:
316 #ifdef OPENSSL
317 tSCC zSign_KeyText[] =
318 "generate sign key (RSA or DSA)";
319 tSCC zSign_Key_NAME[] = "SIGN_KEY";
320 tSCC zSign_Key_Name[] = "sign-key";
321 #define SIGN_KEY_FLAGS (OPTST_DISABLED \
322 | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
324 #else /* disable Sign_Key */
325 #define VALUE_OPT_SIGN_KEY NO_EQUIVALENT
326 #define SIGN_KEY_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
327 #define zSign_KeyText NULL
328 #define zSign_Key_NAME NULL
329 #define zSign_Key_Name NULL
330 #endif /* OPENSSL */
333 * Subject_Name option description:
335 #ifdef OPENSSL
336 tSCC zSubject_NameText[] =
337 "set subject name";
338 tSCC zSubject_Name_NAME[] = "SUBJECT_NAME";
339 tSCC zSubject_Name_Name[] = "subject-name";
340 #define SUBJECT_NAME_FLAGS (OPTST_DISABLED \
341 | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
343 #else /* disable Subject_Name */
344 #define VALUE_OPT_SUBJECT_NAME NO_EQUIVALENT
345 #define SUBJECT_NAME_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
346 #define zSubject_NameText NULL
347 #define zSubject_Name_NAME NULL
348 #define zSubject_Name_Name NULL
349 #endif /* OPENSSL */
352 * Trusted_Cert option description:
354 #ifdef OPENSSL
355 tSCC zTrusted_CertText[] =
356 "trusted certificate (TC scheme)";
357 tSCC zTrusted_Cert_NAME[] = "TRUSTED_CERT";
358 tSCC zTrusted_Cert_Name[] = "trusted-cert";
359 #define TRUSTED_CERT_FLAGS (OPTST_DISABLED)
361 #else /* disable Trusted_Cert */
362 #define VALUE_OPT_TRUSTED_CERT NO_EQUIVALENT
363 #define TRUSTED_CERT_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
364 #define zTrusted_CertText NULL
365 #define zTrusted_Cert_NAME NULL
366 #define zTrusted_Cert_Name NULL
367 #endif /* OPENSSL */
370 * Mv_Params option description:
372 #ifdef OPENSSL
373 tSCC zMv_ParamsText[] =
374 "generate <num> MV parameters";
375 tSCC zMv_Params_NAME[] = "MV_PARAMS";
376 tSCC zMv_Params_Name[] = "mv-params";
377 #define MV_PARAMS_FLAGS (OPTST_DISABLED \
378 | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
380 #else /* disable Mv_Params */
381 #define VALUE_OPT_MV_PARAMS NO_EQUIVALENT
382 #define MV_PARAMS_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
383 #define zMv_ParamsText NULL
384 #define zMv_Params_NAME NULL
385 #define zMv_Params_Name NULL
386 #endif /* OPENSSL */
389 * Mv_Keys option description:
391 #ifdef OPENSSL
392 tSCC zMv_KeysText[] =
393 "update <num> MV keys";
394 tSCC zMv_Keys_NAME[] = "MV_KEYS";
395 tSCC zMv_Keys_Name[] = "mv-keys";
396 #define MV_KEYS_FLAGS (OPTST_DISABLED \
397 | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
399 #else /* disable Mv_Keys */
400 #define VALUE_OPT_MV_KEYS NO_EQUIVALENT
401 #define MV_KEYS_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
402 #define zMv_KeysText NULL
403 #define zMv_Keys_NAME NULL
404 #define zMv_Keys_Name NULL
405 #endif /* OPENSSL */
408 * Help/More_Help/Version option descriptions:
410 tSCC zHelpText[] = "Display usage information and exit";
411 tSCC zHelp_Name[] = "help";
413 tSCC zMore_HelpText[] = "Extended usage information passed thru pager";
414 tSCC zMore_Help_Name[] = "more-help";
416 tSCC zVersionText[] = "Output version information and exit";
417 tSCC zVersion_Name[] = "version";
420 * Save/Load_Opts option description:
422 tSCC zSave_OptsText[] = "Save the option state to a config file";
423 tSCC zSave_Opts_Name[] = "save-opts";
425 tSCC zLoad_OptsText[] = "Load options from a config file";
426 tSCC zLoad_Opts_NAME[] = "LOAD_OPTS";
428 tSCC zNotLoad_Opts_Name[] = "no-load-opts";
429 tSCC zNotLoad_Opts_Pfx[] = "no";
430 #define zLoad_Opts_Name (zNotLoad_Opts_Name + 3)
432 * Declare option callback procedures
434 #ifdef DEBUG
435 static tOptProc doOptSet_Debug_Level;
436 #else /* not DEBUG */
437 # define doOptSet_Debug_Level NULL
438 #endif /* def/not DEBUG */
439 #ifdef OPENSSL
440 static tOptProc doOptModulus;
441 #else /* not OPENSSL */
442 # define doOptModulus NULL
443 #endif /* def/not OPENSSL */
444 #ifdef OPENSSL
445 extern tOptProc optionNumericVal;
446 #else /* not OPENSSL */
447 # define optionNumericVal NULL
448 #endif /* def/not OPENSSL */
449 #ifdef OPENSSL
450 extern tOptProc optionNumericVal;
451 #else /* not OPENSSL */
452 # define optionNumericVal NULL
453 #endif /* def/not OPENSSL */
454 #if defined(TEST_NTP_KEYGEN_OPTS)
456 * Under test, omit argument processing, or call optionStackArg,
457 * if multiple copies are allowed.
459 extern tOptProc
460 optionNumericVal, optionPagedUsage, optionVersionStderr;
461 static tOptProc
462 doOptModulus, doUsageOpt;
465 * #define map the "normal" callout procs to the test ones...
467 #define SET_DEBUG_LEVEL_OPT_PROC optionStackArg
470 #else /* NOT defined TEST_NTP_KEYGEN_OPTS */
472 * When not under test, there are different procs to use
474 extern tOptProc
475 optionPagedUsage, optionPrintVersion;
476 static tOptProc
477 doUsageOpt;
480 * #define map the "normal" callout procs
482 #define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level
484 #define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level
485 #endif /* defined(TEST_NTP_KEYGEN_OPTS) */
486 #ifdef TEST_NTP_KEYGEN_OPTS
487 # define DOVERPROC optionVersionStderr
488 #else
489 # define DOVERPROC optionPrintVersion
490 #endif /* TEST_NTP_KEYGEN_OPTS */
492 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
494 * Define the Ntp_Keygen Option Descriptions.
496 static tOptDesc optDesc[ OPTION_CT ] = {
497 { /* entry idx, value */ 0, VALUE_OPT_CERTIFICATE,
498 /* equiv idx, value */ 0, VALUE_OPT_CERTIFICATE,
499 /* equivalenced to */ NO_EQUIVALENT,
500 /* min, max, act ct */ 0, 1, 0,
501 /* opt state flags */ CERTIFICATE_FLAGS, 0,
502 /* last opt argumnt */ { NULL },
503 /* arg list/cookie */ NULL,
504 /* must/cannot opts */ NULL, NULL,
505 /* option proc */ NULL,
506 /* desc, NAME, name */ zCertificateText, zCertificate_NAME, zCertificate_Name,
507 /* disablement strs */ NULL, NULL },
509 { /* entry idx, value */ 1, VALUE_OPT_DEBUG_LEVEL,
510 /* equiv idx, value */ 1, VALUE_OPT_DEBUG_LEVEL,
511 /* equivalenced to */ NO_EQUIVALENT,
512 /* min, max, act ct */ 0, NOLIMIT, 0,
513 /* opt state flags */ DEBUG_LEVEL_FLAGS, 0,
514 /* last opt argumnt */ { NULL },
515 /* arg list/cookie */ NULL,
516 /* must/cannot opts */ NULL, NULL,
517 /* option proc */ NULL,
518 /* desc, NAME, name */ zDebug_LevelText, zDebug_Level_NAME, zDebug_Level_Name,
519 /* disablement strs */ NULL, NULL },
521 { /* entry idx, value */ 2, VALUE_OPT_SET_DEBUG_LEVEL,
522 /* equiv idx, value */ 2, VALUE_OPT_SET_DEBUG_LEVEL,
523 /* equivalenced to */ NO_EQUIVALENT,
524 /* min, max, act ct */ 0, NOLIMIT, 0,
525 /* opt state flags */ SET_DEBUG_LEVEL_FLAGS, 0,
526 /* last opt argumnt */ { NULL },
527 /* arg list/cookie */ NULL,
528 /* must/cannot opts */ NULL, NULL,
529 /* option proc */ SET_DEBUG_LEVEL_OPT_PROC,
530 /* desc, NAME, name */ zSet_Debug_LevelText, zSet_Debug_Level_NAME, zSet_Debug_Level_Name,
531 /* disablement strs */ NULL, NULL },
533 { /* entry idx, value */ 3, VALUE_OPT_ID_KEY,
534 /* equiv idx, value */ 3, VALUE_OPT_ID_KEY,
535 /* equivalenced to */ NO_EQUIVALENT,
536 /* min, max, act ct */ 0, 1, 0,
537 /* opt state flags */ ID_KEY_FLAGS, 0,
538 /* last opt argumnt */ { NULL },
539 /* arg list/cookie */ NULL,
540 /* must/cannot opts */ NULL, NULL,
541 /* option proc */ NULL,
542 /* desc, NAME, name */ zId_KeyText, zId_Key_NAME, zId_Key_Name,
543 /* disablement strs */ NULL, NULL },
545 { /* entry idx, value */ 4, VALUE_OPT_GQ_PARAMS,
546 /* equiv idx, value */ 4, VALUE_OPT_GQ_PARAMS,
547 /* equivalenced to */ NO_EQUIVALENT,
548 /* min, max, act ct */ 0, 1, 0,
549 /* opt state flags */ GQ_PARAMS_FLAGS, 0,
550 /* last opt argumnt */ { NULL },
551 /* arg list/cookie */ NULL,
552 /* must/cannot opts */ NULL, NULL,
553 /* option proc */ NULL,
554 /* desc, NAME, name */ zGq_ParamsText, zGq_Params_NAME, zGq_Params_Name,
555 /* disablement strs */ NULL, NULL },
557 { /* entry idx, value */ 5, VALUE_OPT_GQ_KEYS,
558 /* equiv idx, value */ 5, VALUE_OPT_GQ_KEYS,
559 /* equivalenced to */ NO_EQUIVALENT,
560 /* min, max, act ct */ 0, 1, 0,
561 /* opt state flags */ GQ_KEYS_FLAGS, 0,
562 /* last opt argumnt */ { NULL },
563 /* arg list/cookie */ NULL,
564 /* must/cannot opts */ NULL, NULL,
565 /* option proc */ NULL,
566 /* desc, NAME, name */ zGq_KeysText, zGq_Keys_NAME, zGq_Keys_Name,
567 /* disablement strs */ NULL, NULL },
569 { /* entry idx, value */ 6, VALUE_OPT_HOST_KEY,
570 /* equiv idx, value */ 6, VALUE_OPT_HOST_KEY,
571 /* equivalenced to */ NO_EQUIVALENT,
572 /* min, max, act ct */ 0, 1, 0,
573 /* opt state flags */ HOST_KEY_FLAGS, 0,
574 /* last opt argumnt */ { NULL },
575 /* arg list/cookie */ NULL,
576 /* must/cannot opts */ NULL, NULL,
577 /* option proc */ NULL,
578 /* desc, NAME, name */ zHost_KeyText, zHost_Key_NAME, zHost_Key_Name,
579 /* disablement strs */ NULL, NULL },
581 { /* entry idx, value */ 7, VALUE_OPT_IFFKEY,
582 /* equiv idx, value */ 7, VALUE_OPT_IFFKEY,
583 /* equivalenced to */ NO_EQUIVALENT,
584 /* min, max, act ct */ 0, 1, 0,
585 /* opt state flags */ IFFKEY_FLAGS, 0,
586 /* last opt argumnt */ { NULL },
587 /* arg list/cookie */ NULL,
588 /* must/cannot opts */ NULL, NULL,
589 /* option proc */ NULL,
590 /* desc, NAME, name */ zIffkeyText, zIffkey_NAME, zIffkey_Name,
591 /* disablement strs */ NULL, NULL },
593 { /* entry idx, value */ 8, VALUE_OPT_ISSUER_NAME,
594 /* equiv idx, value */ 8, VALUE_OPT_ISSUER_NAME,
595 /* equivalenced to */ NO_EQUIVALENT,
596 /* min, max, act ct */ 0, 1, 0,
597 /* opt state flags */ ISSUER_NAME_FLAGS, 0,
598 /* last opt argumnt */ { NULL },
599 /* arg list/cookie */ NULL,
600 /* must/cannot opts */ NULL, NULL,
601 /* option proc */ NULL,
602 /* desc, NAME, name */ zIssuer_NameText, zIssuer_Name_NAME, zIssuer_Name_Name,
603 /* disablement strs */ NULL, NULL },
605 { /* entry idx, value */ 9, VALUE_OPT_MD5KEY,
606 /* equiv idx, value */ 9, VALUE_OPT_MD5KEY,
607 /* equivalenced to */ NO_EQUIVALENT,
608 /* min, max, act ct */ 0, 1, 0,
609 /* opt state flags */ MD5KEY_FLAGS, 0,
610 /* last opt argumnt */ { NULL },
611 /* arg list/cookie */ NULL,
612 /* must/cannot opts */ NULL, NULL,
613 /* option proc */ NULL,
614 /* desc, NAME, name */ zMd5keyText, zMd5key_NAME, zMd5key_Name,
615 /* disablement strs */ NULL, NULL },
617 { /* entry idx, value */ 10, VALUE_OPT_MODULUS,
618 /* equiv idx, value */ 10, VALUE_OPT_MODULUS,
619 /* equivalenced to */ NO_EQUIVALENT,
620 /* min, max, act ct */ 0, 1, 0,
621 /* opt state flags */ MODULUS_FLAGS, 0,
622 /* last opt argumnt */ { NULL },
623 /* arg list/cookie */ NULL,
624 /* must/cannot opts */ NULL, NULL,
625 /* option proc */ doOptModulus,
626 /* desc, NAME, name */ zModulusText, zModulus_NAME, zModulus_Name,
627 /* disablement strs */ NULL, NULL },
629 { /* entry idx, value */ 11, VALUE_OPT_PVT_CERT,
630 /* equiv idx, value */ 11, VALUE_OPT_PVT_CERT,
631 /* equivalenced to */ NO_EQUIVALENT,
632 /* min, max, act ct */ 0, 1, 0,
633 /* opt state flags */ PVT_CERT_FLAGS, 0,
634 /* last opt argumnt */ { NULL },
635 /* arg list/cookie */ NULL,
636 /* must/cannot opts */ NULL, NULL,
637 /* option proc */ NULL,
638 /* desc, NAME, name */ zPvt_CertText, zPvt_Cert_NAME, zPvt_Cert_Name,
639 /* disablement strs */ NULL, NULL },
641 { /* entry idx, value */ 12, VALUE_OPT_PVT_PASSWD,
642 /* equiv idx, value */ 12, VALUE_OPT_PVT_PASSWD,
643 /* equivalenced to */ NO_EQUIVALENT,
644 /* min, max, act ct */ 0, 1, 0,
645 /* opt state flags */ PVT_PASSWD_FLAGS, 0,
646 /* last opt argumnt */ { NULL },
647 /* arg list/cookie */ NULL,
648 /* must/cannot opts */ NULL, NULL,
649 /* option proc */ NULL,
650 /* desc, NAME, name */ zPvt_PasswdText, zPvt_Passwd_NAME, zPvt_Passwd_Name,
651 /* disablement strs */ NULL, NULL },
653 { /* entry idx, value */ 13, VALUE_OPT_GET_PVT_PASSWD,
654 /* equiv idx, value */ 13, VALUE_OPT_GET_PVT_PASSWD,
655 /* equivalenced to */ NO_EQUIVALENT,
656 /* min, max, act ct */ 0, 1, 0,
657 /* opt state flags */ GET_PVT_PASSWD_FLAGS, 0,
658 /* last opt argumnt */ { NULL },
659 /* arg list/cookie */ NULL,
660 /* must/cannot opts */ NULL, NULL,
661 /* option proc */ NULL,
662 /* desc, NAME, name */ zGet_Pvt_PasswdText, zGet_Pvt_Passwd_NAME, zGet_Pvt_Passwd_Name,
663 /* disablement strs */ NULL, NULL },
665 { /* entry idx, value */ 14, VALUE_OPT_SIGN_KEY,
666 /* equiv idx, value */ 14, VALUE_OPT_SIGN_KEY,
667 /* equivalenced to */ NO_EQUIVALENT,
668 /* min, max, act ct */ 0, 1, 0,
669 /* opt state flags */ SIGN_KEY_FLAGS, 0,
670 /* last opt argumnt */ { NULL },
671 /* arg list/cookie */ NULL,
672 /* must/cannot opts */ NULL, NULL,
673 /* option proc */ NULL,
674 /* desc, NAME, name */ zSign_KeyText, zSign_Key_NAME, zSign_Key_Name,
675 /* disablement strs */ NULL, NULL },
677 { /* entry idx, value */ 15, VALUE_OPT_SUBJECT_NAME,
678 /* equiv idx, value */ 15, VALUE_OPT_SUBJECT_NAME,
679 /* equivalenced to */ NO_EQUIVALENT,
680 /* min, max, act ct */ 0, 1, 0,
681 /* opt state flags */ SUBJECT_NAME_FLAGS, 0,
682 /* last opt argumnt */ { NULL },
683 /* arg list/cookie */ NULL,
684 /* must/cannot opts */ NULL, NULL,
685 /* option proc */ NULL,
686 /* desc, NAME, name */ zSubject_NameText, zSubject_Name_NAME, zSubject_Name_Name,
687 /* disablement strs */ NULL, NULL },
689 { /* entry idx, value */ 16, VALUE_OPT_TRUSTED_CERT,
690 /* equiv idx, value */ 16, VALUE_OPT_TRUSTED_CERT,
691 /* equivalenced to */ NO_EQUIVALENT,
692 /* min, max, act ct */ 0, 1, 0,
693 /* opt state flags */ TRUSTED_CERT_FLAGS, 0,
694 /* last opt argumnt */ { NULL },
695 /* arg list/cookie */ NULL,
696 /* must/cannot opts */ NULL, NULL,
697 /* option proc */ NULL,
698 /* desc, NAME, name */ zTrusted_CertText, zTrusted_Cert_NAME, zTrusted_Cert_Name,
699 /* disablement strs */ NULL, NULL },
701 { /* entry idx, value */ 17, VALUE_OPT_MV_PARAMS,
702 /* equiv idx, value */ 17, VALUE_OPT_MV_PARAMS,
703 /* equivalenced to */ NO_EQUIVALENT,
704 /* min, max, act ct */ 0, 1, 0,
705 /* opt state flags */ MV_PARAMS_FLAGS, 0,
706 /* last opt argumnt */ { NULL },
707 /* arg list/cookie */ NULL,
708 /* must/cannot opts */ NULL, NULL,
709 /* option proc */ optionNumericVal,
710 /* desc, NAME, name */ zMv_ParamsText, zMv_Params_NAME, zMv_Params_Name,
711 /* disablement strs */ NULL, NULL },
713 { /* entry idx, value */ 18, VALUE_OPT_MV_KEYS,
714 /* equiv idx, value */ 18, VALUE_OPT_MV_KEYS,
715 /* equivalenced to */ NO_EQUIVALENT,
716 /* min, max, act ct */ 0, 1, 0,
717 /* opt state flags */ MV_KEYS_FLAGS, 0,
718 /* last opt argumnt */ { NULL },
719 /* arg list/cookie */ NULL,
720 /* must/cannot opts */ NULL, NULL,
721 /* option proc */ optionNumericVal,
722 /* desc, NAME, name */ zMv_KeysText, zMv_Keys_NAME, zMv_Keys_Name,
723 /* disablement strs */ NULL, NULL },
725 #ifdef NO_OPTIONAL_OPT_ARGS
726 # define VERSION_OPT_FLAGS OPTST_IMM | OPTST_NO_INIT
727 #else
728 # define VERSION_OPT_FLAGS OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
729 OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT
730 #endif
732 { /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
733 /* equiv idx value */ NO_EQUIVALENT, 0,
734 /* equivalenced to */ NO_EQUIVALENT,
735 /* min, max, act ct */ 0, 1, 0,
736 /* opt state flags */ VERSION_OPT_FLAGS, 0,
737 /* last opt argumnt */ { NULL },
738 /* arg list/cookie */ NULL,
739 /* must/cannot opts */ NULL, NULL,
740 /* option proc */ DOVERPROC,
741 /* desc, NAME, name */ zVersionText, NULL, zVersion_Name,
742 /* disablement strs */ NULL, NULL },
744 #undef VERSION_OPT_FLAGS
747 { /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
748 /* equiv idx value */ NO_EQUIVALENT, 0,
749 /* equivalenced to */ NO_EQUIVALENT,
750 /* min, max, act ct */ 0, 1, 0,
751 /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0,
752 /* last opt argumnt */ { NULL },
753 /* arg list/cookie */ NULL,
754 /* must/cannot opts */ NULL, NULL,
755 /* option proc */ doUsageOpt,
756 /* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
757 /* disablement strs */ NULL, NULL },
759 { /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
760 /* equiv idx value */ NO_EQUIVALENT, 0,
761 /* equivalenced to */ NO_EQUIVALENT,
762 /* min, max, act ct */ 0, 1, 0,
763 /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0,
764 /* last opt argumnt */ { NULL },
765 /* arg list/cookie */ NULL,
766 /* must/cannot opts */ NULL, NULL,
767 /* option proc */ optionPagedUsage,
768 /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name,
769 /* disablement strs */ NULL, NULL },
771 { /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS,
772 /* equiv idx value */ NO_EQUIVALENT, 0,
773 /* equivalenced to */ NO_EQUIVALENT,
774 /* min, max, act ct */ 0, 1, 0,
775 /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
776 | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0,
777 /* last opt argumnt */ { NULL },
778 /* arg list/cookie */ NULL,
779 /* must/cannot opts */ NULL, NULL,
780 /* option proc */ NULL,
781 /* desc, NAME, name */ zSave_OptsText, NULL, zSave_Opts_Name,
782 /* disablement strs */ NULL, NULL },
784 { /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS,
785 /* equiv idx value */ NO_EQUIVALENT, 0,
786 /* equivalenced to */ NO_EQUIVALENT,
787 /* min, max, act ct */ 0, NOLIMIT, 0,
788 /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) \
789 | OPTST_DISABLE_IMM, 0,
790 /* last opt argumnt */ { NULL },
791 /* arg list/cookie */ NULL,
792 /* must/cannot opts */ NULL, NULL,
793 /* option proc */ optionLoadOpt,
794 /* desc, NAME, name */ zLoad_OptsText, zLoad_Opts_NAME, zLoad_Opts_Name,
795 /* disablement strs */ zNotLoad_Opts_Name, zNotLoad_Opts_Pfx }
798 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
800 * Define the Ntp_Keygen Option Environment
802 tSCC zPROGNAME[] = "NTP_KEYGEN";
803 tSCC zUsageTitle[] =
804 "ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.4p8\n\
805 USAGE: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n";
806 tSCC zRcName[] = ".ntprc";
807 tSCC* apzHomeList[] = {
808 "$HOME",
809 ".",
810 NULL };
812 tSCC zBugsAddr[] = "http://bugs.ntp.org, bugs@ntp.org";
813 #define zExplain NULL
814 tSCC zDetail[] = "\n\
815 If there is no new host key, look for an existing one.\n\
816 If one is not found, create it.\n";
817 tSCC zFullVersion[] = NTP_KEYGEN_FULL_VERSION;
818 /* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optcode.tpl near line 408 */
820 #if defined(ENABLE_NLS)
821 # define OPTPROC_BASE OPTPROC_TRANSLATE
822 static tOptionXlateProc translate_option_strings;
823 #else
824 # define OPTPROC_BASE OPTPROC_NONE
825 # define translate_option_strings NULL
826 #endif /* ENABLE_NLS */
828 tOptions ntp_keygenOptions = {
829 OPTIONS_STRUCT_VERSION,
830 0, NULL, /* original argc + argv */
831 ( OPTPROC_BASE
832 + OPTPROC_ERRSTOP
833 + OPTPROC_SHORTOPT
834 + OPTPROC_LONGOPT
835 + OPTPROC_NO_REQ_OPT
836 + OPTPROC_ENVIRON
837 + OPTPROC_NO_ARGS
838 + OPTPROC_HAS_IMMED ),
839 0, NULL, /* current option index, current option */
840 NULL, NULL, zPROGNAME,
841 zRcName, zCopyright, zCopyrightNotice,
842 zFullVersion, apzHomeList, zUsageTitle,
843 zExplain, zDetail, optDesc,
844 zBugsAddr, /* address to send bugs to */
845 NULL, NULL, /* extensions/saved state */
846 optionUsage, /* usage procedure */
847 translate_option_strings, /* translation procedure */
849 * Indexes to special options
851 { INDEX_OPT_MORE_HELP,
852 INDEX_OPT_SAVE_OPTS,
853 NO_EQUIVALENT /* index of '-#' option */,
854 NO_EQUIVALENT /* index of default opt */
856 24 /* full option count */, 19 /* user option count */
860 * Create the static procedure(s) declared above.
862 static void
863 doUsageOpt(
864 tOptions* pOptions,
865 tOptDesc* pOptDesc )
867 USAGE( EXIT_SUCCESS );
870 #if ! defined(TEST_NTP_KEYGEN_OPTS)
872 /* * * * * * *
874 * For the set-debug-level option, when DEBUG is #define-d.
876 #ifdef DEBUG
877 static void
878 doOptSet_Debug_Level(
879 tOptions* pOptions,
880 tOptDesc* pOptDesc )
882 /* extracted from ../include/debug-opt.def, line 29 */
883 DESC(DEBUG_LEVEL).optOccCt = atoi( pOptDesc->pzLastArg );
885 #endif /* defined DEBUG */
887 #endif /* defined(TEST_NTP_KEYGEN_OPTS) */
889 /* * * * * * *
891 * For the modulus option, when OPENSSL is #define-d.
893 #ifdef OPENSSL
894 static void
895 doOptModulus(
896 tOptions* pOptions,
897 tOptDesc* pOptDesc )
899 static const struct {const int rmin, rmax;} rng[ 1 ] = {
900 { 256, 2048 } };
901 int val;
902 int ix;
903 char const* pzIndent = "\t\t\t\t ";
904 extern FILE* option_usage_fp;
906 if (pOptDesc == NULL) /* usage is requesting range list
907 option_usage_fp has already been set */
908 goto emit_ranges;
910 val = atoi( pOptDesc->optArg.argString );
911 for (ix = 0; ix < 1; ix++) {
912 if (val < rng[ix].rmin)
913 continue; /* ranges need not be ordered. */
914 if (val == rng[ix].rmin)
915 goto valid_return;
916 if (rng[ix].rmax == INT_MIN)
917 continue;
918 if (val <= rng[ix].rmax)
919 goto valid_return;
922 option_usage_fp = stderr;
923 fprintf(stderr, _("%s error: %s option value ``%s''is out of range.\n"),
924 pOptions->pzProgName, pOptDesc->pz_Name, pOptDesc->optArg.argString);
925 pzIndent = "\t";
927 emit_ranges:
928 fprintf( option_usage_fp, _("%sit must lie in the range: %d to %d\n"),
929 pzIndent, rng[0].rmin, rng[0].rmax );
930 if (pOptDesc == NULL)
931 return;
933 USAGE( EXIT_FAILURE );
934 /* NOTREACHED */
935 return;
937 valid_return:
938 pOptDesc->optArg.argInt = val;
940 #endif /* defined OPENSSL */
942 /* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optmain.tpl near line 92 */
944 #if defined(TEST_NTP_KEYGEN_OPTS) /* TEST MAIN PROCEDURE: */
947 main( int argc, char** argv )
949 int res = EXIT_SUCCESS;
950 (void)optionProcess( &ntp_keygenOptions, argc, argv );
952 void optionPutShell( tOptions* );
953 optionPutShell( &ntp_keygenOptions );
955 return res;
957 #endif /* defined TEST_NTP_KEYGEN_OPTS */
958 /* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optcode.tpl near line 514 */
960 #if ENABLE_NLS
961 #include <stdio.h>
962 #include <stdlib.h>
963 #include <string.h>
964 #include <unistd.h>
965 #include <autoopts/usage-txt.h>
967 static char* AO_gettext( char const* pz );
968 static void coerce_it(void** s);
970 static char*
971 AO_gettext( char const* pz )
973 char* pzRes;
974 if (pz == NULL)
975 return NULL;
976 pzRes = _(pz);
977 if (pzRes == pz)
978 return pzRes;
979 pzRes = strdup( pzRes );
980 if (pzRes == NULL) {
981 fputs( _("No memory for duping translated strings\n"), stderr );
982 exit( EXIT_FAILURE );
984 return pzRes;
987 static void coerce_it(void** s) { *s = AO_gettext(*s); }
988 #define COERSION(_f) \
989 coerce_it((void*)&(ntp_keygenOptions._f))
992 * This invokes the translation code (e.g. gettext(3)).
994 static void
995 translate_option_strings( void )
998 * Guard against re-translation. It won't work. The strings will have
999 * been changed by the first pass through this code. One shot only.
1001 if (option_usage_text.field_ct == 0)
1002 return;
1004 * Do the translations. The first pointer follows the field count field.
1005 * The field count field is the size of a pointer.
1008 char** ppz = (char**)(void*)&(option_usage_text);
1009 int ix = option_usage_text.field_ct;
1011 do {
1012 ppz++;
1013 *ppz = AO_gettext(*ppz);
1014 } while (--ix > 0);
1016 option_usage_text.field_ct = 0;
1019 tOptDesc* pOD = ntp_keygenOptions.pOptDesc;
1020 int ix = ntp_keygenOptions.optCt;
1022 for (;;) {
1023 pOD->pzText = AO_gettext(pOD->pzText);
1024 pOD->pz_NAME = AO_gettext(pOD->pz_NAME);
1025 pOD->pz_Name = AO_gettext(pOD->pz_Name);
1026 pOD->pz_DisableName = AO_gettext(pOD->pz_DisableName);
1027 pOD->pz_DisablePfx = AO_gettext(pOD->pz_DisablePfx);
1028 if (--ix <= 0)
1029 break;
1030 pOD++;
1033 COERSION(pzCopyright);
1034 COERSION(pzCopyNotice);
1035 COERSION(pzFullVersion);
1036 COERSION(pzUsageTitle);
1037 COERSION(pzExplain);
1038 COERSION(pzDetail);
1041 #endif /* ENABLE_NLS */
1043 #ifdef __cplusplus
1045 #endif
1046 /* ntp-keygen-opts.c ends here */