xref: /netbsd-src/external/bsd/ntp/dist/ntpdc/ntpdc-opts.h (revision 567219e1d7461bff1b180e494a9674a287b057a7)
1 /*	$NetBSD: ntpdc-opts.h,v 1.1.1.2 2012/01/31 21:27:04 kardel Exp $	*/
2 
3 /*
4  *  EDIT THIS FILE WITH CAUTION  (ntpdc-opts.h)
5  *
6  *  It has been AutoGen-ed  December 24, 2011 at 06:34:16 PM by AutoGen 5.12
7  *  From the definitions    ntpdc-opts.def
8  *  and the template file   options
9  *
10  * Generated from AutoOpts 35:0:10 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 ntpdc 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  * This source file is copyrighted and licensed under the following terms:
21  *
22  *  see html/copyright.html
23  *
24  */
25 /*
26  *  This file contains the programmatic interface to the Automated
27  *  Options generated for the ntpdc program.
28  *  These macros are documented in the AutoGen info file in the
29  *  "AutoOpts" chapter.  Please refer to that doc for usage help.
30  */
31 #ifndef AUTOOPTS_NTPDC_OPTS_H_GUARD
32 #define AUTOOPTS_NTPDC_OPTS_H_GUARD 1
33 #include "config.h"
34 #include <autoopts/options.h>
35 
36 /*
37  *  Ensure that the library used for compiling this generated header is at
38  *  least as new as the version current when the header template was released
39  *  (not counting patch version increments).  Also ensure that the oldest
40  *  tolerable version is at least as old as what was current when the header
41  *  template was released.
42  */
43 #define AO_TEMPLATE_VERSION 143360
44 #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
45  || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
46 # error option template version mismatches autoopts/options.h header
47   Choke Me.
48 #endif
49 
50 /*
51  *  Enumeration of each option:
52  */
53 typedef enum {
54     INDEX_OPT_IPV4             =  0,
55     INDEX_OPT_IPV6             =  1,
56     INDEX_OPT_COMMAND          =  2,
57     INDEX_OPT_LISTPEERS        =  3,
58     INDEX_OPT_PEERS            =  4,
59     INDEX_OPT_SHOWPEERS        =  5,
60     INDEX_OPT_INTERACTIVE      =  6,
61     INDEX_OPT_DEBUG_LEVEL      =  7,
62     INDEX_OPT_SET_DEBUG_LEVEL  =  8,
63     INDEX_OPT_NUMERIC          =  9,
64     INDEX_OPT_VERSION          = 10,
65     INDEX_OPT_HELP             = 11,
66     INDEX_OPT_MORE_HELP        = 12,
67     INDEX_OPT_SAVE_OPTS        = 13,
68     INDEX_OPT_LOAD_OPTS        = 14
69 } teOptIndex;
70 
71 #define OPTION_CT    15
72 #define NTPDC_VERSION       "4.2.6p5"
73 #define NTPDC_FULL_VERSION  "ntpdc 4.2.6p5"
74 
75 /*
76  *  Interface defines for all options.  Replace "n" with the UPPER_CASED
77  *  option name (as in the teOptIndex enumeration above).
78  *  e.g. HAVE_OPT(IPV4)
79  */
80 #define         DESC(n) (ntpdcOptions.pOptDesc[INDEX_OPT_## n])
81 #define     HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
82 #define      OPT_ARG(n) (DESC(n).optArg.argString)
83 #define    STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
84 #define    COUNT_OPT(n) (DESC(n).optOccCt)
85 #define    ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
86 #define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
87 #define  ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
88 #define  STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
89 #define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
90 #define    CLEAR_OPT(n) STMTS( \
91                 DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
92                 if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \
93                     DESC(n).fOptState |= OPTST_DISABLED; \
94                 DESC(n).optCookie = NULL )
95 
96 /* * * * * *
97  *
98  *  Enumeration of ntpdc exit codes
99  */
100 typedef enum {
101     NTPDC_EXIT_SUCCESS = 0,
102     NTPDC_EXIT_FAILURE = 1
103 } ntpdc_exit_code_t;
104 /*
105  *  Make sure there are no #define name conflicts with the option names
106  */
107 #ifndef     NO_OPTION_NAME_WARNINGS
108 # ifdef    IPV4
109 #  warning undefining IPV4 due to option name conflict
110 #  undef   IPV4
111 # endif
112 # ifdef    IPV6
113 #  warning undefining IPV6 due to option name conflict
114 #  undef   IPV6
115 # endif
116 # ifdef    COMMAND
117 #  warning undefining COMMAND due to option name conflict
118 #  undef   COMMAND
119 # endif
120 # ifdef    LISTPEERS
121 #  warning undefining LISTPEERS due to option name conflict
122 #  undef   LISTPEERS
123 # endif
124 # ifdef    PEERS
125 #  warning undefining PEERS due to option name conflict
126 #  undef   PEERS
127 # endif
128 # ifdef    SHOWPEERS
129 #  warning undefining SHOWPEERS due to option name conflict
130 #  undef   SHOWPEERS
131 # endif
132 # ifdef    INTERACTIVE
133 #  warning undefining INTERACTIVE due to option name conflict
134 #  undef   INTERACTIVE
135 # endif
136 # ifdef    DEBUG_LEVEL
137 #  warning undefining DEBUG_LEVEL due to option name conflict
138 #  undef   DEBUG_LEVEL
139 # endif
140 # ifdef    SET_DEBUG_LEVEL
141 #  warning undefining SET_DEBUG_LEVEL due to option name conflict
142 #  undef   SET_DEBUG_LEVEL
143 # endif
144 # ifdef    NUMERIC
145 #  warning undefining NUMERIC due to option name conflict
146 #  undef   NUMERIC
147 # endif
148 #else  /* NO_OPTION_NAME_WARNINGS */
149 # undef IPV4
150 # undef IPV6
151 # undef COMMAND
152 # undef LISTPEERS
153 # undef PEERS
154 # undef SHOWPEERS
155 # undef INTERACTIVE
156 # undef DEBUG_LEVEL
157 # undef SET_DEBUG_LEVEL
158 # undef NUMERIC
159 #endif  /*  NO_OPTION_NAME_WARNINGS */
160 
161 /* * * * * *
162  *
163  *  Interface defines for specific options.
164  */
165 #define VALUE_OPT_IPV4           '4'
166 #define VALUE_OPT_IPV6           '6'
167 #define VALUE_OPT_COMMAND        'c'
168 #define VALUE_OPT_LISTPEERS      'l'
169 #define VALUE_OPT_PEERS          'p'
170 #define VALUE_OPT_SHOWPEERS      's'
171 #define VALUE_OPT_INTERACTIVE    'i'
172 #define VALUE_OPT_DEBUG_LEVEL    'd'
173 #define VALUE_OPT_SET_DEBUG_LEVEL 'D'
174 #define VALUE_OPT_NUMERIC        'n'
175 #define VALUE_OPT_HELP          '?'
176 #define VALUE_OPT_MORE_HELP     '!'
177 #define VALUE_OPT_VERSION       INDEX_OPT_VERSION
178 #define VALUE_OPT_SAVE_OPTS     '>'
179 #define VALUE_OPT_LOAD_OPTS     '<'
180 #define SET_OPT_SAVE_OPTS(a)   STMTS( \
181         DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
182         DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
183         DESC(SAVE_OPTS).optArg.argString = (char const*)(a) )
184 /*
185  *  Interface defines not associated with particular options
186  */
187 #define ERRSKIP_OPTERR  STMTS(ntpdcOptions.fOptSet &= ~OPTPROC_ERRSTOP)
188 #define ERRSTOP_OPTERR  STMTS(ntpdcOptions.fOptSet |= OPTPROC_ERRSTOP)
189 #define RESTART_OPT(n)  STMTS( \
190                 ntpdcOptions.curOptIdx = (n); \
191                 ntpdcOptions.pzCurOpt  = NULL)
192 #define START_OPT       RESTART_OPT(1)
193 #define USAGE(c)        (*ntpdcOptions.pUsageProc)(&ntpdcOptions, c)
194 /* extracted from opthead.tlib near line 451 */
195 
196 #ifdef  __cplusplus
197 extern "C" {
198 #endif
199 
200 /* * * * * *
201  *
202  *  Declare the ntpdc option descriptor.
203  */
204 extern tOptions ntpdcOptions;
205 
206 #if defined(ENABLE_NLS)
207 # ifndef _
208 #   include <stdio.h>
209 static inline char* aoGetsText(char const* pz) {
210     if (pz == NULL) return NULL;
211     return (char*)gettext(pz);
212 }
213 #   define _(s)  aoGetsText(s)
214 # endif /* _() */
215 
216 # define OPT_NO_XLAT_CFG_NAMES  STMTS(ntpdcOptions.fOptSet |= \
217                                     OPTPROC_NXLAT_OPT_CFG;)
218 # define OPT_NO_XLAT_OPT_NAMES  STMTS(ntpdcOptions.fOptSet |= \
219                                     OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
220 
221 # define OPT_XLAT_CFG_NAMES     STMTS(ntpdcOptions.fOptSet &= \
222                                   ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
223 # define OPT_XLAT_OPT_NAMES     STMTS(ntpdcOptions.fOptSet &= \
224                                   ~OPTPROC_NXLAT_OPT;)
225 
226 #else   /* ENABLE_NLS */
227 # define OPT_NO_XLAT_CFG_NAMES
228 # define OPT_NO_XLAT_OPT_NAMES
229 
230 # define OPT_XLAT_CFG_NAMES
231 # define OPT_XLAT_OPT_NAMES
232 
233 # ifndef _
234 #   define _(_s)  _s
235 # endif
236 #endif  /* ENABLE_NLS */
237 
238 #ifdef  __cplusplus
239 }
240 #endif
241 #endif /* AUTOOPTS_NTPDC_OPTS_H_GUARD */
242 /* ntpdc-opts.h ends here */
243