xref: /freebsd/contrib/ntp/ntpsnmpd/ntpsnmpd-opts.h (revision f5f40dd63bc7acbb5312b26ac1ea1103c12352a6)
1 /*
2  *  EDIT THIS FILE WITH CAUTION  (ntpsnmpd-opts.h)
3  *
4  *  It has been AutoGen-ed  May 25, 2024 at 12:04:34 AM by AutoGen 5.18.16
5  *  From the definitions    ntpsnmpd-opts.def
6  *  and the template file   options
7  *
8  * Generated from AutoOpts 42:1:17 templates.
9  *
10  *  AutoOpts is a copyrighted work.  This header file is not encumbered
11  *  by AutoOpts licensing, but is provided under the licensing terms chosen
12  *  by the ntpsnmpd author or copyright holder.  AutoOpts is
13  *  licensed under the terms of the LGPL.  The redistributable library
14  *  (``libopts'') is licensed under the terms of either the LGPL or, at the
15  *  users discretion, the BSD license.  See the AutoOpts and/or libopts sources
16  *  for details.
17  *
18  * The ntpsnmpd program is copyrighted and licensed
19  * under the following terms:
20  *
21  *  Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved.
22  *  This is free software. It is licensed for use, modification and
23  *  redistribution under the terms of the NTP License, copies of which
24  *  can be seen at:
25  *    <http://ntp.org/license>
26  *    <http://opensource.org/licenses/ntp-license.php>
27  *
28  *  Permission to use, copy, modify, and distribute this software and its
29  *  documentation for any purpose with or without fee is hereby granted,
30  *  provided that the above copyright notice appears in all copies and that
31  *  both the copyright notice and this permission notice appear in
32  *  supporting documentation, and that the name The University of Delaware not be used in
33  *  advertising or publicity pertaining to distribution of the software
34  *  without specific, written prior permission. The University of Delaware and Network Time Foundation makes no
35  *  representations about the suitability this software for any purpose. It
36  *  is provided "as is" without express or implied warranty.
37  */
38 /**
39  *  This file contains the programmatic interface to the Automated
40  *  Options generated for the ntpsnmpd program.
41  *  These macros are documented in the AutoGen info file in the
42  *  "AutoOpts" chapter.  Please refer to that doc for usage help.
43  */
44 #ifndef AUTOOPTS_NTPSNMPD_OPTS_H_GUARD
45 #define AUTOOPTS_NTPSNMPD_OPTS_H_GUARD 1
46 #include "config.h"
47 #include <autoopts/options.h>
48 #include <stdarg.h>
49 #include <stdnoreturn.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 172033
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 #if GCC_VERSION > 40400
66 #define NOT_REACHED __builtin_unreachable();
67 #else
68 #define NOT_REACHED
69 #endif
70 
71 /**
72  *  Enumeration of each option type for ntpsnmpd
73  */
74 typedef enum {
75     INDEX_OPT_NOFORK        =  0,
76     INDEX_OPT_SYSLOG        =  1,
77     INDEX_OPT_AGENTXSOCKET  =  2,
78     INDEX_OPT_VERSION       =  3,
79     INDEX_OPT_HELP          =  4,
80     INDEX_OPT_MORE_HELP     =  5,
81     INDEX_OPT_SAVE_OPTS     =  6,
82     INDEX_OPT_LOAD_OPTS     =  7
83 } teOptIndex;
84 /** count of all options for ntpsnmpd */
85 #define OPTION_CT    8
86 /** ntpsnmpd version */
87 #define NTPSNMPD_VERSION       "4.2.8p18"
88 /** Full ntpsnmpd version text */
89 #define NTPSNMPD_FULL_VERSION  "ntpsnmpd 4.2.8p18"
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(NOFORK)
95  */
96 #define         DESC(n) (ntpsnmpdOptions.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 ntpsnmpd exit codes
129  */
130 typedef enum {
131     NTPSNMPD_EXIT_SUCCESS         = 0,
132     NTPSNMPD_EXIT_FAILURE         = 1,
133     NTPSNMPD_EXIT_USAGE_ERROR     = 64,
134     NTPSNMPD_EXIT_NO_CONFIG_INPUT = 66,
135     NTPSNMPD_EXIT_LIBOPTS_FAILURE = 70
136 }   ntpsnmpd_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    NOFORK
143 #  warning undefining NOFORK due to option name conflict
144 #  undef   NOFORK
145 # endif
146 # ifdef    SYSLOG
147 #  warning undefining SYSLOG due to option name conflict
148 #  undef   SYSLOG
149 # endif
150 # ifdef    AGENTXSOCKET
151 #  warning undefining AGENTXSOCKET due to option name conflict
152 #  undef   AGENTXSOCKET
153 # endif
154 #else  /* NO_OPTION_NAME_WARNINGS */
155 # undef NOFORK
156 # undef SYSLOG
157 # undef AGENTXSOCKET
158 #endif  /*  NO_OPTION_NAME_WARNINGS */
159 
160 /**
161  *  Interface defines for specific options.
162  * @{
163  */
164 #define VALUE_OPT_NOFORK         'n'
165 #define VALUE_OPT_SYSLOG         'p'
166 #define VALUE_OPT_AGENTXSOCKET   0x1001
167 /** option flag (value) for help-value option */
168 #define VALUE_OPT_HELP          '?'
169 /** option flag (value) for more-help-value option */
170 #define VALUE_OPT_MORE_HELP     '!'
171 /** option flag (value) for version-value option */
172 #define VALUE_OPT_VERSION       0x1002
173 /** option flag (value) for save-opts-value option */
174 #define VALUE_OPT_SAVE_OPTS     '>'
175 /** option flag (value) for load-opts-value option */
176 #define VALUE_OPT_LOAD_OPTS     '<'
177 #define SET_OPT_SAVE_OPTS(a)   STMTS( \
178         DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
179         DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
180         DESC(SAVE_OPTS).optArg.argString = (char const*)(a))
181 /*
182  *  Interface defines not associated with particular options
183  */
184 #define ERRSKIP_OPTERR  STMTS(ntpsnmpdOptions.fOptSet &= ~OPTPROC_ERRSTOP)
185 #define ERRSTOP_OPTERR  STMTS(ntpsnmpdOptions.fOptSet |= OPTPROC_ERRSTOP)
186 #define RESTART_OPT(n)  STMTS( \
187                 ntpsnmpdOptions.curOptIdx = (n); \
188                 ntpsnmpdOptions.pzCurOpt  = NULL )
189 #define START_OPT       RESTART_OPT(1)
190 #define USAGE(c)        (*ntpsnmpdOptions.pUsageProc)(&ntpsnmpdOptions, c)
191 
192 #ifdef  __cplusplus
193 extern "C" {
194 #endif
195 
196 
197 /* * * * * *
198  *
199  *  Declare the ntpsnmpd option descriptor.
200  */
201 extern tOptions ntpsnmpdOptions;
202 
203 #if defined(ENABLE_NLS)
204 # ifndef _
205 #   include <stdio.h>
206 #   ifndef HAVE_GETTEXT
207       extern char * gettext(char const *);
208 #   else
209 #     include <libintl.h>
210 #   endif
211 
212 # ifndef ATTRIBUTE_FORMAT_ARG
213 #   define ATTRIBUTE_FORMAT_ARG(_a)
214 # endif
215 
216 static inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1);
217 static inline char* aoGetsText(char const* pz) {
218     if (pz == NULL) return NULL;
219     return (char*)gettext(pz);
220 }
221 #   define _(s)  aoGetsText(s)
222 # endif /* _() */
223 
224 # define OPT_NO_XLAT_CFG_NAMES  STMTS(ntpsnmpdOptions.fOptSet |= \
225                                     OPTPROC_NXLAT_OPT_CFG;)
226 # define OPT_NO_XLAT_OPT_NAMES  STMTS(ntpsnmpdOptions.fOptSet |= \
227                                     OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
228 
229 # define OPT_XLAT_CFG_NAMES     STMTS(ntpsnmpdOptions.fOptSet &= \
230                                   ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
231 # define OPT_XLAT_OPT_NAMES     STMTS(ntpsnmpdOptions.fOptSet &= \
232                                   ~OPTPROC_NXLAT_OPT;)
233 
234 #else   /* ENABLE_NLS */
235 # define OPT_NO_XLAT_CFG_NAMES
236 # define OPT_NO_XLAT_OPT_NAMES
237 
238 # define OPT_XLAT_CFG_NAMES
239 # define OPT_XLAT_OPT_NAMES
240 
241 # ifndef _
242 #   define _(_s)  _s
243 # endif
244 #endif  /* ENABLE_NLS */
245 
246 
247 #ifdef  __cplusplus
248 }
249 #endif
250 #endif /* AUTOOPTS_NTPSNMPD_OPTS_H_GUARD */
251 
252 /* ntpsnmpd-opts.h ends here */
253