ntpq-opts.h revision 1.15 1 1.14 christos /* $NetBSD: ntpq-opts.h,v 1.15 2024/08/18 20:47:19 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.15 christos * It has been AutoGen-ed May 25, 2024 at 12:04:21 AM by AutoGen 5.18.16
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.15 christos * Generated from AutoOpts 42:1:17 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.15 christos * Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, 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.3 christos * without specific, written prior permission. The University of Delaware and Network Time Foundation 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.15 christos #include <stdarg.h>
51 1.15 christos #include <stdnoreturn.h>
52 1.1 kardel
53 1.2 christos /**
54 1.1 kardel * Ensure that the library used for compiling this generated header is at
55 1.1 kardel * least as new as the version current when the header template was released
56 1.1 kardel * (not counting patch version increments). Also ensure that the oldest
57 1.1 kardel * tolerable version is at least as old as what was current when the header
58 1.1 kardel * template was released.
59 1.1 kardel */
60 1.15 christos #define AO_TEMPLATE_VERSION 172033
61 1.1 kardel #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
62 1.1 kardel || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
63 1.1 kardel # error option template version mismatches autoopts/options.h header
64 1.1 kardel Choke Me.
65 1.1 kardel #endif
66 1.1 kardel
67 1.15 christos #if GCC_VERSION > 40400
68 1.15 christos #define NOT_REACHED __builtin_unreachable();
69 1.15 christos #else
70 1.15 christos #define NOT_REACHED
71 1.15 christos #endif
72 1.15 christos
73 1.2 christos /**
74 1.2 christos * Enumeration of each option type for ntpq
75 1.1 kardel */
76 1.1 kardel typedef enum {
77 1.1 kardel INDEX_OPT_IPV4 = 0,
78 1.1 kardel INDEX_OPT_IPV6 = 1,
79 1.1 kardel INDEX_OPT_COMMAND = 2,
80 1.1 kardel INDEX_OPT_DEBUG_LEVEL = 3,
81 1.1 kardel INDEX_OPT_SET_DEBUG_LEVEL = 4,
82 1.2 christos INDEX_OPT_INTERACTIVE = 5,
83 1.2 christos INDEX_OPT_NUMERIC = 6,
84 1.2 christos INDEX_OPT_OLD_RV = 7,
85 1.2 christos INDEX_OPT_PEERS = 8,
86 1.7 christos INDEX_OPT_REFID = 9,
87 1.15 christos INDEX_OPT_UNCONNECTED = 10,
88 1.15 christos INDEX_OPT_WIDE = 11,
89 1.15 christos INDEX_OPT_VERSION = 12,
90 1.15 christos INDEX_OPT_HELP = 13,
91 1.15 christos INDEX_OPT_MORE_HELP = 14,
92 1.15 christos INDEX_OPT_SAVE_OPTS = 15,
93 1.15 christos INDEX_OPT_LOAD_OPTS = 16
94 1.1 kardel } teOptIndex;
95 1.2 christos /** count of all options for ntpq */
96 1.15 christos #define OPTION_CT 17
97 1.2 christos /** ntpq version */
98 1.15 christos #define NTPQ_VERSION "4.2.8p18"
99 1.2 christos /** Full ntpq version text */
100 1.15 christos #define NTPQ_FULL_VERSION "ntpq 4.2.8p18"
101 1.1 kardel
102 1.2 christos /**
103 1.1 kardel * Interface defines for all options. Replace "n" with the UPPER_CASED
104 1.1 kardel * option name (as in the teOptIndex enumeration above).
105 1.2 christos * e.g. HAVE_OPT(IPV4)
106 1.1 kardel */
107 1.1 kardel #define DESC(n) (ntpqOptions.pOptDesc[INDEX_OPT_## n])
108 1.2 christos /** 'true' if an option has been specified in any way */
109 1.1 kardel #define HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
110 1.2 christos /** The string argument to an option. The argument type must be \"string\". */
111 1.1 kardel #define OPT_ARG(n) (DESC(n).optArg.argString)
112 1.2 christos /** Mask the option state revealing how an option was specified.
113 1.2 christos * It will be one and only one of \a OPTST_SET, \a OPTST_PRESET,
114 1.2 christos * \a OPTST_DEFINED, \a OPTST_RESET or zero.
115 1.2 christos */
116 1.1 kardel #define STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
117 1.2 christos /** Count of option's occurrances *on the command line*. */
118 1.1 kardel #define COUNT_OPT(n) (DESC(n).optOccCt)
119 1.2 christos /** mask of \a OPTST_SET and \a OPTST_DEFINED. */
120 1.1 kardel #define ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
121 1.2 christos /** 'true' if \a HAVE_OPT would yield 'false'. */
122 1.1 kardel #define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
123 1.2 christos /** 'true' if OPTST_DISABLED bit not set. */
124 1.1 kardel #define ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
125 1.2 christos /** number of stacked option arguments.
126 1.2 christos * Valid only for stacked option arguments. */
127 1.1 kardel #define STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
128 1.2 christos /** stacked argument vector.
129 1.2 christos * Valid only for stacked option arguments. */
130 1.1 kardel #define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
131 1.2 christos /** Reset an option. */
132 1.1 kardel #define CLEAR_OPT(n) STMTS( \
133 1.1 kardel DESC(n).fOptState &= OPTST_PERSISTENT_MASK; \
134 1.2 christos if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \
135 1.1 kardel DESC(n).fOptState |= OPTST_DISABLED; \
136 1.1 kardel DESC(n).optCookie = NULL )
137 1.2 christos /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
138 1.2 christos /**
139 1.2 christos * Enumeration of ntpq exit codes
140 1.2 christos */
141 1.2 christos typedef enum {
142 1.2 christos NTPQ_EXIT_SUCCESS = 0,
143 1.2 christos NTPQ_EXIT_FAILURE = 1,
144 1.2 christos NTPQ_EXIT_USAGE_ERROR = 64,
145 1.2 christos NTPQ_EXIT_NO_CONFIG_INPUT = 66,
146 1.2 christos NTPQ_EXIT_LIBOPTS_FAILURE = 70
147 1.2 christos } ntpq_exit_code_t;
148 1.2 christos /** @} */
149 1.2 christos /**
150 1.1 kardel * Make sure there are no #define name conflicts with the option names
151 1.1 kardel */
152 1.1 kardel #ifndef NO_OPTION_NAME_WARNINGS
153 1.1 kardel # ifdef IPV4
154 1.1 kardel # warning undefining IPV4 due to option name conflict
155 1.1 kardel # undef IPV4
156 1.1 kardel # endif
157 1.1 kardel # ifdef IPV6
158 1.1 kardel # warning undefining IPV6 due to option name conflict
159 1.1 kardel # undef IPV6
160 1.1 kardel # endif
161 1.1 kardel # ifdef COMMAND
162 1.1 kardel # warning undefining COMMAND due to option name conflict
163 1.1 kardel # undef COMMAND
164 1.1 kardel # endif
165 1.1 kardel # ifdef DEBUG_LEVEL
166 1.1 kardel # warning undefining DEBUG_LEVEL due to option name conflict
167 1.1 kardel # undef DEBUG_LEVEL
168 1.1 kardel # endif
169 1.1 kardel # ifdef SET_DEBUG_LEVEL
170 1.1 kardel # warning undefining SET_DEBUG_LEVEL due to option name conflict
171 1.1 kardel # undef SET_DEBUG_LEVEL
172 1.1 kardel # endif
173 1.1 kardel # ifdef INTERACTIVE
174 1.1 kardel # warning undefining INTERACTIVE due to option name conflict
175 1.1 kardel # undef INTERACTIVE
176 1.1 kardel # endif
177 1.1 kardel # ifdef NUMERIC
178 1.1 kardel # warning undefining NUMERIC due to option name conflict
179 1.1 kardel # undef NUMERIC
180 1.1 kardel # endif
181 1.1 kardel # ifdef OLD_RV
182 1.1 kardel # warning undefining OLD_RV due to option name conflict
183 1.1 kardel # undef OLD_RV
184 1.1 kardel # endif
185 1.2 christos # ifdef PEERS
186 1.2 christos # warning undefining PEERS due to option name conflict
187 1.2 christos # undef PEERS
188 1.2 christos # endif
189 1.7 christos # ifdef REFID
190 1.7 christos # warning undefining REFID due to option name conflict
191 1.7 christos # undef REFID
192 1.7 christos # endif
193 1.15 christos # ifdef UNCONNECTED
194 1.15 christos # warning undefining UNCONNECTED due to option name conflict
195 1.15 christos # undef UNCONNECTED
196 1.15 christos # endif
197 1.2 christos # ifdef WIDE
198 1.2 christos # warning undefining WIDE due to option name conflict
199 1.2 christos # undef WIDE
200 1.2 christos # endif
201 1.1 kardel #else /* NO_OPTION_NAME_WARNINGS */
202 1.1 kardel # undef IPV4
203 1.1 kardel # undef IPV6
204 1.1 kardel # undef COMMAND
205 1.1 kardel # undef DEBUG_LEVEL
206 1.1 kardel # undef SET_DEBUG_LEVEL
207 1.1 kardel # undef INTERACTIVE
208 1.1 kardel # undef NUMERIC
209 1.1 kardel # undef OLD_RV
210 1.2 christos # undef PEERS
211 1.7 christos # undef REFID
212 1.15 christos # undef UNCONNECTED
213 1.2 christos # undef WIDE
214 1.1 kardel #endif /* NO_OPTION_NAME_WARNINGS */
215 1.1 kardel
216 1.2 christos /**
217 1.1 kardel * Interface defines for specific options.
218 1.2 christos * @{
219 1.1 kardel */
220 1.1 kardel #define VALUE_OPT_IPV4 '4'
221 1.1 kardel #define VALUE_OPT_IPV6 '6'
222 1.1 kardel #define VALUE_OPT_COMMAND 'c'
223 1.1 kardel #define VALUE_OPT_DEBUG_LEVEL 'd'
224 1.1 kardel #define VALUE_OPT_SET_DEBUG_LEVEL 'D'
225 1.2 christos
226 1.2 christos #define OPT_VALUE_SET_DEBUG_LEVEL (DESC(SET_DEBUG_LEVEL).optArg.argInt)
227 1.1 kardel #define VALUE_OPT_INTERACTIVE 'i'
228 1.1 kardel #define VALUE_OPT_NUMERIC 'n'
229 1.2 christos #define VALUE_OPT_OLD_RV 0x1001
230 1.2 christos #define VALUE_OPT_PEERS 'p'
231 1.7 christos #define VALUE_OPT_REFID 'r'
232 1.7 christos
233 1.7 christos typedef enum {
234 1.7 christos REFID_HASH, REFID_IPV4
235 1.7 christos } te_Refid;
236 1.7 christos #define OPT_REFID_VAL2STR(_v) optionKeywordName(&DESC(REFID), (_v))
237 1.7 christos #define OPT_VALUE_REFID (DESC(REFID).optArg.argEnum)
238 1.15 christos #define VALUE_OPT_UNCONNECTED 'u'
239 1.2 christos #define VALUE_OPT_WIDE 'w'
240 1.2 christos /** option flag (value) for help-value option */
241 1.1 kardel #define VALUE_OPT_HELP '?'
242 1.2 christos /** option flag (value) for more-help-value option */
243 1.1 kardel #define VALUE_OPT_MORE_HELP '!'
244 1.2 christos /** option flag (value) for version-value option */
245 1.2 christos #define VALUE_OPT_VERSION 0x1002
246 1.2 christos /** option flag (value) for save-opts-value option */
247 1.1 kardel #define VALUE_OPT_SAVE_OPTS '>'
248 1.2 christos /** option flag (value) for load-opts-value option */
249 1.1 kardel #define VALUE_OPT_LOAD_OPTS '<'
250 1.1 kardel #define SET_OPT_SAVE_OPTS(a) STMTS( \
251 1.1 kardel DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
252 1.1 kardel DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
253 1.2 christos DESC(SAVE_OPTS).optArg.argString = (char const*)(a))
254 1.1 kardel /*
255 1.1 kardel * Interface defines not associated with particular options
256 1.1 kardel */
257 1.2 christos #define ERRSKIP_OPTERR STMTS(ntpqOptions.fOptSet &= ~OPTPROC_ERRSTOP)
258 1.2 christos #define ERRSTOP_OPTERR STMTS(ntpqOptions.fOptSet |= OPTPROC_ERRSTOP)
259 1.1 kardel #define RESTART_OPT(n) STMTS( \
260 1.1 kardel ntpqOptions.curOptIdx = (n); \
261 1.1 kardel ntpqOptions.pzCurOpt = NULL )
262 1.1 kardel #define START_OPT RESTART_OPT(1)
263 1.2 christos #define USAGE(c) (*ntpqOptions.pUsageProc)(&ntpqOptions, c)
264 1.2 christos
265 1.2 christos #ifdef __cplusplus
266 1.2 christos extern "C" {
267 1.2 christos #endif
268 1.2 christos
269 1.1 kardel
270 1.1 kardel /* * * * * *
271 1.1 kardel *
272 1.1 kardel * Declare the ntpq option descriptor.
273 1.1 kardel */
274 1.2 christos extern tOptions ntpqOptions;
275 1.1 kardel
276 1.1 kardel #if defined(ENABLE_NLS)
277 1.1 kardel # ifndef _
278 1.1 kardel # include <stdio.h>
279 1.2 christos # ifndef HAVE_GETTEXT
280 1.2 christos extern char * gettext(char const *);
281 1.2 christos # else
282 1.2 christos # include <libintl.h>
283 1.2 christos # endif
284 1.2 christos
285 1.2 christos # ifndef ATTRIBUTE_FORMAT_ARG
286 1.2 christos # define ATTRIBUTE_FORMAT_ARG(_a)
287 1.2 christos # endif
288 1.2 christos
289 1.2 christos static inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1);
290 1.2 christos static inline char* aoGetsText(char const* pz) {
291 1.2 christos if (pz == NULL) return NULL;
292 1.2 christos return (char*)gettext(pz);
293 1.2 christos }
294 1.1 kardel # define _(s) aoGetsText(s)
295 1.1 kardel # endif /* _() */
296 1.1 kardel
297 1.1 kardel # define OPT_NO_XLAT_CFG_NAMES STMTS(ntpqOptions.fOptSet |= \
298 1.1 kardel OPTPROC_NXLAT_OPT_CFG;)
299 1.1 kardel # define OPT_NO_XLAT_OPT_NAMES STMTS(ntpqOptions.fOptSet |= \
300 1.1 kardel OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
301 1.1 kardel
302 1.1 kardel # define OPT_XLAT_CFG_NAMES STMTS(ntpqOptions.fOptSet &= \
303 1.1 kardel ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
304 1.1 kardel # define OPT_XLAT_OPT_NAMES STMTS(ntpqOptions.fOptSet &= \
305 1.1 kardel ~OPTPROC_NXLAT_OPT;)
306 1.1 kardel
307 1.1 kardel #else /* ENABLE_NLS */
308 1.1 kardel # define OPT_NO_XLAT_CFG_NAMES
309 1.1 kardel # define OPT_NO_XLAT_OPT_NAMES
310 1.1 kardel
311 1.1 kardel # define OPT_XLAT_CFG_NAMES
312 1.1 kardel # define OPT_XLAT_OPT_NAMES
313 1.1 kardel
314 1.1 kardel # ifndef _
315 1.1 kardel # define _(_s) _s
316 1.1 kardel # endif
317 1.1 kardel #endif /* ENABLE_NLS */
318 1.1 kardel
319 1.15 christos
320 1.1 kardel #ifdef __cplusplus
321 1.1 kardel }
322 1.1 kardel #endif
323 1.1 kardel #endif /* AUTOOPTS_NTPQ_OPTS_H_GUARD */
324 1.2 christos
325 1.1 kardel /* ntpq-opts.h ends here */
326