xref: /netbsd-src/external/bsd/ntp/dist/ntpdc/ntpdc-opts.h (revision f8cf1a9151c7af1cb0bd8b09c13c66bca599c027)
1 /*	$NetBSD: ntpdc-opts.h,v 1.15 2024/08/18 20:47:19 christos Exp $	*/
2 
3 /*
4  *  EDIT THIS FILE WITH CAUTION  (ntpdc-opts.h)
5  *
6  *  It has been AutoGen-ed  May 25, 2024 at 12:04:11 AM by AutoGen 5.18.16
7  *  From the definitions    ntpdc-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 ntpdc 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 ntpdc 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 ntpdc 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_NTPDC_OPTS_H_GUARD
47 #define AUTOOPTS_NTPDC_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 ntpdc
75  */
76 typedef enum {
77     INDEX_OPT_IPV4             =  0,
78     INDEX_OPT_IPV6             =  1,
79     INDEX_OPT_COMMAND          =  2,
80     INDEX_OPT_DEBUG_LEVEL      =  3,
81     INDEX_OPT_SET_DEBUG_LEVEL  =  4,
82     INDEX_OPT_INTERACTIVE      =  5,
83     INDEX_OPT_LISTPEERS        =  6,
84     INDEX_OPT_NUMERIC          =  7,
85     INDEX_OPT_PEERS            =  8,
86     INDEX_OPT_SHOWPEERS        =  9,
87     INDEX_OPT_UNCONNECTED      = 10,
88     INDEX_OPT_VERSION          = 11,
89     INDEX_OPT_HELP             = 12,
90     INDEX_OPT_MORE_HELP        = 13,
91     INDEX_OPT_SAVE_OPTS        = 14,
92     INDEX_OPT_LOAD_OPTS        = 15
93 } teOptIndex;
94 /** count of all options for ntpdc */
95 #define OPTION_CT    16
96 /** ntpdc version */
97 #define NTPDC_VERSION       "4.2.8p18"
98 /** Full ntpdc version text */
99 #define NTPDC_FULL_VERSION  "ntpdc 4.2.8p18"
100 
101 /**
102  *  Interface defines for all options.  Replace "n" with the UPPER_CASED
103  *  option name (as in the teOptIndex enumeration above).
104  *  e.g. HAVE_OPT(IPV4)
105  */
106 #define         DESC(n) (ntpdcOptions.pOptDesc[INDEX_OPT_## n])
107 /** 'true' if an option has been specified in any way */
108 #define     HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
109 /** The string argument to an option. The argument type must be \"string\". */
110 #define      OPT_ARG(n) (DESC(n).optArg.argString)
111 /** Mask the option state revealing how an option was specified.
112  *  It will be one and only one of \a OPTST_SET, \a OPTST_PRESET,
113  * \a OPTST_DEFINED, \a OPTST_RESET or zero.
114  */
115 #define    STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
116 /** Count of option's occurrances *on the command line*. */
117 #define    COUNT_OPT(n) (DESC(n).optOccCt)
118 /** mask of \a OPTST_SET and \a OPTST_DEFINED. */
119 #define    ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
120 /** 'true' if \a HAVE_OPT would yield 'false'. */
121 #define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
122 /** 'true' if OPTST_DISABLED bit not set. */
123 #define  ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
124 /** number of stacked option arguments.
125  *  Valid only for stacked option arguments. */
126 #define  STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
127 /** stacked argument vector.
128  *  Valid only for stacked option arguments. */
129 #define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
130 /** Reset an option. */
131 #define    CLEAR_OPT(n) STMTS( \
132                 DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
133                 if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \
134                     DESC(n).fOptState |= OPTST_DISABLED; \
135                 DESC(n).optCookie = NULL )
136 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
137 /**
138  *  Enumeration of ntpdc exit codes
139  */
140 typedef enum {
141     NTPDC_EXIT_SUCCESS         = 0,
142     NTPDC_EXIT_FAILURE         = 1,
143     NTPDC_EXIT_USAGE_ERROR     = 64,
144     NTPDC_EXIT_NO_CONFIG_INPUT = 66,
145     NTPDC_EXIT_LIBOPTS_FAILURE = 70
146 }   ntpdc_exit_code_t;
147 /** @} */
148 /**
149  *  Make sure there are no #define name conflicts with the option names
150  */
151 #ifndef     NO_OPTION_NAME_WARNINGS
152 # ifdef    IPV4
153 #  warning undefining IPV4 due to option name conflict
154 #  undef   IPV4
155 # endif
156 # ifdef    IPV6
157 #  warning undefining IPV6 due to option name conflict
158 #  undef   IPV6
159 # endif
160 # ifdef    COMMAND
161 #  warning undefining COMMAND due to option name conflict
162 #  undef   COMMAND
163 # endif
164 # ifdef    DEBUG_LEVEL
165 #  warning undefining DEBUG_LEVEL due to option name conflict
166 #  undef   DEBUG_LEVEL
167 # endif
168 # ifdef    SET_DEBUG_LEVEL
169 #  warning undefining SET_DEBUG_LEVEL due to option name conflict
170 #  undef   SET_DEBUG_LEVEL
171 # endif
172 # ifdef    INTERACTIVE
173 #  warning undefining INTERACTIVE due to option name conflict
174 #  undef   INTERACTIVE
175 # endif
176 # ifdef    LISTPEERS
177 #  warning undefining LISTPEERS due to option name conflict
178 #  undef   LISTPEERS
179 # endif
180 # ifdef    NUMERIC
181 #  warning undefining NUMERIC due to option name conflict
182 #  undef   NUMERIC
183 # endif
184 # ifdef    PEERS
185 #  warning undefining PEERS due to option name conflict
186 #  undef   PEERS
187 # endif
188 # ifdef    SHOWPEERS
189 #  warning undefining SHOWPEERS due to option name conflict
190 #  undef   SHOWPEERS
191 # endif
192 # ifdef    UNCONNECTED
193 #  warning undefining UNCONNECTED due to option name conflict
194 #  undef   UNCONNECTED
195 # endif
196 #else  /* NO_OPTION_NAME_WARNINGS */
197 # undef IPV4
198 # undef IPV6
199 # undef COMMAND
200 # undef DEBUG_LEVEL
201 # undef SET_DEBUG_LEVEL
202 # undef INTERACTIVE
203 # undef LISTPEERS
204 # undef NUMERIC
205 # undef PEERS
206 # undef SHOWPEERS
207 # undef UNCONNECTED
208 #endif  /*  NO_OPTION_NAME_WARNINGS */
209 
210 /**
211  *  Interface defines for specific options.
212  * @{
213  */
214 #define VALUE_OPT_IPV4           '4'
215 #define VALUE_OPT_IPV6           '6'
216 #define VALUE_OPT_COMMAND        'c'
217 #define VALUE_OPT_DEBUG_LEVEL    'd'
218 #define VALUE_OPT_SET_DEBUG_LEVEL 'D'
219 
220 #define OPT_VALUE_SET_DEBUG_LEVEL (DESC(SET_DEBUG_LEVEL).optArg.argInt)
221 #define VALUE_OPT_INTERACTIVE    'i'
222 #define VALUE_OPT_LISTPEERS      'l'
223 #define VALUE_OPT_NUMERIC        'n'
224 #define VALUE_OPT_PEERS          'p'
225 #define VALUE_OPT_SHOWPEERS      's'
226 #define VALUE_OPT_UNCONNECTED    'u'
227 /** option flag (value) for help-value option */
228 #define VALUE_OPT_HELP          '?'
229 /** option flag (value) for more-help-value option */
230 #define VALUE_OPT_MORE_HELP     '!'
231 /** option flag (value) for version-value option */
232 #define VALUE_OPT_VERSION       0x1001
233 /** option flag (value) for save-opts-value option */
234 #define VALUE_OPT_SAVE_OPTS     '>'
235 /** option flag (value) for load-opts-value option */
236 #define VALUE_OPT_LOAD_OPTS     '<'
237 #define SET_OPT_SAVE_OPTS(a)   STMTS( \
238         DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
239         DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
240         DESC(SAVE_OPTS).optArg.argString = (char const*)(a))
241 /*
242  *  Interface defines not associated with particular options
243  */
244 #define ERRSKIP_OPTERR  STMTS(ntpdcOptions.fOptSet &= ~OPTPROC_ERRSTOP)
245 #define ERRSTOP_OPTERR  STMTS(ntpdcOptions.fOptSet |= OPTPROC_ERRSTOP)
246 #define RESTART_OPT(n)  STMTS( \
247                 ntpdcOptions.curOptIdx = (n); \
248                 ntpdcOptions.pzCurOpt  = NULL )
249 #define START_OPT       RESTART_OPT(1)
250 #define USAGE(c)        (*ntpdcOptions.pUsageProc)(&ntpdcOptions, c)
251 
252 #ifdef  __cplusplus
253 extern "C" {
254 #endif
255 
256 
257 /* * * * * *
258  *
259  *  Declare the ntpdc option descriptor.
260  */
261 extern tOptions ntpdcOptions;
262 
263 #if defined(ENABLE_NLS)
264 # ifndef _
265 #   include <stdio.h>
266 #   ifndef HAVE_GETTEXT
267       extern char * gettext(char const *);
268 #   else
269 #     include <libintl.h>
270 #   endif
271 
272 # ifndef ATTRIBUTE_FORMAT_ARG
273 #   define ATTRIBUTE_FORMAT_ARG(_a)
274 # endif
275 
276 static inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1);
277 static inline char* aoGetsText(char const* pz) {
278     if (pz == NULL) return NULL;
279     return (char*)gettext(pz);
280 }
281 #   define _(s)  aoGetsText(s)
282 # endif /* _() */
283 
284 # define OPT_NO_XLAT_CFG_NAMES  STMTS(ntpdcOptions.fOptSet |= \
285                                     OPTPROC_NXLAT_OPT_CFG;)
286 # define OPT_NO_XLAT_OPT_NAMES  STMTS(ntpdcOptions.fOptSet |= \
287                                     OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
288 
289 # define OPT_XLAT_CFG_NAMES     STMTS(ntpdcOptions.fOptSet &= \
290                                   ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
291 # define OPT_XLAT_OPT_NAMES     STMTS(ntpdcOptions.fOptSet &= \
292                                   ~OPTPROC_NXLAT_OPT;)
293 
294 #else   /* ENABLE_NLS */
295 # define OPT_NO_XLAT_CFG_NAMES
296 # define OPT_NO_XLAT_OPT_NAMES
297 
298 # define OPT_XLAT_CFG_NAMES
299 # define OPT_XLAT_OPT_NAMES
300 
301 # ifndef _
302 #   define _(_s)  _s
303 # endif
304 #endif  /* ENABLE_NLS */
305 
306 
307 #ifdef  __cplusplus
308 }
309 #endif
310 #endif /* AUTOOPTS_NTPDC_OPTS_H_GUARD */
311 
312 /* ntpdc-opts.h ends here */
313