1 /* $NetBSD: ntpsnmpd-opts.h,v 1.15 2024/08/18 20:47:19 christos Exp $ */
2
3 /*
4 * EDIT THIS FILE WITH CAUTION (ntpsnmpd-opts.h)
5 *
6 * It has been AutoGen-ed May 25, 2024 at 12:04:34 AM by AutoGen 5.18.16
7 * From the definitions ntpsnmpd-opts.def
8 * and the template file options
9 *
10 * Generated from AutoOpts 42:1:17 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 ntpsnmpd 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 ntpsnmpd program is copyrighted and licensed
21 * under the following terms:
22 *
23 * Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, 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 and Network Time Foundation 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 ntpsnmpd 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_NTPSNMPD_OPTS_H_GUARD
47 #define AUTOOPTS_NTPSNMPD_OPTS_H_GUARD 1
48 #include "config.h"
49 #include <autoopts/options.h>
50 #include <stdarg.h>
51 #include <stdnoreturn.h>
52
53 /**
54 * Ensure that the library used for compiling this generated header is at
55 * least as new as the version current when the header template was released
56 * (not counting patch version increments). Also ensure that the oldest
57 * tolerable version is at least as old as what was current when the header
58 * template was released.
59 */
60 #define AO_TEMPLATE_VERSION 172033
61 #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
62 || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
63 # error option template version mismatches autoopts/options.h header
64 Choke Me.
65 #endif
66
67 #if GCC_VERSION > 40400
68 #define NOT_REACHED __builtin_unreachable();
69 #else
70 #define NOT_REACHED
71 #endif
72
73 /**
74 * Enumeration of each option type for ntpsnmpd
75 */
76 typedef enum {
77 INDEX_OPT_NOFORK = 0,
78 INDEX_OPT_SYSLOG = 1,
79 INDEX_OPT_AGENTXSOCKET = 2,
80 INDEX_OPT_VERSION = 3,
81 INDEX_OPT_HELP = 4,
82 INDEX_OPT_MORE_HELP = 5,
83 INDEX_OPT_SAVE_OPTS = 6,
84 INDEX_OPT_LOAD_OPTS = 7
85 } teOptIndex;
86 /** count of all options for ntpsnmpd */
87 #define OPTION_CT 8
88 /** ntpsnmpd version */
89 #define NTPSNMPD_VERSION "4.2.8p18"
90 /** Full ntpsnmpd version text */
91 #define NTPSNMPD_FULL_VERSION "ntpsnmpd 4.2.8p18"
92
93 /**
94 * Interface defines for all options. Replace "n" with the UPPER_CASED
95 * option name (as in the teOptIndex enumeration above).
96 * e.g. HAVE_OPT(NOFORK)
97 */
98 #define DESC(n) (ntpsnmpdOptions.pOptDesc[INDEX_OPT_## n])
99 /** 'true' if an option has been specified in any way */
100 #define HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
101 /** The string argument to an option. The argument type must be \"string\". */
102 #define OPT_ARG(n) (DESC(n).optArg.argString)
103 /** Mask the option state revealing how an option was specified.
104 * It will be one and only one of \a OPTST_SET, \a OPTST_PRESET,
105 * \a OPTST_DEFINED, \a OPTST_RESET or zero.
106 */
107 #define STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
108 /** Count of option's occurrances *on the command line*. */
109 #define COUNT_OPT(n) (DESC(n).optOccCt)
110 /** mask of \a OPTST_SET and \a OPTST_DEFINED. */
111 #define ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
112 /** 'true' if \a HAVE_OPT would yield 'false'. */
113 #define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
114 /** 'true' if OPTST_DISABLED bit not set. */
115 #define ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
116 /** number of stacked option arguments.
117 * Valid only for stacked option arguments. */
118 #define STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
119 /** stacked argument vector.
120 * Valid only for stacked option arguments. */
121 #define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
122 /** Reset an option. */
123 #define CLEAR_OPT(n) STMTS( \
124 DESC(n).fOptState &= OPTST_PERSISTENT_MASK; \
125 if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \
126 DESC(n).fOptState |= OPTST_DISABLED; \
127 DESC(n).optCookie = NULL )
128 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
129 /**
130 * Enumeration of ntpsnmpd exit codes
131 */
132 typedef enum {
133 NTPSNMPD_EXIT_SUCCESS = 0,
134 NTPSNMPD_EXIT_FAILURE = 1,
135 NTPSNMPD_EXIT_USAGE_ERROR = 64,
136 NTPSNMPD_EXIT_NO_CONFIG_INPUT = 66,
137 NTPSNMPD_EXIT_LIBOPTS_FAILURE = 70
138 } ntpsnmpd_exit_code_t;
139 /** @} */
140 /**
141 * Make sure there are no #define name conflicts with the option names
142 */
143 #ifndef NO_OPTION_NAME_WARNINGS
144 # ifdef NOFORK
145 # warning undefining NOFORK due to option name conflict
146 # undef NOFORK
147 # endif
148 # ifdef SYSLOG
149 # warning undefining SYSLOG due to option name conflict
150 # undef SYSLOG
151 # endif
152 # ifdef AGENTXSOCKET
153 # warning undefining AGENTXSOCKET due to option name conflict
154 # undef AGENTXSOCKET
155 # endif
156 #else /* NO_OPTION_NAME_WARNINGS */
157 # undef NOFORK
158 # undef SYSLOG
159 # undef AGENTXSOCKET
160 #endif /* NO_OPTION_NAME_WARNINGS */
161
162 /**
163 * Interface defines for specific options.
164 * @{
165 */
166 #define VALUE_OPT_NOFORK 'n'
167 #define VALUE_OPT_SYSLOG 'p'
168 #define VALUE_OPT_AGENTXSOCKET 0x1001
169 /** option flag (value) for help-value option */
170 #define VALUE_OPT_HELP '?'
171 /** option flag (value) for more-help-value option */
172 #define VALUE_OPT_MORE_HELP '!'
173 /** option flag (value) for version-value option */
174 #define VALUE_OPT_VERSION 0x1002
175 /** option flag (value) for save-opts-value option */
176 #define VALUE_OPT_SAVE_OPTS '>'
177 /** option flag (value) for load-opts-value option */
178 #define VALUE_OPT_LOAD_OPTS '<'
179 #define SET_OPT_SAVE_OPTS(a) STMTS( \
180 DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
181 DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
182 DESC(SAVE_OPTS).optArg.argString = (char const*)(a))
183 /*
184 * Interface defines not associated with particular options
185 */
186 #define ERRSKIP_OPTERR STMTS(ntpsnmpdOptions.fOptSet &= ~OPTPROC_ERRSTOP)
187 #define ERRSTOP_OPTERR STMTS(ntpsnmpdOptions.fOptSet |= OPTPROC_ERRSTOP)
188 #define RESTART_OPT(n) STMTS( \
189 ntpsnmpdOptions.curOptIdx = (n); \
190 ntpsnmpdOptions.pzCurOpt = NULL )
191 #define START_OPT RESTART_OPT(1)
192 #define USAGE(c) (*ntpsnmpdOptions.pUsageProc)(&ntpsnmpdOptions, c)
193
194 #ifdef __cplusplus
195 extern "C" {
196 #endif
197
198
199 /* * * * * *
200 *
201 * Declare the ntpsnmpd option descriptor.
202 */
203 extern tOptions ntpsnmpdOptions;
204
205 #if defined(ENABLE_NLS)
206 # ifndef _
207 # include <stdio.h>
208 # ifndef HAVE_GETTEXT
209 extern char * gettext(char const *);
210 # else
211 # include <libintl.h>
212 # endif
213
214 # ifndef ATTRIBUTE_FORMAT_ARG
215 # define ATTRIBUTE_FORMAT_ARG(_a)
216 # endif
217
218 static inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1);
aoGetsText(char const * pz)219 static inline char* aoGetsText(char const* pz) {
220 if (pz == NULL) return NULL;
221 return (char*)gettext(pz);
222 }
223 # define _(s) aoGetsText(s)
224 # endif /* _() */
225
226 # define OPT_NO_XLAT_CFG_NAMES STMTS(ntpsnmpdOptions.fOptSet |= \
227 OPTPROC_NXLAT_OPT_CFG;)
228 # define OPT_NO_XLAT_OPT_NAMES STMTS(ntpsnmpdOptions.fOptSet |= \
229 OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
230
231 # define OPT_XLAT_CFG_NAMES STMTS(ntpsnmpdOptions.fOptSet &= \
232 ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
233 # define OPT_XLAT_OPT_NAMES STMTS(ntpsnmpdOptions.fOptSet &= \
234 ~OPTPROC_NXLAT_OPT;)
235
236 #else /* ENABLE_NLS */
237 # define OPT_NO_XLAT_CFG_NAMES
238 # define OPT_NO_XLAT_OPT_NAMES
239
240 # define OPT_XLAT_CFG_NAMES
241 # define OPT_XLAT_OPT_NAMES
242
243 # ifndef _
244 # define _(_s) _s
245 # endif
246 #endif /* ENABLE_NLS */
247
248
249 #ifdef __cplusplus
250 }
251 #endif
252 #endif /* AUTOOPTS_NTPSNMPD_OPTS_H_GUARD */
253
254 /* ntpsnmpd-opts.h ends here */
255