xref: /freebsd/contrib/ntp/ntpdc/ntpdc-opts.h (revision 66fd12cf4896eb08ad8e7a2627537f84ead84dd3)
1 /*
2  *  EDIT THIS FILE WITH CAUTION  (ntpdc-opts.h)
3  *
4  *  It has been AutoGen-ed  June  6, 2023 at 04:37:52 AM by AutoGen 5.18.16
5  *  From the definitions    ntpdc-opts.def
6  *  and the template file   options
7  *
8  * Generated from AutoOpts 42:1:17 templates.
9  *
10  *  AutoOpts is a copyrighted work.  This header file is not encumbered
11  *  by AutoOpts licensing, but is provided under the licensing terms chosen
12  *  by the ntpdc author or copyright holder.  AutoOpts is
13  *  licensed under the terms of the LGPL.  The redistributable library
14  *  (``libopts'') is licensed under the terms of either the LGPL or, at the
15  *  users discretion, the BSD license.  See the AutoOpts and/or libopts sources
16  *  for details.
17  *
18  * The ntpdc program is copyrighted and licensed
19  * under the following terms:
20  *
21  *  Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation, all rights reserved.
22  *  This is free software. It is licensed for use, modification and
23  *  redistribution under the terms of the NTP License, copies of which
24  *  can be seen at:
25  *    <http://ntp.org/license>
26  *    <http://opensource.org/licenses/ntp-license.php>
27  *
28  *  Permission to use, copy, modify, and distribute this software and its
29  *  documentation for any purpose with or without fee is hereby granted,
30  *  provided that the above copyright notice appears in all copies and that
31  *  both the copyright notice and this permission notice appear in
32  *  supporting documentation, and that the name The University of Delaware not be used in
33  *  advertising or publicity pertaining to distribution of the software
34  *  without specific, written prior permission. The University of Delaware and Network Time Foundation makes no
35  *  representations about the suitability this software for any purpose. It
36  *  is provided "as is" without express or implied warranty.
37  */
38 /**
39  *  This file contains the programmatic interface to the Automated
40  *  Options generated for the ntpdc program.
41  *  These macros are documented in the AutoGen info file in the
42  *  "AutoOpts" chapter.  Please refer to that doc for usage help.
43  */
44 #ifndef AUTOOPTS_NTPDC_OPTS_H_GUARD
45 #define AUTOOPTS_NTPDC_OPTS_H_GUARD 1
46 #include "config.h"
47 #include <autoopts/options.h>
48 #include <stdarg.h>
49 #include <stdnoreturn.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 172033
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 #if GCC_VERSION > 40400
66 #define NOT_REACHED __builtin_unreachable();
67 #else
68 #define NOT_REACHED
69 #endif
70 
71 /**
72  *  Enumeration of each option type for ntpdc
73  */
74 typedef enum {
75     INDEX_OPT_IPV4             =  0,
76     INDEX_OPT_IPV6             =  1,
77     INDEX_OPT_COMMAND          =  2,
78     INDEX_OPT_DEBUG_LEVEL      =  3,
79     INDEX_OPT_SET_DEBUG_LEVEL  =  4,
80     INDEX_OPT_INTERACTIVE      =  5,
81     INDEX_OPT_LISTPEERS        =  6,
82     INDEX_OPT_NUMERIC          =  7,
83     INDEX_OPT_PEERS            =  8,
84     INDEX_OPT_SHOWPEERS        =  9,
85     INDEX_OPT_UNCONNECTED      = 10,
86     INDEX_OPT_VERSION          = 11,
87     INDEX_OPT_HELP             = 12,
88     INDEX_OPT_MORE_HELP        = 13,
89     INDEX_OPT_SAVE_OPTS        = 14,
90     INDEX_OPT_LOAD_OPTS        = 15
91 } teOptIndex;
92 /** count of all options for ntpdc */
93 #define OPTION_CT    16
94 /** ntpdc version */
95 #define NTPDC_VERSION       "4.2.8p17"
96 /** Full ntpdc version text */
97 #define NTPDC_FULL_VERSION  "ntpdc 4.2.8p17"
98 
99 /**
100  *  Interface defines for all options.  Replace "n" with the UPPER_CASED
101  *  option name (as in the teOptIndex enumeration above).
102  *  e.g. HAVE_OPT(IPV4)
103  */
104 #define         DESC(n) (ntpdcOptions.pOptDesc[INDEX_OPT_## n])
105 /** 'true' if an option has been specified in any way */
106 #define     HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
107 /** The string argument to an option. The argument type must be \"string\". */
108 #define      OPT_ARG(n) (DESC(n).optArg.argString)
109 /** Mask the option state revealing how an option was specified.
110  *  It will be one and only one of \a OPTST_SET, \a OPTST_PRESET,
111  * \a OPTST_DEFINED, \a OPTST_RESET or zero.
112  */
113 #define    STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
114 /** Count of option's occurrances *on the command line*. */
115 #define    COUNT_OPT(n) (DESC(n).optOccCt)
116 /** mask of \a OPTST_SET and \a OPTST_DEFINED. */
117 #define    ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
118 /** 'true' if \a HAVE_OPT would yield 'false'. */
119 #define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
120 /** 'true' if OPTST_DISABLED bit not set. */
121 #define  ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
122 /** number of stacked option arguments.
123  *  Valid only for stacked option arguments. */
124 #define  STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
125 /** stacked argument vector.
126  *  Valid only for stacked option arguments. */
127 #define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
128 /** Reset an option. */
129 #define    CLEAR_OPT(n) STMTS( \
130                 DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
131                 if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \
132                     DESC(n).fOptState |= OPTST_DISABLED; \
133                 DESC(n).optCookie = NULL )
134 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
135 /**
136  *  Enumeration of ntpdc exit codes
137  */
138 typedef enum {
139     NTPDC_EXIT_SUCCESS         = 0,
140     NTPDC_EXIT_FAILURE         = 1,
141     NTPDC_EXIT_USAGE_ERROR     = 64,
142     NTPDC_EXIT_NO_CONFIG_INPUT = 66,
143     NTPDC_EXIT_LIBOPTS_FAILURE = 70
144 }   ntpdc_exit_code_t;
145 /** @} */
146 /**
147  *  Make sure there are no #define name conflicts with the option names
148  */
149 #ifndef     NO_OPTION_NAME_WARNINGS
150 # ifdef    IPV4
151 #  warning undefining IPV4 due to option name conflict
152 #  undef   IPV4
153 # endif
154 # ifdef    IPV6
155 #  warning undefining IPV6 due to option name conflict
156 #  undef   IPV6
157 # endif
158 # ifdef    COMMAND
159 #  warning undefining COMMAND due to option name conflict
160 #  undef   COMMAND
161 # endif
162 # ifdef    DEBUG_LEVEL
163 #  warning undefining DEBUG_LEVEL due to option name conflict
164 #  undef   DEBUG_LEVEL
165 # endif
166 # ifdef    SET_DEBUG_LEVEL
167 #  warning undefining SET_DEBUG_LEVEL due to option name conflict
168 #  undef   SET_DEBUG_LEVEL
169 # endif
170 # ifdef    INTERACTIVE
171 #  warning undefining INTERACTIVE due to option name conflict
172 #  undef   INTERACTIVE
173 # endif
174 # ifdef    LISTPEERS
175 #  warning undefining LISTPEERS due to option name conflict
176 #  undef   LISTPEERS
177 # endif
178 # ifdef    NUMERIC
179 #  warning undefining NUMERIC due to option name conflict
180 #  undef   NUMERIC
181 # endif
182 # ifdef    PEERS
183 #  warning undefining PEERS due to option name conflict
184 #  undef   PEERS
185 # endif
186 # ifdef    SHOWPEERS
187 #  warning undefining SHOWPEERS due to option name conflict
188 #  undef   SHOWPEERS
189 # endif
190 # ifdef    UNCONNECTED
191 #  warning undefining UNCONNECTED due to option name conflict
192 #  undef   UNCONNECTED
193 # endif
194 #else  /* NO_OPTION_NAME_WARNINGS */
195 # undef IPV4
196 # undef IPV6
197 # undef COMMAND
198 # undef DEBUG_LEVEL
199 # undef SET_DEBUG_LEVEL
200 # undef INTERACTIVE
201 # undef LISTPEERS
202 # undef NUMERIC
203 # undef PEERS
204 # undef SHOWPEERS
205 # undef UNCONNECTED
206 #endif  /*  NO_OPTION_NAME_WARNINGS */
207 
208 /**
209  *  Interface defines for specific options.
210  * @{
211  */
212 #define VALUE_OPT_IPV4           '4'
213 #define VALUE_OPT_IPV6           '6'
214 #define VALUE_OPT_COMMAND        'c'
215 #define VALUE_OPT_DEBUG_LEVEL    'd'
216 #define VALUE_OPT_SET_DEBUG_LEVEL 'D'
217 
218 #define OPT_VALUE_SET_DEBUG_LEVEL (DESC(SET_DEBUG_LEVEL).optArg.argInt)
219 #define VALUE_OPT_INTERACTIVE    'i'
220 #define VALUE_OPT_LISTPEERS      'l'
221 #define VALUE_OPT_NUMERIC        'n'
222 #define VALUE_OPT_PEERS          'p'
223 #define VALUE_OPT_SHOWPEERS      's'
224 #define VALUE_OPT_UNCONNECTED    'u'
225 /** option flag (value) for help-value option */
226 #define VALUE_OPT_HELP          '?'
227 /** option flag (value) for more-help-value option */
228 #define VALUE_OPT_MORE_HELP     '!'
229 /** option flag (value) for version-value option */
230 #define VALUE_OPT_VERSION       0x1001
231 /** option flag (value) for save-opts-value option */
232 #define VALUE_OPT_SAVE_OPTS     '>'
233 /** option flag (value) for load-opts-value option */
234 #define VALUE_OPT_LOAD_OPTS     '<'
235 #define SET_OPT_SAVE_OPTS(a)   STMTS( \
236         DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
237         DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
238         DESC(SAVE_OPTS).optArg.argString = (char const*)(a))
239 /*
240  *  Interface defines not associated with particular options
241  */
242 #define ERRSKIP_OPTERR  STMTS(ntpdcOptions.fOptSet &= ~OPTPROC_ERRSTOP)
243 #define ERRSTOP_OPTERR  STMTS(ntpdcOptions.fOptSet |= OPTPROC_ERRSTOP)
244 #define RESTART_OPT(n)  STMTS( \
245                 ntpdcOptions.curOptIdx = (n); \
246                 ntpdcOptions.pzCurOpt  = NULL )
247 #define START_OPT       RESTART_OPT(1)
248 #define USAGE(c)        (*ntpdcOptions.pUsageProc)(&ntpdcOptions, c)
249 
250 #ifdef  __cplusplus
251 extern "C" {
252 #endif
253 
254 
255 /* * * * * *
256  *
257  *  Declare the ntpdc option descriptor.
258  */
259 extern tOptions ntpdcOptions;
260 
261 #if defined(ENABLE_NLS)
262 # ifndef _
263 #   include <stdio.h>
264 #   ifndef HAVE_GETTEXT
265       extern char * gettext(char const *);
266 #   else
267 #     include <libintl.h>
268 #   endif
269 
270 # ifndef ATTRIBUTE_FORMAT_ARG
271 #   define ATTRIBUTE_FORMAT_ARG(_a)
272 # endif
273 
274 static inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1);
275 static inline char* aoGetsText(char const* pz) {
276     if (pz == NULL) return NULL;
277     return (char*)gettext(pz);
278 }
279 #   define _(s)  aoGetsText(s)
280 # endif /* _() */
281 
282 # define OPT_NO_XLAT_CFG_NAMES  STMTS(ntpdcOptions.fOptSet |= \
283                                     OPTPROC_NXLAT_OPT_CFG;)
284 # define OPT_NO_XLAT_OPT_NAMES  STMTS(ntpdcOptions.fOptSet |= \
285                                     OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
286 
287 # define OPT_XLAT_CFG_NAMES     STMTS(ntpdcOptions.fOptSet &= \
288                                   ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
289 # define OPT_XLAT_OPT_NAMES     STMTS(ntpdcOptions.fOptSet &= \
290                                   ~OPTPROC_NXLAT_OPT;)
291 
292 #else   /* ENABLE_NLS */
293 # define OPT_NO_XLAT_CFG_NAMES
294 # define OPT_NO_XLAT_OPT_NAMES
295 
296 # define OPT_XLAT_CFG_NAMES
297 # define OPT_XLAT_OPT_NAMES
298 
299 # ifndef _
300 #   define _(_s)  _s
301 # endif
302 #endif  /* ENABLE_NLS */
303 
304 
305 #ifdef  __cplusplus
306 }
307 #endif
308 #endif /* AUTOOPTS_NTPDC_OPTS_H_GUARD */
309 
310 /* ntpdc-opts.h ends here */
311