ntpdc-opts.h revision 316069
1100280Sgordon/*
225184Sjkh *  EDIT THIS FILE WITH CAUTION  (ntpdc-opts.h)
350472Speter *
466830Sobrien *  It has been AutoGen-ed  March 21, 2017 at 10:44:43 AM by AutoGen 5.18.5
525184Sjkh *  From the definitions    ntpdc-opts.def
6117019Smtm *  and the template file   options
7169215Smtm *
8197143Shrs * Generated from AutoOpts 41:0:16 templates.
9136224Smtm *
1025184Sjkh *  AutoOpts is a copyrighted work.  This header file is not encumbered
11100280Sgordon *  by AutoOpts licensing, but is provided under the licensing terms chosen
12197646Sume *  by the ntpdc author or copyright holder.  AutoOpts is
1325184Sjkh *  licensed under the terms of the LGPL.  The redistributable library
14197143Shrs *  (``libopts'') is licensed under the terms of either the LGPL or, at the
15197143Shrs *  users discretion, the BSD license.  See the AutoOpts and/or libopts sources
16197143Shrs *  for details.
17197143Shrs *
18179940Smtm * The ntpdc program is copyrighted and licensed
19179940Smtm * under the following terms:
20179940Smtm *
21179940Smtm *  Copyright (C) 1992-2017 The University of Delaware and Network Time Foundation, all rights reserved.
22179940Smtm *  This is free software. It is licensed for use, modification and
23179940Smtm *  redistribution under the terms of the NTP License, copies of which
24179940Smtm *  can be seen at:
25179940Smtm *    <http://ntp.org/license>
26179940Smtm *    <http://opensource.org/licenses/ntp-license.php>
27197143Shrs *
28197143Shrs *  Permission to use, copy, modify, and distribute this software and its
29197698Shrs *  documentation for any purpose with or without fee is hereby granted,
30197698Shrs *  provided that the above copyright notice appears in all copies and that
31197698Shrs *  both the copyright notice and this permission notice appear in
32197698Shrs *  supporting documentation, and that the name The University of Delaware not be used in
33197698Shrs *  advertising or publicity pertaining to distribution of the software
34197698Shrs *  without specific, written prior permission. The University of Delaware and Network Time Foundation makes no
35197698Shrs *  representations about the suitability this software for any purpose. It
36197698Shrs *  is provided "as is" without express or implied warranty.
37197698Shrs */
38197698Shrs/**
39197702Shrs *  This file contains the programmatic interface to the Automated
40197702Shrs *  Options generated for the ntpdc program.
41197143Shrs *  These macros are documented in the AutoGen info file in the
42197143Shrs *  "AutoOpts" chapter.  Please refer to that doc for usage help.
43220153Semaste */
44220153Semaste#ifndef AUTOOPTS_NTPDC_OPTS_H_GUARD
45197702Shrs#define AUTOOPTS_NTPDC_OPTS_H_GUARD 1
46197702Shrs#include "config.h"
47220153Semaste#include <autoopts/options.h>
48220153Semaste
49197702Shrs/**
50197702Shrs *  Ensure that the library used for compiling this generated header is at
5185831Sdes *  least as new as the version current when the header template was released
52197143Shrs *  (not counting patch version increments).  Also ensure that the oldest
53220153Semaste *  tolerable version is at least as old as what was current when the header
54197698Shrs *  template was released.
55197143Shrs */
56198383Shrs#define AO_TEMPLATE_VERSION 167936
57220153Semaste#if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
58197143Shrs || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
5965532Snectar# error option template version mismatches autoopts/options.h header
60197698Shrs  Choke Me.
61220153Semaste#endif
62197698Shrs
63197143Shrs/**
64198383Shrs *  Enumeration of each option type for ntpdc
65220153Semaste */
66197143Shrstypedef enum {
67169217Smtm    INDEX_OPT_IPV4             =  0,
68197143Shrs    INDEX_OPT_IPV6             =  1,
69197143Shrs    INDEX_OPT_COMMAND          =  2,
70198383Shrs    INDEX_OPT_DEBUG_LEVEL      =  3,
71220153Semaste    INDEX_OPT_SET_DEBUG_LEVEL  =  4,
72197698Shrs    INDEX_OPT_INTERACTIVE      =  5,
73220153Semaste    INDEX_OPT_LISTPEERS        =  6,
74197143Shrs    INDEX_OPT_NUMERIC          =  7,
75169217Smtm    INDEX_OPT_PEERS            =  8,
76197143Shrs    INDEX_OPT_SHOWPEERS        =  9,
77197143Shrs    INDEX_OPT_VERSION          = 10,
78197143Shrs    INDEX_OPT_HELP             = 11,
79197143Shrs    INDEX_OPT_MORE_HELP        = 12,
80220153Semaste    INDEX_OPT_SAVE_OPTS        = 13,
81197143Shrs    INDEX_OPT_LOAD_OPTS        = 14
82197143Shrs} teOptIndex;
83169217Smtm/** count of all options for ntpdc */
84197143Shrs#define OPTION_CT    15
85197143Shrs/** ntpdc version */
86197143Shrs#define NTPDC_VERSION       "4.2.8p10"
87197143Shrs/** Full ntpdc version text */
88220153Semaste#define NTPDC_FULL_VERSION  "ntpdc 4.2.8p10"
89197143Shrs
90197143Shrs/**
91197698Shrs *  Interface defines for all options.  Replace "n" with the UPPER_CASED
92169217Smtm *  option name (as in the teOptIndex enumeration above).
93197698Shrs *  e.g. HAVE_OPT(IPV4)
94197698Shrs */
95197698Shrs#define         DESC(n) (ntpdcOptions.pOptDesc[INDEX_OPT_## n])
96197698Shrs/** 'true' if an option has been specified in any way */
97197698Shrs#define     HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
98220153Semaste/** The string argument to an option. The argument type must be \"string\". */
99197698Shrs#define      OPT_ARG(n) (DESC(n).optArg.argString)
100220153Semaste/** Mask the option state revealing how an option was specified.
101197143Shrs *  It will be one and only one of \a OPTST_SET, \a OPTST_PRESET,
102212576Shrs * \a OPTST_DEFINED, \a OPTST_RESET or zero.
103212576Shrs */
104212576Shrs#define    STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
105212576Shrs/** Count of option's occurrances *on the command line*. */
106220153Semaste#define    COUNT_OPT(n) (DESC(n).optOccCt)
107220153Semaste/** mask of \a OPTST_SET and \a OPTST_DEFINED. */
108212576Shrs#define    ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
109225521Shrs/** 'true' if \a HAVE_OPT would yield 'false'. */
110225521Shrs#define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
111225521Shrs/** 'true' if OPTST_DISABLED bit not set. */
112225521Shrs#define  ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
113225521Shrs/** number of stacked option arguments.
114225521Shrs *  Valid only for stacked option arguments. */
115225521Shrs#define  STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
116225521Shrs/** stacked argument vector.
117225521Shrs *  Valid only for stacked option arguments. */
118225521Shrs#define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
119225521Shrs/** Reset an option. */
120225521Shrs#define    CLEAR_OPT(n) STMTS( \
121225521Shrs                DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
122197143Shrs                if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \
123169217Smtm                    DESC(n).fOptState |= OPTST_DISABLED; \
124197143Shrs                DESC(n).optCookie = NULL )
125197143Shrs/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
126/**
127 *  Enumeration of ntpdc exit codes
128 */
129typedef enum {
130    NTPDC_EXIT_SUCCESS         = 0,
131    NTPDC_EXIT_FAILURE         = 1,
132    NTPDC_EXIT_USAGE_ERROR     = 64,
133    NTPDC_EXIT_NO_CONFIG_INPUT = 66,
134    NTPDC_EXIT_LIBOPTS_FAILURE = 70
135}   ntpdc_exit_code_t;
136/** @} */
137/**
138 *  Make sure there are no #define name conflicts with the option names
139 */
140#ifndef     NO_OPTION_NAME_WARNINGS
141# ifdef    IPV4
142#  warning undefining IPV4 due to option name conflict
143#  undef   IPV4
144# endif
145# ifdef    IPV6
146#  warning undefining IPV6 due to option name conflict
147#  undef   IPV6
148# endif
149# ifdef    COMMAND
150#  warning undefining COMMAND due to option name conflict
151#  undef   COMMAND
152# endif
153# ifdef    DEBUG_LEVEL
154#  warning undefining DEBUG_LEVEL due to option name conflict
155#  undef   DEBUG_LEVEL
156# endif
157# ifdef    SET_DEBUG_LEVEL
158#  warning undefining SET_DEBUG_LEVEL due to option name conflict
159#  undef   SET_DEBUG_LEVEL
160# endif
161# ifdef    INTERACTIVE
162#  warning undefining INTERACTIVE due to option name conflict
163#  undef   INTERACTIVE
164# endif
165# ifdef    LISTPEERS
166#  warning undefining LISTPEERS due to option name conflict
167#  undef   LISTPEERS
168# endif
169# ifdef    NUMERIC
170#  warning undefining NUMERIC due to option name conflict
171#  undef   NUMERIC
172# endif
173# ifdef    PEERS
174#  warning undefining PEERS due to option name conflict
175#  undef   PEERS
176# endif
177# ifdef    SHOWPEERS
178#  warning undefining SHOWPEERS due to option name conflict
179#  undef   SHOWPEERS
180# endif
181#else  /* NO_OPTION_NAME_WARNINGS */
182# undef IPV4
183# undef IPV6
184# undef COMMAND
185# undef DEBUG_LEVEL
186# undef SET_DEBUG_LEVEL
187# undef INTERACTIVE
188# undef LISTPEERS
189# undef NUMERIC
190# undef PEERS
191# undef SHOWPEERS
192#endif  /*  NO_OPTION_NAME_WARNINGS */
193
194/**
195 *  Interface defines for specific options.
196 * @{
197 */
198#define VALUE_OPT_IPV4           '4'
199#define VALUE_OPT_IPV6           '6'
200#define VALUE_OPT_COMMAND        'c'
201#define VALUE_OPT_DEBUG_LEVEL    'd'
202#define VALUE_OPT_SET_DEBUG_LEVEL 'D'
203
204#define OPT_VALUE_SET_DEBUG_LEVEL (DESC(SET_DEBUG_LEVEL).optArg.argInt)
205#define VALUE_OPT_INTERACTIVE    'i'
206#define VALUE_OPT_LISTPEERS      'l'
207#define VALUE_OPT_NUMERIC        'n'
208#define VALUE_OPT_PEERS          'p'
209#define VALUE_OPT_SHOWPEERS      's'
210/** option flag (value) for help-value option */
211#define VALUE_OPT_HELP          '?'
212/** option flag (value) for more-help-value option */
213#define VALUE_OPT_MORE_HELP     '!'
214/** option flag (value) for version-value option */
215#define VALUE_OPT_VERSION       0x1001
216/** option flag (value) for save-opts-value option */
217#define VALUE_OPT_SAVE_OPTS     '>'
218/** option flag (value) for load-opts-value option */
219#define VALUE_OPT_LOAD_OPTS     '<'
220#define SET_OPT_SAVE_OPTS(a)   STMTS( \
221        DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
222        DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
223        DESC(SAVE_OPTS).optArg.argString = (char const*)(a))
224/*
225 *  Interface defines not associated with particular options
226 */
227#define ERRSKIP_OPTERR  STMTS(ntpdcOptions.fOptSet &= ~OPTPROC_ERRSTOP)
228#define ERRSTOP_OPTERR  STMTS(ntpdcOptions.fOptSet |= OPTPROC_ERRSTOP)
229#define RESTART_OPT(n)  STMTS( \
230                ntpdcOptions.curOptIdx = (n); \
231                ntpdcOptions.pzCurOpt  = NULL )
232#define START_OPT       RESTART_OPT(1)
233#define USAGE(c)        (*ntpdcOptions.pUsageProc)(&ntpdcOptions, c)
234
235#ifdef  __cplusplus
236extern "C" {
237#endif
238
239
240/* * * * * *
241 *
242 *  Declare the ntpdc option descriptor.
243 */
244extern tOptions ntpdcOptions;
245
246#if defined(ENABLE_NLS)
247# ifndef _
248#   include <stdio.h>
249#   ifndef HAVE_GETTEXT
250      extern char * gettext(char const *);
251#   else
252#     include <libintl.h>
253#   endif
254
255# ifndef ATTRIBUTE_FORMAT_ARG
256#   define ATTRIBUTE_FORMAT_ARG(_a)
257# endif
258
259static inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1);
260static inline char* aoGetsText(char const* pz) {
261    if (pz == NULL) return NULL;
262    return (char*)gettext(pz);
263}
264#   define _(s)  aoGetsText(s)
265# endif /* _() */
266
267# define OPT_NO_XLAT_CFG_NAMES  STMTS(ntpdcOptions.fOptSet |= \
268                                    OPTPROC_NXLAT_OPT_CFG;)
269# define OPT_NO_XLAT_OPT_NAMES  STMTS(ntpdcOptions.fOptSet |= \
270                                    OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
271
272# define OPT_XLAT_CFG_NAMES     STMTS(ntpdcOptions.fOptSet &= \
273                                  ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
274# define OPT_XLAT_OPT_NAMES     STMTS(ntpdcOptions.fOptSet &= \
275                                  ~OPTPROC_NXLAT_OPT;)
276
277#else   /* ENABLE_NLS */
278# define OPT_NO_XLAT_CFG_NAMES
279# define OPT_NO_XLAT_OPT_NAMES
280
281# define OPT_XLAT_CFG_NAMES
282# define OPT_XLAT_OPT_NAMES
283
284# ifndef _
285#   define _(_s)  _s
286# endif
287#endif  /* ENABLE_NLS */
288
289#ifdef  __cplusplus
290}
291#endif
292#endif /* AUTOOPTS_NTPDC_OPTS_H_GUARD */
293
294/* ntpdc-opts.h ends here */
295