ntpq-opts.h revision 309008
1238104Sdes/*
2238104Sdes *  EDIT THIS FILE WITH CAUTION  (ntpq-opts.h)
3238104Sdes *
4238104Sdes *  It has been AutoGen-ed  November 21, 2016 at 08:02:38 AM by AutoGen 5.18.5
5238104Sdes *  From the definitions    ntpq-opts.def
6238104Sdes *  and the template file   options
7238104Sdes *
8238104Sdes * Generated from AutoOpts 41:0:16 templates.
9238104Sdes *
10238104Sdes *  AutoOpts is a copyrighted work.  This header file is not encumbered
11238104Sdes *  by AutoOpts licensing, but is provided under the licensing terms chosen
12238104Sdes *  by the ntpq author or copyright holder.  AutoOpts is
13238104Sdes *  licensed under the terms of the LGPL.  The redistributable library
14238104Sdes *  (``libopts'') is licensed under the terms of either the LGPL or, at the
15238104Sdes *  users discretion, the BSD license.  See the AutoOpts and/or libopts sources
16238104Sdes *  for details.
17238104Sdes *
18238104Sdes * The ntpq program is copyrighted and licensed
19238104Sdes * under the following terms:
20238104Sdes *
21238104Sdes *  Copyright (C) 1992-2016 The University of Delaware and Network Time Foundation, all rights reserved.
22238104Sdes *  This is free software. It is licensed for use, modification and
23238104Sdes *  redistribution under the terms of the NTP License, copies of which
24238104Sdes *  can be seen at:
25238104Sdes *    <http://ntp.org/license>
26238104Sdes *    <http://opensource.org/licenses/ntp-license.php>
27238104Sdes *
28238104Sdes *  Permission to use, copy, modify, and distribute this software and its
29238104Sdes *  documentation for any purpose with or without fee is hereby granted,
30238104Sdes *  provided that the above copyright notice appears in all copies and that
31238104Sdes *  both the copyright notice and this permission notice appear in
32238104Sdes *  supporting documentation, and that the name The University of Delaware not be used in
33238104Sdes *  advertising or publicity pertaining to distribution of the software
34238104Sdes *  without specific, written prior permission. The University of Delaware and Network Time Foundation makes no
35238104Sdes *  representations about the suitability this software for any purpose. It
36238104Sdes *  is provided "as is" without express or implied warranty.
37238104Sdes */
38238104Sdes/**
39238104Sdes *  This file contains the programmatic interface to the Automated
40238104Sdes *  Options generated for the ntpq program.
41238104Sdes *  These macros are documented in the AutoGen info file in the
42238104Sdes *  "AutoOpts" chapter.  Please refer to that doc for usage help.
43238104Sdes */
44238104Sdes#ifndef AUTOOPTS_NTPQ_OPTS_H_GUARD
45238104Sdes#define AUTOOPTS_NTPQ_OPTS_H_GUARD 1
46238104Sdes#include "config.h"
47238104Sdes#include <autoopts/options.h>
48238104Sdes
49238104Sdes/**
50238104Sdes *  Ensure that the library used for compiling this generated header is at
51238104Sdes *  least as new as the version current when the header template was released
52238104Sdes *  (not counting patch version increments).  Also ensure that the oldest
53238104Sdes *  tolerable version is at least as old as what was current when the header
54238104Sdes *  template was released.
55238104Sdes */
56238104Sdes#define AO_TEMPLATE_VERSION 167936
57238104Sdes#if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
58238104Sdes || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
59238104Sdes# error option template version mismatches autoopts/options.h header
60238104Sdes  Choke Me.
61238104Sdes#endif
62238104Sdes
63238104Sdes/**
64238104Sdes *  Enumeration of each option type for ntpq
65238104Sdes */
66238104Sdestypedef enum {
67238104Sdes    INDEX_OPT_IPV4             =  0,
68238104Sdes    INDEX_OPT_IPV6             =  1,
69238104Sdes    INDEX_OPT_COMMAND          =  2,
70238104Sdes    INDEX_OPT_DEBUG_LEVEL      =  3,
71238104Sdes    INDEX_OPT_SET_DEBUG_LEVEL  =  4,
72238104Sdes    INDEX_OPT_INTERACTIVE      =  5,
73238104Sdes    INDEX_OPT_NUMERIC          =  6,
74238104Sdes    INDEX_OPT_OLD_RV           =  7,
75238104Sdes    INDEX_OPT_PEERS            =  8,
76238104Sdes    INDEX_OPT_REFID            =  9,
77238104Sdes    INDEX_OPT_WIDE             = 10,
78238104Sdes    INDEX_OPT_VERSION          = 11,
79238104Sdes    INDEX_OPT_HELP             = 12,
80238104Sdes    INDEX_OPT_MORE_HELP        = 13,
81238104Sdes    INDEX_OPT_SAVE_OPTS        = 14,
82238104Sdes    INDEX_OPT_LOAD_OPTS        = 15
83238104Sdes} teOptIndex;
84269257Sdes/** count of all options for ntpq */
85238104Sdes#define OPTION_CT    16
86238104Sdes/** ntpq version */
87238104Sdes#define NTPQ_VERSION       "4.2.8p9"
88238104Sdes/** Full ntpq version text */
89238104Sdes#define NTPQ_FULL_VERSION  "ntpq 4.2.8p9"
90238104Sdes
91238104Sdes/**
92238104Sdes *  Interface defines for all options.  Replace "n" with the UPPER_CASED
93238104Sdes *  option name (as in the teOptIndex enumeration above).
94238104Sdes *  e.g. HAVE_OPT(IPV4)
95238104Sdes */
96238104Sdes#define         DESC(n) (ntpqOptions.pOptDesc[INDEX_OPT_## n])
97238104Sdes/** 'true' if an option has been specified in any way */
98238104Sdes#define     HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
99238104Sdes/** The string argument to an option. The argument type must be \"string\". */
100238104Sdes#define      OPT_ARG(n) (DESC(n).optArg.argString)
101238104Sdes/** Mask the option state revealing how an option was specified.
102238104Sdes *  It will be one and only one of \a OPTST_SET, \a OPTST_PRESET,
103238104Sdes * \a OPTST_DEFINED, \a OPTST_RESET or zero.
104238104Sdes */
105238104Sdes#define    STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
106238104Sdes/** Count of option's occurrances *on the command line*. */
107238104Sdes#define    COUNT_OPT(n) (DESC(n).optOccCt)
108238104Sdes/** mask of \a OPTST_SET and \a OPTST_DEFINED. */
109238104Sdes#define    ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
110238104Sdes/** 'true' if \a HAVE_OPT would yield 'false'. */
111238104Sdes#define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
112238104Sdes/** 'true' if OPTST_DISABLED bit not set. */
113238104Sdes#define  ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
114238104Sdes/** number of stacked option arguments.
115238104Sdes *  Valid only for stacked option arguments. */
116238104Sdes#define  STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
117238104Sdes/** stacked argument vector.
118238104Sdes *  Valid only for stacked option arguments. */
119238104Sdes#define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
120238104Sdes/** Reset an option. */
121238104Sdes#define    CLEAR_OPT(n) STMTS( \
122238104Sdes                DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
123238104Sdes                if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \
124238104Sdes                    DESC(n).fOptState |= OPTST_DISABLED; \
125238104Sdes                DESC(n).optCookie = NULL )
126238104Sdes/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
127238104Sdes/**
128238104Sdes *  Enumeration of ntpq exit codes
129238104Sdes */
130238104Sdestypedef enum {
131238104Sdes    NTPQ_EXIT_SUCCESS         = 0,
132238104Sdes    NTPQ_EXIT_FAILURE         = 1,
133238104Sdes    NTPQ_EXIT_USAGE_ERROR     = 64,
134238104Sdes    NTPQ_EXIT_NO_CONFIG_INPUT = 66,
135238104Sdes    NTPQ_EXIT_LIBOPTS_FAILURE = 70
136238104Sdes}   ntpq_exit_code_t;
137238104Sdes/** @} */
138238104Sdes/**
139238104Sdes *  Make sure there are no #define name conflicts with the option names
140238104Sdes */
141238104Sdes#ifndef     NO_OPTION_NAME_WARNINGS
142238104Sdes# ifdef    IPV4
143269257Sdes#  warning undefining IPV4 due to option name conflict
144238104Sdes#  undef   IPV4
145238104Sdes# endif
146269257Sdes# ifdef    IPV6
147238104Sdes#  warning undefining IPV6 due to option name conflict
148238104Sdes#  undef   IPV6
149238104Sdes# endif
150238104Sdes# ifdef    COMMAND
151238104Sdes#  warning undefining COMMAND due to option name conflict
152238104Sdes#  undef   COMMAND
153238104Sdes# endif
154238104Sdes# ifdef    DEBUG_LEVEL
155238104Sdes#  warning undefining DEBUG_LEVEL due to option name conflict
156238104Sdes#  undef   DEBUG_LEVEL
157238104Sdes# endif
158238104Sdes# ifdef    SET_DEBUG_LEVEL
159238104Sdes#  warning undefining SET_DEBUG_LEVEL due to option name conflict
160238104Sdes#  undef   SET_DEBUG_LEVEL
161238104Sdes# endif
162238104Sdes# ifdef    INTERACTIVE
163238104Sdes#  warning undefining INTERACTIVE due to option name conflict
164238104Sdes#  undef   INTERACTIVE
165238104Sdes# endif
166238104Sdes# ifdef    NUMERIC
167238104Sdes#  warning undefining NUMERIC due to option name conflict
168238104Sdes#  undef   NUMERIC
169238104Sdes# endif
170238104Sdes# ifdef    OLD_RV
171238104Sdes#  warning undefining OLD_RV due to option name conflict
172238104Sdes#  undef   OLD_RV
173238104Sdes# endif
174238104Sdes# ifdef    PEERS
175238104Sdes#  warning undefining PEERS due to option name conflict
176238104Sdes#  undef   PEERS
177238104Sdes# endif
178238104Sdes# ifdef    REFID
179269257Sdes#  warning undefining REFID due to option name conflict
180238104Sdes#  undef   REFID
181238104Sdes# endif
182238104Sdes# ifdef    WIDE
183238104Sdes#  warning undefining WIDE due to option name conflict
184238104Sdes#  undef   WIDE
185238104Sdes# endif
186238104Sdes#else  /* NO_OPTION_NAME_WARNINGS */
187238104Sdes# undef IPV4
188238104Sdes# undef IPV6
189238104Sdes# undef COMMAND
190238104Sdes# undef DEBUG_LEVEL
191238104Sdes# undef SET_DEBUG_LEVEL
192238104Sdes# undef INTERACTIVE
193238104Sdes# undef NUMERIC
194238104Sdes# undef OLD_RV
195238104Sdes# undef PEERS
196238104Sdes# undef REFID
197238104Sdes# undef WIDE
198238104Sdes#endif  /*  NO_OPTION_NAME_WARNINGS */
199238104Sdes
200238104Sdes/**
201238104Sdes *  Interface defines for specific options.
202238104Sdes * @{
203238104Sdes */
204238104Sdes#define VALUE_OPT_IPV4           '4'
205238104Sdes#define VALUE_OPT_IPV6           '6'
206269257Sdes#define VALUE_OPT_COMMAND        'c'
207269257Sdes#define VALUE_OPT_DEBUG_LEVEL    'd'
208238104Sdes#define VALUE_OPT_SET_DEBUG_LEVEL 'D'
209238104Sdes
210238104Sdes#define OPT_VALUE_SET_DEBUG_LEVEL (DESC(SET_DEBUG_LEVEL).optArg.argInt)
211238104Sdes#define VALUE_OPT_INTERACTIVE    'i'
212238104Sdes#define VALUE_OPT_NUMERIC        'n'
213238104Sdes#define VALUE_OPT_OLD_RV         0x1001
214238104Sdes#define VALUE_OPT_PEERS          'p'
215238104Sdes#define VALUE_OPT_REFID          'r'
216238104Sdes
217238104Sdestypedef enum {
218238104Sdes    REFID_HASH, REFID_IPV4
219269257Sdes} te_Refid;
220238104Sdes#define OPT_REFID_VAL2STR(_v)    optionKeywordName(&DESC(REFID), (_v))
221238104Sdes#define OPT_VALUE_REFID          (DESC(REFID).optArg.argEnum)
222238104Sdes#define VALUE_OPT_WIDE           'w'
223238104Sdes/** option flag (value) for help-value option */
224238104Sdes#define VALUE_OPT_HELP          '?'
225238104Sdes/** option flag (value) for more-help-value option */
226238104Sdes#define VALUE_OPT_MORE_HELP     '!'
227238104Sdes/** option flag (value) for version-value option */
228238104Sdes#define VALUE_OPT_VERSION       0x1002
229238104Sdes/** option flag (value) for save-opts-value option */
230238104Sdes#define VALUE_OPT_SAVE_OPTS     '>'
231238104Sdes/** option flag (value) for load-opts-value option */
232238104Sdes#define VALUE_OPT_LOAD_OPTS     '<'
233238104Sdes#define SET_OPT_SAVE_OPTS(a)   STMTS( \
234238104Sdes        DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
235238104Sdes        DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
236238104Sdes        DESC(SAVE_OPTS).optArg.argString = (char const*)(a))
237238104Sdes/*
238238104Sdes *  Interface defines not associated with particular options
239238104Sdes */
240238104Sdes#define ERRSKIP_OPTERR  STMTS(ntpqOptions.fOptSet &= ~OPTPROC_ERRSTOP)
241238104Sdes#define ERRSTOP_OPTERR  STMTS(ntpqOptions.fOptSet |= OPTPROC_ERRSTOP)
242238104Sdes#define RESTART_OPT(n)  STMTS( \
243238104Sdes                ntpqOptions.curOptIdx = (n); \
244238104Sdes                ntpqOptions.pzCurOpt  = NULL )
245269257Sdes#define START_OPT       RESTART_OPT(1)
246269257Sdes#define USAGE(c)        (*ntpqOptions.pUsageProc)(&ntpqOptions, c)
247238104Sdes
248238104Sdes#ifdef  __cplusplus
249238104Sdesextern "C" {
250238104Sdes#endif
251238104Sdes
252238104Sdes
253238104Sdes/* * * * * *
254238104Sdes *
255238104Sdes *  Declare the ntpq option descriptor.
256238104Sdes */
257238104Sdesextern tOptions ntpqOptions;
258238104Sdes
259238104Sdes#if defined(ENABLE_NLS)
260238104Sdes# ifndef _
261238104Sdes#   include <stdio.h>
262238104Sdes#   ifndef HAVE_GETTEXT
263238104Sdes      extern char * gettext(char const *);
264238104Sdes#   else
265238104Sdes#     include <libintl.h>
266238104Sdes#   endif
267238104Sdes
268238104Sdes# ifndef ATTRIBUTE_FORMAT_ARG
269238104Sdes#   define ATTRIBUTE_FORMAT_ARG(_a)
270238104Sdes# endif
271238104Sdes
272238104Sdesstatic inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1);
273238104Sdesstatic inline char* aoGetsText(char const* pz) {
274238104Sdes    if (pz == NULL) return NULL;
275238104Sdes    return (char*)gettext(pz);
276238104Sdes}
277238104Sdes#   define _(s)  aoGetsText(s)
278238104Sdes# endif /* _() */
279238104Sdes
280238104Sdes# define OPT_NO_XLAT_CFG_NAMES  STMTS(ntpqOptions.fOptSet |= \
281238104Sdes                                    OPTPROC_NXLAT_OPT_CFG;)
282238104Sdes# define OPT_NO_XLAT_OPT_NAMES  STMTS(ntpqOptions.fOptSet |= \
283238104Sdes                                    OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
284238104Sdes
285238104Sdes# define OPT_XLAT_CFG_NAMES     STMTS(ntpqOptions.fOptSet &= \
286238104Sdes                                  ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
287238104Sdes# define OPT_XLAT_OPT_NAMES     STMTS(ntpqOptions.fOptSet &= \
288238104Sdes                                  ~OPTPROC_NXLAT_OPT;)
289238104Sdes
290238104Sdes#else   /* ENABLE_NLS */
291238104Sdes# define OPT_NO_XLAT_CFG_NAMES
292238104Sdes# define OPT_NO_XLAT_OPT_NAMES
293238104Sdes
294238104Sdes# define OPT_XLAT_CFG_NAMES
295238104Sdes# define OPT_XLAT_OPT_NAMES
296238104Sdes
297238104Sdes# ifndef _
298238104Sdes#   define _(_s)  _s
299238104Sdes# endif
300238104Sdes#endif  /* ENABLE_NLS */
301238104Sdes
302238104Sdes#ifdef  __cplusplus
303238104Sdes}
304238104Sdes#endif
305238104Sdes#endif /* AUTOOPTS_NTPQ_OPTS_H_GUARD */
306238104Sdes
307238104Sdes/* ntpq-opts.h ends here */
308238104Sdes