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