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