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