ntpq-opts.h revision 294569
1179237Sjb/* 2179237Sjb * EDIT THIS FILE WITH CAUTION (ntpq-opts.h) 3179237Sjb * 4179237Sjb * It has been AutoGen-ed January 20, 2016 at 04:18:42 AM by AutoGen 5.18.5 5179237Sjb * From the definitions ntpq-opts.def 6179237Sjb * and the template file options 7179237Sjb * 8179237Sjb * Generated from AutoOpts 41:0:16 templates. 9179237Sjb * 10179237Sjb * AutoOpts is a copyrighted work. This header file is not encumbered 11179237Sjb * by AutoOpts licensing, but is provided under the licensing terms chosen 12179237Sjb * by the ntpq author or copyright holder. AutoOpts is 13179237Sjb * licensed under the terms of the LGPL. The redistributable library 14179237Sjb * (``libopts'') is licensed under the terms of either the LGPL or, at the 15179237Sjb * users discretion, the BSD license. See the AutoOpts and/or libopts sources 16179237Sjb * for details. 17179237Sjb * 18179237Sjb * The ntpq program is copyrighted and licensed 19179237Sjb * under the following terms: 20179237Sjb * 21179237Sjb * Copyright (C) 1992-2016 The University of Delaware and Network Time Foundation, all rights reserved. 22179237Sjb * This is free software. It is licensed for use, modification and 23179237Sjb * redistribution under the terms of the NTP License, copies of which 24179237Sjb * can be seen at: 25179237Sjb * <http://ntp.org/license> 26266101Smarkj * <http://opensource.org/licenses/ntp-license.php> 27266101Smarkj * 28179237Sjb * Permission to use, copy, modify, and distribute this software and its 29179237Sjb * documentation for any purpose with or without fee is hereby granted, 30179237Sjb * provided that the above copyright notice appears in all copies and that 31211608Srpaulo * both the copyright notice and this permission notice appear in 32211608Srpaulo * supporting documentation, and that the name The University of Delaware not be used in 33211608Srpaulo * advertising or publicity pertaining to distribution of the software 34211608Srpaulo * without specific, written prior permission. The University of Delaware and Network Time Foundation makes no 35211608Srpaulo * representations about the suitability this software for any purpose. It 36211608Srpaulo * is provided "as is" without express or implied warranty. 37211608Srpaulo */ 38211608Srpaulo/** 39211608Srpaulo * This file contains the programmatic interface to the Automated 40211608Srpaulo * Options generated for the ntpq program. 41211608Srpaulo * These macros are documented in the AutoGen info file in the 42211608Srpaulo * "AutoOpts" chapter. Please refer to that doc for usage help. 43211608Srpaulo */ 44211608Srpaulo#ifndef AUTOOPTS_NTPQ_OPTS_H_GUARD 45211608Srpaulo#define AUTOOPTS_NTPQ_OPTS_H_GUARD 1 46211608Srpaulo#include "config.h" 47211608Srpaulo#include <autoopts/options.h> 48211608Srpaulo 49211608Srpaulo/** 50211608Srpaulo * Ensure that the library used for compiling this generated header is at 51211608Srpaulo * least as new as the version current when the header template was released 52211608Srpaulo * (not counting patch version increments). Also ensure that the oldest 53211608Srpaulo * tolerable version is at least as old as what was current when the header 54211608Srpaulo * template was released. 55211608Srpaulo */ 56211608Srpaulo#define AO_TEMPLATE_VERSION 167936 57211608Srpaulo#if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \ 58211608Srpaulo || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION) 59211608Srpaulo# error option template version mismatches autoopts/options.h header 60211608Srpaulo Choke Me. 61211608Srpaulo#endif 62211608Srpaulo 63211608Srpaulo/** 64211608Srpaulo * Enumeration of each option type for ntpq 65211608Srpaulo */ 66211608Srpaulotypedef enum { 67211608Srpaulo INDEX_OPT_IPV4 = 0, 68211608Srpaulo INDEX_OPT_IPV6 = 1, 69211608Srpaulo INDEX_OPT_COMMAND = 2, 70211608Srpaulo INDEX_OPT_DEBUG_LEVEL = 3, 71211608Srpaulo INDEX_OPT_SET_DEBUG_LEVEL = 4, 72211608Srpaulo INDEX_OPT_INTERACTIVE = 5, 73211608Srpaulo INDEX_OPT_NUMERIC = 6, 74211608Srpaulo INDEX_OPT_OLD_RV = 7, 75211608Srpaulo INDEX_OPT_PEERS = 8, 76211608Srpaulo INDEX_OPT_WIDE = 9, 77211608Srpaulo INDEX_OPT_VERSION = 10, 78211608Srpaulo INDEX_OPT_HELP = 11, 79211608Srpaulo INDEX_OPT_MORE_HELP = 12, 80179237Sjb INDEX_OPT_SAVE_OPTS = 13, 81179237Sjb INDEX_OPT_LOAD_OPTS = 14 82179237Sjb} teOptIndex; 83179237Sjb/** count of all options for ntpq */ 84179237Sjb#define OPTION_CT 15 85184698Srodrigc/** ntpq version */ 86179237Sjb#define NTPQ_VERSION "4.2.8p6" 87184698Srodrigc/** Full ntpq version text */ 88184698Srodrigc#define NTPQ_FULL_VERSION "ntpq 4.2.8p6" 89184698Srodrigc 90184698Srodrigc/** 91179237Sjb * Interface defines for all options. Replace "n" with the UPPER_CASED 92179237Sjb * option name (as in the teOptIndex enumeration above). 93179237Sjb * e.g. HAVE_OPT(IPV4) 94179237Sjb */ 95179237Sjb#define DESC(n) (ntpqOptions.pOptDesc[INDEX_OPT_## n]) 96179237Sjb/** 'true' if an option has been specified in any way */ 97179237Sjb#define HAVE_OPT(n) (! UNUSED_OPT(& DESC(n))) 98179237Sjb/** The string argument to an option. The argument type must be \"string\". */ 99179237Sjb#define OPT_ARG(n) (DESC(n).optArg.argString) 100179237Sjb/** Mask the option state revealing how an option was specified. 101179237Sjb * It will be one and only one of \a OPTST_SET, \a OPTST_PRESET, 102179237Sjb * \a OPTST_DEFINED, \a OPTST_RESET or zero. 103179237Sjb */ 104179237Sjb#define STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK) 105179237Sjb/** Count of option's occurrances *on the command line*. */ 106179237Sjb#define COUNT_OPT(n) (DESC(n).optOccCt) 107179237Sjb/** mask of \a OPTST_SET and \a OPTST_DEFINED. */ 108179237Sjb#define ISSEL_OPT(n) (SELECTED_OPT(&DESC(n))) 109179237Sjb/** 'true' if \a HAVE_OPT would yield 'false'. */ 110179237Sjb#define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n))) 111179237Sjb/** 'true' if OPTST_DISABLED bit not set. */ 112179237Sjb#define ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n))) 113179237Sjb/** number of stacked option arguments. 114179237Sjb * Valid only for stacked option arguments. */ 115179237Sjb#define STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt) 116179237Sjb/** stacked argument vector. 117179237Sjb * Valid only for stacked option arguments. */ 118179237Sjb#define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs) 119179237Sjb/** Reset an option. */ 120179237Sjb#define CLEAR_OPT(n) STMTS( \ 121179237Sjb DESC(n).fOptState &= OPTST_PERSISTENT_MASK; \ 122179237Sjb if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \ 123179237Sjb DESC(n).fOptState |= OPTST_DISABLED; \ 124179237Sjb DESC(n).optCookie = NULL ) 125179237Sjb/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 126179237Sjb/** 127179237Sjb * Enumeration of ntpq exit codes 128179237Sjb */ 129179237Sjbtypedef enum { 130179237Sjb NTPQ_EXIT_SUCCESS = 0, 131179237Sjb NTPQ_EXIT_FAILURE = 1, 132179237Sjb NTPQ_EXIT_USAGE_ERROR = 64, 133179237Sjb NTPQ_EXIT_NO_CONFIG_INPUT = 66, 134179237Sjb NTPQ_EXIT_LIBOPTS_FAILURE = 70 135179237Sjb} ntpq_exit_code_t; 136179237Sjb/** @} */ 137179237Sjb/** 138179237Sjb * Make sure there are no #define name conflicts with the option names 139179237Sjb */ 140179237Sjb#ifndef NO_OPTION_NAME_WARNINGS 141179237Sjb# ifdef IPV4 142179237Sjb# warning undefining IPV4 due to option name conflict 143179237Sjb# undef IPV4 144179237Sjb# endif 145179237Sjb# ifdef IPV6 146179237Sjb# warning undefining IPV6 due to option name conflict 147179237Sjb# undef IPV6 148179237Sjb# endif 149179237Sjb# ifdef COMMAND 150179237Sjb# warning undefining COMMAND due to option name conflict 151179237Sjb# undef COMMAND 152179237Sjb# endif 153179237Sjb# ifdef DEBUG_LEVEL 154179237Sjb# warning undefining DEBUG_LEVEL due to option name conflict 155179237Sjb# undef DEBUG_LEVEL 156179237Sjb# endif 157179237Sjb# ifdef SET_DEBUG_LEVEL 158179237Sjb# warning undefining SET_DEBUG_LEVEL due to option name conflict 159179237Sjb# undef SET_DEBUG_LEVEL 160179237Sjb# endif 161179237Sjb# ifdef INTERACTIVE 162179237Sjb# warning undefining INTERACTIVE due to option name conflict 163179237Sjb# undef INTERACTIVE 164179237Sjb# endif 165179237Sjb# ifdef NUMERIC 166179237Sjb# warning undefining NUMERIC due to option name conflict 167179237Sjb# undef NUMERIC 168179237Sjb# endif 169179237Sjb# ifdef OLD_RV 170179237Sjb# warning undefining OLD_RV due to option name conflict 171179237Sjb# undef OLD_RV 172179237Sjb# endif 173179237Sjb# ifdef PEERS 174179237Sjb# warning undefining PEERS due to option name conflict 175179237Sjb# undef PEERS 176179237Sjb# endif 177179237Sjb# ifdef WIDE 178179237Sjb# warning undefining WIDE due to option name conflict 179179237Sjb# undef WIDE 180179237Sjb# endif 181179237Sjb#else /* NO_OPTION_NAME_WARNINGS */ 182179237Sjb# undef IPV4 183179237Sjb# undef IPV6 184179237Sjb# undef COMMAND 185179237Sjb# undef DEBUG_LEVEL 186179237Sjb# undef SET_DEBUG_LEVEL 187179237Sjb# undef INTERACTIVE 188179237Sjb# undef NUMERIC 189179237Sjb# undef OLD_RV 190179237Sjb# undef PEERS 191179237Sjb# undef WIDE 192179237Sjb#endif /* NO_OPTION_NAME_WARNINGS */ 193179237Sjb 194179237Sjb/** 195179237Sjb * Interface defines for specific options. 196179237Sjb * @{ 197179237Sjb */ 198179237Sjb#define VALUE_OPT_IPV4 '4' 199179237Sjb#define VALUE_OPT_IPV6 '6' 200179237Sjb#define VALUE_OPT_COMMAND 'c' 201179237Sjb#define VALUE_OPT_DEBUG_LEVEL 'd' 202179237Sjb#define VALUE_OPT_SET_DEBUG_LEVEL 'D' 203179237Sjb 204179237Sjb#define OPT_VALUE_SET_DEBUG_LEVEL (DESC(SET_DEBUG_LEVEL).optArg.argInt) 205179237Sjb#define VALUE_OPT_INTERACTIVE 'i' 206179237Sjb#define VALUE_OPT_NUMERIC 'n' 207179237Sjb#define VALUE_OPT_OLD_RV 0x1001 208179237Sjb#define VALUE_OPT_PEERS 'p' 209179237Sjb#define VALUE_OPT_WIDE 'w' 210179237Sjb/** option flag (value) for help-value option */ 211179237Sjb#define VALUE_OPT_HELP '?' 212179237Sjb/** option flag (value) for more-help-value option */ 213179237Sjb#define VALUE_OPT_MORE_HELP '!' 214179237Sjb/** option flag (value) for version-value option */ 215179237Sjb#define VALUE_OPT_VERSION 0x1002 216179237Sjb/** option flag (value) for save-opts-value option */ 217179237Sjb#define VALUE_OPT_SAVE_OPTS '>' 218179237Sjb/** option flag (value) for load-opts-value option */ 219179237Sjb#define VALUE_OPT_LOAD_OPTS '<' 220179237Sjb#define SET_OPT_SAVE_OPTS(a) STMTS( \ 221179237Sjb DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \ 222179237Sjb DESC(SAVE_OPTS).fOptState |= OPTST_SET; \ 223179237Sjb DESC(SAVE_OPTS).optArg.argString = (char const*)(a)) 224179237Sjb/* 225179237Sjb * Interface defines not associated with particular options 226179237Sjb */ 227179237Sjb#define ERRSKIP_OPTERR STMTS(ntpqOptions.fOptSet &= ~OPTPROC_ERRSTOP) 228179237Sjb#define ERRSTOP_OPTERR STMTS(ntpqOptions.fOptSet |= OPTPROC_ERRSTOP) 229179237Sjb#define RESTART_OPT(n) STMTS( \ 230179237Sjb ntpqOptions.curOptIdx = (n); \ 231179237Sjb ntpqOptions.pzCurOpt = NULL ) 232179237Sjb#define START_OPT RESTART_OPT(1) 233179237Sjb#define USAGE(c) (*ntpqOptions.pUsageProc)(&ntpqOptions, c) 234179237Sjb 235179237Sjb#ifdef __cplusplus 236179237Sjbextern "C" { 237179237Sjb#endif 238179237Sjb 239179237Sjb 240179237Sjb/* * * * * * 241179237Sjb * 242179237Sjb * Declare the ntpq option descriptor. 243179237Sjb */ 244179237Sjbextern tOptions ntpqOptions; 245179237Sjb 246179237Sjb#if defined(ENABLE_NLS) 247179237Sjb# ifndef _ 248179237Sjb# include <stdio.h> 249179237Sjb# ifndef HAVE_GETTEXT 250179237Sjb extern char * gettext(char const *); 251179237Sjb# else 252179237Sjb# include <libintl.h> 253179237Sjb# endif 254179237Sjb 255179237Sjb# ifndef ATTRIBUTE_FORMAT_ARG 256179237Sjb# define ATTRIBUTE_FORMAT_ARG(_a) 257179237Sjb# endif 258179237Sjb 259179237Sjbstatic inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1); 260179237Sjbstatic inline char* aoGetsText(char const* pz) { 261179237Sjb if (pz == NULL) return NULL; 262179237Sjb return (char*)gettext(pz); 263179237Sjb} 264179237Sjb# define _(s) aoGetsText(s) 265179237Sjb# endif /* _() */ 266179237Sjb 267179237Sjb# define OPT_NO_XLAT_CFG_NAMES STMTS(ntpqOptions.fOptSet |= \ 268179237Sjb OPTPROC_NXLAT_OPT_CFG;) 269179237Sjb# define OPT_NO_XLAT_OPT_NAMES STMTS(ntpqOptions.fOptSet |= \ 270179237Sjb OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;) 271179237Sjb 272179237Sjb# define OPT_XLAT_CFG_NAMES STMTS(ntpqOptions.fOptSet &= \ 273179237Sjb ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);) 274179237Sjb# define OPT_XLAT_OPT_NAMES STMTS(ntpqOptions.fOptSet &= \ 275179237Sjb ~OPTPROC_NXLAT_OPT;) 276179237Sjb 277179237Sjb#else /* ENABLE_NLS */ 278179237Sjb# define OPT_NO_XLAT_CFG_NAMES 279179237Sjb# define OPT_NO_XLAT_OPT_NAMES 280179237Sjb 281179237Sjb# define OPT_XLAT_CFG_NAMES 282256002Spfg# define OPT_XLAT_OPT_NAMES 283179237Sjb 284179237Sjb# ifndef _ 285179237Sjb# define _(_s) _s 286179237Sjb# endif 287179237Sjb#endif /* ENABLE_NLS */ 288179237Sjb 289179237Sjb#ifdef __cplusplus 290179237Sjb} 291179237Sjb#endif 292179237Sjb#endif /* AUTOOPTS_NTPQ_OPTS_H_GUARD */ 293179237Sjb 294179237Sjb/* ntpq-opts.h ends here */ 295179237Sjb