xref: /netbsd-src/external/bsd/ntp/dist/util/ntp-keygen-opts.h (revision bdc22b2e01993381dcefeff2bc9b56ca75a4235c)
1 /*	$NetBSD: ntp-keygen-opts.h,v 1.11 2018/04/07 00:19:54 christos Exp $	*/
2 
3 /*
4  *  EDIT THIS FILE WITH CAUTION  (ntp-keygen-opts.h)
5  *
6  *  It has been AutoGen-ed  February 27, 2018 at 05:15:43 PM by AutoGen 5.18.5
7  *  From the definitions    ntp-keygen-opts.def
8  *  and the template file   options
9  *
10  * Generated from AutoOpts 41:0:16 templates.
11  *
12  *  AutoOpts is a copyrighted work.  This header file is not encumbered
13  *  by AutoOpts licensing, but is provided under the licensing terms chosen
14  *  by the ntp-keygen author or copyright holder.  AutoOpts is
15  *  licensed under the terms of the LGPL.  The redistributable library
16  *  (``libopts'') is licensed under the terms of either the LGPL or, at the
17  *  users discretion, the BSD license.  See the AutoOpts and/or libopts sources
18  *  for details.
19  *
20  * The ntp-keygen program is copyrighted and licensed
21  * under the following terms:
22  *
23  *  Copyright (C) 1992-2017 The University of Delaware and Network Time Foundation, all rights reserved.
24  *  This is free software. It is licensed for use, modification and
25  *  redistribution under the terms of the NTP License, copies of which
26  *  can be seen at:
27  *    <http://ntp.org/license>
28  *    <http://opensource.org/licenses/ntp-license.php>
29  *
30  *  Permission to use, copy, modify, and distribute this software and its
31  *  documentation for any purpose with or without fee is hereby granted,
32  *  provided that the above copyright notice appears in all copies and that
33  *  both the copyright notice and this permission notice appear in
34  *  supporting documentation, and that the name The University of Delaware not be used in
35  *  advertising or publicity pertaining to distribution of the software
36  *  without specific, written prior permission. The University of Delaware and Network Time Foundation makes no
37  *  representations about the suitability this software for any purpose. It
38  *  is provided "as is" without express or implied warranty.
39  */
40 /**
41  *  This file contains the programmatic interface to the Automated
42  *  Options generated for the ntp-keygen program.
43  *  These macros are documented in the AutoGen info file in the
44  *  "AutoOpts" chapter.  Please refer to that doc for usage help.
45  */
46 #ifndef AUTOOPTS_NTP_KEYGEN_OPTS_H_GUARD
47 #define AUTOOPTS_NTP_KEYGEN_OPTS_H_GUARD 1
48 #include "config.h"
49 #include <autoopts/options.h>
50 
51 /**
52  *  Ensure that the library used for compiling this generated header is at
53  *  least as new as the version current when the header template was released
54  *  (not counting patch version increments).  Also ensure that the oldest
55  *  tolerable version is at least as old as what was current when the header
56  *  template was released.
57  */
58 #define AO_TEMPLATE_VERSION 167936
59 #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
60  || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
61 # error option template version mismatches autoopts/options.h header
62   Choke Me.
63 #endif
64 
65 /**
66  *  Enumeration of each option type for ntp-keygen
67  */
68 typedef enum {
69     INDEX_OPT_IMBITS           =  0,
70     INDEX_OPT_CERTIFICATE      =  1,
71     INDEX_OPT_CIPHER           =  2,
72     INDEX_OPT_DEBUG_LEVEL      =  3,
73     INDEX_OPT_SET_DEBUG_LEVEL  =  4,
74     INDEX_OPT_ID_KEY           =  5,
75     INDEX_OPT_GQ_PARAMS        =  6,
76     INDEX_OPT_HOST_KEY         =  7,
77     INDEX_OPT_IFFKEY           =  8,
78     INDEX_OPT_IDENT            =  9,
79     INDEX_OPT_LIFETIME         = 10,
80     INDEX_OPT_MODULUS          = 11,
81     INDEX_OPT_MD5KEY           = 12,
82     INDEX_OPT_PVT_CERT         = 13,
83     INDEX_OPT_PASSWORD         = 14,
84     INDEX_OPT_EXPORT_PASSWD    = 15,
85     INDEX_OPT_SUBJECT_NAME     = 16,
86     INDEX_OPT_SIGN_KEY         = 17,
87     INDEX_OPT_TRUSTED_CERT     = 18,
88     INDEX_OPT_MV_PARAMS        = 19,
89     INDEX_OPT_MV_KEYS          = 20,
90     INDEX_OPT_VERSION          = 21,
91     INDEX_OPT_HELP             = 22,
92     INDEX_OPT_MORE_HELP        = 23,
93     INDEX_OPT_SAVE_OPTS        = 24,
94     INDEX_OPT_LOAD_OPTS        = 25
95 } teOptIndex;
96 /** count of all options for ntp-keygen */
97 #define OPTION_CT    26
98 /** ntp-keygen version */
99 #define NTP_KEYGEN_VERSION       "4.2.8p11"
100 /** Full ntp-keygen version text */
101 #define NTP_KEYGEN_FULL_VERSION  "ntp-keygen (ntp) 4.2.8p11"
102 
103 /**
104  *  Interface defines for all options.  Replace "n" with the UPPER_CASED
105  *  option name (as in the teOptIndex enumeration above).
106  *  e.g. HAVE_OPT(IMBITS)
107  */
108 #define         DESC(n) (ntp_keygenOptions.pOptDesc[INDEX_OPT_## n])
109 /** 'true' if an option has been specified in any way */
110 #define     HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
111 /** The string argument to an option. The argument type must be \"string\". */
112 #define      OPT_ARG(n) (DESC(n).optArg.argString)
113 /** Mask the option state revealing how an option was specified.
114  *  It will be one and only one of \a OPTST_SET, \a OPTST_PRESET,
115  * \a OPTST_DEFINED, \a OPTST_RESET or zero.
116  */
117 #define    STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
118 /** Count of option's occurrances *on the command line*. */
119 #define    COUNT_OPT(n) (DESC(n).optOccCt)
120 /** mask of \a OPTST_SET and \a OPTST_DEFINED. */
121 #define    ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
122 /** 'true' if \a HAVE_OPT would yield 'false'. */
123 #define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
124 /** 'true' if OPTST_DISABLED bit not set. */
125 #define  ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
126 /** number of stacked option arguments.
127  *  Valid only for stacked option arguments. */
128 #define  STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
129 /** stacked argument vector.
130  *  Valid only for stacked option arguments. */
131 #define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
132 /** Reset an option. */
133 #define    CLEAR_OPT(n) STMTS( \
134                 DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
135                 if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \
136                     DESC(n).fOptState |= OPTST_DISABLED; \
137                 DESC(n).optCookie = NULL )
138 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
139 /**
140  *  Enumeration of ntp-keygen exit codes
141  */
142 typedef enum {
143     NTP_KEYGEN_EXIT_SUCCESS         = 0,
144     NTP_KEYGEN_EXIT_FAILURE         = 1,
145     NTP_KEYGEN_EXIT_USAGE_ERROR     = 64,
146     NTP_KEYGEN_EXIT_NO_CONFIG_INPUT = 66,
147     NTP_KEYGEN_EXIT_LIBOPTS_FAILURE = 70
148 }   ntp_keygen_exit_code_t;
149 /** @} */
150 /**
151  *  Make sure there are no #define name conflicts with the option names
152  */
153 #ifndef     NO_OPTION_NAME_WARNINGS
154 # ifdef    IMBITS
155 #  warning undefining IMBITS due to option name conflict
156 #  undef   IMBITS
157 # endif
158 # ifdef    CERTIFICATE
159 #  warning undefining CERTIFICATE due to option name conflict
160 #  undef   CERTIFICATE
161 # endif
162 # ifdef    CIPHER
163 #  warning undefining CIPHER due to option name conflict
164 #  undef   CIPHER
165 # endif
166 # ifdef    DEBUG_LEVEL
167 #  warning undefining DEBUG_LEVEL due to option name conflict
168 #  undef   DEBUG_LEVEL
169 # endif
170 # ifdef    SET_DEBUG_LEVEL
171 #  warning undefining SET_DEBUG_LEVEL due to option name conflict
172 #  undef   SET_DEBUG_LEVEL
173 # endif
174 # ifdef    ID_KEY
175 #  warning undefining ID_KEY due to option name conflict
176 #  undef   ID_KEY
177 # endif
178 # ifdef    GQ_PARAMS
179 #  warning undefining GQ_PARAMS due to option name conflict
180 #  undef   GQ_PARAMS
181 # endif
182 # ifdef    HOST_KEY
183 #  warning undefining HOST_KEY due to option name conflict
184 #  undef   HOST_KEY
185 # endif
186 # ifdef    IFFKEY
187 #  warning undefining IFFKEY due to option name conflict
188 #  undef   IFFKEY
189 # endif
190 # ifdef    IDENT
191 #  warning undefining IDENT due to option name conflict
192 #  undef   IDENT
193 # endif
194 # ifdef    LIFETIME
195 #  warning undefining LIFETIME due to option name conflict
196 #  undef   LIFETIME
197 # endif
198 # ifdef    MODULUS
199 #  warning undefining MODULUS due to option name conflict
200 #  undef   MODULUS
201 # endif
202 # ifdef    MD5KEY
203 #  warning undefining MD5KEY due to option name conflict
204 #  undef   MD5KEY
205 # endif
206 # ifdef    PVT_CERT
207 #  warning undefining PVT_CERT due to option name conflict
208 #  undef   PVT_CERT
209 # endif
210 # ifdef    PASSWORD
211 #  warning undefining PASSWORD due to option name conflict
212 #  undef   PASSWORD
213 # endif
214 # ifdef    EXPORT_PASSWD
215 #  warning undefining EXPORT_PASSWD due to option name conflict
216 #  undef   EXPORT_PASSWD
217 # endif
218 # ifdef    SUBJECT_NAME
219 #  warning undefining SUBJECT_NAME due to option name conflict
220 #  undef   SUBJECT_NAME
221 # endif
222 # ifdef    SIGN_KEY
223 #  warning undefining SIGN_KEY due to option name conflict
224 #  undef   SIGN_KEY
225 # endif
226 # ifdef    TRUSTED_CERT
227 #  warning undefining TRUSTED_CERT due to option name conflict
228 #  undef   TRUSTED_CERT
229 # endif
230 # ifdef    MV_PARAMS
231 #  warning undefining MV_PARAMS due to option name conflict
232 #  undef   MV_PARAMS
233 # endif
234 # ifdef    MV_KEYS
235 #  warning undefining MV_KEYS due to option name conflict
236 #  undef   MV_KEYS
237 # endif
238 #else  /* NO_OPTION_NAME_WARNINGS */
239 # undef IMBITS
240 # undef CERTIFICATE
241 # undef CIPHER
242 # undef DEBUG_LEVEL
243 # undef SET_DEBUG_LEVEL
244 # undef ID_KEY
245 # undef GQ_PARAMS
246 # undef HOST_KEY
247 # undef IFFKEY
248 # undef IDENT
249 # undef LIFETIME
250 # undef MODULUS
251 # undef MD5KEY
252 # undef PVT_CERT
253 # undef PASSWORD
254 # undef EXPORT_PASSWD
255 # undef SUBJECT_NAME
256 # undef SIGN_KEY
257 # undef TRUSTED_CERT
258 # undef MV_PARAMS
259 # undef MV_KEYS
260 #endif  /*  NO_OPTION_NAME_WARNINGS */
261 
262 /**
263  *  Interface defines for specific options.
264  * @{
265  */
266 #define VALUE_OPT_IMBITS         'b'
267 #ifdef AUTOKEY
268 #define OPT_VALUE_IMBITS         (DESC(IMBITS).optArg.argInt)
269 #endif /* AUTOKEY */
270 #define VALUE_OPT_CERTIFICATE    'c'
271 #define VALUE_OPT_CIPHER         'C'
272 #define VALUE_OPT_DEBUG_LEVEL    'd'
273 #define VALUE_OPT_SET_DEBUG_LEVEL 'D'
274 
275 #define OPT_VALUE_SET_DEBUG_LEVEL (DESC(SET_DEBUG_LEVEL).optArg.argInt)
276 #define VALUE_OPT_ID_KEY         'e'
277 #define VALUE_OPT_GQ_PARAMS      'G'
278 #define VALUE_OPT_HOST_KEY       'H'
279 #define VALUE_OPT_IFFKEY         'I'
280 #define VALUE_OPT_IDENT          'i'
281 #define VALUE_OPT_LIFETIME       'l'
282 #ifdef AUTOKEY
283 #define OPT_VALUE_LIFETIME       (DESC(LIFETIME).optArg.argInt)
284 #endif /* AUTOKEY */
285 #define VALUE_OPT_MODULUS        'm'
286 #ifdef AUTOKEY
287 #define OPT_VALUE_MODULUS        (DESC(MODULUS).optArg.argInt)
288 #endif /* AUTOKEY */
289 #define VALUE_OPT_MD5KEY         'M'
290 #define VALUE_OPT_PVT_CERT       'P'
291 #define VALUE_OPT_PASSWORD       'p'
292 #define VALUE_OPT_EXPORT_PASSWD  'q'
293 #define VALUE_OPT_SUBJECT_NAME   's'
294 #define VALUE_OPT_SIGN_KEY       'S'
295 #define VALUE_OPT_TRUSTED_CERT   'T'
296 #define VALUE_OPT_MV_PARAMS      'V'
297 #ifdef AUTOKEY
298 #define OPT_VALUE_MV_PARAMS      (DESC(MV_PARAMS).optArg.argInt)
299 #endif /* AUTOKEY */
300 #define VALUE_OPT_MV_KEYS        'v'
301 #ifdef AUTOKEY
302 #define OPT_VALUE_MV_KEYS        (DESC(MV_KEYS).optArg.argInt)
303 #endif /* AUTOKEY */
304 /** option flag (value) for help-value option */
305 #define VALUE_OPT_HELP          '?'
306 /** option flag (value) for more-help-value option */
307 #define VALUE_OPT_MORE_HELP     '!'
308 /** option flag (value) for version-value option */
309 #define VALUE_OPT_VERSION       0x1001
310 /** option flag (value) for save-opts-value option */
311 #define VALUE_OPT_SAVE_OPTS     '>'
312 /** option flag (value) for load-opts-value option */
313 #define VALUE_OPT_LOAD_OPTS     '<'
314 #define SET_OPT_SAVE_OPTS(a)   STMTS( \
315         DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
316         DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
317         DESC(SAVE_OPTS).optArg.argString = (char const*)(a))
318 /*
319  *  Interface defines not associated with particular options
320  */
321 #define ERRSKIP_OPTERR  STMTS(ntp_keygenOptions.fOptSet &= ~OPTPROC_ERRSTOP)
322 #define ERRSTOP_OPTERR  STMTS(ntp_keygenOptions.fOptSet |= OPTPROC_ERRSTOP)
323 #define RESTART_OPT(n)  STMTS( \
324                 ntp_keygenOptions.curOptIdx = (n); \
325                 ntp_keygenOptions.pzCurOpt  = NULL )
326 #define START_OPT       RESTART_OPT(1)
327 #define USAGE(c)        (*ntp_keygenOptions.pUsageProc)(&ntp_keygenOptions, c)
328 
329 #ifdef  __cplusplus
330 extern "C" {
331 #endif
332 
333 
334 /* * * * * *
335  *
336  *  Declare the ntp-keygen option descriptor.
337  */
338 extern tOptions ntp_keygenOptions;
339 
340 #if defined(ENABLE_NLS)
341 # ifndef _
342 #   include <stdio.h>
343 #   ifndef HAVE_GETTEXT
344       extern char * gettext(char const *);
345 #   else
346 #     include <libintl.h>
347 #   endif
348 
349 # ifndef ATTRIBUTE_FORMAT_ARG
350 #   define ATTRIBUTE_FORMAT_ARG(_a)
351 # endif
352 
353 static inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1);
354 static inline char* aoGetsText(char const* pz) {
355     if (pz == NULL) return NULL;
356     return (char*)gettext(pz);
357 }
358 #   define _(s)  aoGetsText(s)
359 # endif /* _() */
360 
361 # define OPT_NO_XLAT_CFG_NAMES  STMTS(ntp_keygenOptions.fOptSet |= \
362                                     OPTPROC_NXLAT_OPT_CFG;)
363 # define OPT_NO_XLAT_OPT_NAMES  STMTS(ntp_keygenOptions.fOptSet |= \
364                                     OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
365 
366 # define OPT_XLAT_CFG_NAMES     STMTS(ntp_keygenOptions.fOptSet &= \
367                                   ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
368 # define OPT_XLAT_OPT_NAMES     STMTS(ntp_keygenOptions.fOptSet &= \
369                                   ~OPTPROC_NXLAT_OPT;)
370 
371 #else   /* ENABLE_NLS */
372 # define OPT_NO_XLAT_CFG_NAMES
373 # define OPT_NO_XLAT_OPT_NAMES
374 
375 # define OPT_XLAT_CFG_NAMES
376 # define OPT_XLAT_OPT_NAMES
377 
378 # ifndef _
379 #   define _(_s)  _s
380 # endif
381 #endif  /* ENABLE_NLS */
382 
383 #ifdef  __cplusplus
384 }
385 #endif
386 #endif /* AUTOOPTS_NTP_KEYGEN_OPTS_H_GUARD */
387 
388 /* ntp-keygen-opts.h ends here */
389