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