1285612Sdelphij/*
2181834Sroberto *  EDIT THIS FILE WITH CAUTION  (ntpq-opts.h)
3285612Sdelphij *
4338531Sdelphij *  It has been AutoGen-ed  August 14, 2018 at 08:29:47 AM by AutoGen 5.18.5
5181834Sroberto *  From the definitions    ntpq-opts.def
6181834Sroberto *  and the template file   options
7181834Sroberto *
8285612Sdelphij * Generated from AutoOpts 41:0:16 templates.
9181834Sroberto *
10285612Sdelphij *  AutoOpts is a copyrighted work.  This header file is not encumbered
11285612Sdelphij *  by AutoOpts licensing, but is provided under the licensing terms chosen
12285612Sdelphij *  by the ntpq author or copyright holder.  AutoOpts is
13285612Sdelphij *  licensed under the terms of the LGPL.  The redistributable library
14285612Sdelphij *  (``libopts'') is licensed under the terms of either the LGPL or, at the
15285612Sdelphij *  users discretion, the BSD license.  See the AutoOpts and/or libopts sources
16285612Sdelphij *  for details.
17181834Sroberto *
18285612Sdelphij * The ntpq program is copyrighted and licensed
19285612Sdelphij * under the following terms:
20181834Sroberto *
21316069Sdelphij *  Copyright (C) 1992-2017 The University of Delaware and Network Time Foundation, all rights reserved.
22285612Sdelphij *  This is free software. It is licensed for use, modification and
23285612Sdelphij *  redistribution under the terms of the NTP License, copies of which
24285612Sdelphij *  can be seen at:
25285612Sdelphij *    <http://ntp.org/license>
26285612Sdelphij *    <http://opensource.org/licenses/ntp-license.php>
27285612Sdelphij *
28285612Sdelphij *  Permission to use, copy, modify, and distribute this software and its
29285612Sdelphij *  documentation for any purpose with or without fee is hereby granted,
30285612Sdelphij *  provided that the above copyright notice appears in all copies and that
31285612Sdelphij *  both the copyright notice and this permission notice appear in
32285612Sdelphij *  supporting documentation, and that the name The University of Delaware not be used in
33285612Sdelphij *  advertising or publicity pertaining to distribution of the software
34285612Sdelphij *  without specific, written prior permission. The University of Delaware and Network Time Foundation makes no
35285612Sdelphij *  representations about the suitability this software for any purpose. It
36285612Sdelphij *  is provided "as is" without express or implied warranty.
37181834Sroberto */
38285612Sdelphij/**
39181834Sroberto *  This file contains the programmatic interface to the Automated
40181834Sroberto *  Options generated for the ntpq program.
41181834Sroberto *  These macros are documented in the AutoGen info file in the
42181834Sroberto *  "AutoOpts" chapter.  Please refer to that doc for usage help.
43181834Sroberto */
44181834Sroberto#ifndef AUTOOPTS_NTPQ_OPTS_H_GUARD
45285612Sdelphij#define AUTOOPTS_NTPQ_OPTS_H_GUARD 1
46181834Sroberto#include "config.h"
47181834Sroberto#include <autoopts/options.h>
48181834Sroberto
49285612Sdelphij/**
50181834Sroberto *  Ensure that the library used for compiling this generated header is at
51181834Sroberto *  least as new as the version current when the header template was released
52181834Sroberto *  (not counting patch version increments).  Also ensure that the oldest
53181834Sroberto *  tolerable version is at least as old as what was current when the header
54181834Sroberto *  template was released.
55181834Sroberto */
56285612Sdelphij#define AO_TEMPLATE_VERSION 167936
57181834Sroberto#if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
58181834Sroberto || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
59181834Sroberto# error option template version mismatches autoopts/options.h header
60181834Sroberto  Choke Me.
61181834Sroberto#endif
62181834Sroberto
63285612Sdelphij/**
64285612Sdelphij *  Enumeration of each option type for ntpq
65181834Sroberto */
66181834Srobertotypedef enum {
67285612Sdelphij    INDEX_OPT_IPV4             =  0,
68285612Sdelphij    INDEX_OPT_IPV6             =  1,
69285612Sdelphij    INDEX_OPT_COMMAND          =  2,
70285612Sdelphij    INDEX_OPT_DEBUG_LEVEL      =  3,
71285612Sdelphij    INDEX_OPT_SET_DEBUG_LEVEL  =  4,
72285612Sdelphij    INDEX_OPT_INTERACTIVE      =  5,
73285612Sdelphij    INDEX_OPT_NUMERIC          =  6,
74285612Sdelphij    INDEX_OPT_OLD_RV           =  7,
75285612Sdelphij    INDEX_OPT_PEERS            =  8,
76298699Sdelphij    INDEX_OPT_REFID            =  9,
77298699Sdelphij    INDEX_OPT_WIDE             = 10,
78298699Sdelphij    INDEX_OPT_VERSION          = 11,
79298699Sdelphij    INDEX_OPT_HELP             = 12,
80298699Sdelphij    INDEX_OPT_MORE_HELP        = 13,
81298699Sdelphij    INDEX_OPT_SAVE_OPTS        = 14,
82298699Sdelphij    INDEX_OPT_LOAD_OPTS        = 15
83181834Sroberto} teOptIndex;
84285612Sdelphij/** count of all options for ntpq */
85298699Sdelphij#define OPTION_CT    16
86285612Sdelphij/** ntpq version */
87338531Sdelphij#define NTPQ_VERSION       "4.2.8p12"
88285612Sdelphij/** Full ntpq version text */
89338531Sdelphij#define NTPQ_FULL_VERSION  "ntpq 4.2.8p12"
90181834Sroberto
91285612Sdelphij/**
92181834Sroberto *  Interface defines for all options.  Replace "n" with the UPPER_CASED
93181834Sroberto *  option name (as in the teOptIndex enumeration above).
94285612Sdelphij *  e.g. HAVE_OPT(IPV4)
95181834Sroberto */
96181834Sroberto#define         DESC(n) (ntpqOptions.pOptDesc[INDEX_OPT_## n])
97285612Sdelphij/** 'true' if an option has been specified in any way */
98181834Sroberto#define     HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
99285612Sdelphij/** The string argument to an option. The argument type must be \"string\". */
100181834Sroberto#define      OPT_ARG(n) (DESC(n).optArg.argString)
101285612Sdelphij/** Mask the option state revealing how an option was specified.
102285612Sdelphij *  It will be one and only one of \a OPTST_SET, \a OPTST_PRESET,
103285612Sdelphij * \a OPTST_DEFINED, \a OPTST_RESET or zero.
104285612Sdelphij */
105181834Sroberto#define    STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
106285612Sdelphij/** Count of option's occurrances *on the command line*. */
107181834Sroberto#define    COUNT_OPT(n) (DESC(n).optOccCt)
108285612Sdelphij/** mask of \a OPTST_SET and \a OPTST_DEFINED. */
109181834Sroberto#define    ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
110285612Sdelphij/** 'true' if \a HAVE_OPT would yield 'false'. */
111181834Sroberto#define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
112285612Sdelphij/** 'true' if OPTST_DISABLED bit not set. */
113181834Sroberto#define  ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
114285612Sdelphij/** number of stacked option arguments.
115285612Sdelphij *  Valid only for stacked option arguments. */
116181834Sroberto#define  STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
117285612Sdelphij/** stacked argument vector.
118285612Sdelphij *  Valid only for stacked option arguments. */
119181834Sroberto#define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
120285612Sdelphij/** Reset an option. */
121181834Sroberto#define    CLEAR_OPT(n) STMTS( \
122181834Sroberto                DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
123285612Sdelphij                if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \
124181834Sroberto                    DESC(n).fOptState |= OPTST_DISABLED; \
125181834Sroberto                DESC(n).optCookie = NULL )
126285612Sdelphij/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
127285612Sdelphij/**
128285612Sdelphij *  Enumeration of ntpq exit codes
129285612Sdelphij */
130285612Sdelphijtypedef enum {
131285612Sdelphij    NTPQ_EXIT_SUCCESS         = 0,
132285612Sdelphij    NTPQ_EXIT_FAILURE         = 1,
133285612Sdelphij    NTPQ_EXIT_USAGE_ERROR     = 64,
134285612Sdelphij    NTPQ_EXIT_NO_CONFIG_INPUT = 66,
135285612Sdelphij    NTPQ_EXIT_LIBOPTS_FAILURE = 70
136285612Sdelphij}   ntpq_exit_code_t;
137285612Sdelphij/** @} */
138285612Sdelphij/**
139181834Sroberto *  Make sure there are no #define name conflicts with the option names
140181834Sroberto */
141181834Sroberto#ifndef     NO_OPTION_NAME_WARNINGS
142181834Sroberto# ifdef    IPV4
143181834Sroberto#  warning undefining IPV4 due to option name conflict
144181834Sroberto#  undef   IPV4
145181834Sroberto# endif
146181834Sroberto# ifdef    IPV6
147181834Sroberto#  warning undefining IPV6 due to option name conflict
148181834Sroberto#  undef   IPV6
149181834Sroberto# endif
150181834Sroberto# ifdef    COMMAND
151181834Sroberto#  warning undefining COMMAND due to option name conflict
152181834Sroberto#  undef   COMMAND
153181834Sroberto# endif
154181834Sroberto# ifdef    DEBUG_LEVEL
155181834Sroberto#  warning undefining DEBUG_LEVEL due to option name conflict
156181834Sroberto#  undef   DEBUG_LEVEL
157181834Sroberto# endif
158181834Sroberto# ifdef    SET_DEBUG_LEVEL
159181834Sroberto#  warning undefining SET_DEBUG_LEVEL due to option name conflict
160181834Sroberto#  undef   SET_DEBUG_LEVEL
161181834Sroberto# endif
162181834Sroberto# ifdef    INTERACTIVE
163181834Sroberto#  warning undefining INTERACTIVE due to option name conflict
164181834Sroberto#  undef   INTERACTIVE
165181834Sroberto# endif
166181834Sroberto# ifdef    NUMERIC
167181834Sroberto#  warning undefining NUMERIC due to option name conflict
168181834Sroberto#  undef   NUMERIC
169181834Sroberto# endif
170285612Sdelphij# ifdef    OLD_RV
171285612Sdelphij#  warning undefining OLD_RV due to option name conflict
172285612Sdelphij#  undef   OLD_RV
173285612Sdelphij# endif
174285612Sdelphij# ifdef    PEERS
175285612Sdelphij#  warning undefining PEERS due to option name conflict
176285612Sdelphij#  undef   PEERS
177285612Sdelphij# endif
178298699Sdelphij# ifdef    REFID
179298699Sdelphij#  warning undefining REFID due to option name conflict
180298699Sdelphij#  undef   REFID
181298699Sdelphij# endif
182285612Sdelphij# ifdef    WIDE
183285612Sdelphij#  warning undefining WIDE due to option name conflict
184285612Sdelphij#  undef   WIDE
185285612Sdelphij# endif
186181834Sroberto#else  /* NO_OPTION_NAME_WARNINGS */
187181834Sroberto# undef IPV4
188181834Sroberto# undef IPV6
189181834Sroberto# undef COMMAND
190181834Sroberto# undef DEBUG_LEVEL
191181834Sroberto# undef SET_DEBUG_LEVEL
192181834Sroberto# undef INTERACTIVE
193181834Sroberto# undef NUMERIC
194285612Sdelphij# undef OLD_RV
195285612Sdelphij# undef PEERS
196298699Sdelphij# undef REFID
197285612Sdelphij# undef WIDE
198181834Sroberto#endif  /*  NO_OPTION_NAME_WARNINGS */
199181834Sroberto
200285612Sdelphij/**
201181834Sroberto *  Interface defines for specific options.
202285612Sdelphij * @{
203181834Sroberto */
204181834Sroberto#define VALUE_OPT_IPV4           '4'
205181834Sroberto#define VALUE_OPT_IPV6           '6'
206181834Sroberto#define VALUE_OPT_COMMAND        'c'
207181834Sroberto#define VALUE_OPT_DEBUG_LEVEL    'd'
208181834Sroberto#define VALUE_OPT_SET_DEBUG_LEVEL 'D'
209285612Sdelphij
210285612Sdelphij#define OPT_VALUE_SET_DEBUG_LEVEL (DESC(SET_DEBUG_LEVEL).optArg.argInt)
211181834Sroberto#define VALUE_OPT_INTERACTIVE    'i'
212181834Sroberto#define VALUE_OPT_NUMERIC        'n'
213285612Sdelphij#define VALUE_OPT_OLD_RV         0x1001
214285612Sdelphij#define VALUE_OPT_PEERS          'p'
215298699Sdelphij#define VALUE_OPT_REFID          'r'
216298699Sdelphij
217298699Sdelphijtypedef enum {
218298699Sdelphij    REFID_HASH, REFID_IPV4
219298699Sdelphij} te_Refid;
220298699Sdelphij#define OPT_REFID_VAL2STR(_v)    optionKeywordName(&DESC(REFID), (_v))
221298699Sdelphij#define OPT_VALUE_REFID          (DESC(REFID).optArg.argEnum)
222285612Sdelphij#define VALUE_OPT_WIDE           'w'
223285612Sdelphij/** option flag (value) for help-value option */
224181834Sroberto#define VALUE_OPT_HELP          '?'
225285612Sdelphij/** option flag (value) for more-help-value option */
226181834Sroberto#define VALUE_OPT_MORE_HELP     '!'
227285612Sdelphij/** option flag (value) for version-value option */
228285612Sdelphij#define VALUE_OPT_VERSION       0x1002
229285612Sdelphij/** option flag (value) for save-opts-value option */
230181834Sroberto#define VALUE_OPT_SAVE_OPTS     '>'
231285612Sdelphij/** option flag (value) for load-opts-value option */
232181834Sroberto#define VALUE_OPT_LOAD_OPTS     '<'
233181834Sroberto#define SET_OPT_SAVE_OPTS(a)   STMTS( \
234181834Sroberto        DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
235181834Sroberto        DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
236285612Sdelphij        DESC(SAVE_OPTS).optArg.argString = (char const*)(a))
237181834Sroberto/*
238181834Sroberto *  Interface defines not associated with particular options
239181834Sroberto */
240285612Sdelphij#define ERRSKIP_OPTERR  STMTS(ntpqOptions.fOptSet &= ~OPTPROC_ERRSTOP)
241285612Sdelphij#define ERRSTOP_OPTERR  STMTS(ntpqOptions.fOptSet |= OPTPROC_ERRSTOP)
242181834Sroberto#define RESTART_OPT(n)  STMTS( \
243181834Sroberto                ntpqOptions.curOptIdx = (n); \
244181834Sroberto                ntpqOptions.pzCurOpt  = NULL )
245181834Sroberto#define START_OPT       RESTART_OPT(1)
246285612Sdelphij#define USAGE(c)        (*ntpqOptions.pUsageProc)(&ntpqOptions, c)
247181834Sroberto
248285612Sdelphij#ifdef  __cplusplus
249285612Sdelphijextern "C" {
250285612Sdelphij#endif
251285612Sdelphij
252285612Sdelphij
253181834Sroberto/* * * * * *
254181834Sroberto *
255181834Sroberto *  Declare the ntpq option descriptor.
256181834Sroberto */
257285612Sdelphijextern tOptions ntpqOptions;
258181834Sroberto
259285612Sdelphij#if defined(ENABLE_NLS)
260285612Sdelphij# ifndef _
261285612Sdelphij#   include <stdio.h>
262285612Sdelphij#   ifndef HAVE_GETTEXT
263285612Sdelphij      extern char * gettext(char const *);
264285612Sdelphij#   else
265285612Sdelphij#     include <libintl.h>
266285612Sdelphij#   endif
267181834Sroberto
268285612Sdelphij# ifndef ATTRIBUTE_FORMAT_ARG
269285612Sdelphij#   define ATTRIBUTE_FORMAT_ARG(_a)
270285612Sdelphij# endif
271181834Sroberto
272285612Sdelphijstatic inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1);
273285612Sdelphijstatic inline char* aoGetsText(char const* pz) {
274285612Sdelphij    if (pz == NULL) return NULL;
275285612Sdelphij    return (char*)gettext(pz);
276285612Sdelphij}
277285612Sdelphij#   define _(s)  aoGetsText(s)
278285612Sdelphij# endif /* _() */
279285612Sdelphij
280285612Sdelphij# define OPT_NO_XLAT_CFG_NAMES  STMTS(ntpqOptions.fOptSet |= \
281285612Sdelphij                                    OPTPROC_NXLAT_OPT_CFG;)
282285612Sdelphij# define OPT_NO_XLAT_OPT_NAMES  STMTS(ntpqOptions.fOptSet |= \
283285612Sdelphij                                    OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
284285612Sdelphij
285285612Sdelphij# define OPT_XLAT_CFG_NAMES     STMTS(ntpqOptions.fOptSet &= \
286285612Sdelphij                                  ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
287285612Sdelphij# define OPT_XLAT_OPT_NAMES     STMTS(ntpqOptions.fOptSet &= \
288285612Sdelphij                                  ~OPTPROC_NXLAT_OPT;)
289285612Sdelphij
290285612Sdelphij#else   /* ENABLE_NLS */
291285612Sdelphij# define OPT_NO_XLAT_CFG_NAMES
292285612Sdelphij# define OPT_NO_XLAT_OPT_NAMES
293285612Sdelphij
294285612Sdelphij# define OPT_XLAT_CFG_NAMES
295285612Sdelphij# define OPT_XLAT_OPT_NAMES
296285612Sdelphij
297285612Sdelphij# ifndef _
298285612Sdelphij#   define _(_s)  _s
299285612Sdelphij# endif
300285612Sdelphij#endif  /* ENABLE_NLS */
301285612Sdelphij
302181834Sroberto#ifdef  __cplusplus
303181834Sroberto}
304181834Sroberto#endif
305181834Sroberto#endif /* AUTOOPTS_NTPQ_OPTS_H_GUARD */
306285612Sdelphij
307181834Sroberto/* ntpq-opts.h ends here */
308