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