xref: /freebsd/contrib/ntp/ntpq/ntpq-opts.h (revision 7aa383846770374466b1dcb2cefd71bde9acf463)
1 /*
2  *  EDIT THIS FILE WITH CAUTION  (ntpq-opts.h)
3  *
4  *  It has been AutoGen-ed  Tuesday December  8, 2009 at 08:14:26 AM EST
5  *  From the definitions    ntpq-opts.def
6  *  and the template file   options
7  *
8  * Generated from AutoOpts 29:0:4 templates.
9  */
10 
11 /*
12  *  This file was produced by an AutoOpts template.  AutoOpts is a
13  *  copyrighted work.  This header file is not encumbered by AutoOpts
14  *  licensing, but is provided under the licensing terms chosen by the
15  *  ntpq author or copyright holder.  AutoOpts is licensed under
16  *  the terms of the LGPL.  The redistributable library (``libopts'') is
17  *  licensed under the terms of either the LGPL or, at the users discretion,
18  *  the BSD license.  See the AutoOpts and/or libopts sources for details.
19  *
20  * This source file is copyrighted and licensed under the following terms:
21  *
22  * ntpq copyright 1970-2009 David L. Mills and/or others - all rights reserved
23  *
24  * see html/copyright.html
25  */
26 /*
27  *  This file contains the programmatic interface to the Automated
28  *  Options generated for the ntpq program.
29  *  These macros are documented in the AutoGen info file in the
30  *  "AutoOpts" chapter.  Please refer to that doc for usage help.
31  */
32 #ifndef AUTOOPTS_NTPQ_OPTS_H_GUARD
33 #define AUTOOPTS_NTPQ_OPTS_H_GUARD
34 #include "config.h"
35 #include <autoopts/options.h>
36 
37 /*
38  *  Ensure that the library used for compiling this generated header is at
39  *  least as new as the version current when the header template was released
40  *  (not counting patch version increments).  Also ensure that the oldest
41  *  tolerable version is at least as old as what was current when the header
42  *  template was released.
43  */
44 #define AO_TEMPLATE_VERSION 118784
45 #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
46  || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
47 # error option template version mismatches autoopts/options.h header
48   Choke Me.
49 #endif
50 
51 /*
52  *  Enumeration of each option:
53  */
54 typedef enum {
55         INDEX_OPT_IPV4             =  0,
56         INDEX_OPT_IPV6             =  1,
57         INDEX_OPT_COMMAND          =  2,
58         INDEX_OPT_DEBUG_LEVEL      =  3,
59         INDEX_OPT_SET_DEBUG_LEVEL  =  4,
60         INDEX_OPT_PEERS            =  5,
61         INDEX_OPT_INTERACTIVE      =  6,
62         INDEX_OPT_NUMERIC          =  7,
63         INDEX_OPT_VERSION          = 8,
64         INDEX_OPT_HELP             = 9,
65         INDEX_OPT_MORE_HELP        = 10,
66         INDEX_OPT_SAVE_OPTS        = 11,
67         INDEX_OPT_LOAD_OPTS        = 12
68 } teOptIndex;
69 
70 #define OPTION_CT    13
71 #define NTPQ_VERSION       "4.2.4p8"
72 #define NTPQ_FULL_VERSION  "ntpq - standard NTP query program - Ver. 4.2.4p8"
73 
74 /*
75  *  Interface defines for all options.  Replace "n" with the UPPER_CASED
76  *  option name (as in the teOptIndex enumeration above).
77  *  e.g. HAVE_OPT( IPV4 )
78  */
79 #define         DESC(n) (ntpqOptions.pOptDesc[INDEX_OPT_## n])
80 #define     HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
81 #define      OPT_ARG(n) (DESC(n).optArg.argString)
82 #define    STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
83 #define    COUNT_OPT(n) (DESC(n).optOccCt)
84 #define    ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
85 #define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
86 #define  ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
87 #define  STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
88 #define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
89 #define    CLEAR_OPT(n) STMTS( \
90                 DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
91                 if ( (DESC(n).fOptState & OPTST_INITENABLED) == 0) \
92                     DESC(n).fOptState |= OPTST_DISABLED; \
93                 DESC(n).optCookie = NULL )
94 
95 /*
96  *  Make sure there are no #define name conflicts with the option names
97  */
98 #ifndef     NO_OPTION_NAME_WARNINGS
99 # ifdef    IPV4
100 #  warning undefining IPV4 due to option name conflict
101 #  undef   IPV4
102 # endif
103 # ifdef    IPV6
104 #  warning undefining IPV6 due to option name conflict
105 #  undef   IPV6
106 # endif
107 # ifdef    COMMAND
108 #  warning undefining COMMAND due to option name conflict
109 #  undef   COMMAND
110 # endif
111 # ifdef    DEBUG_LEVEL
112 #  warning undefining DEBUG_LEVEL due to option name conflict
113 #  undef   DEBUG_LEVEL
114 # endif
115 # ifdef    SET_DEBUG_LEVEL
116 #  warning undefining SET_DEBUG_LEVEL due to option name conflict
117 #  undef   SET_DEBUG_LEVEL
118 # endif
119 # ifdef    PEERS
120 #  warning undefining PEERS due to option name conflict
121 #  undef   PEERS
122 # endif
123 # ifdef    INTERACTIVE
124 #  warning undefining INTERACTIVE due to option name conflict
125 #  undef   INTERACTIVE
126 # endif
127 # ifdef    NUMERIC
128 #  warning undefining NUMERIC due to option name conflict
129 #  undef   NUMERIC
130 # endif
131 #else  /* NO_OPTION_NAME_WARNINGS */
132 # undef IPV4
133 # undef IPV6
134 # undef COMMAND
135 # undef DEBUG_LEVEL
136 # undef SET_DEBUG_LEVEL
137 # undef PEERS
138 # undef INTERACTIVE
139 # undef NUMERIC
140 #endif  /*  NO_OPTION_NAME_WARNINGS */
141 
142 /*
143  *  Interface defines for specific options.
144  */
145 #define VALUE_OPT_IPV4           '4'
146 #define WHICH_OPT_IPV4           (DESC(IPV4).optActualValue)
147 #define WHICH_IDX_IPV4           (DESC(IPV4).optActualIndex)
148 #define VALUE_OPT_IPV6           '6'
149 #define VALUE_OPT_COMMAND        'c'
150 #ifdef DEBUG
151 #define VALUE_OPT_DEBUG_LEVEL    'd'
152 #endif /* DEBUG */
153 #ifdef DEBUG
154 #define VALUE_OPT_SET_DEBUG_LEVEL 'D'
155 #endif /* DEBUG */
156 #define VALUE_OPT_PEERS          'p'
157 #define VALUE_OPT_INTERACTIVE    'i'
158 #define VALUE_OPT_NUMERIC        'n'
159 
160 #define VALUE_OPT_VERSION       'v'
161 #define VALUE_OPT_HELP          '?'
162 #define VALUE_OPT_MORE_HELP     '!'
163 #define VALUE_OPT_SAVE_OPTS     '>'
164 #define VALUE_OPT_LOAD_OPTS     '<'
165 #define SET_OPT_SAVE_OPTS(a)   STMTS( \
166         DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
167         DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
168         DESC(SAVE_OPTS).optArg.argString = (char const*)(a) )
169 /*
170  *  Interface defines not associated with particular options
171  */
172 #define ERRSKIP_OPTERR  STMTS( ntpqOptions.fOptSet &= ~OPTPROC_ERRSTOP )
173 #define ERRSTOP_OPTERR  STMTS( ntpqOptions.fOptSet |= OPTPROC_ERRSTOP )
174 #define RESTART_OPT(n)  STMTS( \
175                 ntpqOptions.curOptIdx = (n); \
176                 ntpqOptions.pzCurOpt  = NULL )
177 #define START_OPT       RESTART_OPT(1)
178 #define USAGE(c)        (*ntpqOptions.pUsageProc)( &ntpqOptions, c )
179 /* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/opthead.tpl near line 360 */
180 
181 /* * * * * *
182  *
183  *  Declare the ntpq option descriptor.
184  */
185 #ifdef  __cplusplus
186 extern "C" {
187 #endif
188 
189 extern tOptions   ntpqOptions;
190 
191 #ifndef _
192 #  if ENABLE_NLS
193 #    include <stdio.h>
194      static inline char* aoGetsText( char const* pz ) {
195          if (pz == NULL) return NULL;
196          return (char*)gettext( pz );
197      }
198 #    define _(s)  aoGetsText(s)
199 #  else  /* ENABLE_NLS */
200 #    define _(s)  s
201 #  endif /* ENABLE_NLS */
202 #endif
203 
204 #ifdef  __cplusplus
205 }
206 #endif
207 #endif /* AUTOOPTS_NTPQ_OPTS_H_GUARD */
208 /* ntpq-opts.h ends here */
209