1 /*
2 * EDIT THIS FILE WITH CAUTION (sntp-opts.h)
3 *
4 * It has been AutoGen-ed June 6, 2023 at 04:35:52 AM by AutoGen 5.18.16
5 * From the definitions sntp-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 sntp 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 sntp 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 sntp 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_SNTP_OPTS_H_GUARD
45 #define AUTOOPTS_SNTP_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 sntp
73 */
74 typedef enum {
75 INDEX_OPT_IPV4 = 0,
76 INDEX_OPT_IPV6 = 1,
77 INDEX_OPT_AUTHENTICATION = 2,
78 INDEX_OPT_BROADCAST = 3,
79 INDEX_OPT_CONCURRENT = 4,
80 INDEX_OPT_DEBUG_LEVEL = 5,
81 INDEX_OPT_SET_DEBUG_LEVEL = 6,
82 INDEX_OPT_GAP = 7,
83 INDEX_OPT_KOD = 8,
84 INDEX_OPT_KEYFILE = 9,
85 INDEX_OPT_LOGFILE = 10,
86 INDEX_OPT_STEPLIMIT = 11,
87 INDEX_OPT_NTPVERSION = 12,
88 INDEX_OPT_USERESERVEDPORT = 13,
89 INDEX_OPT_STEP = 14,
90 INDEX_OPT_SLEW = 15,
91 INDEX_OPT_TIMEOUT = 16,
92 INDEX_OPT_WAIT = 17,
93 INDEX_OPT_VERSION = 18,
94 INDEX_OPT_HELP = 19,
95 INDEX_OPT_MORE_HELP = 20,
96 INDEX_OPT_SAVE_OPTS = 21,
97 INDEX_OPT_LOAD_OPTS = 22
98 } teOptIndex;
99 /** count of all options for sntp */
100 #define OPTION_CT 23
101 /** sntp version */
102 #define SNTP_VERSION "4.2.8p17"
103 /** Full sntp version text */
104 #define SNTP_FULL_VERSION "sntp 4.2.8p17"
105
106 /**
107 * Interface defines for all options. Replace "n" with the UPPER_CASED
108 * option name (as in the teOptIndex enumeration above).
109 * e.g. HAVE_OPT(IPV4)
110 */
111 #define DESC(n) (sntpOptions.pOptDesc[INDEX_OPT_## n])
112 /** 'true' if an option has been specified in any way */
113 #define HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
114 /** The string argument to an option. The argument type must be \"string\". */
115 #define OPT_ARG(n) (DESC(n).optArg.argString)
116 /** Mask the option state revealing how an option was specified.
117 * It will be one and only one of \a OPTST_SET, \a OPTST_PRESET,
118 * \a OPTST_DEFINED, \a OPTST_RESET or zero.
119 */
120 #define STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
121 /** Count of option's occurrances *on the command line*. */
122 #define COUNT_OPT(n) (DESC(n).optOccCt)
123 /** mask of \a OPTST_SET and \a OPTST_DEFINED. */
124 #define ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
125 /** 'true' if \a HAVE_OPT would yield 'false'. */
126 #define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
127 /** 'true' if OPTST_DISABLED bit not set. */
128 #define ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
129 /** number of stacked option arguments.
130 * Valid only for stacked option arguments. */
131 #define STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
132 /** stacked argument vector.
133 * Valid only for stacked option arguments. */
134 #define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
135 /** Reset an option. */
136 #define CLEAR_OPT(n) STMTS( \
137 DESC(n).fOptState &= OPTST_PERSISTENT_MASK; \
138 if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \
139 DESC(n).fOptState |= OPTST_DISABLED; \
140 DESC(n).optCookie = NULL )
141 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
142 /**
143 * Enumeration of sntp exit codes
144 */
145 typedef enum {
146 SNTP_EXIT_SUCCESS = 0,
147 SNTP_EXIT_FAILURE = 1,
148 SNTP_EXIT_USAGE_ERROR = 64,
149 SNTP_EXIT_NO_CONFIG_INPUT = 66,
150 SNTP_EXIT_LIBOPTS_FAILURE = 70
151 } sntp_exit_code_t;
152 /** @} */
153 /**
154 * Make sure there are no #define name conflicts with the option names
155 */
156 #ifndef NO_OPTION_NAME_WARNINGS
157 # ifdef IPV4
158 # warning undefining IPV4 due to option name conflict
159 # undef IPV4
160 # endif
161 # ifdef IPV6
162 # warning undefining IPV6 due to option name conflict
163 # undef IPV6
164 # endif
165 # ifdef AUTHENTICATION
166 # warning undefining AUTHENTICATION due to option name conflict
167 # undef AUTHENTICATION
168 # endif
169 # ifdef BROADCAST
170 # warning undefining BROADCAST due to option name conflict
171 # undef BROADCAST
172 # endif
173 # ifdef CONCURRENT
174 # warning undefining CONCURRENT due to option name conflict
175 # undef CONCURRENT
176 # endif
177 # ifdef DEBUG_LEVEL
178 # warning undefining DEBUG_LEVEL due to option name conflict
179 # undef DEBUG_LEVEL
180 # endif
181 # ifdef SET_DEBUG_LEVEL
182 # warning undefining SET_DEBUG_LEVEL due to option name conflict
183 # undef SET_DEBUG_LEVEL
184 # endif
185 # ifdef GAP
186 # warning undefining GAP due to option name conflict
187 # undef GAP
188 # endif
189 # ifdef KOD
190 # warning undefining KOD due to option name conflict
191 # undef KOD
192 # endif
193 # ifdef KEYFILE
194 # warning undefining KEYFILE due to option name conflict
195 # undef KEYFILE
196 # endif
197 # ifdef LOGFILE
198 # warning undefining LOGFILE due to option name conflict
199 # undef LOGFILE
200 # endif
201 # ifdef STEPLIMIT
202 # warning undefining STEPLIMIT due to option name conflict
203 # undef STEPLIMIT
204 # endif
205 # ifdef NTPVERSION
206 # warning undefining NTPVERSION due to option name conflict
207 # undef NTPVERSION
208 # endif
209 # ifdef USERESERVEDPORT
210 # warning undefining USERESERVEDPORT due to option name conflict
211 # undef USERESERVEDPORT
212 # endif
213 # ifdef STEP
214 # warning undefining STEP due to option name conflict
215 # undef STEP
216 # endif
217 # ifdef SLEW
218 # warning undefining SLEW due to option name conflict
219 # undef SLEW
220 # endif
221 # ifdef TIMEOUT
222 # warning undefining TIMEOUT due to option name conflict
223 # undef TIMEOUT
224 # endif
225 # ifdef WAIT
226 # warning undefining WAIT due to option name conflict
227 # undef WAIT
228 # endif
229 #else /* NO_OPTION_NAME_WARNINGS */
230 # undef IPV4
231 # undef IPV6
232 # undef AUTHENTICATION
233 # undef BROADCAST
234 # undef CONCURRENT
235 # undef DEBUG_LEVEL
236 # undef SET_DEBUG_LEVEL
237 # undef GAP
238 # undef KOD
239 # undef KEYFILE
240 # undef LOGFILE
241 # undef STEPLIMIT
242 # undef NTPVERSION
243 # undef USERESERVEDPORT
244 # undef STEP
245 # undef SLEW
246 # undef TIMEOUT
247 # undef WAIT
248 #endif /* NO_OPTION_NAME_WARNINGS */
249
250 /**
251 * Interface defines for specific options.
252 * @{
253 */
254 #define VALUE_OPT_IPV4 '4'
255 #define VALUE_OPT_IPV6 '6'
256 #define VALUE_OPT_AUTHENTICATION 'a'
257
258 #define OPT_VALUE_AUTHENTICATION (DESC(AUTHENTICATION).optArg.argInt)
259 #define VALUE_OPT_BROADCAST 'b'
260 #define VALUE_OPT_CONCURRENT 'c'
261 #define VALUE_OPT_DEBUG_LEVEL 'd'
262 #define VALUE_OPT_SET_DEBUG_LEVEL 'D'
263
264 #define OPT_VALUE_SET_DEBUG_LEVEL (DESC(SET_DEBUG_LEVEL).optArg.argInt)
265 #define VALUE_OPT_GAP 'g'
266
267 #define OPT_VALUE_GAP (DESC(GAP).optArg.argInt)
268 #define VALUE_OPT_KOD 'K'
269 #define VALUE_OPT_KEYFILE 'k'
270 #define VALUE_OPT_LOGFILE 'l'
271 #define VALUE_OPT_STEPLIMIT 'M'
272
273 #define OPT_VALUE_STEPLIMIT (DESC(STEPLIMIT).optArg.argInt)
274 #define VALUE_OPT_NTPVERSION 'o'
275
276 #define OPT_VALUE_NTPVERSION (DESC(NTPVERSION).optArg.argInt)
277 #define VALUE_OPT_USERESERVEDPORT 'r'
278 #define VALUE_OPT_STEP 'S'
279 #define VALUE_OPT_SLEW 's'
280 #define VALUE_OPT_TIMEOUT 't'
281
282 #define OPT_VALUE_TIMEOUT (DESC(TIMEOUT).optArg.argInt)
283 #define VALUE_OPT_WAIT 0x1001
284
285 #define SET_OPT_WAIT STMTS( \
286 DESC(WAIT).optActualIndex = 17; \
287 DESC(WAIT).optActualValue = VALUE_OPT_WAIT; \
288 DESC(WAIT).fOptState &= OPTST_PERSISTENT_MASK; \
289 DESC(WAIT).fOptState |= OPTST_SET )
290 #define DISABLE_OPT_WAIT STMTS( \
291 DESC(WAIT).fOptState &= OPTST_PERSISTENT_MASK; \
292 DESC(WAIT).fOptState |= OPTST_SET | OPTST_DISABLED; \
293 DESC(WAIT).optArg.argString = NULL )
294 /** option flag (value) for help-value option */
295 #define VALUE_OPT_HELP '?'
296 /** option flag (value) for more-help-value option */
297 #define VALUE_OPT_MORE_HELP '!'
298 /** option flag (value) for version-value option */
299 #define VALUE_OPT_VERSION 0x1002
300 /** option flag (value) for save-opts-value option */
301 #define VALUE_OPT_SAVE_OPTS '>'
302 /** option flag (value) for load-opts-value option */
303 #define VALUE_OPT_LOAD_OPTS '<'
304 #define SET_OPT_SAVE_OPTS(a) STMTS( \
305 DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
306 DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
307 DESC(SAVE_OPTS).optArg.argString = (char const*)(a))
308 /*
309 * Interface defines not associated with particular options
310 */
311 #define ERRSKIP_OPTERR STMTS(sntpOptions.fOptSet &= ~OPTPROC_ERRSTOP)
312 #define ERRSTOP_OPTERR STMTS(sntpOptions.fOptSet |= OPTPROC_ERRSTOP)
313 #define RESTART_OPT(n) STMTS( \
314 sntpOptions.curOptIdx = (n); \
315 sntpOptions.pzCurOpt = NULL )
316 #define START_OPT RESTART_OPT(1)
317 #define USAGE(c) (*sntpOptions.pUsageProc)(&sntpOptions, c)
318
319 #ifdef __cplusplus
320 extern "C" {
321 #endif
322
323
324 /* * * * * *
325 *
326 * Declare the sntp option descriptor.
327 */
328 extern tOptions sntpOptions;
329
330 #if defined(ENABLE_NLS)
331 # ifndef _
332 # include <stdio.h>
333 # ifndef HAVE_GETTEXT
334 extern char * gettext(char const *);
335 # else
336 # include <libintl.h>
337 # endif
338
339 # ifndef ATTRIBUTE_FORMAT_ARG
340 # define ATTRIBUTE_FORMAT_ARG(_a)
341 # endif
342
343 static inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1);
aoGetsText(char const * pz)344 static inline char* aoGetsText(char const* pz) {
345 if (pz == NULL) return NULL;
346 return (char*)gettext(pz);
347 }
348 # define _(s) aoGetsText(s)
349 # endif /* _() */
350
351 # define OPT_NO_XLAT_CFG_NAMES STMTS(sntpOptions.fOptSet |= \
352 OPTPROC_NXLAT_OPT_CFG;)
353 # define OPT_NO_XLAT_OPT_NAMES STMTS(sntpOptions.fOptSet |= \
354 OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
355
356 # define OPT_XLAT_CFG_NAMES STMTS(sntpOptions.fOptSet &= \
357 ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
358 # define OPT_XLAT_OPT_NAMES STMTS(sntpOptions.fOptSet &= \
359 ~OPTPROC_NXLAT_OPT;)
360
361 #else /* ENABLE_NLS */
362 # define OPT_NO_XLAT_CFG_NAMES
363 # define OPT_NO_XLAT_OPT_NAMES
364
365 # define OPT_XLAT_CFG_NAMES
366 # define OPT_XLAT_OPT_NAMES
367
368 # ifndef _
369 # define _(_s) _s
370 # endif
371 #endif /* ENABLE_NLS */
372
373
374 #ifdef __cplusplus
375 }
376 #endif
377 #endif /* AUTOOPTS_SNTP_OPTS_H_GUARD */
378
379 /* sntp-opts.h ends here */
380