xref: /freebsd/contrib/ntp/ntpdc/ntpdc-opts.h (revision 2b15cb3d0922bd70ea592f0da9b4a5b167f4d53f)
1ea906c41SOllivier Robert /*
2ea906c41SOllivier Robert  *  EDIT THIS FILE WITH CAUTION  (ntpdc-opts.h)
3ea906c41SOllivier Robert  *
4*2b15cb3dSCy Schubert  *  It has been AutoGen-ed  February  4, 2015 at 02:42:23 AM by AutoGen 5.18.5pre4
5ea906c41SOllivier Robert  *  From the definitions    ntpdc-opts.def
6ea906c41SOllivier Robert  *  and the template file   options
7ea906c41SOllivier Robert  *
8*2b15cb3dSCy Schubert  * Generated from AutoOpts 41:0:16 templates.
9*2b15cb3dSCy Schubert  *
10*2b15cb3dSCy Schubert  *  AutoOpts is a copyrighted work.  This header file is not encumbered
11*2b15cb3dSCy Schubert  *  by AutoOpts licensing, but is provided under the licensing terms chosen
12*2b15cb3dSCy Schubert  *  by the ntpdc author or copyright holder.  AutoOpts is
13*2b15cb3dSCy Schubert  *  licensed under the terms of the LGPL.  The redistributable library
14*2b15cb3dSCy Schubert  *  (``libopts'') is licensed under the terms of either the LGPL or, at the
15*2b15cb3dSCy Schubert  *  users discretion, the BSD license.  See the AutoOpts and/or libopts sources
16*2b15cb3dSCy Schubert  *  for details.
17*2b15cb3dSCy Schubert  *
18*2b15cb3dSCy Schubert  * The ntpdc program is copyrighted and licensed
19*2b15cb3dSCy Schubert  * under the following terms:
20*2b15cb3dSCy Schubert  *
21*2b15cb3dSCy Schubert  *  Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.
22*2b15cb3dSCy Schubert  *  This is free software. It is licensed for use, modification and
23*2b15cb3dSCy Schubert  *  redistribution under the terms of the NTP License, copies of which
24*2b15cb3dSCy Schubert  *  can be seen at:
25*2b15cb3dSCy Schubert  *    <http://ntp.org/license>
26*2b15cb3dSCy Schubert  *    <http://opensource.org/licenses/ntp-license.php>
27*2b15cb3dSCy Schubert  *
28*2b15cb3dSCy Schubert  *  Permission to use, copy, modify, and distribute this software and its
29*2b15cb3dSCy Schubert  *  documentation for any purpose with or without fee is hereby granted,
30*2b15cb3dSCy Schubert  *  provided that the above copyright notice appears in all copies and that
31*2b15cb3dSCy Schubert  *  both the copyright notice and this permission notice appear in
32*2b15cb3dSCy Schubert  *  supporting documentation, and that the name The University of Delaware not be used in
33*2b15cb3dSCy Schubert  *  advertising or publicity pertaining to distribution of the software
34*2b15cb3dSCy Schubert  *  without specific, written prior permission. The University of Delaware and Network Time Foundation makes no
35*2b15cb3dSCy Schubert  *  representations about the suitability this software for any purpose. It
36*2b15cb3dSCy Schubert  *  is provided "as is" without express or implied warranty.
37ea906c41SOllivier Robert  */
38*2b15cb3dSCy Schubert /**
39ea906c41SOllivier Robert  *  This file contains the programmatic interface to the Automated
40ea906c41SOllivier Robert  *  Options generated for the ntpdc program.
41ea906c41SOllivier Robert  *  These macros are documented in the AutoGen info file in the
42ea906c41SOllivier Robert  *  "AutoOpts" chapter.  Please refer to that doc for usage help.
43ea906c41SOllivier Robert  */
44ea906c41SOllivier Robert #ifndef AUTOOPTS_NTPDC_OPTS_H_GUARD
45*2b15cb3dSCy Schubert #define AUTOOPTS_NTPDC_OPTS_H_GUARD 1
46ea906c41SOllivier Robert #include "config.h"
47ea906c41SOllivier Robert #include <autoopts/options.h>
48ea906c41SOllivier Robert 
49*2b15cb3dSCy Schubert /**
50ea906c41SOllivier Robert  *  Ensure that the library used for compiling this generated header is at
51ea906c41SOllivier Robert  *  least as new as the version current when the header template was released
52ea906c41SOllivier Robert  *  (not counting patch version increments).  Also ensure that the oldest
53ea906c41SOllivier Robert  *  tolerable version is at least as old as what was current when the header
54ea906c41SOllivier Robert  *  template was released.
55ea906c41SOllivier Robert  */
56*2b15cb3dSCy Schubert #define AO_TEMPLATE_VERSION 167936
57ea906c41SOllivier Robert #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
58ea906c41SOllivier Robert  || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
59ea906c41SOllivier Robert # error option template version mismatches autoopts/options.h header
60ea906c41SOllivier Robert   Choke Me.
61ea906c41SOllivier Robert #endif
62ea906c41SOllivier Robert 
63*2b15cb3dSCy Schubert /**
64*2b15cb3dSCy Schubert  *  Enumeration of each option type for ntpdc
65ea906c41SOllivier Robert  */
66ea906c41SOllivier Robert typedef enum {
67ea906c41SOllivier Robert     INDEX_OPT_IPV4             =  0,
68ea906c41SOllivier Robert     INDEX_OPT_IPV6             =  1,
69ea906c41SOllivier Robert     INDEX_OPT_COMMAND          =  2,
70*2b15cb3dSCy Schubert     INDEX_OPT_DEBUG_LEVEL      =  3,
71*2b15cb3dSCy Schubert     INDEX_OPT_SET_DEBUG_LEVEL  =  4,
72*2b15cb3dSCy Schubert     INDEX_OPT_INTERACTIVE      =  5,
73*2b15cb3dSCy Schubert     INDEX_OPT_LISTPEERS        =  6,
74*2b15cb3dSCy Schubert     INDEX_OPT_NUMERIC          =  7,
75*2b15cb3dSCy Schubert     INDEX_OPT_PEERS            =  8,
76*2b15cb3dSCy Schubert     INDEX_OPT_SHOWPEERS        =  9,
77ea906c41SOllivier Robert     INDEX_OPT_VERSION          = 10,
78ea906c41SOllivier Robert     INDEX_OPT_HELP             = 11,
79ea906c41SOllivier Robert     INDEX_OPT_MORE_HELP        = 12,
80ea906c41SOllivier Robert     INDEX_OPT_SAVE_OPTS        = 13,
81ea906c41SOllivier Robert     INDEX_OPT_LOAD_OPTS        = 14
82ea906c41SOllivier Robert } teOptIndex;
83*2b15cb3dSCy Schubert /** count of all options for ntpdc */
84ea906c41SOllivier Robert #define OPTION_CT    15
85*2b15cb3dSCy Schubert /** ntpdc version */
86*2b15cb3dSCy Schubert #define NTPDC_VERSION       "4.2.8p1"
87*2b15cb3dSCy Schubert /** Full ntpdc version text */
88*2b15cb3dSCy Schubert #define NTPDC_FULL_VERSION  "ntpdc 4.2.8p1"
89ea906c41SOllivier Robert 
90*2b15cb3dSCy Schubert /**
91ea906c41SOllivier Robert  *  Interface defines for all options.  Replace "n" with the UPPER_CASED
92ea906c41SOllivier Robert  *  option name (as in the teOptIndex enumeration above).
93ea906c41SOllivier Robert  *  e.g. HAVE_OPT(IPV4)
94ea906c41SOllivier Robert  */
95ea906c41SOllivier Robert #define         DESC(n) (ntpdcOptions.pOptDesc[INDEX_OPT_## n])
96*2b15cb3dSCy Schubert /** 'true' if an option has been specified in any way */
97ea906c41SOllivier Robert #define     HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
98*2b15cb3dSCy Schubert /** The string argument to an option. The argument type must be \"string\". */
99ea906c41SOllivier Robert #define      OPT_ARG(n) (DESC(n).optArg.argString)
100*2b15cb3dSCy Schubert /** Mask the option state revealing how an option was specified.
101*2b15cb3dSCy Schubert  *  It will be one and only one of \a OPTST_SET, \a OPTST_PRESET,
102*2b15cb3dSCy Schubert  * \a OPTST_DEFINED, \a OPTST_RESET or zero.
103*2b15cb3dSCy Schubert  */
104ea906c41SOllivier Robert #define    STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
105*2b15cb3dSCy Schubert /** Count of option's occurrances *on the command line*. */
106ea906c41SOllivier Robert #define    COUNT_OPT(n) (DESC(n).optOccCt)
107*2b15cb3dSCy Schubert /** mask of \a OPTST_SET and \a OPTST_DEFINED. */
108ea906c41SOllivier Robert #define    ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
109*2b15cb3dSCy Schubert /** 'true' if \a HAVE_OPT would yield 'false'. */
110ea906c41SOllivier Robert #define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
111*2b15cb3dSCy Schubert /** 'true' if OPTST_DISABLED bit not set. */
112ea906c41SOllivier Robert #define  ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
113*2b15cb3dSCy Schubert /** number of stacked option arguments.
114*2b15cb3dSCy Schubert  *  Valid only for stacked option arguments. */
115ea906c41SOllivier Robert #define  STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
116*2b15cb3dSCy Schubert /** stacked argument vector.
117*2b15cb3dSCy Schubert  *  Valid only for stacked option arguments. */
118ea906c41SOllivier Robert #define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
119*2b15cb3dSCy Schubert /** Reset an option. */
120ea906c41SOllivier Robert #define    CLEAR_OPT(n) STMTS( \
121ea906c41SOllivier Robert                 DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
122ea906c41SOllivier Robert                 if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \
123ea906c41SOllivier Robert                     DESC(n).fOptState |= OPTST_DISABLED; \
124ea906c41SOllivier Robert                 DESC(n).optCookie = NULL )
125*2b15cb3dSCy Schubert /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
126*2b15cb3dSCy Schubert /**
127*2b15cb3dSCy Schubert  *  Enumeration of ntpdc exit codes
128*2b15cb3dSCy Schubert  */
129*2b15cb3dSCy Schubert typedef enum {
130*2b15cb3dSCy Schubert     NTPDC_EXIT_SUCCESS         = 0,
131*2b15cb3dSCy Schubert     NTPDC_EXIT_FAILURE         = 1,
132*2b15cb3dSCy Schubert     NTPDC_EXIT_USAGE_ERROR     = 64,
133*2b15cb3dSCy Schubert     NTPDC_EXIT_NO_CONFIG_INPUT = 66,
134*2b15cb3dSCy Schubert     NTPDC_EXIT_LIBOPTS_FAILURE = 70
135*2b15cb3dSCy Schubert }   ntpdc_exit_code_t;
136*2b15cb3dSCy Schubert /** @} */
137*2b15cb3dSCy Schubert /**
138ea906c41SOllivier Robert  *  Make sure there are no #define name conflicts with the option names
139ea906c41SOllivier Robert  */
140ea906c41SOllivier Robert #ifndef     NO_OPTION_NAME_WARNINGS
141ea906c41SOllivier Robert # ifdef    IPV4
142ea906c41SOllivier Robert #  warning undefining IPV4 due to option name conflict
143ea906c41SOllivier Robert #  undef   IPV4
144ea906c41SOllivier Robert # endif
145ea906c41SOllivier Robert # ifdef    IPV6
146ea906c41SOllivier Robert #  warning undefining IPV6 due to option name conflict
147ea906c41SOllivier Robert #  undef   IPV6
148ea906c41SOllivier Robert # endif
149ea906c41SOllivier Robert # ifdef    COMMAND
150ea906c41SOllivier Robert #  warning undefining COMMAND due to option name conflict
151ea906c41SOllivier Robert #  undef   COMMAND
152ea906c41SOllivier Robert # endif
153*2b15cb3dSCy Schubert # ifdef    DEBUG_LEVEL
154*2b15cb3dSCy Schubert #  warning undefining DEBUG_LEVEL due to option name conflict
155*2b15cb3dSCy Schubert #  undef   DEBUG_LEVEL
156*2b15cb3dSCy Schubert # endif
157*2b15cb3dSCy Schubert # ifdef    SET_DEBUG_LEVEL
158*2b15cb3dSCy Schubert #  warning undefining SET_DEBUG_LEVEL due to option name conflict
159*2b15cb3dSCy Schubert #  undef   SET_DEBUG_LEVEL
160*2b15cb3dSCy Schubert # endif
161*2b15cb3dSCy Schubert # ifdef    INTERACTIVE
162*2b15cb3dSCy Schubert #  warning undefining INTERACTIVE due to option name conflict
163*2b15cb3dSCy Schubert #  undef   INTERACTIVE
164*2b15cb3dSCy Schubert # endif
165ea906c41SOllivier Robert # ifdef    LISTPEERS
166ea906c41SOllivier Robert #  warning undefining LISTPEERS due to option name conflict
167ea906c41SOllivier Robert #  undef   LISTPEERS
168ea906c41SOllivier Robert # endif
169*2b15cb3dSCy Schubert # ifdef    NUMERIC
170*2b15cb3dSCy Schubert #  warning undefining NUMERIC due to option name conflict
171*2b15cb3dSCy Schubert #  undef   NUMERIC
172*2b15cb3dSCy Schubert # endif
173ea906c41SOllivier Robert # ifdef    PEERS
174ea906c41SOllivier Robert #  warning undefining PEERS due to option name conflict
175ea906c41SOllivier Robert #  undef   PEERS
176ea906c41SOllivier Robert # endif
177ea906c41SOllivier Robert # ifdef    SHOWPEERS
178ea906c41SOllivier Robert #  warning undefining SHOWPEERS due to option name conflict
179ea906c41SOllivier Robert #  undef   SHOWPEERS
180ea906c41SOllivier Robert # endif
181ea906c41SOllivier Robert #else  /* NO_OPTION_NAME_WARNINGS */
182ea906c41SOllivier Robert # undef IPV4
183ea906c41SOllivier Robert # undef IPV6
184ea906c41SOllivier Robert # undef COMMAND
185ea906c41SOllivier Robert # undef DEBUG_LEVEL
186ea906c41SOllivier Robert # undef SET_DEBUG_LEVEL
187*2b15cb3dSCy Schubert # undef INTERACTIVE
188*2b15cb3dSCy Schubert # undef LISTPEERS
189ea906c41SOllivier Robert # undef NUMERIC
190*2b15cb3dSCy Schubert # undef PEERS
191*2b15cb3dSCy Schubert # undef SHOWPEERS
192ea906c41SOllivier Robert #endif  /*  NO_OPTION_NAME_WARNINGS */
193ea906c41SOllivier Robert 
194*2b15cb3dSCy Schubert /**
195ea906c41SOllivier Robert  *  Interface defines for specific options.
196*2b15cb3dSCy Schubert  * @{
197ea906c41SOllivier Robert  */
198ea906c41SOllivier Robert #define VALUE_OPT_IPV4           '4'
199ea906c41SOllivier Robert #define VALUE_OPT_IPV6           '6'
200ea906c41SOllivier Robert #define VALUE_OPT_COMMAND        'c'
201*2b15cb3dSCy Schubert #define VALUE_OPT_DEBUG_LEVEL    'd'
202*2b15cb3dSCy Schubert #define VALUE_OPT_SET_DEBUG_LEVEL 'D'
203*2b15cb3dSCy Schubert 
204*2b15cb3dSCy Schubert #define OPT_VALUE_SET_DEBUG_LEVEL (DESC(SET_DEBUG_LEVEL).optArg.argInt)
205*2b15cb3dSCy Schubert #define VALUE_OPT_INTERACTIVE    'i'
206ea906c41SOllivier Robert #define VALUE_OPT_LISTPEERS      'l'
207*2b15cb3dSCy Schubert #define VALUE_OPT_NUMERIC        'n'
208ea906c41SOllivier Robert #define VALUE_OPT_PEERS          'p'
209ea906c41SOllivier Robert #define VALUE_OPT_SHOWPEERS      's'
210*2b15cb3dSCy Schubert /** option flag (value) for help-value option */
211ea906c41SOllivier Robert #define VALUE_OPT_HELP          '?'
212*2b15cb3dSCy Schubert /** option flag (value) for more-help-value option */
213ea906c41SOllivier Robert #define VALUE_OPT_MORE_HELP     '!'
214*2b15cb3dSCy Schubert /** option flag (value) for version-value option */
215*2b15cb3dSCy Schubert #define VALUE_OPT_VERSION       0x1001
216*2b15cb3dSCy Schubert /** option flag (value) for save-opts-value option */
217ea906c41SOllivier Robert #define VALUE_OPT_SAVE_OPTS     '>'
218*2b15cb3dSCy Schubert /** option flag (value) for load-opts-value option */
219ea906c41SOllivier Robert #define VALUE_OPT_LOAD_OPTS     '<'
220ea906c41SOllivier Robert #define SET_OPT_SAVE_OPTS(a)   STMTS( \
221ea906c41SOllivier Robert         DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
222ea906c41SOllivier Robert         DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
223ea906c41SOllivier Robert         DESC(SAVE_OPTS).optArg.argString = (char const*)(a))
224ea906c41SOllivier Robert /*
225ea906c41SOllivier Robert  *  Interface defines not associated with particular options
226ea906c41SOllivier Robert  */
227ea906c41SOllivier Robert #define ERRSKIP_OPTERR  STMTS(ntpdcOptions.fOptSet &= ~OPTPROC_ERRSTOP)
228ea906c41SOllivier Robert #define ERRSTOP_OPTERR  STMTS(ntpdcOptions.fOptSet |= OPTPROC_ERRSTOP)
229ea906c41SOllivier Robert #define RESTART_OPT(n)  STMTS( \
230ea906c41SOllivier Robert                 ntpdcOptions.curOptIdx = (n); \
231ea906c41SOllivier Robert                 ntpdcOptions.pzCurOpt  = NULL )
232ea906c41SOllivier Robert #define START_OPT       RESTART_OPT(1)
233ea906c41SOllivier Robert #define USAGE(c)        (*ntpdcOptions.pUsageProc)(&ntpdcOptions, c)
234*2b15cb3dSCy Schubert 
235*2b15cb3dSCy Schubert #ifdef  __cplusplus
236*2b15cb3dSCy Schubert extern "C" {
237*2b15cb3dSCy Schubert #endif
238*2b15cb3dSCy Schubert 
239ea906c41SOllivier Robert 
240ea906c41SOllivier Robert /* * * * * *
241ea906c41SOllivier Robert  *
242ea906c41SOllivier Robert  *  Declare the ntpdc option descriptor.
243ea906c41SOllivier Robert  */
244ea906c41SOllivier Robert extern tOptions ntpdcOptions;
245ea906c41SOllivier Robert 
246*2b15cb3dSCy Schubert #if defined(ENABLE_NLS)
247ea906c41SOllivier Robert # ifndef _
248ea906c41SOllivier Robert #   include <stdio.h>
249*2b15cb3dSCy Schubert #   ifndef HAVE_GETTEXT
250*2b15cb3dSCy Schubert       extern char * gettext(char const *);
251*2b15cb3dSCy Schubert #   else
252*2b15cb3dSCy Schubert #     include <libintl.h>
253*2b15cb3dSCy Schubert #   endif
254*2b15cb3dSCy Schubert 
255*2b15cb3dSCy Schubert # ifndef ATTRIBUTE_FORMAT_ARG
256*2b15cb3dSCy Schubert #   define ATTRIBUTE_FORMAT_ARG(_a)
257*2b15cb3dSCy Schubert # endif
258*2b15cb3dSCy Schubert 
259*2b15cb3dSCy Schubert static inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1);
260ea906c41SOllivier Robert static inline char* aoGetsText(char const* pz) {
261ea906c41SOllivier Robert     if (pz == NULL) return NULL;
262ea906c41SOllivier Robert     return (char*)gettext(pz);
263ea906c41SOllivier Robert }
264ea906c41SOllivier Robert #   define _(s)  aoGetsText(s)
265*2b15cb3dSCy Schubert # endif /* _() */
266*2b15cb3dSCy Schubert 
267*2b15cb3dSCy Schubert # define OPT_NO_XLAT_CFG_NAMES  STMTS(ntpdcOptions.fOptSet |= \
268*2b15cb3dSCy Schubert                                     OPTPROC_NXLAT_OPT_CFG;)
269*2b15cb3dSCy Schubert # define OPT_NO_XLAT_OPT_NAMES  STMTS(ntpdcOptions.fOptSet |= \
270*2b15cb3dSCy Schubert                                     OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
271*2b15cb3dSCy Schubert 
272*2b15cb3dSCy Schubert # define OPT_XLAT_CFG_NAMES     STMTS(ntpdcOptions.fOptSet &= \
273*2b15cb3dSCy Schubert                                   ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
274*2b15cb3dSCy Schubert # define OPT_XLAT_OPT_NAMES     STMTS(ntpdcOptions.fOptSet &= \
275*2b15cb3dSCy Schubert                                   ~OPTPROC_NXLAT_OPT;)
276*2b15cb3dSCy Schubert 
277ea906c41SOllivier Robert #else   /* ENABLE_NLS */
278*2b15cb3dSCy Schubert # define OPT_NO_XLAT_CFG_NAMES
279*2b15cb3dSCy Schubert # define OPT_NO_XLAT_OPT_NAMES
280*2b15cb3dSCy Schubert 
281*2b15cb3dSCy Schubert # define OPT_XLAT_CFG_NAMES
282*2b15cb3dSCy Schubert # define OPT_XLAT_OPT_NAMES
283*2b15cb3dSCy Schubert 
284*2b15cb3dSCy Schubert # ifndef _
285*2b15cb3dSCy Schubert #   define _(_s)  _s
286ea906c41SOllivier Robert # endif
287*2b15cb3dSCy Schubert #endif  /* ENABLE_NLS */
288ea906c41SOllivier Robert 
289ea906c41SOllivier Robert #ifdef  __cplusplus
290ea906c41SOllivier Robert }
291ea906c41SOllivier Robert #endif
292ea906c41SOllivier Robert #endif /* AUTOOPTS_NTPDC_OPTS_H_GUARD */
293*2b15cb3dSCy Schubert 
294ea906c41SOllivier Robert /* ntpdc-opts.h ends here */
295