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