ntpq-opts.h revision 1.1.1.3 1 /* $NetBSD: ntpq-opts.h,v 1.1.1.3 2013/12/27 23:31:06 christos Exp $ */
2
3 /*
4 * EDIT THIS FILE WITH CAUTION (ntpq-opts.h)
5 *
6 * It has been AutoGen-ed December 24, 2013 at 11:38:50 AM by AutoGen 5.18.3pre5
7 * From the definitions ntpq-opts.def
8 * and the template file options
9 *
10 * Generated from AutoOpts 40:1:15 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 ntpq 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 ntpq program is copyrighted and licensed
21 * under the following terms:
22 *
23 * Copyright (C) 1970-2013 The University of Delaware, 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 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 ntpq 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_NTPQ_OPTS_H_GUARD
47 #define AUTOOPTS_NTPQ_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 163841
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 ntpq
67 */
68 typedef enum {
69 INDEX_OPT_IPV4 = 0,
70 INDEX_OPT_IPV6 = 1,
71 INDEX_OPT_COMMAND = 2,
72 INDEX_OPT_DEBUG_LEVEL = 3,
73 INDEX_OPT_SET_DEBUG_LEVEL = 4,
74 INDEX_OPT_PEERS = 5,
75 INDEX_OPT_INTERACTIVE = 6,
76 INDEX_OPT_NUMERIC = 7,
77 INDEX_OPT_OLD_RV = 8,
78 INDEX_OPT_VERSION = 9,
79 INDEX_OPT_HELP = 10,
80 INDEX_OPT_MORE_HELP = 11,
81 INDEX_OPT_SAVE_OPTS = 12,
82 INDEX_OPT_LOAD_OPTS = 13
83 } teOptIndex;
84 /** count of all options for ntpq */
85 #define OPTION_CT 14
86 /** ntpq version */
87 #define NTPQ_VERSION "4.2.7p404"
88 /** Full ntpq version text */
89 #define NTPQ_FULL_VERSION "ntpq 4.2.7p404"
90
91 /**
92 * Interface defines for all options. Replace "n" with the UPPER_CASED
93 * option name (as in the teOptIndex enumeration above).
94 * e.g. HAVE_OPT(IPV4)
95 */
96 #define DESC(n) (ntpqOptions.pOptDesc[INDEX_OPT_## n])
97 /** 'true' if an option has been specified in any way */
98 #define HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
99 /** The string argument to an option. The argument type must be \"string\". */
100 #define OPT_ARG(n) (DESC(n).optArg.argString)
101 /** Mask the option state revealing how an option was specified.
102 * It will be one and only one of \a OPTST_SET, \a OPTST_PRESET,
103 * \a OPTST_DEFINED, \a OPTST_RESET or zero.
104 */
105 #define STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
106 /** Count of option's occurrances *on the command line*. */
107 #define COUNT_OPT(n) (DESC(n).optOccCt)
108 /** mask of \a OPTST_SET and \a OPTST_DEFINED. */
109 #define ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
110 /** 'true' if \a HAVE_OPT would yield 'false'. */
111 #define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
112 /** 'true' if OPTST_DISABLED bit not set. */
113 #define ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
114 /** number of stacked option arguments.
115 * Valid only for stacked option arguments. */
116 #define STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
117 /** stacked argument vector.
118 * Valid only for stacked option arguments. */
119 #define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
120 /** Reset an option. */
121 #define CLEAR_OPT(n) STMTS( \
122 DESC(n).fOptState &= OPTST_PERSISTENT_MASK; \
123 if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \
124 DESC(n).fOptState |= OPTST_DISABLED; \
125 DESC(n).optCookie = NULL )
126 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
127 /**
128 * Enumeration of ntpq exit codes
129 */
130 typedef enum {
131 NTPQ_EXIT_SUCCESS = 0,
132 NTPQ_EXIT_FAILURE = 1,
133 NTPQ_EXIT_USAGE_ERROR = 64,
134 NTPQ_EXIT_NO_CONFIG_INPUT = 66,
135 NTPQ_EXIT_LIBOPTS_FAILURE = 70
136 } ntpq_exit_code_t;
137 /** @} */
138 /**
139 * Make sure there are no #define name conflicts with the option names
140 */
141 #ifndef NO_OPTION_NAME_WARNINGS
142 # ifdef IPV4
143 # warning undefining IPV4 due to option name conflict
144 # undef IPV4
145 # endif
146 # ifdef IPV6
147 # warning undefining IPV6 due to option name conflict
148 # undef IPV6
149 # endif
150 # ifdef COMMAND
151 # warning undefining COMMAND due to option name conflict
152 # undef COMMAND
153 # endif
154 # ifdef DEBUG_LEVEL
155 # warning undefining DEBUG_LEVEL due to option name conflict
156 # undef DEBUG_LEVEL
157 # endif
158 # ifdef SET_DEBUG_LEVEL
159 # warning undefining SET_DEBUG_LEVEL due to option name conflict
160 # undef SET_DEBUG_LEVEL
161 # endif
162 # ifdef PEERS
163 # warning undefining PEERS due to option name conflict
164 # undef PEERS
165 # endif
166 # ifdef INTERACTIVE
167 # warning undefining INTERACTIVE due to option name conflict
168 # undef INTERACTIVE
169 # endif
170 # ifdef NUMERIC
171 # warning undefining NUMERIC due to option name conflict
172 # undef NUMERIC
173 # endif
174 # ifdef OLD_RV
175 # warning undefining OLD_RV due to option name conflict
176 # undef OLD_RV
177 # endif
178 #else /* NO_OPTION_NAME_WARNINGS */
179 # undef IPV4
180 # undef IPV6
181 # undef COMMAND
182 # undef DEBUG_LEVEL
183 # undef SET_DEBUG_LEVEL
184 # undef PEERS
185 # undef INTERACTIVE
186 # undef NUMERIC
187 # undef OLD_RV
188 #endif /* NO_OPTION_NAME_WARNINGS */
189
190 /**
191 * Interface defines for specific options.
192 * @{
193 */
194 #define VALUE_OPT_IPV4 '4'
195 #define VALUE_OPT_IPV6 '6'
196 #define VALUE_OPT_COMMAND 'c'
197 #define VALUE_OPT_DEBUG_LEVEL 'd'
198 #define VALUE_OPT_SET_DEBUG_LEVEL 'D'
199
200 #define OPT_VALUE_SET_DEBUG_LEVEL (DESC(SET_DEBUG_LEVEL).optArg.argInt)
201 #define VALUE_OPT_PEERS 'p'
202 #define VALUE_OPT_INTERACTIVE 'i'
203 #define VALUE_OPT_NUMERIC 'n'
204 #define VALUE_OPT_OLD_RV 0x1001
205 /** option flag (value) for " (get "val-name") " option */
206 #define VALUE_OPT_HELP '?'
207 /** option flag (value) for " (get "val-name") " option */
208 #define VALUE_OPT_MORE_HELP '!'
209 /** option flag (value) for " (get "val-name") " option */
210 #define VALUE_OPT_VERSION 0x1002
211 /** option flag (value) for " (get "val-name") " option */
212 #define VALUE_OPT_SAVE_OPTS '>'
213 /** option flag (value) for " (get "val-name") " option */
214 #define VALUE_OPT_LOAD_OPTS '<'
215 #define SET_OPT_SAVE_OPTS(a) STMTS( \
216 DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
217 DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
218 DESC(SAVE_OPTS).optArg.argString = (char const*)(a))
219 /*
220 * Interface defines not associated with particular options
221 */
222 #define ERRSKIP_OPTERR STMTS(ntpqOptions.fOptSet &= ~OPTPROC_ERRSTOP)
223 #define ERRSTOP_OPTERR STMTS(ntpqOptions.fOptSet |= OPTPROC_ERRSTOP)
224 #define RESTART_OPT(n) STMTS( \
225 ntpqOptions.curOptIdx = (n); \
226 ntpqOptions.pzCurOpt = NULL )
227 #define START_OPT RESTART_OPT(1)
228 #define USAGE(c) (*ntpqOptions.pUsageProc)(&ntpqOptions, c)
229
230 #ifdef __cplusplus
231 extern "C" {
232 #endif
233
234
235 /* * * * * *
236 *
237 * Declare the ntpq option descriptor.
238 */
239 extern tOptions ntpqOptions;
240
241 #if defined(ENABLE_NLS)
242 # ifndef _
243 # include <stdio.h>
244 # ifndef HAVE_GETTEXT
245 extern char * gettext(char const *);
246 # else
247 # include <libintl.h>
248 # endif
249
250 static inline char* aoGetsText(char const* pz) {
251 if (pz == NULL) return NULL;
252 return (char*)gettext(pz);
253 }
254 # define _(s) aoGetsText(s)
255 # endif /* _() */
256
257 # define OPT_NO_XLAT_CFG_NAMES STMTS(ntpqOptions.fOptSet |= \
258 OPTPROC_NXLAT_OPT_CFG;)
259 # define OPT_NO_XLAT_OPT_NAMES STMTS(ntpqOptions.fOptSet |= \
260 OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
261
262 # define OPT_XLAT_CFG_NAMES STMTS(ntpqOptions.fOptSet &= \
263 ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
264 # define OPT_XLAT_OPT_NAMES STMTS(ntpqOptions.fOptSet &= \
265 ~OPTPROC_NXLAT_OPT;)
266
267 #else /* ENABLE_NLS */
268 # define OPT_NO_XLAT_CFG_NAMES
269 # define OPT_NO_XLAT_OPT_NAMES
270
271 # define OPT_XLAT_CFG_NAMES
272 # define OPT_XLAT_OPT_NAMES
273
274 # ifndef _
275 # define _(_s) _s
276 # endif
277 #endif /* ENABLE_NLS */
278
279 #ifdef __cplusplus
280 }
281 #endif
282 #endif /* AUTOOPTS_NTPQ_OPTS_H_GUARD */
283
284 /* ntpq-opts.h ends here */
285