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