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