xref: /freebsd/contrib/ntp/ntpdc/ntpdc-opts.h (revision f5f40dd63bc7acbb5312b26ac1ea1103c12352a6)
1ea906c41SOllivier Robert /*
2ea906c41SOllivier Robert  *  EDIT THIS FILE WITH CAUTION  (ntpdc-opts.h)
3ea906c41SOllivier Robert  *
4*f5f40dd6SCy Schubert  *  It has been AutoGen-ed  May 25, 2024 at 12:04:11 AM by AutoGen 5.18.16
5ea906c41SOllivier Robert  *  From the definitions    ntpdc-opts.def
6ea906c41SOllivier Robert  *  and the template file   options
7ea906c41SOllivier Robert  *
8a466cc55SCy Schubert  * Generated from AutoOpts 42:1:17 templates.
92b15cb3dSCy Schubert  *
102b15cb3dSCy Schubert  *  AutoOpts is a copyrighted work.  This header file is not encumbered
112b15cb3dSCy Schubert  *  by AutoOpts licensing, but is provided under the licensing terms chosen
122b15cb3dSCy Schubert  *  by the ntpdc author or copyright holder.  AutoOpts is
132b15cb3dSCy Schubert  *  licensed under the terms of the LGPL.  The redistributable library
142b15cb3dSCy Schubert  *  (``libopts'') is licensed under the terms of either the LGPL or, at the
152b15cb3dSCy Schubert  *  users discretion, the BSD license.  See the AutoOpts and/or libopts sources
162b15cb3dSCy Schubert  *  for details.
172b15cb3dSCy Schubert  *
182b15cb3dSCy Schubert  * The ntpdc program is copyrighted and licensed
192b15cb3dSCy Schubert  * under the following terms:
202b15cb3dSCy Schubert  *
21*f5f40dd6SCy Schubert  *  Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved.
222b15cb3dSCy Schubert  *  This is free software. It is licensed for use, modification and
232b15cb3dSCy Schubert  *  redistribution under the terms of the NTP License, copies of which
242b15cb3dSCy Schubert  *  can be seen at:
252b15cb3dSCy Schubert  *    <http://ntp.org/license>
262b15cb3dSCy Schubert  *    <http://opensource.org/licenses/ntp-license.php>
272b15cb3dSCy Schubert  *
282b15cb3dSCy Schubert  *  Permission to use, copy, modify, and distribute this software and its
292b15cb3dSCy Schubert  *  documentation for any purpose with or without fee is hereby granted,
302b15cb3dSCy Schubert  *  provided that the above copyright notice appears in all copies and that
312b15cb3dSCy Schubert  *  both the copyright notice and this permission notice appear in
322b15cb3dSCy Schubert  *  supporting documentation, and that the name The University of Delaware not be used in
332b15cb3dSCy Schubert  *  advertising or publicity pertaining to distribution of the software
342b15cb3dSCy Schubert  *  without specific, written prior permission. The University of Delaware and Network Time Foundation makes no
352b15cb3dSCy Schubert  *  representations about the suitability this software for any purpose. It
362b15cb3dSCy Schubert  *  is provided "as is" without express or implied warranty.
37ea906c41SOllivier Robert  */
382b15cb3dSCy Schubert /**
39ea906c41SOllivier Robert  *  This file contains the programmatic interface to the Automated
40ea906c41SOllivier Robert  *  Options generated for the ntpdc program.
41ea906c41SOllivier Robert  *  These macros are documented in the AutoGen info file in the
42ea906c41SOllivier Robert  *  "AutoOpts" chapter.  Please refer to that doc for usage help.
43ea906c41SOllivier Robert  */
44ea906c41SOllivier Robert #ifndef AUTOOPTS_NTPDC_OPTS_H_GUARD
452b15cb3dSCy Schubert #define AUTOOPTS_NTPDC_OPTS_H_GUARD 1
46ea906c41SOllivier Robert #include "config.h"
47ea906c41SOllivier Robert #include <autoopts/options.h>
48a466cc55SCy Schubert #include <stdarg.h>
49a466cc55SCy Schubert #include <stdnoreturn.h>
50ea906c41SOllivier Robert 
512b15cb3dSCy Schubert /**
52ea906c41SOllivier Robert  *  Ensure that the library used for compiling this generated header is at
53ea906c41SOllivier Robert  *  least as new as the version current when the header template was released
54ea906c41SOllivier Robert  *  (not counting patch version increments).  Also ensure that the oldest
55ea906c41SOllivier Robert  *  tolerable version is at least as old as what was current when the header
56ea906c41SOllivier Robert  *  template was released.
57ea906c41SOllivier Robert  */
58a466cc55SCy Schubert #define AO_TEMPLATE_VERSION 172033
59ea906c41SOllivier Robert #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
60ea906c41SOllivier Robert  || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
61ea906c41SOllivier Robert # error option template version mismatches autoopts/options.h header
62ea906c41SOllivier Robert   Choke Me.
63ea906c41SOllivier Robert #endif
64ea906c41SOllivier Robert 
65a466cc55SCy Schubert #if GCC_VERSION > 40400
66a466cc55SCy Schubert #define NOT_REACHED __builtin_unreachable();
67a466cc55SCy Schubert #else
68a466cc55SCy Schubert #define NOT_REACHED
69a466cc55SCy Schubert #endif
70a466cc55SCy Schubert 
712b15cb3dSCy Schubert /**
722b15cb3dSCy Schubert  *  Enumeration of each option type for ntpdc
73ea906c41SOllivier Robert  */
74ea906c41SOllivier Robert typedef enum {
75ea906c41SOllivier Robert     INDEX_OPT_IPV4             =  0,
76ea906c41SOllivier Robert     INDEX_OPT_IPV6             =  1,
77ea906c41SOllivier Robert     INDEX_OPT_COMMAND          =  2,
782b15cb3dSCy Schubert     INDEX_OPT_DEBUG_LEVEL      =  3,
792b15cb3dSCy Schubert     INDEX_OPT_SET_DEBUG_LEVEL  =  4,
802b15cb3dSCy Schubert     INDEX_OPT_INTERACTIVE      =  5,
812b15cb3dSCy Schubert     INDEX_OPT_LISTPEERS        =  6,
822b15cb3dSCy Schubert     INDEX_OPT_NUMERIC          =  7,
832b15cb3dSCy Schubert     INDEX_OPT_PEERS            =  8,
842b15cb3dSCy Schubert     INDEX_OPT_SHOWPEERS        =  9,
85a466cc55SCy Schubert     INDEX_OPT_UNCONNECTED      = 10,
86a466cc55SCy Schubert     INDEX_OPT_VERSION          = 11,
87a466cc55SCy Schubert     INDEX_OPT_HELP             = 12,
88a466cc55SCy Schubert     INDEX_OPT_MORE_HELP        = 13,
89a466cc55SCy Schubert     INDEX_OPT_SAVE_OPTS        = 14,
90a466cc55SCy Schubert     INDEX_OPT_LOAD_OPTS        = 15
91ea906c41SOllivier Robert } teOptIndex;
922b15cb3dSCy Schubert /** count of all options for ntpdc */
93a466cc55SCy Schubert #define OPTION_CT    16
942b15cb3dSCy Schubert /** ntpdc version */
95*f5f40dd6SCy Schubert #define NTPDC_VERSION       "4.2.8p18"
962b15cb3dSCy Schubert /** Full ntpdc version text */
97*f5f40dd6SCy Schubert #define NTPDC_FULL_VERSION  "ntpdc 4.2.8p18"
98ea906c41SOllivier Robert 
992b15cb3dSCy Schubert /**
100ea906c41SOllivier Robert  *  Interface defines for all options.  Replace "n" with the UPPER_CASED
101ea906c41SOllivier Robert  *  option name (as in the teOptIndex enumeration above).
102ea906c41SOllivier Robert  *  e.g. HAVE_OPT(IPV4)
103ea906c41SOllivier Robert  */
104ea906c41SOllivier Robert #define         DESC(n) (ntpdcOptions.pOptDesc[INDEX_OPT_## n])
1052b15cb3dSCy Schubert /** 'true' if an option has been specified in any way */
106ea906c41SOllivier Robert #define     HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
1072b15cb3dSCy Schubert /** The string argument to an option. The argument type must be \"string\". */
108ea906c41SOllivier Robert #define      OPT_ARG(n) (DESC(n).optArg.argString)
1092b15cb3dSCy Schubert /** Mask the option state revealing how an option was specified.
1102b15cb3dSCy Schubert  *  It will be one and only one of \a OPTST_SET, \a OPTST_PRESET,
1112b15cb3dSCy Schubert  * \a OPTST_DEFINED, \a OPTST_RESET or zero.
1122b15cb3dSCy Schubert  */
113ea906c41SOllivier Robert #define    STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
1142b15cb3dSCy Schubert /** Count of option's occurrances *on the command line*. */
115ea906c41SOllivier Robert #define    COUNT_OPT(n) (DESC(n).optOccCt)
1162b15cb3dSCy Schubert /** mask of \a OPTST_SET and \a OPTST_DEFINED. */
117ea906c41SOllivier Robert #define    ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
1182b15cb3dSCy Schubert /** 'true' if \a HAVE_OPT would yield 'false'. */
119ea906c41SOllivier Robert #define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
1202b15cb3dSCy Schubert /** 'true' if OPTST_DISABLED bit not set. */
121ea906c41SOllivier Robert #define  ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
1222b15cb3dSCy Schubert /** number of stacked option arguments.
1232b15cb3dSCy Schubert  *  Valid only for stacked option arguments. */
124ea906c41SOllivier Robert #define  STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
1252b15cb3dSCy Schubert /** stacked argument vector.
1262b15cb3dSCy Schubert  *  Valid only for stacked option arguments. */
127ea906c41SOllivier Robert #define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
1282b15cb3dSCy Schubert /** Reset an option. */
129ea906c41SOllivier Robert #define    CLEAR_OPT(n) STMTS( \
130ea906c41SOllivier Robert                 DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
131ea906c41SOllivier Robert                 if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \
132ea906c41SOllivier Robert                     DESC(n).fOptState |= OPTST_DISABLED; \
133ea906c41SOllivier Robert                 DESC(n).optCookie = NULL )
1342b15cb3dSCy Schubert /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1352b15cb3dSCy Schubert /**
1362b15cb3dSCy Schubert  *  Enumeration of ntpdc exit codes
1372b15cb3dSCy Schubert  */
1382b15cb3dSCy Schubert typedef enum {
1392b15cb3dSCy Schubert     NTPDC_EXIT_SUCCESS         = 0,
1402b15cb3dSCy Schubert     NTPDC_EXIT_FAILURE         = 1,
1412b15cb3dSCy Schubert     NTPDC_EXIT_USAGE_ERROR     = 64,
1422b15cb3dSCy Schubert     NTPDC_EXIT_NO_CONFIG_INPUT = 66,
1432b15cb3dSCy Schubert     NTPDC_EXIT_LIBOPTS_FAILURE = 70
1442b15cb3dSCy Schubert }   ntpdc_exit_code_t;
1452b15cb3dSCy Schubert /** @} */
1462b15cb3dSCy Schubert /**
147ea906c41SOllivier Robert  *  Make sure there are no #define name conflicts with the option names
148ea906c41SOllivier Robert  */
149ea906c41SOllivier Robert #ifndef     NO_OPTION_NAME_WARNINGS
150ea906c41SOllivier Robert # ifdef    IPV4
151ea906c41SOllivier Robert #  warning undefining IPV4 due to option name conflict
152ea906c41SOllivier Robert #  undef   IPV4
153ea906c41SOllivier Robert # endif
154ea906c41SOllivier Robert # ifdef    IPV6
155ea906c41SOllivier Robert #  warning undefining IPV6 due to option name conflict
156ea906c41SOllivier Robert #  undef   IPV6
157ea906c41SOllivier Robert # endif
158ea906c41SOllivier Robert # ifdef    COMMAND
159ea906c41SOllivier Robert #  warning undefining COMMAND due to option name conflict
160ea906c41SOllivier Robert #  undef   COMMAND
161ea906c41SOllivier Robert # endif
1622b15cb3dSCy Schubert # ifdef    DEBUG_LEVEL
1632b15cb3dSCy Schubert #  warning undefining DEBUG_LEVEL due to option name conflict
1642b15cb3dSCy Schubert #  undef   DEBUG_LEVEL
1652b15cb3dSCy Schubert # endif
1662b15cb3dSCy Schubert # ifdef    SET_DEBUG_LEVEL
1672b15cb3dSCy Schubert #  warning undefining SET_DEBUG_LEVEL due to option name conflict
1682b15cb3dSCy Schubert #  undef   SET_DEBUG_LEVEL
1692b15cb3dSCy Schubert # endif
1702b15cb3dSCy Schubert # ifdef    INTERACTIVE
1712b15cb3dSCy Schubert #  warning undefining INTERACTIVE due to option name conflict
1722b15cb3dSCy Schubert #  undef   INTERACTIVE
1732b15cb3dSCy Schubert # endif
174ea906c41SOllivier Robert # ifdef    LISTPEERS
175ea906c41SOllivier Robert #  warning undefining LISTPEERS due to option name conflict
176ea906c41SOllivier Robert #  undef   LISTPEERS
177ea906c41SOllivier Robert # endif
1782b15cb3dSCy Schubert # ifdef    NUMERIC
1792b15cb3dSCy Schubert #  warning undefining NUMERIC due to option name conflict
1802b15cb3dSCy Schubert #  undef   NUMERIC
1812b15cb3dSCy Schubert # endif
182ea906c41SOllivier Robert # ifdef    PEERS
183ea906c41SOllivier Robert #  warning undefining PEERS due to option name conflict
184ea906c41SOllivier Robert #  undef   PEERS
185ea906c41SOllivier Robert # endif
186ea906c41SOllivier Robert # ifdef    SHOWPEERS
187ea906c41SOllivier Robert #  warning undefining SHOWPEERS due to option name conflict
188ea906c41SOllivier Robert #  undef   SHOWPEERS
189ea906c41SOllivier Robert # endif
190a466cc55SCy Schubert # ifdef    UNCONNECTED
191a466cc55SCy Schubert #  warning undefining UNCONNECTED due to option name conflict
192a466cc55SCy Schubert #  undef   UNCONNECTED
193a466cc55SCy Schubert # endif
194ea906c41SOllivier Robert #else  /* NO_OPTION_NAME_WARNINGS */
195ea906c41SOllivier Robert # undef IPV4
196ea906c41SOllivier Robert # undef IPV6
197ea906c41SOllivier Robert # undef COMMAND
198ea906c41SOllivier Robert # undef DEBUG_LEVEL
199ea906c41SOllivier Robert # undef SET_DEBUG_LEVEL
2002b15cb3dSCy Schubert # undef INTERACTIVE
2012b15cb3dSCy Schubert # undef LISTPEERS
202ea906c41SOllivier Robert # undef NUMERIC
2032b15cb3dSCy Schubert # undef PEERS
2042b15cb3dSCy Schubert # undef SHOWPEERS
205a466cc55SCy Schubert # undef UNCONNECTED
206ea906c41SOllivier Robert #endif  /*  NO_OPTION_NAME_WARNINGS */
207ea906c41SOllivier Robert 
2082b15cb3dSCy Schubert /**
209ea906c41SOllivier Robert  *  Interface defines for specific options.
2102b15cb3dSCy Schubert  * @{
211ea906c41SOllivier Robert  */
212ea906c41SOllivier Robert #define VALUE_OPT_IPV4           '4'
213ea906c41SOllivier Robert #define VALUE_OPT_IPV6           '6'
214ea906c41SOllivier Robert #define VALUE_OPT_COMMAND        'c'
2152b15cb3dSCy Schubert #define VALUE_OPT_DEBUG_LEVEL    'd'
2162b15cb3dSCy Schubert #define VALUE_OPT_SET_DEBUG_LEVEL 'D'
2172b15cb3dSCy Schubert 
2182b15cb3dSCy Schubert #define OPT_VALUE_SET_DEBUG_LEVEL (DESC(SET_DEBUG_LEVEL).optArg.argInt)
2192b15cb3dSCy Schubert #define VALUE_OPT_INTERACTIVE    'i'
220ea906c41SOllivier Robert #define VALUE_OPT_LISTPEERS      'l'
2212b15cb3dSCy Schubert #define VALUE_OPT_NUMERIC        'n'
222ea906c41SOllivier Robert #define VALUE_OPT_PEERS          'p'
223ea906c41SOllivier Robert #define VALUE_OPT_SHOWPEERS      's'
224a466cc55SCy Schubert #define VALUE_OPT_UNCONNECTED    'u'
2252b15cb3dSCy Schubert /** option flag (value) for help-value option */
226ea906c41SOllivier Robert #define VALUE_OPT_HELP          '?'
2272b15cb3dSCy Schubert /** option flag (value) for more-help-value option */
228ea906c41SOllivier Robert #define VALUE_OPT_MORE_HELP     '!'
2292b15cb3dSCy Schubert /** option flag (value) for version-value option */
2302b15cb3dSCy Schubert #define VALUE_OPT_VERSION       0x1001
2312b15cb3dSCy Schubert /** option flag (value) for save-opts-value option */
232ea906c41SOllivier Robert #define VALUE_OPT_SAVE_OPTS     '>'
2332b15cb3dSCy Schubert /** option flag (value) for load-opts-value option */
234ea906c41SOllivier Robert #define VALUE_OPT_LOAD_OPTS     '<'
235ea906c41SOllivier Robert #define SET_OPT_SAVE_OPTS(a)   STMTS( \
236ea906c41SOllivier Robert         DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
237ea906c41SOllivier Robert         DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
238ea906c41SOllivier Robert         DESC(SAVE_OPTS).optArg.argString = (char const*)(a))
239ea906c41SOllivier Robert /*
240ea906c41SOllivier Robert  *  Interface defines not associated with particular options
241ea906c41SOllivier Robert  */
242ea906c41SOllivier Robert #define ERRSKIP_OPTERR  STMTS(ntpdcOptions.fOptSet &= ~OPTPROC_ERRSTOP)
243ea906c41SOllivier Robert #define ERRSTOP_OPTERR  STMTS(ntpdcOptions.fOptSet |= OPTPROC_ERRSTOP)
244ea906c41SOllivier Robert #define RESTART_OPT(n)  STMTS( \
245ea906c41SOllivier Robert                 ntpdcOptions.curOptIdx = (n); \
246ea906c41SOllivier Robert                 ntpdcOptions.pzCurOpt  = NULL )
247ea906c41SOllivier Robert #define START_OPT       RESTART_OPT(1)
248ea906c41SOllivier Robert #define USAGE(c)        (*ntpdcOptions.pUsageProc)(&ntpdcOptions, c)
2492b15cb3dSCy Schubert 
2502b15cb3dSCy Schubert #ifdef  __cplusplus
2512b15cb3dSCy Schubert extern "C" {
2522b15cb3dSCy Schubert #endif
2532b15cb3dSCy Schubert 
254ea906c41SOllivier Robert 
255ea906c41SOllivier Robert /* * * * * *
256ea906c41SOllivier Robert  *
257ea906c41SOllivier Robert  *  Declare the ntpdc option descriptor.
258ea906c41SOllivier Robert  */
259ea906c41SOllivier Robert extern tOptions ntpdcOptions;
260ea906c41SOllivier Robert 
2612b15cb3dSCy Schubert #if defined(ENABLE_NLS)
262ea906c41SOllivier Robert # ifndef _
263ea906c41SOllivier Robert #   include <stdio.h>
2642b15cb3dSCy Schubert #   ifndef HAVE_GETTEXT
2652b15cb3dSCy Schubert       extern char * gettext(char const *);
2662b15cb3dSCy Schubert #   else
2672b15cb3dSCy Schubert #     include <libintl.h>
2682b15cb3dSCy Schubert #   endif
2692b15cb3dSCy Schubert 
2702b15cb3dSCy Schubert # ifndef ATTRIBUTE_FORMAT_ARG
2712b15cb3dSCy Schubert #   define ATTRIBUTE_FORMAT_ARG(_a)
2722b15cb3dSCy Schubert # endif
2732b15cb3dSCy Schubert 
2742b15cb3dSCy Schubert static inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1);
275ea906c41SOllivier Robert static inline char* aoGetsText(char const* pz) {
276ea906c41SOllivier Robert     if (pz == NULL) return NULL;
277ea906c41SOllivier Robert     return (char*)gettext(pz);
278ea906c41SOllivier Robert }
279ea906c41SOllivier Robert #   define _(s)  aoGetsText(s)
2802b15cb3dSCy Schubert # endif /* _() */
2812b15cb3dSCy Schubert 
2822b15cb3dSCy Schubert # define OPT_NO_XLAT_CFG_NAMES  STMTS(ntpdcOptions.fOptSet |= \
2832b15cb3dSCy Schubert                                     OPTPROC_NXLAT_OPT_CFG;)
2842b15cb3dSCy Schubert # define OPT_NO_XLAT_OPT_NAMES  STMTS(ntpdcOptions.fOptSet |= \
2852b15cb3dSCy Schubert                                     OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
2862b15cb3dSCy Schubert 
2872b15cb3dSCy Schubert # define OPT_XLAT_CFG_NAMES     STMTS(ntpdcOptions.fOptSet &= \
2882b15cb3dSCy Schubert                                   ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
2892b15cb3dSCy Schubert # define OPT_XLAT_OPT_NAMES     STMTS(ntpdcOptions.fOptSet &= \
2902b15cb3dSCy Schubert                                   ~OPTPROC_NXLAT_OPT;)
2912b15cb3dSCy Schubert 
292ea906c41SOllivier Robert #else   /* ENABLE_NLS */
2932b15cb3dSCy Schubert # define OPT_NO_XLAT_CFG_NAMES
2942b15cb3dSCy Schubert # define OPT_NO_XLAT_OPT_NAMES
2952b15cb3dSCy Schubert 
2962b15cb3dSCy Schubert # define OPT_XLAT_CFG_NAMES
2972b15cb3dSCy Schubert # define OPT_XLAT_OPT_NAMES
2982b15cb3dSCy Schubert 
2992b15cb3dSCy Schubert # ifndef _
3002b15cb3dSCy Schubert #   define _(_s)  _s
301ea906c41SOllivier Robert # endif
3022b15cb3dSCy Schubert #endif  /* ENABLE_NLS */
303ea906c41SOllivier Robert 
304a466cc55SCy Schubert 
305ea906c41SOllivier Robert #ifdef  __cplusplus
306ea906c41SOllivier Robert }
307ea906c41SOllivier Robert #endif
308ea906c41SOllivier Robert #endif /* AUTOOPTS_NTPDC_OPTS_H_GUARD */
3092b15cb3dSCy Schubert 
310ea906c41SOllivier Robert /* ntpdc-opts.h ends here */
311