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