1280849Scy/* 2181834Sroberto * EDIT THIS FILE WITH CAUTION (ntpq-opts.h) 3280849Scy * 4316722Sdelphij * It has been AutoGen-ed March 21, 2017 at 10:45:04 AM by AutoGen 5.18.5 5181834Sroberto * From the definitions ntpq-opts.def 6181834Sroberto * and the template file options 7181834Sroberto * 8280849Scy * Generated from AutoOpts 41:0:16 templates. 9181834Sroberto * 10280849Scy * AutoOpts is a copyrighted work. This header file is not encumbered 11280849Scy * by AutoOpts licensing, but is provided under the licensing terms chosen 12280849Scy * by the ntpq author or copyright holder. AutoOpts is 13280849Scy * licensed under the terms of the LGPL. The redistributable library 14280849Scy * (``libopts'') is licensed under the terms of either the LGPL or, at the 15280849Scy * users discretion, the BSD license. See the AutoOpts and/or libopts sources 16280849Scy * for details. 17181834Sroberto * 18280849Scy * The ntpq program is copyrighted and licensed 19280849Scy * under the following terms: 20181834Sroberto * 21316722Sdelphij * Copyright (C) 1992-2017 The University of Delaware and Network Time Foundation, all rights reserved. 22280849Scy * This is free software. It is licensed for use, modification and 23280849Scy * redistribution under the terms of the NTP License, copies of which 24280849Scy * can be seen at: 25280849Scy * <http://ntp.org/license> 26280849Scy * <http://opensource.org/licenses/ntp-license.php> 27280849Scy * 28280849Scy * Permission to use, copy, modify, and distribute this software and its 29280849Scy * documentation for any purpose with or without fee is hereby granted, 30280849Scy * provided that the above copyright notice appears in all copies and that 31280849Scy * both the copyright notice and this permission notice appear in 32280849Scy * supporting documentation, and that the name The University of Delaware not be used in 33280849Scy * advertising or publicity pertaining to distribution of the software 34280849Scy * without specific, written prior permission. The University of Delaware and Network Time Foundation makes no 35280849Scy * representations about the suitability this software for any purpose. It 36280849Scy * is provided "as is" without express or implied warranty. 37181834Sroberto */ 38280849Scy/** 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 45280849Scy#define AUTOOPTS_NTPQ_OPTS_H_GUARD 1 46181834Sroberto#include "config.h" 47181834Sroberto#include <autoopts/options.h> 48181834Sroberto 49280849Scy/** 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 */ 56280849Scy#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 63280849Scy/** 64280849Scy * Enumeration of each option type for ntpq 65181834Sroberto */ 66181834Srobertotypedef enum { 67280849Scy INDEX_OPT_IPV4 = 0, 68280849Scy INDEX_OPT_IPV6 = 1, 69280849Scy INDEX_OPT_COMMAND = 2, 70280849Scy INDEX_OPT_DEBUG_LEVEL = 3, 71280849Scy INDEX_OPT_SET_DEBUG_LEVEL = 4, 72280849Scy INDEX_OPT_INTERACTIVE = 5, 73280849Scy INDEX_OPT_NUMERIC = 6, 74280849Scy INDEX_OPT_OLD_RV = 7, 75280849Scy INDEX_OPT_PEERS = 8, 76298695Sdelphij INDEX_OPT_REFID = 9, 77298695Sdelphij INDEX_OPT_WIDE = 10, 78298695Sdelphij INDEX_OPT_VERSION = 11, 79298695Sdelphij INDEX_OPT_HELP = 12, 80298695Sdelphij INDEX_OPT_MORE_HELP = 13, 81298695Sdelphij INDEX_OPT_SAVE_OPTS = 14, 82298695Sdelphij INDEX_OPT_LOAD_OPTS = 15 83181834Sroberto} teOptIndex; 84280849Scy/** count of all options for ntpq */ 85298695Sdelphij#define OPTION_CT 16 86280849Scy/** ntpq version */ 87316722Sdelphij#define NTPQ_VERSION "4.2.8p10" 88280849Scy/** Full ntpq version text */ 89316722Sdelphij#define NTPQ_FULL_VERSION "ntpq 4.2.8p10" 90181834Sroberto 91280849Scy/** 92181834Sroberto * Interface defines for all options. Replace "n" with the UPPER_CASED 93181834Sroberto * option name (as in the teOptIndex enumeration above). 94280849Scy * e.g. HAVE_OPT(IPV4) 95181834Sroberto */ 96181834Sroberto#define DESC(n) (ntpqOptions.pOptDesc[INDEX_OPT_## n]) 97280849Scy/** 'true' if an option has been specified in any way */ 98181834Sroberto#define HAVE_OPT(n) (! UNUSED_OPT(& DESC(n))) 99280849Scy/** The string argument to an option. The argument type must be \"string\". */ 100181834Sroberto#define OPT_ARG(n) (DESC(n).optArg.argString) 101280849Scy/** Mask the option state revealing how an option was specified. 102280849Scy * It will be one and only one of \a OPTST_SET, \a OPTST_PRESET, 103280849Scy * \a OPTST_DEFINED, \a OPTST_RESET or zero. 104280849Scy */ 105181834Sroberto#define STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK) 106280849Scy/** Count of option's occurrances *on the command line*. */ 107181834Sroberto#define COUNT_OPT(n) (DESC(n).optOccCt) 108280849Scy/** mask of \a OPTST_SET and \a OPTST_DEFINED. */ 109181834Sroberto#define ISSEL_OPT(n) (SELECTED_OPT(&DESC(n))) 110280849Scy/** 'true' if \a HAVE_OPT would yield 'false'. */ 111181834Sroberto#define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n))) 112280849Scy/** 'true' if OPTST_DISABLED bit not set. */ 113181834Sroberto#define ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n))) 114280849Scy/** number of stacked option arguments. 115280849Scy * Valid only for stacked option arguments. */ 116181834Sroberto#define STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt) 117280849Scy/** stacked argument vector. 118280849Scy * Valid only for stacked option arguments. */ 119181834Sroberto#define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs) 120280849Scy/** Reset an option. */ 121181834Sroberto#define CLEAR_OPT(n) STMTS( \ 122181834Sroberto DESC(n).fOptState &= OPTST_PERSISTENT_MASK; \ 123280849Scy if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \ 124181834Sroberto DESC(n).fOptState |= OPTST_DISABLED; \ 125181834Sroberto DESC(n).optCookie = NULL ) 126280849Scy/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 127280849Scy/** 128280849Scy * Enumeration of ntpq exit codes 129280849Scy */ 130280849Scytypedef enum { 131280849Scy NTPQ_EXIT_SUCCESS = 0, 132280849Scy NTPQ_EXIT_FAILURE = 1, 133280849Scy NTPQ_EXIT_USAGE_ERROR = 64, 134280849Scy NTPQ_EXIT_NO_CONFIG_INPUT = 66, 135280849Scy NTPQ_EXIT_LIBOPTS_FAILURE = 70 136280849Scy} ntpq_exit_code_t; 137280849Scy/** @} */ 138280849Scy/** 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 170280849Scy# ifdef OLD_RV 171280849Scy# warning undefining OLD_RV due to option name conflict 172280849Scy# undef OLD_RV 173280849Scy# endif 174280849Scy# ifdef PEERS 175280849Scy# warning undefining PEERS due to option name conflict 176280849Scy# undef PEERS 177280849Scy# endif 178298695Sdelphij# ifdef REFID 179298695Sdelphij# warning undefining REFID due to option name conflict 180298695Sdelphij# undef REFID 181298695Sdelphij# endif 182280849Scy# ifdef WIDE 183280849Scy# warning undefining WIDE due to option name conflict 184280849Scy# undef WIDE 185280849Scy# 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 194280849Scy# undef OLD_RV 195280849Scy# undef PEERS 196298695Sdelphij# undef REFID 197280849Scy# undef WIDE 198181834Sroberto#endif /* NO_OPTION_NAME_WARNINGS */ 199181834Sroberto 200280849Scy/** 201181834Sroberto * Interface defines for specific options. 202280849Scy * @{ 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' 209280849Scy 210280849Scy#define OPT_VALUE_SET_DEBUG_LEVEL (DESC(SET_DEBUG_LEVEL).optArg.argInt) 211181834Sroberto#define VALUE_OPT_INTERACTIVE 'i' 212181834Sroberto#define VALUE_OPT_NUMERIC 'n' 213280849Scy#define VALUE_OPT_OLD_RV 0x1001 214280849Scy#define VALUE_OPT_PEERS 'p' 215298695Sdelphij#define VALUE_OPT_REFID 'r' 216298695Sdelphij 217298695Sdelphijtypedef enum { 218298695Sdelphij REFID_HASH, REFID_IPV4 219298695Sdelphij} te_Refid; 220298695Sdelphij#define OPT_REFID_VAL2STR(_v) optionKeywordName(&DESC(REFID), (_v)) 221298695Sdelphij#define OPT_VALUE_REFID (DESC(REFID).optArg.argEnum) 222280849Scy#define VALUE_OPT_WIDE 'w' 223280849Scy/** option flag (value) for help-value option */ 224181834Sroberto#define VALUE_OPT_HELP '?' 225280849Scy/** option flag (value) for more-help-value option */ 226181834Sroberto#define VALUE_OPT_MORE_HELP '!' 227280849Scy/** option flag (value) for version-value option */ 228280849Scy#define VALUE_OPT_VERSION 0x1002 229280849Scy/** option flag (value) for save-opts-value option */ 230181834Sroberto#define VALUE_OPT_SAVE_OPTS '>' 231280849Scy/** 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; \ 236280849Scy DESC(SAVE_OPTS).optArg.argString = (char const*)(a)) 237181834Sroberto/* 238181834Sroberto * Interface defines not associated with particular options 239181834Sroberto */ 240280849Scy#define ERRSKIP_OPTERR STMTS(ntpqOptions.fOptSet &= ~OPTPROC_ERRSTOP) 241280849Scy#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) 246280849Scy#define USAGE(c) (*ntpqOptions.pUsageProc)(&ntpqOptions, c) 247181834Sroberto 248280849Scy#ifdef __cplusplus 249280849Scyextern "C" { 250280849Scy#endif 251280849Scy 252280849Scy 253181834Sroberto/* * * * * * 254181834Sroberto * 255181834Sroberto * Declare the ntpq option descriptor. 256181834Sroberto */ 257280849Scyextern tOptions ntpqOptions; 258181834Sroberto 259280849Scy#if defined(ENABLE_NLS) 260280849Scy# ifndef _ 261280849Scy# include <stdio.h> 262280849Scy# ifndef HAVE_GETTEXT 263280849Scy extern char * gettext(char const *); 264280849Scy# else 265280849Scy# include <libintl.h> 266280849Scy# endif 267181834Sroberto 268280849Scy# ifndef ATTRIBUTE_FORMAT_ARG 269280849Scy# define ATTRIBUTE_FORMAT_ARG(_a) 270280849Scy# endif 271181834Sroberto 272280849Scystatic inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1); 273280849Scystatic inline char* aoGetsText(char const* pz) { 274280849Scy if (pz == NULL) return NULL; 275280849Scy return (char*)gettext(pz); 276280849Scy} 277280849Scy# define _(s) aoGetsText(s) 278280849Scy# endif /* _() */ 279280849Scy 280280849Scy# define OPT_NO_XLAT_CFG_NAMES STMTS(ntpqOptions.fOptSet |= \ 281280849Scy OPTPROC_NXLAT_OPT_CFG;) 282280849Scy# define OPT_NO_XLAT_OPT_NAMES STMTS(ntpqOptions.fOptSet |= \ 283280849Scy OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;) 284280849Scy 285280849Scy# define OPT_XLAT_CFG_NAMES STMTS(ntpqOptions.fOptSet &= \ 286280849Scy ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);) 287280849Scy# define OPT_XLAT_OPT_NAMES STMTS(ntpqOptions.fOptSet &= \ 288280849Scy ~OPTPROC_NXLAT_OPT;) 289280849Scy 290280849Scy#else /* ENABLE_NLS */ 291280849Scy# define OPT_NO_XLAT_CFG_NAMES 292280849Scy# define OPT_NO_XLAT_OPT_NAMES 293280849Scy 294280849Scy# define OPT_XLAT_CFG_NAMES 295280849Scy# define OPT_XLAT_OPT_NAMES 296280849Scy 297280849Scy# ifndef _ 298280849Scy# define _(_s) _s 299280849Scy# endif 300280849Scy#endif /* ENABLE_NLS */ 301280849Scy 302181834Sroberto#ifdef __cplusplus 303181834Sroberto} 304181834Sroberto#endif 305181834Sroberto#endif /* AUTOOPTS_NTPQ_OPTS_H_GUARD */ 306280849Scy 307181834Sroberto/* ntpq-opts.h ends here */ 308