Home | History | Annotate | Line # | Download | only in ntpq
ntpq-opts.h revision 1.1.1.2.2.2
      1 /*	$NetBSD: ntpq-opts.h,v 1.1.1.2.2.2 2015/11/07 22:26:38 snj Exp $	*/
      2 
      3 /*
      4  *  EDIT THIS FILE WITH CAUTION  (ntpq-opts.h)
      5  *
      6  *  It has been AutoGen-ed  October 21, 2015 at 12:39:00 PM by AutoGen 5.18.5
      7  *  From the definitions    ntpq-opts.def
      8  *  and the template file   options
      9  *
     10  * Generated from AutoOpts 41:0:16 templates.
     11  *
     12  *  AutoOpts is a copyrighted work.  This header file is not encumbered
     13  *  by AutoOpts licensing, but is provided under the licensing terms chosen
     14  *  by the ntpq author or copyright holder.  AutoOpts is
     15  *  licensed under the terms of the LGPL.  The redistributable library
     16  *  (``libopts'') is licensed under the terms of either the LGPL or, at the
     17  *  users discretion, the BSD license.  See the AutoOpts and/or libopts sources
     18  *  for details.
     19  *
     20  * The ntpq program is copyrighted and licensed
     21  * under the following terms:
     22  *
     23  *  Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.
     24  *  This is free software. It is licensed for use, modification and
     25  *  redistribution under the terms of the NTP License, copies of which
     26  *  can be seen at:
     27  *    <http://ntp.org/license>
     28  *    <http://opensource.org/licenses/ntp-license.php>
     29  *
     30  *  Permission to use, copy, modify, and distribute this software and its
     31  *  documentation for any purpose with or without fee is hereby granted,
     32  *  provided that the above copyright notice appears in all copies and that
     33  *  both the copyright notice and this permission notice appear in
     34  *  supporting documentation, and that the name The University of Delaware not be used in
     35  *  advertising or publicity pertaining to distribution of the software
     36  *  without specific, written prior permission. The University of Delaware and Network Time Foundation makes no
     37  *  representations about the suitability this software for any purpose. It
     38  *  is provided "as is" without express or implied warranty.
     39  */
     40 /**
     41  *  This file contains the programmatic interface to the Automated
     42  *  Options generated for the ntpq program.
     43  *  These macros are documented in the AutoGen info file in the
     44  *  "AutoOpts" chapter.  Please refer to that doc for usage help.
     45  */
     46 #ifndef AUTOOPTS_NTPQ_OPTS_H_GUARD
     47 #define AUTOOPTS_NTPQ_OPTS_H_GUARD 1
     48 #include "config.h"
     49 #include <autoopts/options.h>
     50 
     51 /**
     52  *  Ensure that the library used for compiling this generated header is at
     53  *  least as new as the version current when the header template was released
     54  *  (not counting patch version increments).  Also ensure that the oldest
     55  *  tolerable version is at least as old as what was current when the header
     56  *  template was released.
     57  */
     58 #define AO_TEMPLATE_VERSION 167936
     59 #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
     60  || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
     61 # error option template version mismatches autoopts/options.h header
     62   Choke Me.
     63 #endif
     64 
     65 /**
     66  *  Enumeration of each option type for ntpq
     67  */
     68 typedef enum {
     69     INDEX_OPT_IPV4             =  0,
     70     INDEX_OPT_IPV6             =  1,
     71     INDEX_OPT_COMMAND          =  2,
     72     INDEX_OPT_DEBUG_LEVEL      =  3,
     73     INDEX_OPT_SET_DEBUG_LEVEL  =  4,
     74     INDEX_OPT_INTERACTIVE      =  5,
     75     INDEX_OPT_NUMERIC          =  6,
     76     INDEX_OPT_OLD_RV           =  7,
     77     INDEX_OPT_PEERS            =  8,
     78     INDEX_OPT_WIDE             =  9,
     79     INDEX_OPT_VERSION          = 10,
     80     INDEX_OPT_HELP             = 11,
     81     INDEX_OPT_MORE_HELP        = 12,
     82     INDEX_OPT_SAVE_OPTS        = 13,
     83     INDEX_OPT_LOAD_OPTS        = 14
     84 } teOptIndex;
     85 /** count of all options for ntpq */
     86 #define OPTION_CT    15
     87 /** ntpq version */
     88 #define NTPQ_VERSION       "4.2.8p4"
     89 /** Full ntpq version text */
     90 #define NTPQ_FULL_VERSION  "ntpq 4.2.8p4"
     91 
     92 /**
     93  *  Interface defines for all options.  Replace "n" with the UPPER_CASED
     94  *  option name (as in the teOptIndex enumeration above).
     95  *  e.g. HAVE_OPT(IPV4)
     96  */
     97 #define         DESC(n) (ntpqOptions.pOptDesc[INDEX_OPT_## n])
     98 /** 'true' if an option has been specified in any way */
     99 #define     HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
    100 /** The string argument to an option. The argument type must be \"string\". */
    101 #define      OPT_ARG(n) (DESC(n).optArg.argString)
    102 /** Mask the option state revealing how an option was specified.
    103  *  It will be one and only one of \a OPTST_SET, \a OPTST_PRESET,
    104  * \a OPTST_DEFINED, \a OPTST_RESET or zero.
    105  */
    106 #define    STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
    107 /** Count of option's occurrances *on the command line*. */
    108 #define    COUNT_OPT(n) (DESC(n).optOccCt)
    109 /** mask of \a OPTST_SET and \a OPTST_DEFINED. */
    110 #define    ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
    111 /** 'true' if \a HAVE_OPT would yield 'false'. */
    112 #define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
    113 /** 'true' if OPTST_DISABLED bit not set. */
    114 #define  ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
    115 /** number of stacked option arguments.
    116  *  Valid only for stacked option arguments. */
    117 #define  STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
    118 /** stacked argument vector.
    119  *  Valid only for stacked option arguments. */
    120 #define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
    121 /** Reset an option. */
    122 #define    CLEAR_OPT(n) STMTS( \
    123                 DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
    124                 if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \
    125                     DESC(n).fOptState |= OPTST_DISABLED; \
    126                 DESC(n).optCookie = NULL )
    127 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    128 /**
    129  *  Enumeration of ntpq exit codes
    130  */
    131 typedef enum {
    132     NTPQ_EXIT_SUCCESS         = 0,
    133     NTPQ_EXIT_FAILURE         = 1,
    134     NTPQ_EXIT_USAGE_ERROR     = 64,
    135     NTPQ_EXIT_NO_CONFIG_INPUT = 66,
    136     NTPQ_EXIT_LIBOPTS_FAILURE = 70
    137 }   ntpq_exit_code_t;
    138 /** @} */
    139 /**
    140  *  Make sure there are no #define name conflicts with the option names
    141  */
    142 #ifndef     NO_OPTION_NAME_WARNINGS
    143 # ifdef    IPV4
    144 #  warning undefining IPV4 due to option name conflict
    145 #  undef   IPV4
    146 # endif
    147 # ifdef    IPV6
    148 #  warning undefining IPV6 due to option name conflict
    149 #  undef   IPV6
    150 # endif
    151 # ifdef    COMMAND
    152 #  warning undefining COMMAND due to option name conflict
    153 #  undef   COMMAND
    154 # endif
    155 # ifdef    DEBUG_LEVEL
    156 #  warning undefining DEBUG_LEVEL due to option name conflict
    157 #  undef   DEBUG_LEVEL
    158 # endif
    159 # ifdef    SET_DEBUG_LEVEL
    160 #  warning undefining SET_DEBUG_LEVEL due to option name conflict
    161 #  undef   SET_DEBUG_LEVEL
    162 # endif
    163 # ifdef    INTERACTIVE
    164 #  warning undefining INTERACTIVE due to option name conflict
    165 #  undef   INTERACTIVE
    166 # endif
    167 # ifdef    NUMERIC
    168 #  warning undefining NUMERIC due to option name conflict
    169 #  undef   NUMERIC
    170 # endif
    171 # ifdef    OLD_RV
    172 #  warning undefining OLD_RV due to option name conflict
    173 #  undef   OLD_RV
    174 # endif
    175 # ifdef    PEERS
    176 #  warning undefining PEERS due to option name conflict
    177 #  undef   PEERS
    178 # endif
    179 # ifdef    WIDE
    180 #  warning undefining WIDE due to option name conflict
    181 #  undef   WIDE
    182 # endif
    183 #else  /* NO_OPTION_NAME_WARNINGS */
    184 # undef IPV4
    185 # undef IPV6
    186 # undef COMMAND
    187 # undef DEBUG_LEVEL
    188 # undef SET_DEBUG_LEVEL
    189 # undef INTERACTIVE
    190 # undef NUMERIC
    191 # undef OLD_RV
    192 # undef PEERS
    193 # undef WIDE
    194 #endif  /*  NO_OPTION_NAME_WARNINGS */
    195 
    196 /**
    197  *  Interface defines for specific options.
    198  * @{
    199  */
    200 #define VALUE_OPT_IPV4           '4'
    201 #define VALUE_OPT_IPV6           '6'
    202 #define VALUE_OPT_COMMAND        'c'
    203 #define VALUE_OPT_DEBUG_LEVEL    'd'
    204 #define VALUE_OPT_SET_DEBUG_LEVEL 'D'
    205 
    206 #define OPT_VALUE_SET_DEBUG_LEVEL (DESC(SET_DEBUG_LEVEL).optArg.argInt)
    207 #define VALUE_OPT_INTERACTIVE    'i'
    208 #define VALUE_OPT_NUMERIC        'n'
    209 #define VALUE_OPT_OLD_RV         0x1001
    210 #define VALUE_OPT_PEERS          'p'
    211 #define VALUE_OPT_WIDE           'w'
    212 /** option flag (value) for help-value option */
    213 #define VALUE_OPT_HELP          '?'
    214 /** option flag (value) for more-help-value option */
    215 #define VALUE_OPT_MORE_HELP     '!'
    216 /** option flag (value) for version-value option */
    217 #define VALUE_OPT_VERSION       0x1002
    218 /** option flag (value) for save-opts-value option */
    219 #define VALUE_OPT_SAVE_OPTS     '>'
    220 /** option flag (value) for load-opts-value option */
    221 #define VALUE_OPT_LOAD_OPTS     '<'
    222 #define SET_OPT_SAVE_OPTS(a)   STMTS( \
    223         DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
    224         DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
    225         DESC(SAVE_OPTS).optArg.argString = (char const*)(a))
    226 /*
    227  *  Interface defines not associated with particular options
    228  */
    229 #define ERRSKIP_OPTERR  STMTS(ntpqOptions.fOptSet &= ~OPTPROC_ERRSTOP)
    230 #define ERRSTOP_OPTERR  STMTS(ntpqOptions.fOptSet |= OPTPROC_ERRSTOP)
    231 #define RESTART_OPT(n)  STMTS( \
    232                 ntpqOptions.curOptIdx = (n); \
    233                 ntpqOptions.pzCurOpt  = NULL )
    234 #define START_OPT       RESTART_OPT(1)
    235 #define USAGE(c)        (*ntpqOptions.pUsageProc)(&ntpqOptions, c)
    236 
    237 #ifdef  __cplusplus
    238 extern "C" {
    239 #endif
    240 
    241 
    242 /* * * * * *
    243  *
    244  *  Declare the ntpq option descriptor.
    245  */
    246 extern tOptions ntpqOptions;
    247 
    248 #if defined(ENABLE_NLS)
    249 # ifndef _
    250 #   include <stdio.h>
    251 #   ifndef HAVE_GETTEXT
    252       extern char * gettext(char const *);
    253 #   else
    254 #     include <libintl.h>
    255 #   endif
    256 
    257 # ifndef ATTRIBUTE_FORMAT_ARG
    258 #   define ATTRIBUTE_FORMAT_ARG(_a)
    259 # endif
    260 
    261 static inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1);
    262 static inline char* aoGetsText(char const* pz) {
    263     if (pz == NULL) return NULL;
    264     return (char*)gettext(pz);
    265 }
    266 #   define _(s)  aoGetsText(s)
    267 # endif /* _() */
    268 
    269 # define OPT_NO_XLAT_CFG_NAMES  STMTS(ntpqOptions.fOptSet |= \
    270                                     OPTPROC_NXLAT_OPT_CFG;)
    271 # define OPT_NO_XLAT_OPT_NAMES  STMTS(ntpqOptions.fOptSet |= \
    272                                     OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
    273 
    274 # define OPT_XLAT_CFG_NAMES     STMTS(ntpqOptions.fOptSet &= \
    275                                   ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
    276 # define OPT_XLAT_OPT_NAMES     STMTS(ntpqOptions.fOptSet &= \
    277                                   ~OPTPROC_NXLAT_OPT;)
    278 
    279 #else   /* ENABLE_NLS */
    280 # define OPT_NO_XLAT_CFG_NAMES
    281 # define OPT_NO_XLAT_OPT_NAMES
    282 
    283 # define OPT_XLAT_CFG_NAMES
    284 # define OPT_XLAT_OPT_NAMES
    285 
    286 # ifndef _
    287 #   define _(_s)  _s
    288 # endif
    289 #endif  /* ENABLE_NLS */
    290 
    291 #ifdef  __cplusplus
    292 }
    293 #endif
    294 #endif /* AUTOOPTS_NTPQ_OPTS_H_GUARD */
    295 
    296 /* ntpq-opts.h ends here */
    297