Annotation of embedaddon/ntp/util/ntp-keygen-opts.c, revision 1.1.1.1
1.1 misho 1: /*
2: * EDIT THIS FILE WITH CAUTION (ntp-keygen-opts.c)
3: *
4: * It has been AutoGen-ed December 24, 2011 at 06:34:40 PM by AutoGen 5.12
5: * From the definitions ntp-keygen-opts.def
6: * and the template file options
7: *
8: * Generated from AutoOpts 35:0:10 templates.
9: *
10: * AutoOpts is a copyrighted work. This source file is not encumbered
11: * by AutoOpts licensing, but is provided under the licensing terms chosen
12: * by the ntp-keygen author or copyright holder. AutoOpts is
13: * licensed under the terms of the LGPL. The redistributable library
14: * (``libopts'') is licensed under the terms of either the LGPL or, at the
15: * users discretion, the BSD license. See the AutoOpts and/or libopts sources
16: * for details.
17: *
18: * This source file is copyrighted and licensed under the following terms:
19: *
20: * see html/copyright.html
21: *
22: */
23:
24: #include <sys/types.h>
25:
26: #include <limits.h>
27: #include <stdio.h>
28: #include <stdlib.h>
29: #include <errno.h>
30: #define OPTION_CODE_COMPILE 1
31: #include "ntp-keygen-opts.h"
32:
33: #ifdef __cplusplus
34: extern "C" {
35: #endif
36: extern FILE * option_usage_fp;
37:
38: /* TRANSLATORS: choose the translation for option names wisely because you
39: cannot ever change your mind. */
40: static char const zCopyright[50] =
41: "ntp-keygen (ntp) 4.2.6p5\n\
42: see html/copyright.html\n";
43: static char const zLicenseDescrip[25] =
44: "see html/copyright.html\n";
45:
46: extern tUsageProc optionUsage;
47:
48: /*
49: * global included definitions
50: */
51: #include <stdlib.h>
52: #ifdef __windows
53: extern int atoi(const char*);
54: #else
55: # include <stdlib.h>
56: #endif
57:
58: #ifndef NULL
59: # define NULL 0
60: #endif
61:
62: /*
63: * Certificate option description:
64: */
65: #ifdef OPENSSL
66: static char const zCertificateText[] =
67: "certificate scheme";
68: static char const zCertificate_NAME[] = "CERTIFICATE";
69: static char const zCertificate_Name[] = "certificate";
70: #define CERTIFICATE_FLAGS (OPTST_DISABLED \
71: | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
72:
73: #else /* disable Certificate */
74: #define CERTIFICATE_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
75: #define zCertificate_NAME NULL
76: #define zCertificateText NULL
77: #define zCertificate_Name NULL
78: #endif /* OPENSSL */
79:
80: /*
81: * Debug_Level option description:
82: */
83: static char const zDebug_LevelText[] =
84: "Increase output debug message level";
85: static char const zDebug_Level_NAME[] = "DEBUG_LEVEL";
86: static char const zDebug_Level_Name[] = "debug-level";
87: #define DEBUG_LEVEL_FLAGS (OPTST_DISABLED)
88:
89: /*
90: * Set_Debug_Level option description:
91: */
92: static char const zSet_Debug_LevelText[] =
93: "Set the output debug message level";
94: static char const zSet_Debug_Level_NAME[] = "SET_DEBUG_LEVEL";
95: static char const zSet_Debug_Level_Name[] = "set-debug-level";
96: #define SET_DEBUG_LEVEL_FLAGS (OPTST_DISABLED \
97: | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
98:
99: /*
100: * Id_Key option description:
101: */
102: #ifdef OPENSSL
103: static char const zId_KeyText[] =
104: "Write IFF or GQ identity keys";
105: static char const zId_Key_NAME[] = "ID_KEY";
106: static char const zId_Key_Name[] = "id-key";
107: #define ID_KEY_FLAGS (OPTST_DISABLED)
108:
109: #else /* disable Id_Key */
110: #define ID_KEY_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
111: #define zId_Key_NAME NULL
112: #define zId_KeyText NULL
113: #define zId_Key_Name NULL
114: #endif /* OPENSSL */
115:
116: /*
117: * Gq_Params option description:
118: */
119: #ifdef OPENSSL
120: static char const zGq_ParamsText[] =
121: "Generate GQ parameters and keys";
122: static char const zGq_Params_NAME[] = "GQ_PARAMS";
123: static char const zGq_Params_Name[] = "gq-params";
124: #define GQ_PARAMS_FLAGS (OPTST_DISABLED)
125:
126: #else /* disable Gq_Params */
127: #define GQ_PARAMS_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
128: #define zGq_Params_NAME NULL
129: #define zGq_ParamsText NULL
130: #define zGq_Params_Name NULL
131: #endif /* OPENSSL */
132:
133: /*
134: * Host_Key option description:
135: */
136: #ifdef OPENSSL
137: static char const zHost_KeyText[] =
138: "generate RSA host key";
139: static char const zHost_Key_NAME[] = "HOST_KEY";
140: static char const zHost_Key_Name[] = "host-key";
141: #define HOST_KEY_FLAGS (OPTST_DISABLED)
142:
143: #else /* disable Host_Key */
144: #define HOST_KEY_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
145: #define zHost_Key_NAME NULL
146: #define zHost_KeyText NULL
147: #define zHost_Key_Name NULL
148: #endif /* OPENSSL */
149:
150: /*
151: * Iffkey option description:
152: */
153: #ifdef OPENSSL
154: static char const zIffkeyText[] =
155: "generate IFF parameters";
156: static char const zIffkey_NAME[] = "IFFKEY";
157: static char const zIffkey_Name[] = "iffkey";
158: #define IFFKEY_FLAGS (OPTST_DISABLED)
159:
160: #else /* disable Iffkey */
161: #define IFFKEY_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
162: #define zIffkey_NAME NULL
163: #define zIffkeyText NULL
164: #define zIffkey_Name NULL
165: #endif /* OPENSSL */
166:
167: /*
168: * Issuer_Name option description:
169: */
170: #ifdef OPENSSL
171: static char const zIssuer_NameText[] =
172: "set issuer name";
173: static char const zIssuer_Name_NAME[] = "ISSUER_NAME";
174: static char const zIssuer_Name_Name[] = "issuer-name";
175: #define ISSUER_NAME_FLAGS (OPTST_DISABLED \
176: | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
177:
178: #else /* disable Issuer_Name */
179: #define ISSUER_NAME_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
180: #define zIssuer_Name_NAME NULL
181: #define zIssuer_NameText NULL
182: #define zIssuer_Name_Name NULL
183: #endif /* OPENSSL */
184:
185: /*
186: * Md5key option description:
187: */
188: static char const zMd5keyText[] =
189: "generate MD5 keys";
190: static char const zMd5key_NAME[] = "MD5KEY";
191: static char const zMd5key_Name[] = "md5key";
192: #define MD5KEY_FLAGS (OPTST_DISABLED)
193:
194: /*
195: * Modulus option description:
196: */
197: #ifdef OPENSSL
198: static char const zModulusText[] =
199: "modulus";
200: static char const zModulus_NAME[] = "MODULUS";
201: static char const zModulus_Name[] = "modulus";
202: #define MODULUS_FLAGS (OPTST_DISABLED \
203: | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
204:
205: #else /* disable Modulus */
206: #define MODULUS_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
207: #define zModulus_NAME NULL
208: #define zModulusText NULL
209: #define zModulus_Name NULL
210: #endif /* OPENSSL */
211:
212: /*
213: * Pvt_Cert option description:
214: */
215: #ifdef OPENSSL
216: static char const zPvt_CertText[] =
217: "generate PC private certificate";
218: static char const zPvt_Cert_NAME[] = "PVT_CERT";
219: static char const zPvt_Cert_Name[] = "pvt-cert";
220: #define PVT_CERT_FLAGS (OPTST_DISABLED)
221:
222: #else /* disable Pvt_Cert */
223: #define PVT_CERT_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
224: #define zPvt_Cert_NAME NULL
225: #define zPvt_CertText NULL
226: #define zPvt_Cert_Name NULL
227: #endif /* OPENSSL */
228:
229: /*
230: * Pvt_Passwd option description:
231: */
232: #ifdef OPENSSL
233: static char const zPvt_PasswdText[] =
234: "output private password";
235: static char const zPvt_Passwd_NAME[] = "PVT_PASSWD";
236: static char const zPvt_Passwd_Name[] = "pvt-passwd";
237: #define PVT_PASSWD_FLAGS (OPTST_DISABLED \
238: | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
239:
240: #else /* disable Pvt_Passwd */
241: #define PVT_PASSWD_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
242: #define zPvt_Passwd_NAME NULL
243: #define zPvt_PasswdText NULL
244: #define zPvt_Passwd_Name NULL
245: #endif /* OPENSSL */
246:
247: /*
248: * Get_Pvt_Passwd option description:
249: */
250: #ifdef OPENSSL
251: static char const zGet_Pvt_PasswdText[] =
252: "input private password";
253: static char const zGet_Pvt_Passwd_NAME[] = "GET_PVT_PASSWD";
254: static char const zGet_Pvt_Passwd_Name[] = "get-pvt-passwd";
255: #define GET_PVT_PASSWD_FLAGS (OPTST_DISABLED \
256: | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
257:
258: #else /* disable Get_Pvt_Passwd */
259: #define GET_PVT_PASSWD_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
260: #define zGet_Pvt_Passwd_NAME NULL
261: #define zGet_Pvt_PasswdText NULL
262: #define zGet_Pvt_Passwd_Name NULL
263: #endif /* OPENSSL */
264:
265: /*
266: * Sign_Key option description:
267: */
268: #ifdef OPENSSL
269: static char const zSign_KeyText[] =
270: "generate sign key (RSA or DSA)";
271: static char const zSign_Key_NAME[] = "SIGN_KEY";
272: static char const zSign_Key_Name[] = "sign-key";
273: #define SIGN_KEY_FLAGS (OPTST_DISABLED \
274: | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
275:
276: #else /* disable Sign_Key */
277: #define SIGN_KEY_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
278: #define zSign_Key_NAME NULL
279: #define zSign_KeyText NULL
280: #define zSign_Key_Name NULL
281: #endif /* OPENSSL */
282:
283: /*
284: * Subject_Name option description:
285: */
286: #ifdef OPENSSL
287: static char const zSubject_NameText[] =
288: "set subject name";
289: static char const zSubject_Name_NAME[] = "SUBJECT_NAME";
290: static char const zSubject_Name_Name[] = "subject-name";
291: #define SUBJECT_NAME_FLAGS (OPTST_DISABLED \
292: | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
293:
294: #else /* disable Subject_Name */
295: #define SUBJECT_NAME_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
296: #define zSubject_Name_NAME NULL
297: #define zSubject_NameText NULL
298: #define zSubject_Name_Name NULL
299: #endif /* OPENSSL */
300:
301: /*
302: * Trusted_Cert option description:
303: */
304: #ifdef OPENSSL
305: static char const zTrusted_CertText[] =
306: "trusted certificate (TC scheme)";
307: static char const zTrusted_Cert_NAME[] = "TRUSTED_CERT";
308: static char const zTrusted_Cert_Name[] = "trusted-cert";
309: #define TRUSTED_CERT_FLAGS (OPTST_DISABLED)
310:
311: #else /* disable Trusted_Cert */
312: #define TRUSTED_CERT_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
313: #define zTrusted_Cert_NAME NULL
314: #define zTrusted_CertText NULL
315: #define zTrusted_Cert_Name NULL
316: #endif /* OPENSSL */
317:
318: /*
319: * Mv_Params option description:
320: */
321: #ifdef OPENSSL
322: static char const zMv_ParamsText[] =
323: "generate <num> MV parameters";
324: static char const zMv_Params_NAME[] = "MV_PARAMS";
325: static char const zMv_Params_Name[] = "mv-params";
326: #define MV_PARAMS_FLAGS (OPTST_DISABLED \
327: | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
328:
329: #else /* disable Mv_Params */
330: #define MV_PARAMS_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
331: #define zMv_Params_NAME NULL
332: #define zMv_ParamsText NULL
333: #define zMv_Params_Name NULL
334: #endif /* OPENSSL */
335:
336: /*
337: * Mv_Keys option description:
338: */
339: #ifdef OPENSSL
340: static char const zMv_KeysText[] =
341: "update <num> MV keys";
342: static char const zMv_Keys_NAME[] = "MV_KEYS";
343: static char const zMv_Keys_Name[] = "mv-keys";
344: #define MV_KEYS_FLAGS (OPTST_DISABLED \
345: | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
346:
347: #else /* disable Mv_Keys */
348: #define MV_KEYS_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
349: #define zMv_Keys_NAME NULL
350: #define zMv_KeysText NULL
351: #define zMv_Keys_Name NULL
352: #endif /* OPENSSL */
353:
354: /*
355: * Help/More_Help/Version option descriptions:
356: */
357: static char const zHelpText[] = "Display extended usage information and exit";
358: static char const zHelp_Name[] = "help";
359: #ifdef HAVE_WORKING_FORK
360: #define OPTST_MORE_HELP_FLAGS (OPTST_IMM | OPTST_NO_INIT)
361: static char const zMore_Help_Name[] = "more-help";
362: static char const zMore_HelpText[] = "Extended usage information passed thru pager";
363: #else
364: #define OPTST_MORE_HELP_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
365: #define zMore_Help_Name NULL
366: #define zMore_HelpText NULL
367: #endif
368: #ifdef NO_OPTIONAL_OPT_ARGS
369: # define OPTST_VERSION_FLAGS OPTST_IMM | OPTST_NO_INIT
370: #else
371: # define OPTST_VERSION_FLAGS OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
372: OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT
373: #endif
374:
375: static char const zVersionText[] = "Output version information and exit";
376: static char const zVersion_Name[] = "version";
377: static char const zSave_OptsText[] = "Save the option state to a config file";
378: static char const zSave_Opts_Name[] = "save-opts";
379: static char const zLoad_OptsText[] = "Load options from a config file";
380: static char const zLoad_Opts_NAME[] = "LOAD_OPTS";
381: static char const zNotLoad_Opts_Name[] = "no-load-opts";
382: static char const zNotLoad_Opts_Pfx[] = "no";
383: #define zLoad_Opts_Name (zNotLoad_Opts_Name + 3)
384: /*
385: * Declare option callback procedures
386: */
387: #ifdef OPENSSL
388: static tOptProc doOptModulus;
389: #else /* not OPENSSL */
390: # define doOptModulus NULL
391: #endif /* def/not OPENSSL */
392: #if defined(TEST_NTP_KEYGEN_OPTS)
393: /*
394: * Under test, omit argument processing, or call optionStackArg,
395: * if multiple copies are allowed.
396: */
397: static tOptProc
398: doUsageOpt;
399:
400: /*
401: * #define map the "normal" callout procs to the test ones...
402: */
403: #define SET_DEBUG_LEVEL_OPT_PROC optionStackArg
404:
405:
406: #else /* NOT defined TEST_NTP_KEYGEN_OPTS */
407: /*
408: * When not under test, there are different procs to use
409: */
410: extern tOptProc
411: optionBooleanVal, optionNestedVal, optionNumericVal,
412: optionPagedUsage, optionPrintVersion, optionResetOpt,
413: optionStackArg, optionTimeDate, optionTimeVal,
414: optionUnstackArg, optionVersionStderr;
415: static tOptProc
416: doOptSet_Debug_Level, doUsageOpt;
417:
418: /*
419: * #define map the "normal" callout procs
420: */
421: #define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level
422:
423: #define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level
424: #endif /* defined(TEST_NTP_KEYGEN_OPTS) */
425: #ifdef TEST_NTP_KEYGEN_OPTS
426: # define DOVERPROC optionVersionStderr
427: #else
428: # define DOVERPROC optionPrintVersion
429: #endif /* TEST_NTP_KEYGEN_OPTS */
430:
431: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
432: *
433: * Define the Ntp_Keygen Option Descriptions.
434: */
435: static tOptDesc optDesc[OPTION_CT] = {
436: { /* entry idx, value */ 0, VALUE_OPT_CERTIFICATE,
437: /* equiv idx, value */ 0, VALUE_OPT_CERTIFICATE,
438: /* equivalenced to */ NO_EQUIVALENT,
439: /* min, max, act ct */ 0, 1, 0,
440: /* opt state flags */ CERTIFICATE_FLAGS, 0,
441: /* last opt argumnt */ { NULL },
442: /* arg list/cookie */ NULL,
443: /* must/cannot opts */ NULL, NULL,
444: /* option proc */ NULL,
445: /* desc, NAME, name */ zCertificateText, zCertificate_NAME, zCertificate_Name,
446: /* disablement strs */ NULL, NULL },
447:
448: { /* entry idx, value */ 1, VALUE_OPT_DEBUG_LEVEL,
449: /* equiv idx, value */ 1, VALUE_OPT_DEBUG_LEVEL,
450: /* equivalenced to */ NO_EQUIVALENT,
451: /* min, max, act ct */ 0, NOLIMIT, 0,
452: /* opt state flags */ DEBUG_LEVEL_FLAGS, 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 */ zDebug_LevelText, zDebug_Level_NAME, zDebug_Level_Name,
458: /* disablement strs */ NULL, NULL },
459:
460: { /* entry idx, value */ 2, VALUE_OPT_SET_DEBUG_LEVEL,
461: /* equiv idx, value */ 2, VALUE_OPT_SET_DEBUG_LEVEL,
462: /* equivalenced to */ NO_EQUIVALENT,
463: /* min, max, act ct */ 0, NOLIMIT, 0,
464: /* opt state flags */ SET_DEBUG_LEVEL_FLAGS, 0,
465: /* last opt argumnt */ { NULL },
466: /* arg list/cookie */ NULL,
467: /* must/cannot opts */ NULL, NULL,
468: /* option proc */ SET_DEBUG_LEVEL_OPT_PROC,
469: /* desc, NAME, name */ zSet_Debug_LevelText, zSet_Debug_Level_NAME, zSet_Debug_Level_Name,
470: /* disablement strs */ NULL, NULL },
471:
472: { /* entry idx, value */ 3, VALUE_OPT_ID_KEY,
473: /* equiv idx, value */ 3, VALUE_OPT_ID_KEY,
474: /* equivalenced to */ NO_EQUIVALENT,
475: /* min, max, act ct */ 0, 1, 0,
476: /* opt state flags */ ID_KEY_FLAGS, 0,
477: /* last opt argumnt */ { NULL },
478: /* arg list/cookie */ NULL,
479: /* must/cannot opts */ NULL, NULL,
480: /* option proc */ NULL,
481: /* desc, NAME, name */ zId_KeyText, zId_Key_NAME, zId_Key_Name,
482: /* disablement strs */ NULL, NULL },
483:
484: { /* entry idx, value */ 4, VALUE_OPT_GQ_PARAMS,
485: /* equiv idx, value */ 4, VALUE_OPT_GQ_PARAMS,
486: /* equivalenced to */ NO_EQUIVALENT,
487: /* min, max, act ct */ 0, 1, 0,
488: /* opt state flags */ GQ_PARAMS_FLAGS, 0,
489: /* last opt argumnt */ { NULL },
490: /* arg list/cookie */ NULL,
491: /* must/cannot opts */ NULL, NULL,
492: /* option proc */ NULL,
493: /* desc, NAME, name */ zGq_ParamsText, zGq_Params_NAME, zGq_Params_Name,
494: /* disablement strs */ NULL, NULL },
495:
496: { /* entry idx, value */ 5, VALUE_OPT_HOST_KEY,
497: /* equiv idx, value */ 5, VALUE_OPT_HOST_KEY,
498: /* equivalenced to */ NO_EQUIVALENT,
499: /* min, max, act ct */ 0, 1, 0,
500: /* opt state flags */ HOST_KEY_FLAGS, 0,
501: /* last opt argumnt */ { NULL },
502: /* arg list/cookie */ NULL,
503: /* must/cannot opts */ NULL, NULL,
504: /* option proc */ NULL,
505: /* desc, NAME, name */ zHost_KeyText, zHost_Key_NAME, zHost_Key_Name,
506: /* disablement strs */ NULL, NULL },
507:
508: { /* entry idx, value */ 6, VALUE_OPT_IFFKEY,
509: /* equiv idx, value */ 6, VALUE_OPT_IFFKEY,
510: /* equivalenced to */ NO_EQUIVALENT,
511: /* min, max, act ct */ 0, 1, 0,
512: /* opt state flags */ IFFKEY_FLAGS, 0,
513: /* last opt argumnt */ { NULL },
514: /* arg list/cookie */ NULL,
515: /* must/cannot opts */ NULL, NULL,
516: /* option proc */ NULL,
517: /* desc, NAME, name */ zIffkeyText, zIffkey_NAME, zIffkey_Name,
518: /* disablement strs */ NULL, NULL },
519:
520: { /* entry idx, value */ 7, VALUE_OPT_ISSUER_NAME,
521: /* equiv idx, value */ 7, VALUE_OPT_ISSUER_NAME,
522: /* equivalenced to */ NO_EQUIVALENT,
523: /* min, max, act ct */ 0, 1, 0,
524: /* opt state flags */ ISSUER_NAME_FLAGS, 0,
525: /* last opt argumnt */ { NULL },
526: /* arg list/cookie */ NULL,
527: /* must/cannot opts */ NULL, NULL,
528: /* option proc */ NULL,
529: /* desc, NAME, name */ zIssuer_NameText, zIssuer_Name_NAME, zIssuer_Name_Name,
530: /* disablement strs */ NULL, NULL },
531:
532: { /* entry idx, value */ 8, VALUE_OPT_MD5KEY,
533: /* equiv idx, value */ 8, VALUE_OPT_MD5KEY,
534: /* equivalenced to */ NO_EQUIVALENT,
535: /* min, max, act ct */ 0, 1, 0,
536: /* opt state flags */ MD5KEY_FLAGS, 0,
537: /* last opt argumnt */ { NULL },
538: /* arg list/cookie */ NULL,
539: /* must/cannot opts */ NULL, NULL,
540: /* option proc */ NULL,
541: /* desc, NAME, name */ zMd5keyText, zMd5key_NAME, zMd5key_Name,
542: /* disablement strs */ NULL, NULL },
543:
544: { /* entry idx, value */ 9, VALUE_OPT_MODULUS,
545: /* equiv idx, value */ 9, VALUE_OPT_MODULUS,
546: /* equivalenced to */ NO_EQUIVALENT,
547: /* min, max, act ct */ 0, 1, 0,
548: /* opt state flags */ MODULUS_FLAGS, 0,
549: /* last opt argumnt */ { NULL },
550: /* arg list/cookie */ NULL,
551: /* must/cannot opts */ NULL, NULL,
552: /* option proc */ doOptModulus,
553: /* desc, NAME, name */ zModulusText, zModulus_NAME, zModulus_Name,
554: /* disablement strs */ NULL, NULL },
555:
556: { /* entry idx, value */ 10, VALUE_OPT_PVT_CERT,
557: /* equiv idx, value */ 10, VALUE_OPT_PVT_CERT,
558: /* equivalenced to */ NO_EQUIVALENT,
559: /* min, max, act ct */ 0, 1, 0,
560: /* opt state flags */ PVT_CERT_FLAGS, 0,
561: /* last opt argumnt */ { NULL },
562: /* arg list/cookie */ NULL,
563: /* must/cannot opts */ NULL, NULL,
564: /* option proc */ NULL,
565: /* desc, NAME, name */ zPvt_CertText, zPvt_Cert_NAME, zPvt_Cert_Name,
566: /* disablement strs */ NULL, NULL },
567:
568: { /* entry idx, value */ 11, VALUE_OPT_PVT_PASSWD,
569: /* equiv idx, value */ 11, VALUE_OPT_PVT_PASSWD,
570: /* equivalenced to */ NO_EQUIVALENT,
571: /* min, max, act ct */ 0, 1, 0,
572: /* opt state flags */ PVT_PASSWD_FLAGS, 0,
573: /* last opt argumnt */ { NULL },
574: /* arg list/cookie */ NULL,
575: /* must/cannot opts */ NULL, NULL,
576: /* option proc */ NULL,
577: /* desc, NAME, name */ zPvt_PasswdText, zPvt_Passwd_NAME, zPvt_Passwd_Name,
578: /* disablement strs */ NULL, NULL },
579:
580: { /* entry idx, value */ 12, VALUE_OPT_GET_PVT_PASSWD,
581: /* equiv idx, value */ 12, VALUE_OPT_GET_PVT_PASSWD,
582: /* equivalenced to */ NO_EQUIVALENT,
583: /* min, max, act ct */ 0, 1, 0,
584: /* opt state flags */ GET_PVT_PASSWD_FLAGS, 0,
585: /* last opt argumnt */ { NULL },
586: /* arg list/cookie */ NULL,
587: /* must/cannot opts */ NULL, NULL,
588: /* option proc */ NULL,
589: /* desc, NAME, name */ zGet_Pvt_PasswdText, zGet_Pvt_Passwd_NAME, zGet_Pvt_Passwd_Name,
590: /* disablement strs */ NULL, NULL },
591:
592: { /* entry idx, value */ 13, VALUE_OPT_SIGN_KEY,
593: /* equiv idx, value */ 13, VALUE_OPT_SIGN_KEY,
594: /* equivalenced to */ NO_EQUIVALENT,
595: /* min, max, act ct */ 0, 1, 0,
596: /* opt state flags */ SIGN_KEY_FLAGS, 0,
597: /* last opt argumnt */ { NULL },
598: /* arg list/cookie */ NULL,
599: /* must/cannot opts */ NULL, NULL,
600: /* option proc */ NULL,
601: /* desc, NAME, name */ zSign_KeyText, zSign_Key_NAME, zSign_Key_Name,
602: /* disablement strs */ NULL, NULL },
603:
604: { /* entry idx, value */ 14, VALUE_OPT_SUBJECT_NAME,
605: /* equiv idx, value */ 14, VALUE_OPT_SUBJECT_NAME,
606: /* equivalenced to */ NO_EQUIVALENT,
607: /* min, max, act ct */ 0, 1, 0,
608: /* opt state flags */ SUBJECT_NAME_FLAGS, 0,
609: /* last opt argumnt */ { NULL },
610: /* arg list/cookie */ NULL,
611: /* must/cannot opts */ NULL, NULL,
612: /* option proc */ NULL,
613: /* desc, NAME, name */ zSubject_NameText, zSubject_Name_NAME, zSubject_Name_Name,
614: /* disablement strs */ NULL, NULL },
615:
616: { /* entry idx, value */ 15, VALUE_OPT_TRUSTED_CERT,
617: /* equiv idx, value */ 15, VALUE_OPT_TRUSTED_CERT,
618: /* equivalenced to */ NO_EQUIVALENT,
619: /* min, max, act ct */ 0, 1, 0,
620: /* opt state flags */ TRUSTED_CERT_FLAGS, 0,
621: /* last opt argumnt */ { NULL },
622: /* arg list/cookie */ NULL,
623: /* must/cannot opts */ NULL, NULL,
624: /* option proc */ NULL,
625: /* desc, NAME, name */ zTrusted_CertText, zTrusted_Cert_NAME, zTrusted_Cert_Name,
626: /* disablement strs */ NULL, NULL },
627:
628: { /* entry idx, value */ 16, VALUE_OPT_MV_PARAMS,
629: /* equiv idx, value */ 16, VALUE_OPT_MV_PARAMS,
630: /* equivalenced to */ NO_EQUIVALENT,
631: /* min, max, act ct */ 0, 1, 0,
632: /* opt state flags */ MV_PARAMS_FLAGS, 0,
633: /* last opt argumnt */ { NULL },
634: /* arg list/cookie */ NULL,
635: /* must/cannot opts */ NULL, NULL,
636: /* option proc */ optionNumericVal,
637: /* desc, NAME, name */ zMv_ParamsText, zMv_Params_NAME, zMv_Params_Name,
638: /* disablement strs */ NULL, NULL },
639:
640: { /* entry idx, value */ 17, VALUE_OPT_MV_KEYS,
641: /* equiv idx, value */ 17, VALUE_OPT_MV_KEYS,
642: /* equivalenced to */ NO_EQUIVALENT,
643: /* min, max, act ct */ 0, 1, 0,
644: /* opt state flags */ MV_KEYS_FLAGS, 0,
645: /* last opt argumnt */ { NULL },
646: /* arg list/cookie */ NULL,
647: /* must/cannot opts */ NULL, NULL,
648: /* option proc */ optionNumericVal,
649: /* desc, NAME, name */ zMv_KeysText, zMv_Keys_NAME, zMv_Keys_Name,
650: /* disablement strs */ NULL, NULL },
651:
652: { /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
653: /* equiv idx value */ NO_EQUIVALENT, 0,
654: /* equivalenced to */ NO_EQUIVALENT,
655: /* min, max, act ct */ 0, 1, 0,
656: /* opt state flags */ OPTST_VERSION_FLAGS, 0,
657: /* last opt argumnt */ { NULL },
658: /* arg list/cookie */ NULL,
659: /* must/cannot opts */ NULL, NULL,
660: /* option proc */ DOVERPROC,
661: /* desc, NAME, name */ zVersionText, NULL, zVersion_Name,
662: /* disablement strs */ NULL, NULL },
663:
664:
665:
666: { /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
667: /* equiv idx value */ NO_EQUIVALENT, 0,
668: /* equivalenced to */ NO_EQUIVALENT,
669: /* min, max, act ct */ 0, 1, 0,
670: /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0,
671: /* last opt argumnt */ { NULL },
672: /* arg list/cookie */ NULL,
673: /* must/cannot opts */ NULL, NULL,
674: /* option proc */ doUsageOpt,
675: /* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
676: /* disablement strs */ NULL, NULL },
677:
678: { /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
679: /* equiv idx value */ NO_EQUIVALENT, 0,
680: /* equivalenced to */ NO_EQUIVALENT,
681: /* min, max, act ct */ 0, 1, 0,
682: /* opt state flags */ OPTST_MORE_HELP_FLAGS, 0,
683: /* last opt argumnt */ { NULL },
684: /* arg list/cookie */ NULL,
685: /* must/cannot opts */ NULL, NULL,
686: /* option proc */ optionPagedUsage,
687: /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name,
688: /* disablement strs */ NULL, NULL },
689:
690: { /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS,
691: /* equiv idx value */ NO_EQUIVALENT, 0,
692: /* equivalenced to */ NO_EQUIVALENT,
693: /* min, max, act ct */ 0, 1, 0,
694: /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
695: | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0,
696: /* last opt argumnt */ { NULL },
697: /* arg list/cookie */ NULL,
698: /* must/cannot opts */ NULL, NULL,
699: /* option proc */ NULL,
700: /* desc, NAME, name */ zSave_OptsText, NULL, zSave_Opts_Name,
701: /* disablement strs */ NULL, NULL },
702:
703: { /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS,
704: /* equiv idx value */ NO_EQUIVALENT, 0,
705: /* equivalenced to */ NO_EQUIVALENT,
706: /* min, max, act ct */ 0, NOLIMIT, 0,
707: /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
708: | OPTST_DISABLE_IMM, 0,
709: /* last opt argumnt */ { NULL },
710: /* arg list/cookie */ NULL,
711: /* must/cannot opts */ NULL, NULL,
712: /* option proc */ optionLoadOpt,
713: /* desc, NAME, name */ zLoad_OptsText, zLoad_Opts_NAME, zLoad_Opts_Name,
714: /* disablement strs */ zNotLoad_Opts_Name, zNotLoad_Opts_Pfx }
715: };
716:
717: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
718: *
719: * Define the Ntp_Keygen Option Environment
720: */
721: static char const zPROGNAME[11] = "NTP_KEYGEN";
722: static char const zUsageTitle[114] =
723: "ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.6p5\n\
724: USAGE: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n";
725: static char const zRcName[7] = ".ntprc";
726: static char const * const apzHomeList[3] = {
727: "$HOME",
728: ".",
729: NULL };
730:
731: static char const zBugsAddr[34] = "http://bugs.ntp.org, bugs@ntp.org";
732: #define zExplain NULL
733: static char const zDetail[99] = "\n\
734: If there is no new host key, look for an existing one. If one is not\n\
735: found, create it.\n";
736: static char const zFullVersion[] = NTP_KEYGEN_FULL_VERSION;
737: /* extracted from optcode.tlib near line 515 */
738:
739: #if defined(ENABLE_NLS)
740: # define OPTPROC_BASE OPTPROC_TRANSLATE
741: static tOptionXlateProc translate_option_strings;
742: #else
743: # define OPTPROC_BASE OPTPROC_NONE
744: # define translate_option_strings NULL
745: #endif /* ENABLE_NLS */
746:
747:
748: #define ntp_keygen_full_usage NULL
749: #define ntp_keygen_short_usage NULL
750: #ifndef PKGDATADIR
751: # define PKGDATADIR ""
752: #endif
753:
754: #ifndef WITH_PACKAGER
755: # define ntp_keygen_packager_info NULL
756: #else
757: static char const ntp_keygen_packager_info[] =
758: "Packaged by " WITH_PACKAGER
759:
760: # ifdef WITH_PACKAGER_VERSION
761: " ("WITH_PACKAGER_VERSION")"
762: # endif
763:
764: # ifdef WITH_PACKAGER_BUG_REPORTS
765: "\nReport ntp_keygen bugs to " WITH_PACKAGER_BUG_REPORTS
766: # endif
767: "\n";
768: #endif
769:
770: tOptions ntp_keygenOptions = {
771: OPTIONS_STRUCT_VERSION,
772: 0, NULL, /* original argc + argv */
773: ( OPTPROC_BASE
774: + OPTPROC_ERRSTOP
775: + OPTPROC_SHORTOPT
776: + OPTPROC_LONGOPT
777: + OPTPROC_NO_REQ_OPT
778: + OPTPROC_ENVIRON
779: + OPTPROC_NO_ARGS
780: + OPTPROC_MISUSE ),
781: 0, NULL, /* current option index, current option */
782: NULL, NULL, zPROGNAME,
783: zRcName, zCopyright, zLicenseDescrip,
784: zFullVersion, apzHomeList, zUsageTitle,
785: zExplain, zDetail, optDesc,
786: zBugsAddr, /* address to send bugs to */
787: NULL, NULL, /* extensions/saved state */
788: optionUsage, /* usage procedure */
789: translate_option_strings, /* translation procedure */
790: /*
791: * Indexes to special options
792: */
793: { INDEX_OPT_MORE_HELP, /* more-help option index */
794: INDEX_OPT_SAVE_OPTS, /* save option index */
795: NO_EQUIVALENT, /* '-#' option index */
796: NO_EQUIVALENT /* index of default opt */
797: },
798: 23 /* full option count */, 18 /* user option count */,
799: ntp_keygen_full_usage, ntp_keygen_short_usage,
800: NULL, NULL,
801: PKGDATADIR, ntp_keygen_packager_info
802: };
803:
804: /*
805: * Create the static procedure(s) declared above.
806: */
807: static void
808: doUsageOpt(tOptions * pOptions, tOptDesc * pOptDesc)
809: {
810: (void)pOptions;
811: USAGE(NTP_KEYGEN_EXIT_SUCCESS);
812: }
813:
814: #if ! defined(TEST_NTP_KEYGEN_OPTS)
815:
816: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
817: *
818: * For the set-debug-level option.
819: */
820: static void
821: doOptSet_Debug_Level(tOptions* pOptions, tOptDesc* pOptDesc)
822: {
823: /* extracted from debug-opt.def, line 27 */
824: DESC(DEBUG_LEVEL).optOccCt = atoi( pOptDesc->pzLastArg );
825: }
826: #endif /* defined(TEST_NTP_KEYGEN_OPTS) */
827:
828: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
829: *
830: * For the modulus option, when OPENSSL is #define-d.
831: */
832: #ifdef OPENSSL
833: static void
834: doOptModulus(tOptions* pOptions, tOptDesc* pOptDesc)
835: {
836: static const struct {long const rmin, rmax;} rng[1] = {
837: { 256, 2048 } };
838: int ix;
839:
840: if (pOptions <= OPTPROC_EMIT_LIMIT)
841: goto emit_ranges;
842: optionNumericVal(pOptions, pOptDesc);
843:
844: for (ix = 0; ix < 1; ix++) {
845: if (pOptDesc->optArg.argInt < rng[ix].rmin)
846: continue; /* ranges need not be ordered. */
847: if (pOptDesc->optArg.argInt == rng[ix].rmin)
848: return;
849: if (rng[ix].rmax == LONG_MIN)
850: continue;
851: if (pOptDesc->optArg.argInt <= rng[ix].rmax)
852: return;
853: }
854:
855: option_usage_fp = stderr;
856:
857: emit_ranges:
858:
859: optionShowRange(pOptions, pOptDesc, (void *)rng, 1);
860: }
861: #endif /* defined OPENSSL */
862: /* extracted from optmain.tlib near line 128 */
863:
864: #if defined(TEST_NTP_KEYGEN_OPTS) /* TEST MAIN PROCEDURE: */
865:
866: extern void optionPutShell(tOptions*);
867:
868: int
869: main(int argc, char ** argv)
870: {
871: int res = NTP_KEYGEN_EXIT_SUCCESS;
872: (void)optionProcess(&ntp_keygenOptions, argc, argv);
873: optionPutShell(&ntp_keygenOptions);
874: res = ferror(stdout);
875: if (res != 0)
876: fputs("output error writing to stdout\n", stderr);
877: return res;
878: }
879: #endif /* defined TEST_NTP_KEYGEN_OPTS */
880: /* extracted from optcode.tlib near line 666 */
881:
882: #if ENABLE_NLS
883: #include <stdio.h>
884: #include <stdlib.h>
885: #include <string.h>
886: #include <unistd.h>
887: #include <autoopts/usage-txt.h>
888:
889: static char* AO_gettext(char const* pz);
890: static void coerce_it(void** s);
891:
892: static char*
893: AO_gettext(char const* pz)
894: {
895: char* pzRes;
896: if (pz == NULL)
897: return NULL;
898: pzRes = _(pz);
899: if (pzRes == pz)
900: return pzRes;
901: pzRes = strdup(pzRes);
902: if (pzRes == NULL) {
903: fputs(_("No memory for duping translated strings\n"), stderr);
904: exit(NTP_KEYGEN_EXIT_FAILURE);
905: }
906: return pzRes;
907: }
908:
909: static void coerce_it(void** s) { *s = AO_gettext(*s);
910: }
911:
912: /*
913: * This invokes the translation code (e.g. gettext(3)).
914: */
915: static void
916: translate_option_strings(void)
917: {
918: tOptions * const pOpt = &ntp_keygenOptions;
919:
920: /*
921: * Guard against re-translation. It won't work. The strings will have
922: * been changed by the first pass through this code. One shot only.
923: */
924: if (option_usage_text.field_ct != 0) {
925: /*
926: * Do the translations. The first pointer follows the field count
927: * field. The field count field is the size of a pointer.
928: */
929: tOptDesc * pOD = pOpt->pOptDesc;
930: char ** ppz = (char**)(void*)&(option_usage_text);
931: int ix = option_usage_text.field_ct;
932:
933: do {
934: ppz++;
935: *ppz = AO_gettext(*ppz);
936: } while (--ix > 0);
937:
938: coerce_it((void*)&(pOpt->pzCopyright));
939: coerce_it((void*)&(pOpt->pzCopyNotice));
940: coerce_it((void*)&(pOpt->pzFullVersion));
941: coerce_it((void*)&(pOpt->pzUsageTitle));
942: coerce_it((void*)&(pOpt->pzExplain));
943: coerce_it((void*)&(pOpt->pzDetail));
944: coerce_it((void*)&(pOpt->pzPackager));
945: option_usage_text.field_ct = 0;
946:
947: for (ix = pOpt->optCt; ix > 0; ix--, pOD++)
948: coerce_it((void*)&(pOD->pzText));
949: }
950:
951: if ((pOpt->fOptSet & OPTPROC_NXLAT_OPT_CFG) == 0) {
952: tOptDesc * pOD = pOpt->pOptDesc;
953: int ix;
954:
955: for (ix = pOpt->optCt; ix > 0; ix--, pOD++) {
956: coerce_it((void*)&(pOD->pz_Name));
957: coerce_it((void*)&(pOD->pz_DisableName));
958: coerce_it((void*)&(pOD->pz_DisablePfx));
959: }
960: /* prevent re-translation */
961: ntp_keygenOptions.fOptSet |= OPTPROC_NXLAT_OPT_CFG | OPTPROC_NXLAT_OPT;
962: }
963: }
964:
965: #endif /* ENABLE_NLS */
966:
967: #ifdef __cplusplus
968: }
969: #endif
970: /* ntp-keygen-opts.c ends here */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>