1 /* $NetBSD: ntpd-opts.h,v 1.18 2024/08/18 20:47:18 christos Exp $ */
2
3 /*
4 * EDIT THIS FILE WITH CAUTION (ntpd-opts.h)
5 *
6 * It has been AutoGen-ed May 25, 2024 at 12:03:08 AM by AutoGen 5.18.16
7 * From the definitions ntpd-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 ntpd 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 ntpd 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 ntpd 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_NTPD_OPTS_H_GUARD
47 #define AUTOOPTS_NTPD_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 ntpd
75 */
76 typedef enum {
77 INDEX_OPT_IPV4 = 0,
78 INDEX_OPT_IPV6 = 1,
79 INDEX_OPT_AUTHREQ = 2,
80 INDEX_OPT_AUTHNOREQ = 3,
81 INDEX_OPT_BCASTSYNC = 4,
82 INDEX_OPT_CONFIGFILE = 5,
83 INDEX_OPT_DEBUG_LEVEL = 6,
84 INDEX_OPT_SET_DEBUG_LEVEL = 7,
85 INDEX_OPT_DRIFTFILE = 8,
86 INDEX_OPT_PANICGATE = 9,
87 INDEX_OPT_FORCE_STEP_ONCE = 10,
88 INDEX_OPT_JAILDIR = 11,
89 INDEX_OPT_INTERFACE = 12,
90 INDEX_OPT_KEYFILE = 13,
91 INDEX_OPT_LOGFILE = 14,
92 INDEX_OPT_NOVIRTUALIPS = 15,
93 INDEX_OPT_MODIFYMMTIMER = 16,
94 INDEX_OPT_NOFORK = 17,
95 INDEX_OPT_NICE = 18,
96 INDEX_OPT_PIDFILE = 19,
97 INDEX_OPT_PRIORITY = 20,
98 INDEX_OPT_QUIT = 21,
99 INDEX_OPT_PROPAGATIONDELAY = 22,
100 INDEX_OPT_SAVECONFIGQUIT = 23,
101 INDEX_OPT_STATSDIR = 24,
102 INDEX_OPT_TRUSTEDKEY = 25,
103 INDEX_OPT_USER = 26,
104 INDEX_OPT_UPDATEINTERVAL = 27,
105 INDEX_OPT_VAR = 28,
106 INDEX_OPT_DVAR = 29,
107 INDEX_OPT_WAIT_SYNC = 30,
108 INDEX_OPT_SLEW = 31,
109 INDEX_OPT_USEPCC = 32,
110 INDEX_OPT_PCCFREQ = 33,
111 INDEX_OPT_MDNS = 34,
112 INDEX_OPT_VERSION = 35,
113 INDEX_OPT_HELP = 36,
114 INDEX_OPT_MORE_HELP = 37
115 } teOptIndex;
116 /** count of all options for ntpd */
117 #define OPTION_CT 38
118 /** ntpd version */
119 #define NTPD_VERSION "4.2.8p18"
120 /** Full ntpd version text */
121 #define NTPD_FULL_VERSION "ntpd 4.2.8p18"
122
123 /**
124 * Interface defines for all options. Replace "n" with the UPPER_CASED
125 * option name (as in the teOptIndex enumeration above).
126 * e.g. HAVE_OPT(IPV4)
127 */
128 #define DESC(n) (ntpdOptions.pOptDesc[INDEX_OPT_## n])
129 /** 'true' if an option has been specified in any way */
130 #define HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
131 /** The string argument to an option. The argument type must be \"string\". */
132 #define OPT_ARG(n) (DESC(n).optArg.argString)
133 /** Mask the option state revealing how an option was specified.
134 * It will be one and only one of \a OPTST_SET, \a OPTST_PRESET,
135 * \a OPTST_DEFINED, \a OPTST_RESET or zero.
136 */
137 #define STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
138 /** Count of option's occurrances *on the command line*. */
139 #define COUNT_OPT(n) (DESC(n).optOccCt)
140 /** mask of \a OPTST_SET and \a OPTST_DEFINED. */
141 #define ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
142 /** 'true' if \a HAVE_OPT would yield 'false'. */
143 #define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
144 /** 'true' if OPTST_DISABLED bit not set. */
145 #define ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
146 /** number of stacked option arguments.
147 * Valid only for stacked option arguments. */
148 #define STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
149 /** stacked argument vector.
150 * Valid only for stacked option arguments. */
151 #define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
152 /** Reset an option. */
153 #define CLEAR_OPT(n) STMTS( \
154 DESC(n).fOptState &= OPTST_PERSISTENT_MASK; \
155 if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \
156 DESC(n).fOptState |= OPTST_DISABLED; \
157 DESC(n).optCookie = NULL )
158 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
159 /**
160 * Enumeration of ntpd exit codes
161 */
162 typedef enum {
163 NTPD_EXIT_SUCCESS = 0,
164 NTPD_EXIT_FAILURE = 1,
165 NTPD_EXIT_USAGE_ERROR = 64,
166 NTPD_EXIT_LIBOPTS_FAILURE = 70
167 } ntpd_exit_code_t;
168 /** @} */
169 /**
170 * Make sure there are no #define name conflicts with the option names
171 */
172 #ifndef NO_OPTION_NAME_WARNINGS
173 # ifdef IPV4
174 # warning undefining IPV4 due to option name conflict
175 # undef IPV4
176 # endif
177 # ifdef IPV6
178 # warning undefining IPV6 due to option name conflict
179 # undef IPV6
180 # endif
181 # ifdef AUTHREQ
182 # warning undefining AUTHREQ due to option name conflict
183 # undef AUTHREQ
184 # endif
185 # ifdef AUTHNOREQ
186 # warning undefining AUTHNOREQ due to option name conflict
187 # undef AUTHNOREQ
188 # endif
189 # ifdef BCASTSYNC
190 # warning undefining BCASTSYNC due to option name conflict
191 # undef BCASTSYNC
192 # endif
193 # ifdef CONFIGFILE
194 # warning undefining CONFIGFILE due to option name conflict
195 # undef CONFIGFILE
196 # endif
197 # ifdef DEBUG_LEVEL
198 # warning undefining DEBUG_LEVEL due to option name conflict
199 # undef DEBUG_LEVEL
200 # endif
201 # ifdef SET_DEBUG_LEVEL
202 # warning undefining SET_DEBUG_LEVEL due to option name conflict
203 # undef SET_DEBUG_LEVEL
204 # endif
205 # ifdef DRIFTFILE
206 # warning undefining DRIFTFILE due to option name conflict
207 # undef DRIFTFILE
208 # endif
209 # ifdef PANICGATE
210 # warning undefining PANICGATE due to option name conflict
211 # undef PANICGATE
212 # endif
213 # ifdef FORCE_STEP_ONCE
214 # warning undefining FORCE_STEP_ONCE due to option name conflict
215 # undef FORCE_STEP_ONCE
216 # endif
217 # ifdef JAILDIR
218 # warning undefining JAILDIR due to option name conflict
219 # undef JAILDIR
220 # endif
221 # ifdef INTERFACE
222 # warning undefining INTERFACE due to option name conflict
223 # undef INTERFACE
224 # endif
225 # ifdef KEYFILE
226 # warning undefining KEYFILE due to option name conflict
227 # undef KEYFILE
228 # endif
229 # ifdef LOGFILE
230 # warning undefining LOGFILE due to option name conflict
231 # undef LOGFILE
232 # endif
233 # ifdef NOVIRTUALIPS
234 # warning undefining NOVIRTUALIPS due to option name conflict
235 # undef NOVIRTUALIPS
236 # endif
237 # ifdef MODIFYMMTIMER
238 # warning undefining MODIFYMMTIMER due to option name conflict
239 # undef MODIFYMMTIMER
240 # endif
241 # ifdef NOFORK
242 # warning undefining NOFORK due to option name conflict
243 # undef NOFORK
244 # endif
245 # ifdef NICE
246 # warning undefining NICE due to option name conflict
247 # undef NICE
248 # endif
249 # ifdef PIDFILE
250 # warning undefining PIDFILE due to option name conflict
251 # undef PIDFILE
252 # endif
253 # ifdef PRIORITY
254 # warning undefining PRIORITY due to option name conflict
255 # undef PRIORITY
256 # endif
257 # ifdef QUIT
258 # warning undefining QUIT due to option name conflict
259 # undef QUIT
260 # endif
261 # ifdef PROPAGATIONDELAY
262 # warning undefining PROPAGATIONDELAY due to option name conflict
263 # undef PROPAGATIONDELAY
264 # endif
265 # ifdef SAVECONFIGQUIT
266 # warning undefining SAVECONFIGQUIT due to option name conflict
267 # undef SAVECONFIGQUIT
268 # endif
269 # ifdef STATSDIR
270 # warning undefining STATSDIR due to option name conflict
271 # undef STATSDIR
272 # endif
273 # ifdef TRUSTEDKEY
274 # warning undefining TRUSTEDKEY due to option name conflict
275 # undef TRUSTEDKEY
276 # endif
277 # ifdef USER
278 # warning undefining USER due to option name conflict
279 # undef USER
280 # endif
281 # ifdef UPDATEINTERVAL
282 # warning undefining UPDATEINTERVAL due to option name conflict
283 # undef UPDATEINTERVAL
284 # endif
285 # ifdef VAR
286 # warning undefining VAR due to option name conflict
287 # undef VAR
288 # endif
289 # ifdef DVAR
290 # warning undefining DVAR due to option name conflict
291 # undef DVAR
292 # endif
293 # ifdef WAIT_SYNC
294 # warning undefining WAIT_SYNC due to option name conflict
295 # undef WAIT_SYNC
296 # endif
297 # ifdef SLEW
298 # warning undefining SLEW due to option name conflict
299 # undef SLEW
300 # endif
301
302 # ifdef USEPCC
303 # warning undefining USEPCC due to option name conflict
304 # undef USEPCC
305 # endif
306 # ifdef PCCFREQ
307 # warning undefining PCCFREQ due to option name conflict
308 # undef PCCFREQ
309 # endif
310 # ifdef MDNS
311 # warning undefining MDNS due to option name conflict
312 # undef MDNS
313 # endif
314 #else /* NO_OPTION_NAME_WARNINGS */
315 # undef IPV4
316 # undef IPV6
317 # undef AUTHREQ
318 # undef AUTHNOREQ
319 # undef BCASTSYNC
320 # undef CONFIGFILE
321 # undef DEBUG_LEVEL
322 # undef SET_DEBUG_LEVEL
323 # undef DRIFTFILE
324 # undef PANICGATE
325 # undef FORCE_STEP_ONCE
326 # undef JAILDIR
327 # undef INTERFACE
328 # undef KEYFILE
329 # undef LOGFILE
330 # undef NOVIRTUALIPS
331 # undef MODIFYMMTIMER
332 # undef NOFORK
333 # undef NICE
334 # undef PIDFILE
335 # undef PRIORITY
336 # undef QUIT
337 # undef PROPAGATIONDELAY
338 # undef SAVECONFIGQUIT
339 # undef STATSDIR
340 # undef TRUSTEDKEY
341 # undef USER
342 # undef UPDATEINTERVAL
343 # undef VAR
344 # undef DVAR
345 # undef WAIT_SYNC
346 # undef SLEW
347 # undef USEPCC
348 # undef PCCFREQ
349 # undef MDNS
350 #endif /* NO_OPTION_NAME_WARNINGS */
351
352 /**
353 * Interface defines for specific options.
354 * @{
355 */
356 #define VALUE_OPT_IPV4 '4'
357 #define VALUE_OPT_IPV6 '6'
358 #define VALUE_OPT_AUTHREQ 'a'
359 #define VALUE_OPT_AUTHNOREQ 'A'
360 #define VALUE_OPT_BCASTSYNC 'b'
361 #define VALUE_OPT_CONFIGFILE 'c'
362 #define VALUE_OPT_DEBUG_LEVEL 'd'
363 #define VALUE_OPT_SET_DEBUG_LEVEL 'D'
364
365 #define OPT_VALUE_SET_DEBUG_LEVEL (DESC(SET_DEBUG_LEVEL).optArg.argInt)
366 #define VALUE_OPT_DRIFTFILE 'f'
367 #define VALUE_OPT_PANICGATE 'g'
368 #define VALUE_OPT_FORCE_STEP_ONCE 'G'
369 #define VALUE_OPT_JAILDIR 'i'
370 #define VALUE_OPT_INTERFACE 'I'
371 #define VALUE_OPT_KEYFILE 'k'
372 #define VALUE_OPT_LOGFILE 'l'
373 #define VALUE_OPT_NOVIRTUALIPS 'L'
374 #define VALUE_OPT_MODIFYMMTIMER 'M'
375 #define VALUE_OPT_NOFORK 'n'
376 #define VALUE_OPT_NICE 'N'
377 #define VALUE_OPT_PIDFILE 'p'
378 #define VALUE_OPT_PRIORITY 'P'
379
380 #define OPT_VALUE_PRIORITY (DESC(PRIORITY).optArg.argInt)
381 #define VALUE_OPT_QUIT 'q'
382 #define VALUE_OPT_PROPAGATIONDELAY 'r'
383 #define VALUE_OPT_SAVECONFIGQUIT 0x1001
384 #define VALUE_OPT_STATSDIR 's'
385 #define VALUE_OPT_TRUSTEDKEY 't'
386 #define VALUE_OPT_USER 'u'
387 #define VALUE_OPT_UPDATEINTERVAL 'U'
388
389 #define OPT_VALUE_UPDATEINTERVAL (DESC(UPDATEINTERVAL).optArg.argInt)
390 #define VALUE_OPT_VAR 0x1002
391 #define VALUE_OPT_DVAR 0x1003
392 #define VALUE_OPT_WAIT_SYNC 'w'
393 #ifdef HAVE_WORKING_FORK
394 #define OPT_VALUE_WAIT_SYNC (DESC(WAIT_SYNC).optArg.argInt)
395 #endif /* HAVE_WORKING_FORK */
396 #define VALUE_OPT_SLEW 'x'
397 #define VALUE_OPT_USEPCC 0x1004
398 #define VALUE_OPT_PCCFREQ 0x1005
399 #define VALUE_OPT_MDNS 'm'
400 /** option flag (value) for help-value option */
401 #define VALUE_OPT_HELP '?'
402 /** option flag (value) for more-help-value option */
403 #define VALUE_OPT_MORE_HELP '!'
404 /** option flag (value) for version-value option */
405 #define VALUE_OPT_VERSION 0x1006
406 /*
407 * Interface defines not associated with particular options
408 */
409 #define ERRSKIP_OPTERR STMTS(ntpdOptions.fOptSet &= ~OPTPROC_ERRSTOP)
410 #define ERRSTOP_OPTERR STMTS(ntpdOptions.fOptSet |= OPTPROC_ERRSTOP)
411 #define RESTART_OPT(n) STMTS( \
412 ntpdOptions.curOptIdx = (n); \
413 ntpdOptions.pzCurOpt = NULL )
414 #define START_OPT RESTART_OPT(1)
415 #define USAGE(c) (*ntpdOptions.pUsageProc)(&ntpdOptions, c)
416
417 #ifdef __cplusplus
418 extern "C" {
419 #endif
420
421
422 /* * * * * *
423 *
424 * Declare the ntpd option descriptor.
425 */
426 extern tOptions ntpdOptions;
427
428 #if defined(ENABLE_NLS)
429 # ifndef _
430 # include <stdio.h>
431 # ifndef HAVE_GETTEXT
432 extern char * gettext(char const *);
433 # else
434 # include <libintl.h>
435 # endif
436
437 # ifndef ATTRIBUTE_FORMAT_ARG
438 # define ATTRIBUTE_FORMAT_ARG(_a)
439 # endif
440
441 static inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1);
aoGetsText(char const * pz)442 static inline char* aoGetsText(char const* pz) {
443 if (pz == NULL) return NULL;
444 return (char*)gettext(pz);
445 }
446 # define _(s) aoGetsText(s)
447 # endif /* _() */
448
449 # define OPT_NO_XLAT_CFG_NAMES STMTS(ntpdOptions.fOptSet |= \
450 OPTPROC_NXLAT_OPT_CFG;)
451 # define OPT_NO_XLAT_OPT_NAMES STMTS(ntpdOptions.fOptSet |= \
452 OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
453
454 # define OPT_XLAT_CFG_NAMES STMTS(ntpdOptions.fOptSet &= \
455 ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
456 # define OPT_XLAT_OPT_NAMES STMTS(ntpdOptions.fOptSet &= \
457 ~OPTPROC_NXLAT_OPT;)
458
459 #else /* ENABLE_NLS */
460 # define OPT_NO_XLAT_CFG_NAMES
461 # define OPT_NO_XLAT_OPT_NAMES
462
463 # define OPT_XLAT_CFG_NAMES
464 # define OPT_XLAT_OPT_NAMES
465
466 # ifndef _
467 # define _(_s) _s
468 # endif
469 #endif /* ENABLE_NLS */
470
471
472 #ifdef __cplusplus
473 }
474 #endif
475 #endif /* AUTOOPTS_NTPD_OPTS_H_GUARD */
476
477 /* ntpd-opts.h ends here */
478