xref: /netbsd-src/external/bsd/ntp/dist/ntpdc/ntpdc-opts.h (revision eabc0478de71e4e011a5b4e0392741e01d491794)
1*eabc0478Schristos /*	$NetBSD: ntpdc-opts.h,v 1.15 2024/08/18 20:47:19 christos Exp $	*/
2abb0f93cSkardel 
3abb0f93cSkardel /*
4abb0f93cSkardel  *  EDIT THIS FILE WITH CAUTION  (ntpdc-opts.h)
5abb0f93cSkardel  *
6*eabc0478Schristos  *  It has been AutoGen-ed  May 25, 2024 at 12:04:11 AM by AutoGen 5.18.16
7abb0f93cSkardel  *  From the definitions    ntpdc-opts.def
8abb0f93cSkardel  *  and the template file   options
9abb0f93cSkardel  *
10*eabc0478Schristos  * Generated from AutoOpts 42:1:17 templates.
11f003fb54Skardel  *
12f003fb54Skardel  *  AutoOpts is a copyrighted work.  This header file is not encumbered
13f003fb54Skardel  *  by AutoOpts licensing, but is provided under the licensing terms chosen
14f003fb54Skardel  *  by the ntpdc author or copyright holder.  AutoOpts is
15f003fb54Skardel  *  licensed under the terms of the LGPL.  The redistributable library
16f003fb54Skardel  *  (``libopts'') is licensed under the terms of either the LGPL or, at the
17f003fb54Skardel  *  users discretion, the BSD license.  See the AutoOpts and/or libopts sources
18f003fb54Skardel  *  for details.
19abb0f93cSkardel  *
208585484eSchristos  * The ntpdc program is copyrighted and licensed
218585484eSchristos  * under the following terms:
22abb0f93cSkardel  *
23*eabc0478Schristos  *  Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved.
248585484eSchristos  *  This is free software. It is licensed for use, modification and
258585484eSchristos  *  redistribution under the terms of the NTP License, copies of which
268585484eSchristos  *  can be seen at:
278585484eSchristos  *    <http://ntp.org/license>
288585484eSchristos  *    <http://opensource.org/licenses/ntp-license.php>
29f003fb54Skardel  *
308585484eSchristos  *  Permission to use, copy, modify, and distribute this software and its
318585484eSchristos  *  documentation for any purpose with or without fee is hereby granted,
328585484eSchristos  *  provided that the above copyright notice appears in all copies and that
338585484eSchristos  *  both the copyright notice and this permission notice appear in
348585484eSchristos  *  supporting documentation, and that the name The University of Delaware not be used in
358585484eSchristos  *  advertising or publicity pertaining to distribution of the software
367476e6e4Schristos  *  without specific, written prior permission. The University of Delaware and Network Time Foundation makes no
378585484eSchristos  *  representations about the suitability this software for any purpose. It
388585484eSchristos  *  is provided "as is" without express or implied warranty.
39abb0f93cSkardel  */
408585484eSchristos /**
41abb0f93cSkardel  *  This file contains the programmatic interface to the Automated
42abb0f93cSkardel  *  Options generated for the ntpdc program.
43abb0f93cSkardel  *  These macros are documented in the AutoGen info file in the
44abb0f93cSkardel  *  "AutoOpts" chapter.  Please refer to that doc for usage help.
45abb0f93cSkardel  */
46abb0f93cSkardel #ifndef AUTOOPTS_NTPDC_OPTS_H_GUARD
47abb0f93cSkardel #define AUTOOPTS_NTPDC_OPTS_H_GUARD 1
48abb0f93cSkardel #include "config.h"
49abb0f93cSkardel #include <autoopts/options.h>
50*eabc0478Schristos #include <stdarg.h>
51*eabc0478Schristos #include <stdnoreturn.h>
52abb0f93cSkardel 
538585484eSchristos /**
54abb0f93cSkardel  *  Ensure that the library used for compiling this generated header is at
55abb0f93cSkardel  *  least as new as the version current when the header template was released
56abb0f93cSkardel  *  (not counting patch version increments).  Also ensure that the oldest
57abb0f93cSkardel  *  tolerable version is at least as old as what was current when the header
58abb0f93cSkardel  *  template was released.
59abb0f93cSkardel  */
60*eabc0478Schristos #define AO_TEMPLATE_VERSION 172033
61abb0f93cSkardel #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
62abb0f93cSkardel  || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
63abb0f93cSkardel # error option template version mismatches autoopts/options.h header
64abb0f93cSkardel   Choke Me.
65abb0f93cSkardel #endif
66abb0f93cSkardel 
67*eabc0478Schristos #if GCC_VERSION > 40400
68*eabc0478Schristos #define NOT_REACHED __builtin_unreachable();
69*eabc0478Schristos #else
70*eabc0478Schristos #define NOT_REACHED
71*eabc0478Schristos #endif
72*eabc0478Schristos 
738585484eSchristos /**
748585484eSchristos  *  Enumeration of each option type for ntpdc
75abb0f93cSkardel  */
76abb0f93cSkardel typedef enum {
77abb0f93cSkardel     INDEX_OPT_IPV4             =  0,
78abb0f93cSkardel     INDEX_OPT_IPV6             =  1,
79abb0f93cSkardel     INDEX_OPT_COMMAND          =  2,
808585484eSchristos     INDEX_OPT_DEBUG_LEVEL      =  3,
818585484eSchristos     INDEX_OPT_SET_DEBUG_LEVEL  =  4,
828585484eSchristos     INDEX_OPT_INTERACTIVE      =  5,
838585484eSchristos     INDEX_OPT_LISTPEERS        =  6,
848585484eSchristos     INDEX_OPT_NUMERIC          =  7,
858585484eSchristos     INDEX_OPT_PEERS            =  8,
868585484eSchristos     INDEX_OPT_SHOWPEERS        =  9,
87*eabc0478Schristos     INDEX_OPT_UNCONNECTED      = 10,
88*eabc0478Schristos     INDEX_OPT_VERSION          = 11,
89*eabc0478Schristos     INDEX_OPT_HELP             = 12,
90*eabc0478Schristos     INDEX_OPT_MORE_HELP        = 13,
91*eabc0478Schristos     INDEX_OPT_SAVE_OPTS        = 14,
92*eabc0478Schristos     INDEX_OPT_LOAD_OPTS        = 15
93abb0f93cSkardel } teOptIndex;
948585484eSchristos /** count of all options for ntpdc */
95*eabc0478Schristos #define OPTION_CT    16
968585484eSchristos /** ntpdc version */
97*eabc0478Schristos #define NTPDC_VERSION       "4.2.8p18"
988585484eSchristos /** Full ntpdc version text */
99*eabc0478Schristos #define NTPDC_FULL_VERSION  "ntpdc 4.2.8p18"
100abb0f93cSkardel 
1018585484eSchristos /**
102abb0f93cSkardel  *  Interface defines for all options.  Replace "n" with the UPPER_CASED
103abb0f93cSkardel  *  option name (as in the teOptIndex enumeration above).
104abb0f93cSkardel  *  e.g. HAVE_OPT(IPV4)
105abb0f93cSkardel  */
106abb0f93cSkardel #define         DESC(n) (ntpdcOptions.pOptDesc[INDEX_OPT_## n])
1078585484eSchristos /** 'true' if an option has been specified in any way */
108abb0f93cSkardel #define     HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
1098585484eSchristos /** The string argument to an option. The argument type must be \"string\". */
110abb0f93cSkardel #define      OPT_ARG(n) (DESC(n).optArg.argString)
1118585484eSchristos /** Mask the option state revealing how an option was specified.
1128585484eSchristos  *  It will be one and only one of \a OPTST_SET, \a OPTST_PRESET,
1138585484eSchristos  * \a OPTST_DEFINED, \a OPTST_RESET or zero.
1148585484eSchristos  */
115abb0f93cSkardel #define    STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
1168585484eSchristos /** Count of option's occurrances *on the command line*. */
117abb0f93cSkardel #define    COUNT_OPT(n) (DESC(n).optOccCt)
1188585484eSchristos /** mask of \a OPTST_SET and \a OPTST_DEFINED. */
119abb0f93cSkardel #define    ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
1208585484eSchristos /** 'true' if \a HAVE_OPT would yield 'false'. */
121abb0f93cSkardel #define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
1228585484eSchristos /** 'true' if OPTST_DISABLED bit not set. */
123abb0f93cSkardel #define  ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
1248585484eSchristos /** number of stacked option arguments.
1258585484eSchristos  *  Valid only for stacked option arguments. */
126abb0f93cSkardel #define  STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
1278585484eSchristos /** stacked argument vector.
1288585484eSchristos  *  Valid only for stacked option arguments. */
129abb0f93cSkardel #define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
1308585484eSchristos /** Reset an option. */
131abb0f93cSkardel #define    CLEAR_OPT(n) STMTS( \
132abb0f93cSkardel                 DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
133abb0f93cSkardel                 if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \
134abb0f93cSkardel                     DESC(n).fOptState |= OPTST_DISABLED; \
135abb0f93cSkardel                 DESC(n).optCookie = NULL )
1368585484eSchristos /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1378585484eSchristos /**
138f003fb54Skardel  *  Enumeration of ntpdc exit codes
139f003fb54Skardel  */
140f003fb54Skardel typedef enum {
141f003fb54Skardel     NTPDC_EXIT_SUCCESS         = 0,
1428585484eSchristos     NTPDC_EXIT_FAILURE         = 1,
1438585484eSchristos     NTPDC_EXIT_USAGE_ERROR     = 64,
1448585484eSchristos     NTPDC_EXIT_NO_CONFIG_INPUT = 66,
1458585484eSchristos     NTPDC_EXIT_LIBOPTS_FAILURE = 70
146f003fb54Skardel }   ntpdc_exit_code_t;
1478585484eSchristos /** @} */
1488585484eSchristos /**
149abb0f93cSkardel  *  Make sure there are no #define name conflicts with the option names
150abb0f93cSkardel  */
151abb0f93cSkardel #ifndef     NO_OPTION_NAME_WARNINGS
152abb0f93cSkardel # ifdef    IPV4
153abb0f93cSkardel #  warning undefining IPV4 due to option name conflict
154abb0f93cSkardel #  undef   IPV4
155abb0f93cSkardel # endif
156abb0f93cSkardel # ifdef    IPV6
157abb0f93cSkardel #  warning undefining IPV6 due to option name conflict
158abb0f93cSkardel #  undef   IPV6
159abb0f93cSkardel # endif
160abb0f93cSkardel # ifdef    COMMAND
161abb0f93cSkardel #  warning undefining COMMAND due to option name conflict
162abb0f93cSkardel #  undef   COMMAND
163abb0f93cSkardel # endif
1648585484eSchristos # ifdef    DEBUG_LEVEL
1658585484eSchristos #  warning undefining DEBUG_LEVEL due to option name conflict
1668585484eSchristos #  undef   DEBUG_LEVEL
1678585484eSchristos # endif
1688585484eSchristos # ifdef    SET_DEBUG_LEVEL
1698585484eSchristos #  warning undefining SET_DEBUG_LEVEL due to option name conflict
1708585484eSchristos #  undef   SET_DEBUG_LEVEL
1718585484eSchristos # endif
1728585484eSchristos # ifdef    INTERACTIVE
1738585484eSchristos #  warning undefining INTERACTIVE due to option name conflict
1748585484eSchristos #  undef   INTERACTIVE
1758585484eSchristos # endif
176abb0f93cSkardel # ifdef    LISTPEERS
177abb0f93cSkardel #  warning undefining LISTPEERS due to option name conflict
178abb0f93cSkardel #  undef   LISTPEERS
179abb0f93cSkardel # endif
1808585484eSchristos # ifdef    NUMERIC
1818585484eSchristos #  warning undefining NUMERIC due to option name conflict
1828585484eSchristos #  undef   NUMERIC
1838585484eSchristos # endif
184abb0f93cSkardel # ifdef    PEERS
185abb0f93cSkardel #  warning undefining PEERS due to option name conflict
186abb0f93cSkardel #  undef   PEERS
187abb0f93cSkardel # endif
188abb0f93cSkardel # ifdef    SHOWPEERS
189abb0f93cSkardel #  warning undefining SHOWPEERS due to option name conflict
190abb0f93cSkardel #  undef   SHOWPEERS
191abb0f93cSkardel # endif
192*eabc0478Schristos # ifdef    UNCONNECTED
193*eabc0478Schristos #  warning undefining UNCONNECTED due to option name conflict
194*eabc0478Schristos #  undef   UNCONNECTED
195*eabc0478Schristos # endif
196abb0f93cSkardel #else  /* NO_OPTION_NAME_WARNINGS */
197abb0f93cSkardel # undef IPV4
198abb0f93cSkardel # undef IPV6
199abb0f93cSkardel # undef COMMAND
200abb0f93cSkardel # undef DEBUG_LEVEL
201abb0f93cSkardel # undef SET_DEBUG_LEVEL
2028585484eSchristos # undef INTERACTIVE
2038585484eSchristos # undef LISTPEERS
204abb0f93cSkardel # undef NUMERIC
2058585484eSchristos # undef PEERS
2068585484eSchristos # undef SHOWPEERS
207*eabc0478Schristos # undef UNCONNECTED
208abb0f93cSkardel #endif  /*  NO_OPTION_NAME_WARNINGS */
209abb0f93cSkardel 
2108585484eSchristos /**
211abb0f93cSkardel  *  Interface defines for specific options.
2128585484eSchristos  * @{
213abb0f93cSkardel  */
214abb0f93cSkardel #define VALUE_OPT_IPV4           '4'
215abb0f93cSkardel #define VALUE_OPT_IPV6           '6'
216abb0f93cSkardel #define VALUE_OPT_COMMAND        'c'
217abb0f93cSkardel #define VALUE_OPT_DEBUG_LEVEL    'd'
218abb0f93cSkardel #define VALUE_OPT_SET_DEBUG_LEVEL 'D'
2198585484eSchristos 
2208585484eSchristos #define OPT_VALUE_SET_DEBUG_LEVEL (DESC(SET_DEBUG_LEVEL).optArg.argInt)
2218585484eSchristos #define VALUE_OPT_INTERACTIVE    'i'
2228585484eSchristos #define VALUE_OPT_LISTPEERS      'l'
223abb0f93cSkardel #define VALUE_OPT_NUMERIC        'n'
2248585484eSchristos #define VALUE_OPT_PEERS          'p'
2258585484eSchristos #define VALUE_OPT_SHOWPEERS      's'
226*eabc0478Schristos #define VALUE_OPT_UNCONNECTED    'u'
227b8ecfcfeSchristos /** option flag (value) for help-value option */
228abb0f93cSkardel #define VALUE_OPT_HELP          '?'
229b8ecfcfeSchristos /** option flag (value) for more-help-value option */
230abb0f93cSkardel #define VALUE_OPT_MORE_HELP     '!'
231b8ecfcfeSchristos /** option flag (value) for version-value option */
2328585484eSchristos #define VALUE_OPT_VERSION       0x1001
233b8ecfcfeSchristos /** option flag (value) for save-opts-value option */
234abb0f93cSkardel #define VALUE_OPT_SAVE_OPTS     '>'
235b8ecfcfeSchristos /** option flag (value) for load-opts-value option */
236abb0f93cSkardel #define VALUE_OPT_LOAD_OPTS     '<'
237abb0f93cSkardel #define SET_OPT_SAVE_OPTS(a)   STMTS( \
238abb0f93cSkardel         DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
239abb0f93cSkardel         DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
240abb0f93cSkardel         DESC(SAVE_OPTS).optArg.argString = (char const*)(a))
241abb0f93cSkardel /*
242abb0f93cSkardel  *  Interface defines not associated with particular options
243abb0f93cSkardel  */
244abb0f93cSkardel #define ERRSKIP_OPTERR  STMTS(ntpdcOptions.fOptSet &= ~OPTPROC_ERRSTOP)
245abb0f93cSkardel #define ERRSTOP_OPTERR  STMTS(ntpdcOptions.fOptSet |= OPTPROC_ERRSTOP)
246abb0f93cSkardel #define RESTART_OPT(n)  STMTS( \
247abb0f93cSkardel                 ntpdcOptions.curOptIdx = (n); \
248abb0f93cSkardel                 ntpdcOptions.pzCurOpt  = NULL )
249abb0f93cSkardel #define START_OPT       RESTART_OPT(1)
250abb0f93cSkardel #define USAGE(c)        (*ntpdcOptions.pUsageProc)(&ntpdcOptions, c)
251f003fb54Skardel 
252f003fb54Skardel #ifdef  __cplusplus
253f003fb54Skardel extern "C" {
254f003fb54Skardel #endif
255abb0f93cSkardel 
2568585484eSchristos 
257abb0f93cSkardel /* * * * * *
258abb0f93cSkardel  *
259abb0f93cSkardel  *  Declare the ntpdc option descriptor.
260abb0f93cSkardel  */
261abb0f93cSkardel extern tOptions ntpdcOptions;
262abb0f93cSkardel 
263abb0f93cSkardel #if defined(ENABLE_NLS)
264abb0f93cSkardel # ifndef _
265abb0f93cSkardel #   include <stdio.h>
2668585484eSchristos #   ifndef HAVE_GETTEXT
2678585484eSchristos       extern char * gettext(char const *);
2688585484eSchristos #   else
2698585484eSchristos #     include <libintl.h>
2708585484eSchristos #   endif
2718585484eSchristos 
272b8ecfcfeSchristos # ifndef ATTRIBUTE_FORMAT_ARG
273b8ecfcfeSchristos #   define ATTRIBUTE_FORMAT_ARG(_a)
274b8ecfcfeSchristos # endif
275b8ecfcfeSchristos 
276b8ecfcfeSchristos static inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1);
277abb0f93cSkardel static inline char* aoGetsText(char const* pz) {
278abb0f93cSkardel     if (pz == NULL) return NULL;
279abb0f93cSkardel     return (char*)gettext(pz);
280abb0f93cSkardel }
281abb0f93cSkardel #   define _(s)  aoGetsText(s)
282abb0f93cSkardel # endif /* _() */
283abb0f93cSkardel 
284abb0f93cSkardel # define OPT_NO_XLAT_CFG_NAMES  STMTS(ntpdcOptions.fOptSet |= \
285abb0f93cSkardel                                     OPTPROC_NXLAT_OPT_CFG;)
286abb0f93cSkardel # define OPT_NO_XLAT_OPT_NAMES  STMTS(ntpdcOptions.fOptSet |= \
287abb0f93cSkardel                                     OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
288abb0f93cSkardel 
289abb0f93cSkardel # define OPT_XLAT_CFG_NAMES     STMTS(ntpdcOptions.fOptSet &= \
290abb0f93cSkardel                                   ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
291abb0f93cSkardel # define OPT_XLAT_OPT_NAMES     STMTS(ntpdcOptions.fOptSet &= \
292abb0f93cSkardel                                   ~OPTPROC_NXLAT_OPT;)
293abb0f93cSkardel 
294abb0f93cSkardel #else   /* ENABLE_NLS */
295abb0f93cSkardel # define OPT_NO_XLAT_CFG_NAMES
296abb0f93cSkardel # define OPT_NO_XLAT_OPT_NAMES
297abb0f93cSkardel 
298abb0f93cSkardel # define OPT_XLAT_CFG_NAMES
299abb0f93cSkardel # define OPT_XLAT_OPT_NAMES
300abb0f93cSkardel 
301abb0f93cSkardel # ifndef _
302abb0f93cSkardel #   define _(_s)  _s
303abb0f93cSkardel # endif
304abb0f93cSkardel #endif  /* ENABLE_NLS */
305abb0f93cSkardel 
306*eabc0478Schristos 
307abb0f93cSkardel #ifdef  __cplusplus
308abb0f93cSkardel }
309abb0f93cSkardel #endif
310abb0f93cSkardel #endif /* AUTOOPTS_NTPDC_OPTS_H_GUARD */
3118585484eSchristos 
312abb0f93cSkardel /* ntpdc-opts.h ends here */
313