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