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