ntpq-opts.h revision 301301
1133391Sharti/*
2133391Sharti *  EDIT THIS FILE WITH CAUTION  (ntpq-opts.h)
3133391Sharti *
4133391Sharti *  It has been AutoGen-ed  June  2, 2016 at 07:37:04 AM by AutoGen 5.18.5
5133391Sharti *  From the definitions    ntpq-opts.def
6133391Sharti *  and the template file   options
7133391Sharti *
8133391Sharti * Generated from AutoOpts 41:0:16 templates.
9133391Sharti *
10133391Sharti *  AutoOpts is a copyrighted work.  This header file is not encumbered
11133391Sharti *  by AutoOpts licensing, but is provided under the licensing terms chosen
12133391Sharti *  by the ntpq author or copyright holder.  AutoOpts is
13133391Sharti *  licensed under the terms of the LGPL.  The redistributable library
14133391Sharti *  (``libopts'') is licensed under the terms of either the LGPL or, at the
15133391Sharti *  users discretion, the BSD license.  See the AutoOpts and/or libopts sources
16133391Sharti *  for details.
17133391Sharti *
18133391Sharti * The ntpq program is copyrighted and licensed
19133391Sharti * under the following terms:
20133391Sharti *
21133391Sharti *  Copyright (C) 1992-2016 The University of Delaware and Network Time Foundation, all rights reserved.
22133391Sharti *  This is free software. It is licensed for use, modification and
23133391Sharti *  redistribution under the terms of the NTP License, copies of which
24133391Sharti *  can be seen at:
25133391Sharti *    <http://ntp.org/license>
26133391Sharti *    <http://opensource.org/licenses/ntp-license.php>
27133391Sharti *
28133391Sharti *  Permission to use, copy, modify, and distribute this software and its
29133391Sharti *  documentation for any purpose with or without fee is hereby granted,
30133391Sharti *  provided that the above copyright notice appears in all copies and that
31133391Sharti *  both the copyright notice and this permission notice appear in
32133391Sharti *  supporting documentation, and that the name The University of Delaware not be used in
33133391Sharti *  advertising or publicity pertaining to distribution of the software
34133391Sharti *  without specific, written prior permission. The University of Delaware and Network Time Foundation makes no
35133391Sharti *  representations about the suitability this software for any purpose. It
36133391Sharti *  is provided "as is" without express or implied warranty.
37133391Sharti */
38133391Sharti/**
39133391Sharti *  This file contains the programmatic interface to the Automated
40133391Sharti *  Options generated for the ntpq program.
41133391Sharti *  These macros are documented in the AutoGen info file in the
42133391Sharti *  "AutoOpts" chapter.  Please refer to that doc for usage help.
43133391Sharti */
44133391Sharti#ifndef AUTOOPTS_NTPQ_OPTS_H_GUARD
45133391Sharti#define AUTOOPTS_NTPQ_OPTS_H_GUARD 1
46133391Sharti#include "config.h"
47133391Sharti#include <autoopts/options.h>
48133391Sharti
49133391Sharti/**
50133391Sharti *  Ensure that the library used for compiling this generated header is at
51133391Sharti *  least as new as the version current when the header template was released
52133391Sharti *  (not counting patch version increments).  Also ensure that the oldest
53133391Sharti *  tolerable version is at least as old as what was current when the header
54133391Sharti *  template was released.
55133391Sharti */
56133391Sharti#define AO_TEMPLATE_VERSION 167936
57133391Sharti#if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
58133391Sharti || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
59133391Sharti# error option template version mismatches autoopts/options.h header
60133391Sharti  Choke Me.
61133391Sharti#endif
62133391Sharti
63133391Sharti/**
64133391Sharti *  Enumeration of each option type for ntpq
65133391Sharti */
66133391Shartitypedef enum {
67133391Sharti    INDEX_OPT_IPV4             =  0,
68133391Sharti    INDEX_OPT_IPV6             =  1,
69133391Sharti    INDEX_OPT_COMMAND          =  2,
70133391Sharti    INDEX_OPT_DEBUG_LEVEL      =  3,
71133391Sharti    INDEX_OPT_SET_DEBUG_LEVEL  =  4,
72133391Sharti    INDEX_OPT_INTERACTIVE      =  5,
73133391Sharti    INDEX_OPT_NUMERIC          =  6,
74133391Sharti    INDEX_OPT_OLD_RV           =  7,
75133391Sharti    INDEX_OPT_PEERS            =  8,
76133391Sharti    INDEX_OPT_REFID            =  9,
77133391Sharti    INDEX_OPT_WIDE             = 10,
78133391Sharti    INDEX_OPT_VERSION          = 11,
79133391Sharti    INDEX_OPT_HELP             = 12,
80133391Sharti    INDEX_OPT_MORE_HELP        = 13,
81133391Sharti    INDEX_OPT_SAVE_OPTS        = 14,
82133391Sharti    INDEX_OPT_LOAD_OPTS        = 15
83133391Sharti} teOptIndex;
84133391Sharti/** count of all options for ntpq */
85133391Sharti#define OPTION_CT    16
86133391Sharti/** ntpq version */
87133391Sharti#define NTPQ_VERSION       "4.2.8p8"
88133391Sharti/** Full ntpq version text */
89133391Sharti#define NTPQ_FULL_VERSION  "ntpq 4.2.8p8"
90133391Sharti
91133391Sharti/**
92133391Sharti *  Interface defines for all options.  Replace "n" with the UPPER_CASED
93133391Sharti *  option name (as in the teOptIndex enumeration above).
94133391Sharti *  e.g. HAVE_OPT(IPV4)
95133391Sharti */
96133391Sharti#define         DESC(n) (ntpqOptions.pOptDesc[INDEX_OPT_## n])
97133391Sharti/** 'true' if an option has been specified in any way */
98133391Sharti#define     HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
99133391Sharti/** The string argument to an option. The argument type must be \"string\". */
100133391Sharti#define      OPT_ARG(n) (DESC(n).optArg.argString)
101133391Sharti/** Mask the option state revealing how an option was specified.
102133391Sharti *  It will be one and only one of \a OPTST_SET, \a OPTST_PRESET,
103133391Sharti * \a OPTST_DEFINED, \a OPTST_RESET or zero.
104133391Sharti */
105133391Sharti#define    STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
106133391Sharti/** Count of option's occurrances *on the command line*. */
107133391Sharti#define    COUNT_OPT(n) (DESC(n).optOccCt)
108133391Sharti/** mask of \a OPTST_SET and \a OPTST_DEFINED. */
109133391Sharti#define    ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
110133391Sharti/** 'true' if \a HAVE_OPT would yield 'false'. */
111133391Sharti#define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
112133391Sharti/** 'true' if OPTST_DISABLED bit not set. */
113133391Sharti#define  ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
114133391Sharti/** number of stacked option arguments.
115133391Sharti *  Valid only for stacked option arguments. */
116133391Sharti#define  STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
117133391Sharti/** stacked argument vector.
118133391Sharti *  Valid only for stacked option arguments. */
119133391Sharti#define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
120133391Sharti/** Reset an option. */
121133391Sharti#define    CLEAR_OPT(n) STMTS( \
122133391Sharti                DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
123133391Sharti                if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \
124133391Sharti                    DESC(n).fOptState |= OPTST_DISABLED; \
125133391Sharti                DESC(n).optCookie = NULL )
126133391Sharti/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
127133391Sharti/**
128133391Sharti *  Enumeration of ntpq exit codes
129133391Sharti */
130133391Shartitypedef enum {
131133391Sharti    NTPQ_EXIT_SUCCESS         = 0,
132133391Sharti    NTPQ_EXIT_FAILURE         = 1,
133133391Sharti    NTPQ_EXIT_USAGE_ERROR     = 64,
134133391Sharti    NTPQ_EXIT_NO_CONFIG_INPUT = 66,
135133391Sharti    NTPQ_EXIT_LIBOPTS_FAILURE = 70
136133391Sharti}   ntpq_exit_code_t;
137133391Sharti/** @} */
138133391Sharti/**
139133391Sharti *  Make sure there are no #define name conflicts with the option names
140133391Sharti */
141133391Sharti#ifndef     NO_OPTION_NAME_WARNINGS
142133391Sharti# ifdef    IPV4
143133391Sharti#  warning undefining IPV4 due to option name conflict
144133391Sharti#  undef   IPV4
145133391Sharti# endif
146133391Sharti# ifdef    IPV6
147133391Sharti#  warning undefining IPV6 due to option name conflict
148133391Sharti#  undef   IPV6
149133391Sharti# endif
150133391Sharti# ifdef    COMMAND
151133391Sharti#  warning undefining COMMAND due to option name conflict
152133391Sharti#  undef   COMMAND
153133391Sharti# endif
154133391Sharti# ifdef    DEBUG_LEVEL
155133391Sharti#  warning undefining DEBUG_LEVEL due to option name conflict
156133391Sharti#  undef   DEBUG_LEVEL
157133391Sharti# endif
158133391Sharti# ifdef    SET_DEBUG_LEVEL
159133391Sharti#  warning undefining SET_DEBUG_LEVEL due to option name conflict
160133391Sharti#  undef   SET_DEBUG_LEVEL
161133391Sharti# endif
162133391Sharti# ifdef    INTERACTIVE
163133391Sharti#  warning undefining INTERACTIVE due to option name conflict
164133391Sharti#  undef   INTERACTIVE
165133391Sharti# endif
166133391Sharti# ifdef    NUMERIC
167133391Sharti#  warning undefining NUMERIC due to option name conflict
168133391Sharti#  undef   NUMERIC
169133391Sharti# endif
170133391Sharti# ifdef    OLD_RV
171133391Sharti#  warning undefining OLD_RV due to option name conflict
172133391Sharti#  undef   OLD_RV
173133391Sharti# endif
174133391Sharti# ifdef    PEERS
175133391Sharti#  warning undefining PEERS due to option name conflict
176133391Sharti#  undef   PEERS
177133391Sharti# endif
178133391Sharti# ifdef    REFID
179133391Sharti#  warning undefining REFID due to option name conflict
180133391Sharti#  undef   REFID
181133391Sharti# endif
182133391Sharti# ifdef    WIDE
183133391Sharti#  warning undefining WIDE due to option name conflict
184133391Sharti#  undef   WIDE
185133391Sharti# endif
186133391Sharti#else  /* NO_OPTION_NAME_WARNINGS */
187133391Sharti# undef IPV4
188133391Sharti# undef IPV6
189133391Sharti# undef COMMAND
190133391Sharti# undef DEBUG_LEVEL
191133391Sharti# undef SET_DEBUG_LEVEL
192133391Sharti# undef INTERACTIVE
193133391Sharti# undef NUMERIC
194133391Sharti# undef OLD_RV
195133391Sharti# undef PEERS
196133391Sharti# undef REFID
197133391Sharti# undef WIDE
198133391Sharti#endif  /*  NO_OPTION_NAME_WARNINGS */
199133391Sharti
200133391Sharti/**
201133391Sharti *  Interface defines for specific options.
202133391Sharti * @{
203133391Sharti */
204133391Sharti#define VALUE_OPT_IPV4           '4'
205133391Sharti#define VALUE_OPT_IPV6           '6'
206133391Sharti#define VALUE_OPT_COMMAND        'c'
207133391Sharti#define VALUE_OPT_DEBUG_LEVEL    'd'
208133391Sharti#define VALUE_OPT_SET_DEBUG_LEVEL 'D'
209133391Sharti
210133391Sharti#define OPT_VALUE_SET_DEBUG_LEVEL (DESC(SET_DEBUG_LEVEL).optArg.argInt)
211133391Sharti#define VALUE_OPT_INTERACTIVE    'i'
212133391Sharti#define VALUE_OPT_NUMERIC        'n'
213133391Sharti#define VALUE_OPT_OLD_RV         0x1001
214133391Sharti#define VALUE_OPT_PEERS          'p'
215133391Sharti#define VALUE_OPT_REFID          'r'
216133391Sharti
217133391Shartitypedef enum {
218133391Sharti    REFID_HASH, REFID_IPV4
219133391Sharti} te_Refid;
220133391Sharti#define OPT_REFID_VAL2STR(_v)    optionKeywordName(&DESC(REFID), (_v))
221133391Sharti#define OPT_VALUE_REFID          (DESC(REFID).optArg.argEnum)
222133391Sharti#define VALUE_OPT_WIDE           'w'
223133391Sharti/** option flag (value) for help-value option */
224133391Sharti#define VALUE_OPT_HELP          '?'
225133391Sharti/** option flag (value) for more-help-value option */
226133391Sharti#define VALUE_OPT_MORE_HELP     '!'
227133391Sharti/** option flag (value) for version-value option */
228133391Sharti#define VALUE_OPT_VERSION       0x1002
229133391Sharti/** option flag (value) for save-opts-value option */
230133391Sharti#define VALUE_OPT_SAVE_OPTS     '>'
231133391Sharti/** option flag (value) for load-opts-value option */
232133391Sharti#define VALUE_OPT_LOAD_OPTS     '<'
233133391Sharti#define SET_OPT_SAVE_OPTS(a)   STMTS( \
234133391Sharti        DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
235133391Sharti        DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
236133391Sharti        DESC(SAVE_OPTS).optArg.argString = (char const*)(a))
237133391Sharti/*
238133391Sharti *  Interface defines not associated with particular options
239133391Sharti */
240133391Sharti#define ERRSKIP_OPTERR  STMTS(ntpqOptions.fOptSet &= ~OPTPROC_ERRSTOP)
241133391Sharti#define ERRSTOP_OPTERR  STMTS(ntpqOptions.fOptSet |= OPTPROC_ERRSTOP)
242133391Sharti#define RESTART_OPT(n)  STMTS( \
243133391Sharti                ntpqOptions.curOptIdx = (n); \
244133391Sharti                ntpqOptions.pzCurOpt  = NULL )
245133391Sharti#define START_OPT       RESTART_OPT(1)
246133391Sharti#define USAGE(c)        (*ntpqOptions.pUsageProc)(&ntpqOptions, c)
247133391Sharti
248133391Sharti#ifdef  __cplusplus
249133391Shartiextern "C" {
250133391Sharti#endif
251133391Sharti
252133391Sharti
253133391Sharti/* * * * * *
254133391Sharti *
255133391Sharti *  Declare the ntpq option descriptor.
256133391Sharti */
257133391Shartiextern tOptions ntpqOptions;
258133391Sharti
259133391Sharti#if defined(ENABLE_NLS)
260133391Sharti# ifndef _
261133391Sharti#   include <stdio.h>
262133391Sharti#   ifndef HAVE_GETTEXT
263133391Sharti      extern char * gettext(char const *);
264133391Sharti#   else
265133391Sharti#     include <libintl.h>
266133391Sharti#   endif
267133391Sharti
268133391Sharti# ifndef ATTRIBUTE_FORMAT_ARG
269133391Sharti#   define ATTRIBUTE_FORMAT_ARG(_a)
270133391Sharti# endif
271133391Sharti
272133391Shartistatic inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1);
273133391Shartistatic inline char* aoGetsText(char const* pz) {
274133391Sharti    if (pz == NULL) return NULL;
275133391Sharti    return (char*)gettext(pz);
276133391Sharti}
277133391Sharti#   define _(s)  aoGetsText(s)
278133391Sharti# endif /* _() */
279133391Sharti
280133391Sharti# define OPT_NO_XLAT_CFG_NAMES  STMTS(ntpqOptions.fOptSet |= \
281133391Sharti                                    OPTPROC_NXLAT_OPT_CFG;)
282133391Sharti# define OPT_NO_XLAT_OPT_NAMES  STMTS(ntpqOptions.fOptSet |= \
283133391Sharti                                    OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
284133391Sharti
285133391Sharti# define OPT_XLAT_CFG_NAMES     STMTS(ntpqOptions.fOptSet &= \
286133391Sharti                                  ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
287133391Sharti# define OPT_XLAT_OPT_NAMES     STMTS(ntpqOptions.fOptSet &= \
288133391Sharti                                  ~OPTPROC_NXLAT_OPT;)
289133391Sharti
290133391Sharti#else   /* ENABLE_NLS */
291133391Sharti# define OPT_NO_XLAT_CFG_NAMES
292133391Sharti# define OPT_NO_XLAT_OPT_NAMES
293133391Sharti
294133391Sharti# define OPT_XLAT_CFG_NAMES
295133391Sharti# define OPT_XLAT_OPT_NAMES
296133391Sharti
297133391Sharti# ifndef _
298133391Sharti#   define _(_s)  _s
299133391Sharti# endif
300133391Sharti#endif  /* ENABLE_NLS */
301133391Sharti
302#ifdef  __cplusplus
303}
304#endif
305#endif /* AUTOOPTS_NTPQ_OPTS_H_GUARD */
306
307/* ntpq-opts.h ends here */
308