1290001Sglebius/* 2181834Sroberto * EDIT THIS FILE WITH CAUTION (ntpq-opts.h) 3290001Sglebius * 4310419Sdelphij * It has been AutoGen-ed November 21, 2016 at 08:02:38 AM by AutoGen 5.18.5 5181834Sroberto * From the definitions ntpq-opts.def 6181834Sroberto * and the template file options 7181834Sroberto * 8290001Sglebius * Generated from AutoOpts 41:0:16 templates. 9181834Sroberto * 10290001Sglebius * AutoOpts is a copyrighted work. This header file is not encumbered 11290001Sglebius * by AutoOpts licensing, but is provided under the licensing terms chosen 12290001Sglebius * by the ntpq author or copyright holder. AutoOpts is 13290001Sglebius * licensed under the terms of the LGPL. The redistributable library 14290001Sglebius * (``libopts'') is licensed under the terms of either the LGPL or, at the 15290001Sglebius * users discretion, the BSD license. See the AutoOpts and/or libopts sources 16290001Sglebius * for details. 17181834Sroberto * 18290001Sglebius * The ntpq program is copyrighted and licensed 19290001Sglebius * under the following terms: 20181834Sroberto * 21294905Sdelphij * Copyright (C) 1992-2016 The University of Delaware and Network Time Foundation, all rights reserved. 22290001Sglebius * This is free software. It is licensed for use, modification and 23290001Sglebius * redistribution under the terms of the NTP License, copies of which 24290001Sglebius * can be seen at: 25290001Sglebius * <http://ntp.org/license> 26290001Sglebius * <http://opensource.org/licenses/ntp-license.php> 27290001Sglebius * 28290001Sglebius * Permission to use, copy, modify, and distribute this software and its 29290001Sglebius * documentation for any purpose with or without fee is hereby granted, 30290001Sglebius * provided that the above copyright notice appears in all copies and that 31290001Sglebius * both the copyright notice and this permission notice appear in 32290001Sglebius * supporting documentation, and that the name The University of Delaware not be used in 33290001Sglebius * advertising or publicity pertaining to distribution of the software 34290001Sglebius * without specific, written prior permission. The University of Delaware and Network Time Foundation makes no 35290001Sglebius * representations about the suitability this software for any purpose. It 36290001Sglebius * is provided "as is" without express or implied warranty. 37181834Sroberto */ 38290001Sglebius/** 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 45290001Sglebius#define AUTOOPTS_NTPQ_OPTS_H_GUARD 1 46181834Sroberto#include "config.h" 47181834Sroberto#include <autoopts/options.h> 48181834Sroberto 49290001Sglebius/** 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 */ 56290001Sglebius#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 63290001Sglebius/** 64290001Sglebius * Enumeration of each option type for ntpq 65181834Sroberto */ 66181834Srobertotypedef enum { 67290001Sglebius INDEX_OPT_IPV4 = 0, 68290001Sglebius INDEX_OPT_IPV6 = 1, 69290001Sglebius INDEX_OPT_COMMAND = 2, 70290001Sglebius INDEX_OPT_DEBUG_LEVEL = 3, 71290001Sglebius INDEX_OPT_SET_DEBUG_LEVEL = 4, 72290001Sglebius INDEX_OPT_INTERACTIVE = 5, 73290001Sglebius INDEX_OPT_NUMERIC = 6, 74290001Sglebius INDEX_OPT_OLD_RV = 7, 75290001Sglebius INDEX_OPT_PEERS = 8, 76298770Sdelphij INDEX_OPT_REFID = 9, 77298770Sdelphij INDEX_OPT_WIDE = 10, 78298770Sdelphij INDEX_OPT_VERSION = 11, 79298770Sdelphij INDEX_OPT_HELP = 12, 80298770Sdelphij INDEX_OPT_MORE_HELP = 13, 81298770Sdelphij INDEX_OPT_SAVE_OPTS = 14, 82298770Sdelphij INDEX_OPT_LOAD_OPTS = 15 83181834Sroberto} teOptIndex; 84290001Sglebius/** count of all options for ntpq */ 85298770Sdelphij#define OPTION_CT 16 86290001Sglebius/** ntpq version */ 87310419Sdelphij#define NTPQ_VERSION "4.2.8p9" 88290001Sglebius/** Full ntpq version text */ 89310419Sdelphij#define NTPQ_FULL_VERSION "ntpq 4.2.8p9" 90181834Sroberto 91290001Sglebius/** 92181834Sroberto * Interface defines for all options. Replace "n" with the UPPER_CASED 93181834Sroberto * option name (as in the teOptIndex enumeration above). 94290001Sglebius * e.g. HAVE_OPT(IPV4) 95181834Sroberto */ 96181834Sroberto#define DESC(n) (ntpqOptions.pOptDesc[INDEX_OPT_## n]) 97290001Sglebius/** 'true' if an option has been specified in any way */ 98181834Sroberto#define HAVE_OPT(n) (! UNUSED_OPT(& DESC(n))) 99290001Sglebius/** The string argument to an option. The argument type must be \"string\". */ 100181834Sroberto#define OPT_ARG(n) (DESC(n).optArg.argString) 101290001Sglebius/** Mask the option state revealing how an option was specified. 102290001Sglebius * It will be one and only one of \a OPTST_SET, \a OPTST_PRESET, 103290001Sglebius * \a OPTST_DEFINED, \a OPTST_RESET or zero. 104290001Sglebius */ 105181834Sroberto#define STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK) 106290001Sglebius/** Count of option's occurrances *on the command line*. */ 107181834Sroberto#define COUNT_OPT(n) (DESC(n).optOccCt) 108290001Sglebius/** mask of \a OPTST_SET and \a OPTST_DEFINED. */ 109181834Sroberto#define ISSEL_OPT(n) (SELECTED_OPT(&DESC(n))) 110290001Sglebius/** 'true' if \a HAVE_OPT would yield 'false'. */ 111181834Sroberto#define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n))) 112290001Sglebius/** 'true' if OPTST_DISABLED bit not set. */ 113181834Sroberto#define ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n))) 114290001Sglebius/** number of stacked option arguments. 115290001Sglebius * Valid only for stacked option arguments. */ 116181834Sroberto#define STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt) 117290001Sglebius/** stacked argument vector. 118290001Sglebius * Valid only for stacked option arguments. */ 119181834Sroberto#define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs) 120290001Sglebius/** Reset an option. */ 121181834Sroberto#define CLEAR_OPT(n) STMTS( \ 122181834Sroberto DESC(n).fOptState &= OPTST_PERSISTENT_MASK; \ 123290001Sglebius if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \ 124181834Sroberto DESC(n).fOptState |= OPTST_DISABLED; \ 125181834Sroberto DESC(n).optCookie = NULL ) 126290001Sglebius/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 127290001Sglebius/** 128290001Sglebius * Enumeration of ntpq exit codes 129290001Sglebius */ 130290001Sglebiustypedef enum { 131290001Sglebius NTPQ_EXIT_SUCCESS = 0, 132290001Sglebius NTPQ_EXIT_FAILURE = 1, 133290001Sglebius NTPQ_EXIT_USAGE_ERROR = 64, 134290001Sglebius NTPQ_EXIT_NO_CONFIG_INPUT = 66, 135290001Sglebius NTPQ_EXIT_LIBOPTS_FAILURE = 70 136290001Sglebius} ntpq_exit_code_t; 137290001Sglebius/** @} */ 138290001Sglebius/** 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 170290001Sglebius# ifdef OLD_RV 171290001Sglebius# warning undefining OLD_RV due to option name conflict 172290001Sglebius# undef OLD_RV 173290001Sglebius# endif 174290001Sglebius# ifdef PEERS 175290001Sglebius# warning undefining PEERS due to option name conflict 176290001Sglebius# undef PEERS 177290001Sglebius# endif 178298770Sdelphij# ifdef REFID 179298770Sdelphij# warning undefining REFID due to option name conflict 180298770Sdelphij# undef REFID 181298770Sdelphij# endif 182290001Sglebius# ifdef WIDE 183290001Sglebius# warning undefining WIDE due to option name conflict 184290001Sglebius# undef WIDE 185290001Sglebius# 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 194290001Sglebius# undef OLD_RV 195290001Sglebius# undef PEERS 196298770Sdelphij# undef REFID 197290001Sglebius# undef WIDE 198181834Sroberto#endif /* NO_OPTION_NAME_WARNINGS */ 199181834Sroberto 200290001Sglebius/** 201181834Sroberto * Interface defines for specific options. 202290001Sglebius * @{ 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' 209290001Sglebius 210290001Sglebius#define OPT_VALUE_SET_DEBUG_LEVEL (DESC(SET_DEBUG_LEVEL).optArg.argInt) 211181834Sroberto#define VALUE_OPT_INTERACTIVE 'i' 212181834Sroberto#define VALUE_OPT_NUMERIC 'n' 213290001Sglebius#define VALUE_OPT_OLD_RV 0x1001 214290001Sglebius#define VALUE_OPT_PEERS 'p' 215298770Sdelphij#define VALUE_OPT_REFID 'r' 216298770Sdelphij 217298770Sdelphijtypedef enum { 218298770Sdelphij REFID_HASH, REFID_IPV4 219298770Sdelphij} te_Refid; 220298770Sdelphij#define OPT_REFID_VAL2STR(_v) optionKeywordName(&DESC(REFID), (_v)) 221298770Sdelphij#define OPT_VALUE_REFID (DESC(REFID).optArg.argEnum) 222290001Sglebius#define VALUE_OPT_WIDE 'w' 223290001Sglebius/** option flag (value) for help-value option */ 224181834Sroberto#define VALUE_OPT_HELP '?' 225290001Sglebius/** option flag (value) for more-help-value option */ 226181834Sroberto#define VALUE_OPT_MORE_HELP '!' 227290001Sglebius/** option flag (value) for version-value option */ 228290001Sglebius#define VALUE_OPT_VERSION 0x1002 229290001Sglebius/** option flag (value) for save-opts-value option */ 230181834Sroberto#define VALUE_OPT_SAVE_OPTS '>' 231290001Sglebius/** 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; \ 236290001Sglebius DESC(SAVE_OPTS).optArg.argString = (char const*)(a)) 237181834Sroberto/* 238181834Sroberto * Interface defines not associated with particular options 239181834Sroberto */ 240290001Sglebius#define ERRSKIP_OPTERR STMTS(ntpqOptions.fOptSet &= ~OPTPROC_ERRSTOP) 241290001Sglebius#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) 246290001Sglebius#define USAGE(c) (*ntpqOptions.pUsageProc)(&ntpqOptions, c) 247181834Sroberto 248290001Sglebius#ifdef __cplusplus 249290001Sglebiusextern "C" { 250290001Sglebius#endif 251290001Sglebius 252290001Sglebius 253181834Sroberto/* * * * * * 254181834Sroberto * 255181834Sroberto * Declare the ntpq option descriptor. 256181834Sroberto */ 257290001Sglebiusextern tOptions ntpqOptions; 258181834Sroberto 259290001Sglebius#if defined(ENABLE_NLS) 260290001Sglebius# ifndef _ 261290001Sglebius# include <stdio.h> 262290001Sglebius# ifndef HAVE_GETTEXT 263290001Sglebius extern char * gettext(char const *); 264290001Sglebius# else 265290001Sglebius# include <libintl.h> 266290001Sglebius# endif 267181834Sroberto 268290001Sglebius# ifndef ATTRIBUTE_FORMAT_ARG 269290001Sglebius# define ATTRIBUTE_FORMAT_ARG(_a) 270290001Sglebius# endif 271181834Sroberto 272290001Sglebiusstatic inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1); 273290001Sglebiusstatic inline char* aoGetsText(char const* pz) { 274290001Sglebius if (pz == NULL) return NULL; 275290001Sglebius return (char*)gettext(pz); 276290001Sglebius} 277290001Sglebius# define _(s) aoGetsText(s) 278290001Sglebius# endif /* _() */ 279290001Sglebius 280290001Sglebius# define OPT_NO_XLAT_CFG_NAMES STMTS(ntpqOptions.fOptSet |= \ 281290001Sglebius OPTPROC_NXLAT_OPT_CFG;) 282290001Sglebius# define OPT_NO_XLAT_OPT_NAMES STMTS(ntpqOptions.fOptSet |= \ 283290001Sglebius OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;) 284290001Sglebius 285290001Sglebius# define OPT_XLAT_CFG_NAMES STMTS(ntpqOptions.fOptSet &= \ 286290001Sglebius ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);) 287290001Sglebius# define OPT_XLAT_OPT_NAMES STMTS(ntpqOptions.fOptSet &= \ 288290001Sglebius ~OPTPROC_NXLAT_OPT;) 289290001Sglebius 290290001Sglebius#else /* ENABLE_NLS */ 291290001Sglebius# define OPT_NO_XLAT_CFG_NAMES 292290001Sglebius# define OPT_NO_XLAT_OPT_NAMES 293290001Sglebius 294290001Sglebius# define OPT_XLAT_CFG_NAMES 295290001Sglebius# define OPT_XLAT_OPT_NAMES 296290001Sglebius 297290001Sglebius# ifndef _ 298290001Sglebius# define _(_s) _s 299290001Sglebius# endif 300290001Sglebius#endif /* ENABLE_NLS */ 301290001Sglebius 302181834Sroberto#ifdef __cplusplus 303181834Sroberto} 304181834Sroberto#endif 305181834Sroberto#endif /* AUTOOPTS_NTPQ_OPTS_H_GUARD */ 306290001Sglebius 307181834Sroberto/* ntpq-opts.h ends here */ 308