1ea906c41SOllivier Robert /* 2ea906c41SOllivier Robert * EDIT THIS FILE WITH CAUTION (ntpq-opts.h) 3ea906c41SOllivier Robert * 4*f5f40dd6SCy Schubert * It has been AutoGen-ed May 25, 2024 at 12:04:21 AM by AutoGen 5.18.16 5ea906c41SOllivier Robert * From the definitions ntpq-opts.def 6ea906c41SOllivier Robert * and the template file options 7ea906c41SOllivier Robert * 8a466cc55SCy Schubert * Generated from AutoOpts 42:1:17 templates. 92b15cb3dSCy Schubert * 102b15cb3dSCy Schubert * AutoOpts is a copyrighted work. This header file is not encumbered 112b15cb3dSCy Schubert * by AutoOpts licensing, but is provided under the licensing terms chosen 122b15cb3dSCy Schubert * by the ntpq author or copyright holder. AutoOpts is 132b15cb3dSCy Schubert * licensed under the terms of the LGPL. The redistributable library 142b15cb3dSCy Schubert * (``libopts'') is licensed under the terms of either the LGPL or, at the 152b15cb3dSCy Schubert * users discretion, the BSD license. See the AutoOpts and/or libopts sources 162b15cb3dSCy Schubert * for details. 172b15cb3dSCy Schubert * 182b15cb3dSCy Schubert * The ntpq program is copyrighted and licensed 192b15cb3dSCy Schubert * under the following terms: 202b15cb3dSCy Schubert * 21*f5f40dd6SCy Schubert * Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved. 222b15cb3dSCy Schubert * This is free software. It is licensed for use, modification and 232b15cb3dSCy Schubert * redistribution under the terms of the NTP License, copies of which 242b15cb3dSCy Schubert * can be seen at: 252b15cb3dSCy Schubert * <http://ntp.org/license> 262b15cb3dSCy Schubert * <http://opensource.org/licenses/ntp-license.php> 272b15cb3dSCy Schubert * 282b15cb3dSCy Schubert * Permission to use, copy, modify, and distribute this software and its 292b15cb3dSCy Schubert * documentation for any purpose with or without fee is hereby granted, 302b15cb3dSCy Schubert * provided that the above copyright notice appears in all copies and that 312b15cb3dSCy Schubert * both the copyright notice and this permission notice appear in 322b15cb3dSCy Schubert * supporting documentation, and that the name The University of Delaware not be used in 332b15cb3dSCy Schubert * advertising or publicity pertaining to distribution of the software 342b15cb3dSCy Schubert * without specific, written prior permission. The University of Delaware and Network Time Foundation makes no 352b15cb3dSCy Schubert * representations about the suitability this software for any purpose. It 362b15cb3dSCy Schubert * is provided "as is" without express or implied warranty. 37ea906c41SOllivier Robert */ 382b15cb3dSCy Schubert /** 39ea906c41SOllivier Robert * This file contains the programmatic interface to the Automated 40ea906c41SOllivier Robert * Options generated for the ntpq program. 41ea906c41SOllivier Robert * These macros are documented in the AutoGen info file in the 42ea906c41SOllivier Robert * "AutoOpts" chapter. Please refer to that doc for usage help. 43ea906c41SOllivier Robert */ 44ea906c41SOllivier Robert #ifndef AUTOOPTS_NTPQ_OPTS_H_GUARD 452b15cb3dSCy Schubert #define AUTOOPTS_NTPQ_OPTS_H_GUARD 1 46ea906c41SOllivier Robert #include "config.h" 47ea906c41SOllivier Robert #include <autoopts/options.h> 48a466cc55SCy Schubert #include <stdarg.h> 49a466cc55SCy Schubert #include <stdnoreturn.h> 50ea906c41SOllivier Robert 512b15cb3dSCy Schubert /** 52ea906c41SOllivier Robert * Ensure that the library used for compiling this generated header is at 53ea906c41SOllivier Robert * least as new as the version current when the header template was released 54ea906c41SOllivier Robert * (not counting patch version increments). Also ensure that the oldest 55ea906c41SOllivier Robert * tolerable version is at least as old as what was current when the header 56ea906c41SOllivier Robert * template was released. 57ea906c41SOllivier Robert */ 58a466cc55SCy Schubert #define AO_TEMPLATE_VERSION 172033 59ea906c41SOllivier Robert #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \ 60ea906c41SOllivier Robert || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION) 61ea906c41SOllivier Robert # error option template version mismatches autoopts/options.h header 62ea906c41SOllivier Robert Choke Me. 63ea906c41SOllivier Robert #endif 64ea906c41SOllivier Robert 65a466cc55SCy Schubert #if GCC_VERSION > 40400 66a466cc55SCy Schubert #define NOT_REACHED __builtin_unreachable(); 67a466cc55SCy Schubert #else 68a466cc55SCy Schubert #define NOT_REACHED 69a466cc55SCy Schubert #endif 70a466cc55SCy Schubert 712b15cb3dSCy Schubert /** 722b15cb3dSCy Schubert * Enumeration of each option type for ntpq 73ea906c41SOllivier Robert */ 74ea906c41SOllivier Robert typedef enum { 75ea906c41SOllivier Robert INDEX_OPT_IPV4 = 0, 76ea906c41SOllivier Robert INDEX_OPT_IPV6 = 1, 77ea906c41SOllivier Robert INDEX_OPT_COMMAND = 2, 78ea906c41SOllivier Robert INDEX_OPT_DEBUG_LEVEL = 3, 79ea906c41SOllivier Robert INDEX_OPT_SET_DEBUG_LEVEL = 4, 802b15cb3dSCy Schubert INDEX_OPT_INTERACTIVE = 5, 812b15cb3dSCy Schubert INDEX_OPT_NUMERIC = 6, 822b15cb3dSCy Schubert INDEX_OPT_OLD_RV = 7, 832b15cb3dSCy Schubert INDEX_OPT_PEERS = 8, 844990d495SXin LI INDEX_OPT_REFID = 9, 85a466cc55SCy Schubert INDEX_OPT_UNCONNECTED = 10, 86a466cc55SCy Schubert INDEX_OPT_WIDE = 11, 87a466cc55SCy Schubert INDEX_OPT_VERSION = 12, 88a466cc55SCy Schubert INDEX_OPT_HELP = 13, 89a466cc55SCy Schubert INDEX_OPT_MORE_HELP = 14, 90a466cc55SCy Schubert INDEX_OPT_SAVE_OPTS = 15, 91a466cc55SCy Schubert INDEX_OPT_LOAD_OPTS = 16 92ea906c41SOllivier Robert } teOptIndex; 932b15cb3dSCy Schubert /** count of all options for ntpq */ 94a466cc55SCy Schubert #define OPTION_CT 17 952b15cb3dSCy Schubert /** ntpq version */ 96*f5f40dd6SCy Schubert #define NTPQ_VERSION "4.2.8p18" 972b15cb3dSCy Schubert /** Full ntpq version text */ 98*f5f40dd6SCy Schubert #define NTPQ_FULL_VERSION "ntpq 4.2.8p18" 99ea906c41SOllivier Robert 1002b15cb3dSCy Schubert /** 101ea906c41SOllivier Robert * Interface defines for all options. Replace "n" with the UPPER_CASED 102ea906c41SOllivier Robert * option name (as in the teOptIndex enumeration above). 103ea906c41SOllivier Robert * e.g. HAVE_OPT(IPV4) 104ea906c41SOllivier Robert */ 105ea906c41SOllivier Robert #define DESC(n) (ntpqOptions.pOptDesc[INDEX_OPT_## n]) 1062b15cb3dSCy Schubert /** 'true' if an option has been specified in any way */ 107ea906c41SOllivier Robert #define HAVE_OPT(n) (! UNUSED_OPT(& DESC(n))) 1082b15cb3dSCy Schubert /** The string argument to an option. The argument type must be \"string\". */ 109ea906c41SOllivier Robert #define OPT_ARG(n) (DESC(n).optArg.argString) 1102b15cb3dSCy Schubert /** Mask the option state revealing how an option was specified. 1112b15cb3dSCy Schubert * It will be one and only one of \a OPTST_SET, \a OPTST_PRESET, 1122b15cb3dSCy Schubert * \a OPTST_DEFINED, \a OPTST_RESET or zero. 1132b15cb3dSCy Schubert */ 114ea906c41SOllivier Robert #define STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK) 1152b15cb3dSCy Schubert /** Count of option's occurrances *on the command line*. */ 116ea906c41SOllivier Robert #define COUNT_OPT(n) (DESC(n).optOccCt) 1172b15cb3dSCy Schubert /** mask of \a OPTST_SET and \a OPTST_DEFINED. */ 118ea906c41SOllivier Robert #define ISSEL_OPT(n) (SELECTED_OPT(&DESC(n))) 1192b15cb3dSCy Schubert /** 'true' if \a HAVE_OPT would yield 'false'. */ 120ea906c41SOllivier Robert #define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n))) 1212b15cb3dSCy Schubert /** 'true' if OPTST_DISABLED bit not set. */ 122ea906c41SOllivier Robert #define ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n))) 1232b15cb3dSCy Schubert /** number of stacked option arguments. 1242b15cb3dSCy Schubert * Valid only for stacked option arguments. */ 125ea906c41SOllivier Robert #define STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt) 1262b15cb3dSCy Schubert /** stacked argument vector. 1272b15cb3dSCy Schubert * Valid only for stacked option arguments. */ 128ea906c41SOllivier Robert #define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs) 1292b15cb3dSCy Schubert /** Reset an option. */ 130ea906c41SOllivier Robert #define CLEAR_OPT(n) STMTS( \ 131ea906c41SOllivier Robert DESC(n).fOptState &= OPTST_PERSISTENT_MASK; \ 132ea906c41SOllivier Robert if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \ 133ea906c41SOllivier Robert DESC(n).fOptState |= OPTST_DISABLED; \ 134ea906c41SOllivier Robert DESC(n).optCookie = NULL ) 1352b15cb3dSCy Schubert /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 1362b15cb3dSCy Schubert /** 1372b15cb3dSCy Schubert * Enumeration of ntpq exit codes 1382b15cb3dSCy Schubert */ 1392b15cb3dSCy Schubert typedef enum { 1402b15cb3dSCy Schubert NTPQ_EXIT_SUCCESS = 0, 1412b15cb3dSCy Schubert NTPQ_EXIT_FAILURE = 1, 1422b15cb3dSCy Schubert NTPQ_EXIT_USAGE_ERROR = 64, 1432b15cb3dSCy Schubert NTPQ_EXIT_NO_CONFIG_INPUT = 66, 1442b15cb3dSCy Schubert NTPQ_EXIT_LIBOPTS_FAILURE = 70 1452b15cb3dSCy Schubert } ntpq_exit_code_t; 1462b15cb3dSCy Schubert /** @} */ 1472b15cb3dSCy Schubert /** 148ea906c41SOllivier Robert * Make sure there are no #define name conflicts with the option names 149ea906c41SOllivier Robert */ 150ea906c41SOllivier Robert #ifndef NO_OPTION_NAME_WARNINGS 151ea906c41SOllivier Robert # ifdef IPV4 152ea906c41SOllivier Robert # warning undefining IPV4 due to option name conflict 153ea906c41SOllivier Robert # undef IPV4 154ea906c41SOllivier Robert # endif 155ea906c41SOllivier Robert # ifdef IPV6 156ea906c41SOllivier Robert # warning undefining IPV6 due to option name conflict 157ea906c41SOllivier Robert # undef IPV6 158ea906c41SOllivier Robert # endif 159ea906c41SOllivier Robert # ifdef COMMAND 160ea906c41SOllivier Robert # warning undefining COMMAND due to option name conflict 161ea906c41SOllivier Robert # undef COMMAND 162ea906c41SOllivier Robert # endif 163ea906c41SOllivier Robert # ifdef DEBUG_LEVEL 164ea906c41SOllivier Robert # warning undefining DEBUG_LEVEL due to option name conflict 165ea906c41SOllivier Robert # undef DEBUG_LEVEL 166ea906c41SOllivier Robert # endif 167ea906c41SOllivier Robert # ifdef SET_DEBUG_LEVEL 168ea906c41SOllivier Robert # warning undefining SET_DEBUG_LEVEL due to option name conflict 169ea906c41SOllivier Robert # undef SET_DEBUG_LEVEL 170ea906c41SOllivier Robert # endif 171ea906c41SOllivier Robert # ifdef INTERACTIVE 172ea906c41SOllivier Robert # warning undefining INTERACTIVE due to option name conflict 173ea906c41SOllivier Robert # undef INTERACTIVE 174ea906c41SOllivier Robert # endif 175ea906c41SOllivier Robert # ifdef NUMERIC 176ea906c41SOllivier Robert # warning undefining NUMERIC due to option name conflict 177ea906c41SOllivier Robert # undef NUMERIC 178ea906c41SOllivier Robert # endif 1792b15cb3dSCy Schubert # ifdef OLD_RV 1802b15cb3dSCy Schubert # warning undefining OLD_RV due to option name conflict 1812b15cb3dSCy Schubert # undef OLD_RV 1822b15cb3dSCy Schubert # endif 1832b15cb3dSCy Schubert # ifdef PEERS 1842b15cb3dSCy Schubert # warning undefining PEERS due to option name conflict 1852b15cb3dSCy Schubert # undef PEERS 1862b15cb3dSCy Schubert # endif 1874990d495SXin LI # ifdef REFID 1884990d495SXin LI # warning undefining REFID due to option name conflict 1894990d495SXin LI # undef REFID 1904990d495SXin LI # endif 191a466cc55SCy Schubert # ifdef UNCONNECTED 192a466cc55SCy Schubert # warning undefining UNCONNECTED due to option name conflict 193a466cc55SCy Schubert # undef UNCONNECTED 194a466cc55SCy Schubert # endif 1952b15cb3dSCy Schubert # ifdef WIDE 1962b15cb3dSCy Schubert # warning undefining WIDE due to option name conflict 1972b15cb3dSCy Schubert # undef WIDE 1982b15cb3dSCy Schubert # endif 199ea906c41SOllivier Robert #else /* NO_OPTION_NAME_WARNINGS */ 200ea906c41SOllivier Robert # undef IPV4 201ea906c41SOllivier Robert # undef IPV6 202ea906c41SOllivier Robert # undef COMMAND 203ea906c41SOllivier Robert # undef DEBUG_LEVEL 204ea906c41SOllivier Robert # undef SET_DEBUG_LEVEL 205ea906c41SOllivier Robert # undef INTERACTIVE 206ea906c41SOllivier Robert # undef NUMERIC 2072b15cb3dSCy Schubert # undef OLD_RV 2082b15cb3dSCy Schubert # undef PEERS 2094990d495SXin LI # undef REFID 210a466cc55SCy Schubert # undef UNCONNECTED 2112b15cb3dSCy Schubert # undef WIDE 212ea906c41SOllivier Robert #endif /* NO_OPTION_NAME_WARNINGS */ 213ea906c41SOllivier Robert 2142b15cb3dSCy Schubert /** 215ea906c41SOllivier Robert * Interface defines for specific options. 2162b15cb3dSCy Schubert * @{ 217ea906c41SOllivier Robert */ 218ea906c41SOllivier Robert #define VALUE_OPT_IPV4 '4' 219ea906c41SOllivier Robert #define VALUE_OPT_IPV6 '6' 220ea906c41SOllivier Robert #define VALUE_OPT_COMMAND 'c' 221ea906c41SOllivier Robert #define VALUE_OPT_DEBUG_LEVEL 'd' 222ea906c41SOllivier Robert #define VALUE_OPT_SET_DEBUG_LEVEL 'D' 2232b15cb3dSCy Schubert 2242b15cb3dSCy Schubert #define OPT_VALUE_SET_DEBUG_LEVEL (DESC(SET_DEBUG_LEVEL).optArg.argInt) 225ea906c41SOllivier Robert #define VALUE_OPT_INTERACTIVE 'i' 226ea906c41SOllivier Robert #define VALUE_OPT_NUMERIC 'n' 2272b15cb3dSCy Schubert #define VALUE_OPT_OLD_RV 0x1001 2282b15cb3dSCy Schubert #define VALUE_OPT_PEERS 'p' 2294990d495SXin LI #define VALUE_OPT_REFID 'r' 2304990d495SXin LI 2314990d495SXin LI typedef enum { 2324990d495SXin LI REFID_HASH, REFID_IPV4 2334990d495SXin LI } te_Refid; 2344990d495SXin LI #define OPT_REFID_VAL2STR(_v) optionKeywordName(&DESC(REFID), (_v)) 2354990d495SXin LI #define OPT_VALUE_REFID (DESC(REFID).optArg.argEnum) 236a466cc55SCy Schubert #define VALUE_OPT_UNCONNECTED 'u' 2372b15cb3dSCy Schubert #define VALUE_OPT_WIDE 'w' 2382b15cb3dSCy Schubert /** option flag (value) for help-value option */ 239ea906c41SOllivier Robert #define VALUE_OPT_HELP '?' 2402b15cb3dSCy Schubert /** option flag (value) for more-help-value option */ 241ea906c41SOllivier Robert #define VALUE_OPT_MORE_HELP '!' 2422b15cb3dSCy Schubert /** option flag (value) for version-value option */ 2432b15cb3dSCy Schubert #define VALUE_OPT_VERSION 0x1002 2442b15cb3dSCy Schubert /** option flag (value) for save-opts-value option */ 245ea906c41SOllivier Robert #define VALUE_OPT_SAVE_OPTS '>' 2462b15cb3dSCy Schubert /** option flag (value) for load-opts-value option */ 247ea906c41SOllivier Robert #define VALUE_OPT_LOAD_OPTS '<' 248ea906c41SOllivier Robert #define SET_OPT_SAVE_OPTS(a) STMTS( \ 249ea906c41SOllivier Robert DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \ 250ea906c41SOllivier Robert DESC(SAVE_OPTS).fOptState |= OPTST_SET; \ 251ea906c41SOllivier Robert DESC(SAVE_OPTS).optArg.argString = (char const*)(a)) 252ea906c41SOllivier Robert /* 253ea906c41SOllivier Robert * Interface defines not associated with particular options 254ea906c41SOllivier Robert */ 255ea906c41SOllivier Robert #define ERRSKIP_OPTERR STMTS(ntpqOptions.fOptSet &= ~OPTPROC_ERRSTOP) 256ea906c41SOllivier Robert #define ERRSTOP_OPTERR STMTS(ntpqOptions.fOptSet |= OPTPROC_ERRSTOP) 257ea906c41SOllivier Robert #define RESTART_OPT(n) STMTS( \ 258ea906c41SOllivier Robert ntpqOptions.curOptIdx = (n); \ 259ea906c41SOllivier Robert ntpqOptions.pzCurOpt = NULL ) 260ea906c41SOllivier Robert #define START_OPT RESTART_OPT(1) 261ea906c41SOllivier Robert #define USAGE(c) (*ntpqOptions.pUsageProc)(&ntpqOptions, c) 2622b15cb3dSCy Schubert 2632b15cb3dSCy Schubert #ifdef __cplusplus 2642b15cb3dSCy Schubert extern "C" { 2652b15cb3dSCy Schubert #endif 2662b15cb3dSCy Schubert 267ea906c41SOllivier Robert 268ea906c41SOllivier Robert /* * * * * * 269ea906c41SOllivier Robert * 270ea906c41SOllivier Robert * Declare the ntpq option descriptor. 271ea906c41SOllivier Robert */ 272ea906c41SOllivier Robert extern tOptions ntpqOptions; 273ea906c41SOllivier Robert 2742b15cb3dSCy Schubert #if defined(ENABLE_NLS) 275ea906c41SOllivier Robert # ifndef _ 276ea906c41SOllivier Robert # include <stdio.h> 2772b15cb3dSCy Schubert # ifndef HAVE_GETTEXT 2782b15cb3dSCy Schubert extern char * gettext(char const *); 2792b15cb3dSCy Schubert # else 2802b15cb3dSCy Schubert # include <libintl.h> 2812b15cb3dSCy Schubert # endif 2822b15cb3dSCy Schubert 2832b15cb3dSCy Schubert # ifndef ATTRIBUTE_FORMAT_ARG 2842b15cb3dSCy Schubert # define ATTRIBUTE_FORMAT_ARG(_a) 2852b15cb3dSCy Schubert # endif 2862b15cb3dSCy Schubert 2872b15cb3dSCy Schubert static inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1); 288ea906c41SOllivier Robert static inline char* aoGetsText(char const* pz) { 289ea906c41SOllivier Robert if (pz == NULL) return NULL; 290ea906c41SOllivier Robert return (char*)gettext(pz); 291ea906c41SOllivier Robert } 292ea906c41SOllivier Robert # define _(s) aoGetsText(s) 2932b15cb3dSCy Schubert # endif /* _() */ 2942b15cb3dSCy Schubert 2952b15cb3dSCy Schubert # define OPT_NO_XLAT_CFG_NAMES STMTS(ntpqOptions.fOptSet |= \ 2962b15cb3dSCy Schubert OPTPROC_NXLAT_OPT_CFG;) 2972b15cb3dSCy Schubert # define OPT_NO_XLAT_OPT_NAMES STMTS(ntpqOptions.fOptSet |= \ 2982b15cb3dSCy Schubert OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;) 2992b15cb3dSCy Schubert 3002b15cb3dSCy Schubert # define OPT_XLAT_CFG_NAMES STMTS(ntpqOptions.fOptSet &= \ 3012b15cb3dSCy Schubert ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);) 3022b15cb3dSCy Schubert # define OPT_XLAT_OPT_NAMES STMTS(ntpqOptions.fOptSet &= \ 3032b15cb3dSCy Schubert ~OPTPROC_NXLAT_OPT;) 3042b15cb3dSCy Schubert 305ea906c41SOllivier Robert #else /* ENABLE_NLS */ 3062b15cb3dSCy Schubert # define OPT_NO_XLAT_CFG_NAMES 3072b15cb3dSCy Schubert # define OPT_NO_XLAT_OPT_NAMES 3082b15cb3dSCy Schubert 3092b15cb3dSCy Schubert # define OPT_XLAT_CFG_NAMES 3102b15cb3dSCy Schubert # define OPT_XLAT_OPT_NAMES 3112b15cb3dSCy Schubert 3122b15cb3dSCy Schubert # ifndef _ 3132b15cb3dSCy Schubert # define _(_s) _s 314ea906c41SOllivier Robert # endif 3152b15cb3dSCy Schubert #endif /* ENABLE_NLS */ 316ea906c41SOllivier Robert 317a466cc55SCy Schubert 318ea906c41SOllivier Robert #ifdef __cplusplus 319ea906c41SOllivier Robert } 320ea906c41SOllivier Robert #endif 321ea906c41SOllivier Robert #endif /* AUTOOPTS_NTPQ_OPTS_H_GUARD */ 3222b15cb3dSCy Schubert 323ea906c41SOllivier Robert /* ntpq-opts.h ends here */ 324