1*eabc0478Schristos /* $NetBSD: sntp-opts.h,v 1.15 2024/08/18 20:47:20 christos Exp $ */ 2abb0f93cSkardel 3abb0f93cSkardel /* 4abb0f93cSkardel * EDIT THIS FILE WITH CAUTION (sntp-opts.h) 5abb0f93cSkardel * 6*eabc0478Schristos * It has been AutoGen-ed May 25, 2024 at 12:02:07 AM by AutoGen 5.18.16 7abb0f93cSkardel * From the definitions sntp-opts.def 8abb0f93cSkardel * and the template file options 9abb0f93cSkardel * 10*eabc0478Schristos * Generated from AutoOpts 42:1:17 templates. 11f003fb54Skardel * 12f003fb54Skardel * AutoOpts is a copyrighted work. This header file is not encumbered 13f003fb54Skardel * by AutoOpts licensing, but is provided under the licensing terms chosen 14f003fb54Skardel * by the sntp author or copyright holder. AutoOpts is 15f003fb54Skardel * licensed under the terms of the LGPL. The redistributable library 16f003fb54Skardel * (``libopts'') is licensed under the terms of either the LGPL or, at the 17f003fb54Skardel * users discretion, the BSD license. See the AutoOpts and/or libopts sources 18f003fb54Skardel * for details. 19abb0f93cSkardel * 208585484eSchristos * The sntp program is copyrighted and licensed 218585484eSchristos * under the following terms: 22abb0f93cSkardel * 23*eabc0478Schristos * Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved. 248585484eSchristos * This is free software. It is licensed for use, modification and 258585484eSchristos * redistribution under the terms of the NTP License, copies of which 268585484eSchristos * can be seen at: 278585484eSchristos * <http://ntp.org/license> 288585484eSchristos * <http://opensource.org/licenses/ntp-license.php> 29f003fb54Skardel * 308585484eSchristos * Permission to use, copy, modify, and distribute this software and its 318585484eSchristos * documentation for any purpose with or without fee is hereby granted, 328585484eSchristos * provided that the above copyright notice appears in all copies and that 338585484eSchristos * both the copyright notice and this permission notice appear in 348585484eSchristos * supporting documentation, and that the name The University of Delaware not be used in 358585484eSchristos * advertising or publicity pertaining to distribution of the software 367476e6e4Schristos * without specific, written prior permission. The University of Delaware and Network Time Foundation makes no 378585484eSchristos * representations about the suitability this software for any purpose. It 388585484eSchristos * is provided "as is" without express or implied warranty. 39abb0f93cSkardel */ 408585484eSchristos /** 41abb0f93cSkardel * This file contains the programmatic interface to the Automated 42abb0f93cSkardel * Options generated for the sntp program. 43abb0f93cSkardel * These macros are documented in the AutoGen info file in the 44abb0f93cSkardel * "AutoOpts" chapter. Please refer to that doc for usage help. 45abb0f93cSkardel */ 46abb0f93cSkardel #ifndef AUTOOPTS_SNTP_OPTS_H_GUARD 47abb0f93cSkardel #define AUTOOPTS_SNTP_OPTS_H_GUARD 1 48abb0f93cSkardel #include "config.h" 49abb0f93cSkardel #include <autoopts/options.h> 50*eabc0478Schristos #include <stdarg.h> 51*eabc0478Schristos #include <stdnoreturn.h> 52abb0f93cSkardel 538585484eSchristos /** 54abb0f93cSkardel * Ensure that the library used for compiling this generated header is at 55abb0f93cSkardel * least as new as the version current when the header template was released 56abb0f93cSkardel * (not counting patch version increments). Also ensure that the oldest 57abb0f93cSkardel * tolerable version is at least as old as what was current when the header 58abb0f93cSkardel * template was released. 59abb0f93cSkardel */ 60*eabc0478Schristos #define AO_TEMPLATE_VERSION 172033 61abb0f93cSkardel #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \ 62abb0f93cSkardel || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION) 63abb0f93cSkardel # error option template version mismatches autoopts/options.h header 64abb0f93cSkardel Choke Me. 65abb0f93cSkardel #endif 66abb0f93cSkardel 67*eabc0478Schristos #if GCC_VERSION > 40400 68*eabc0478Schristos #define NOT_REACHED __builtin_unreachable(); 69*eabc0478Schristos #else 70*eabc0478Schristos #define NOT_REACHED 71*eabc0478Schristos #endif 72*eabc0478Schristos 738585484eSchristos /** 748585484eSchristos * Enumeration of each option type for sntp 75abb0f93cSkardel */ 76abb0f93cSkardel typedef enum { 77abb0f93cSkardel INDEX_OPT_IPV4 = 0, 78abb0f93cSkardel INDEX_OPT_IPV6 = 1, 798585484eSchristos INDEX_OPT_AUTHENTICATION = 2, 808585484eSchristos INDEX_OPT_BROADCAST = 3, 818585484eSchristos INDEX_OPT_CONCURRENT = 4, 828585484eSchristos INDEX_OPT_DEBUG_LEVEL = 5, 838585484eSchristos INDEX_OPT_SET_DEBUG_LEVEL = 6, 848585484eSchristos INDEX_OPT_GAP = 7, 858585484eSchristos INDEX_OPT_KOD = 8, 868585484eSchristos INDEX_OPT_KEYFILE = 9, 878585484eSchristos INDEX_OPT_LOGFILE = 10, 888585484eSchristos INDEX_OPT_STEPLIMIT = 11, 898585484eSchristos INDEX_OPT_NTPVERSION = 12, 908585484eSchristos INDEX_OPT_USERESERVEDPORT = 13, 918585484eSchristos INDEX_OPT_STEP = 14, 928585484eSchristos INDEX_OPT_SLEW = 15, 938585484eSchristos INDEX_OPT_TIMEOUT = 16, 948585484eSchristos INDEX_OPT_WAIT = 17, 958585484eSchristos INDEX_OPT_VERSION = 18, 968585484eSchristos INDEX_OPT_HELP = 19, 978585484eSchristos INDEX_OPT_MORE_HELP = 20, 988585484eSchristos INDEX_OPT_SAVE_OPTS = 21, 998585484eSchristos INDEX_OPT_LOAD_OPTS = 22 100abb0f93cSkardel } teOptIndex; 1018585484eSchristos /** count of all options for sntp */ 1028585484eSchristos #define OPTION_CT 23 1038585484eSchristos /** sntp version */ 104*eabc0478Schristos #define SNTP_VERSION "4.2.8p18" 1058585484eSchristos /** Full sntp version text */ 106*eabc0478Schristos #define SNTP_FULL_VERSION "sntp 4.2.8p18" 107abb0f93cSkardel 1088585484eSchristos /** 109abb0f93cSkardel * Interface defines for all options. Replace "n" with the UPPER_CASED 110abb0f93cSkardel * option name (as in the teOptIndex enumeration above). 111abb0f93cSkardel * e.g. HAVE_OPT(IPV4) 112abb0f93cSkardel */ 113abb0f93cSkardel #define DESC(n) (sntpOptions.pOptDesc[INDEX_OPT_## n]) 1148585484eSchristos /** 'true' if an option has been specified in any way */ 115abb0f93cSkardel #define HAVE_OPT(n) (! UNUSED_OPT(& DESC(n))) 1168585484eSchristos /** The string argument to an option. The argument type must be \"string\". */ 117abb0f93cSkardel #define OPT_ARG(n) (DESC(n).optArg.argString) 1188585484eSchristos /** Mask the option state revealing how an option was specified. 1198585484eSchristos * It will be one and only one of \a OPTST_SET, \a OPTST_PRESET, 1208585484eSchristos * \a OPTST_DEFINED, \a OPTST_RESET or zero. 1218585484eSchristos */ 122abb0f93cSkardel #define STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK) 1238585484eSchristos /** Count of option's occurrances *on the command line*. */ 124abb0f93cSkardel #define COUNT_OPT(n) (DESC(n).optOccCt) 1258585484eSchristos /** mask of \a OPTST_SET and \a OPTST_DEFINED. */ 126abb0f93cSkardel #define ISSEL_OPT(n) (SELECTED_OPT(&DESC(n))) 1278585484eSchristos /** 'true' if \a HAVE_OPT would yield 'false'. */ 128abb0f93cSkardel #define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n))) 1298585484eSchristos /** 'true' if OPTST_DISABLED bit not set. */ 130abb0f93cSkardel #define ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n))) 1318585484eSchristos /** number of stacked option arguments. 1328585484eSchristos * Valid only for stacked option arguments. */ 133abb0f93cSkardel #define STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt) 1348585484eSchristos /** stacked argument vector. 1358585484eSchristos * Valid only for stacked option arguments. */ 136abb0f93cSkardel #define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs) 1378585484eSchristos /** Reset an option. */ 138abb0f93cSkardel #define CLEAR_OPT(n) STMTS( \ 139abb0f93cSkardel DESC(n).fOptState &= OPTST_PERSISTENT_MASK; \ 140abb0f93cSkardel if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \ 141abb0f93cSkardel DESC(n).fOptState |= OPTST_DISABLED; \ 142abb0f93cSkardel DESC(n).optCookie = NULL ) 1438585484eSchristos /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 1448585484eSchristos /** 145f003fb54Skardel * Enumeration of sntp exit codes 146f003fb54Skardel */ 147f003fb54Skardel typedef enum { 148f003fb54Skardel SNTP_EXIT_SUCCESS = 0, 1498585484eSchristos SNTP_EXIT_FAILURE = 1, 1508585484eSchristos SNTP_EXIT_USAGE_ERROR = 64, 1518585484eSchristos SNTP_EXIT_NO_CONFIG_INPUT = 66, 1528585484eSchristos SNTP_EXIT_LIBOPTS_FAILURE = 70 153f003fb54Skardel } sntp_exit_code_t; 1548585484eSchristos /** @} */ 1558585484eSchristos /** 156abb0f93cSkardel * Make sure there are no #define name conflicts with the option names 157abb0f93cSkardel */ 158abb0f93cSkardel #ifndef NO_OPTION_NAME_WARNINGS 159abb0f93cSkardel # ifdef IPV4 160abb0f93cSkardel # warning undefining IPV4 due to option name conflict 161abb0f93cSkardel # undef IPV4 162abb0f93cSkardel # endif 163abb0f93cSkardel # ifdef IPV6 164abb0f93cSkardel # warning undefining IPV6 due to option name conflict 165abb0f93cSkardel # undef IPV6 166abb0f93cSkardel # endif 1678585484eSchristos # ifdef AUTHENTICATION 1688585484eSchristos # warning undefining AUTHENTICATION due to option name conflict 1698585484eSchristos # undef AUTHENTICATION 170abb0f93cSkardel # endif 171abb0f93cSkardel # ifdef BROADCAST 172abb0f93cSkardel # warning undefining BROADCAST due to option name conflict 173abb0f93cSkardel # undef BROADCAST 174abb0f93cSkardel # endif 1758585484eSchristos # ifdef CONCURRENT 1768585484eSchristos # warning undefining CONCURRENT due to option name conflict 1778585484eSchristos # undef CONCURRENT 178abb0f93cSkardel # endif 1798585484eSchristos # ifdef DEBUG_LEVEL 1808585484eSchristos # warning undefining DEBUG_LEVEL due to option name conflict 1818585484eSchristos # undef DEBUG_LEVEL 1828585484eSchristos # endif 1838585484eSchristos # ifdef SET_DEBUG_LEVEL 1848585484eSchristos # warning undefining SET_DEBUG_LEVEL due to option name conflict 1858585484eSchristos # undef SET_DEBUG_LEVEL 1868585484eSchristos # endif 1878585484eSchristos # ifdef GAP 1888585484eSchristos # warning undefining GAP due to option name conflict 1898585484eSchristos # undef GAP 1908585484eSchristos # endif 1918585484eSchristos # ifdef KOD 1928585484eSchristos # warning undefining KOD due to option name conflict 1938585484eSchristos # undef KOD 194abb0f93cSkardel # endif 195abb0f93cSkardel # ifdef KEYFILE 196abb0f93cSkardel # warning undefining KEYFILE due to option name conflict 197abb0f93cSkardel # undef KEYFILE 198abb0f93cSkardel # endif 1998585484eSchristos # ifdef LOGFILE 2008585484eSchristos # warning undefining LOGFILE due to option name conflict 2018585484eSchristos # undef LOGFILE 2028585484eSchristos # endif 2038585484eSchristos # ifdef STEPLIMIT 2048585484eSchristos # warning undefining STEPLIMIT due to option name conflict 2058585484eSchristos # undef STEPLIMIT 2068585484eSchristos # endif 2078585484eSchristos # ifdef NTPVERSION 2088585484eSchristos # warning undefining NTPVERSION due to option name conflict 2098585484eSchristos # undef NTPVERSION 2108585484eSchristos # endif 2118585484eSchristos # ifdef USERESERVEDPORT 2128585484eSchristos # warning undefining USERESERVEDPORT due to option name conflict 2138585484eSchristos # undef USERESERVEDPORT 2148585484eSchristos # endif 2158585484eSchristos # ifdef STEP 2168585484eSchristos # warning undefining STEP due to option name conflict 2178585484eSchristos # undef STEP 2188585484eSchristos # endif 2198585484eSchristos # ifdef SLEW 2208585484eSchristos # warning undefining SLEW due to option name conflict 2218585484eSchristos # undef SLEW 2228585484eSchristos # endif 2238585484eSchristos # ifdef TIMEOUT 2248585484eSchristos # warning undefining TIMEOUT due to option name conflict 2258585484eSchristos # undef TIMEOUT 2268585484eSchristos # endif 2278585484eSchristos # ifdef WAIT 2288585484eSchristos # warning undefining WAIT due to option name conflict 2298585484eSchristos # undef WAIT 2308585484eSchristos # endif 231abb0f93cSkardel #else /* NO_OPTION_NAME_WARNINGS */ 232abb0f93cSkardel # undef IPV4 233abb0f93cSkardel # undef IPV6 234abb0f93cSkardel # undef AUTHENTICATION 2358585484eSchristos # undef BROADCAST 2368585484eSchristos # undef CONCURRENT 2378585484eSchristos # undef DEBUG_LEVEL 2388585484eSchristos # undef SET_DEBUG_LEVEL 2398585484eSchristos # undef GAP 2408585484eSchristos # undef KOD 241abb0f93cSkardel # undef KEYFILE 2428585484eSchristos # undef LOGFILE 2438585484eSchristos # undef STEPLIMIT 2448585484eSchristos # undef NTPVERSION 2458585484eSchristos # undef USERESERVEDPORT 2468585484eSchristos # undef STEP 2478585484eSchristos # undef SLEW 2488585484eSchristos # undef TIMEOUT 2498585484eSchristos # undef WAIT 250abb0f93cSkardel #endif /* NO_OPTION_NAME_WARNINGS */ 251abb0f93cSkardel 2528585484eSchristos /** 253abb0f93cSkardel * Interface defines for specific options. 2548585484eSchristos * @{ 255abb0f93cSkardel */ 256abb0f93cSkardel #define VALUE_OPT_IPV4 '4' 257abb0f93cSkardel #define VALUE_OPT_IPV6 '6' 258abb0f93cSkardel #define VALUE_OPT_AUTHENTICATION 'a' 259abb0f93cSkardel 260abb0f93cSkardel #define OPT_VALUE_AUTHENTICATION (DESC(AUTHENTICATION).optArg.argInt) 2618585484eSchristos #define VALUE_OPT_BROADCAST 'b' 2628585484eSchristos #define VALUE_OPT_CONCURRENT 'c' 2638585484eSchristos #define VALUE_OPT_DEBUG_LEVEL 'd' 2648585484eSchristos #define VALUE_OPT_SET_DEBUG_LEVEL 'D' 2658585484eSchristos 2668585484eSchristos #define OPT_VALUE_SET_DEBUG_LEVEL (DESC(SET_DEBUG_LEVEL).optArg.argInt) 2678585484eSchristos #define VALUE_OPT_GAP 'g' 2688585484eSchristos 2698585484eSchristos #define OPT_VALUE_GAP (DESC(GAP).optArg.argInt) 2708585484eSchristos #define VALUE_OPT_KOD 'K' 271abb0f93cSkardel #define VALUE_OPT_KEYFILE 'k' 2728585484eSchristos #define VALUE_OPT_LOGFILE 'l' 2738585484eSchristos #define VALUE_OPT_STEPLIMIT 'M' 2748585484eSchristos 2758585484eSchristos #define OPT_VALUE_STEPLIMIT (DESC(STEPLIMIT).optArg.argInt) 2768585484eSchristos #define VALUE_OPT_NTPVERSION 'o' 2778585484eSchristos 2788585484eSchristos #define OPT_VALUE_NTPVERSION (DESC(NTPVERSION).optArg.argInt) 2798585484eSchristos #define VALUE_OPT_USERESERVEDPORT 'r' 2808585484eSchristos #define VALUE_OPT_STEP 'S' 2818585484eSchristos #define VALUE_OPT_SLEW 's' 2828585484eSchristos #define VALUE_OPT_TIMEOUT 't' 2838585484eSchristos 2848585484eSchristos #define OPT_VALUE_TIMEOUT (DESC(TIMEOUT).optArg.argInt) 2858585484eSchristos #define VALUE_OPT_WAIT 0x1001 2868585484eSchristos 2878585484eSchristos #define SET_OPT_WAIT STMTS( \ 2888585484eSchristos DESC(WAIT).optActualIndex = 17; \ 2898585484eSchristos DESC(WAIT).optActualValue = VALUE_OPT_WAIT; \ 2908585484eSchristos DESC(WAIT).fOptState &= OPTST_PERSISTENT_MASK; \ 2918585484eSchristos DESC(WAIT).fOptState |= OPTST_SET ) 2928585484eSchristos #define DISABLE_OPT_WAIT STMTS( \ 2938585484eSchristos DESC(WAIT).fOptState &= OPTST_PERSISTENT_MASK; \ 2948585484eSchristos DESC(WAIT).fOptState |= OPTST_SET | OPTST_DISABLED; \ 2958585484eSchristos DESC(WAIT).optArg.argString = NULL ) 296b8ecfcfeSchristos /** option flag (value) for help-value option */ 297abb0f93cSkardel #define VALUE_OPT_HELP '?' 298b8ecfcfeSchristos /** option flag (value) for more-help-value option */ 299abb0f93cSkardel #define VALUE_OPT_MORE_HELP '!' 300b8ecfcfeSchristos /** option flag (value) for version-value option */ 3018585484eSchristos #define VALUE_OPT_VERSION 0x1002 302b8ecfcfeSchristos /** option flag (value) for save-opts-value option */ 303abb0f93cSkardel #define VALUE_OPT_SAVE_OPTS '>' 304b8ecfcfeSchristos /** option flag (value) for load-opts-value option */ 305abb0f93cSkardel #define VALUE_OPT_LOAD_OPTS '<' 306abb0f93cSkardel #define SET_OPT_SAVE_OPTS(a) STMTS( \ 307abb0f93cSkardel DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \ 308abb0f93cSkardel DESC(SAVE_OPTS).fOptState |= OPTST_SET; \ 309abb0f93cSkardel DESC(SAVE_OPTS).optArg.argString = (char const*)(a)) 310abb0f93cSkardel /* 311abb0f93cSkardel * Interface defines not associated with particular options 312abb0f93cSkardel */ 313abb0f93cSkardel #define ERRSKIP_OPTERR STMTS(sntpOptions.fOptSet &= ~OPTPROC_ERRSTOP) 314abb0f93cSkardel #define ERRSTOP_OPTERR STMTS(sntpOptions.fOptSet |= OPTPROC_ERRSTOP) 315abb0f93cSkardel #define RESTART_OPT(n) STMTS( \ 316abb0f93cSkardel sntpOptions.curOptIdx = (n); \ 317abb0f93cSkardel sntpOptions.pzCurOpt = NULL ) 318abb0f93cSkardel #define START_OPT RESTART_OPT(1) 319abb0f93cSkardel #define USAGE(c) (*sntpOptions.pUsageProc)(&sntpOptions, c) 320f003fb54Skardel 321f003fb54Skardel #ifdef __cplusplus 322f003fb54Skardel extern "C" { 323f003fb54Skardel #endif 324abb0f93cSkardel 3258585484eSchristos 326abb0f93cSkardel /* * * * * * 327abb0f93cSkardel * 328abb0f93cSkardel * Declare the sntp option descriptor. 329abb0f93cSkardel */ 330abb0f93cSkardel extern tOptions sntpOptions; 331abb0f93cSkardel 332abb0f93cSkardel #if defined(ENABLE_NLS) 333abb0f93cSkardel # ifndef _ 334abb0f93cSkardel # include <stdio.h> 3358585484eSchristos # ifndef HAVE_GETTEXT 3368585484eSchristos extern char * gettext(char const *); 3378585484eSchristos # else 3388585484eSchristos # include <libintl.h> 3398585484eSchristos # endif 3408585484eSchristos 341b8ecfcfeSchristos # ifndef ATTRIBUTE_FORMAT_ARG 342b8ecfcfeSchristos # define ATTRIBUTE_FORMAT_ARG(_a) 343b8ecfcfeSchristos # endif 344b8ecfcfeSchristos 345b8ecfcfeSchristos static inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1); 346abb0f93cSkardel static inline char* aoGetsText(char const* pz) { 347abb0f93cSkardel if (pz == NULL) return NULL; 348abb0f93cSkardel return (char*)gettext(pz); 349abb0f93cSkardel } 350abb0f93cSkardel # define _(s) aoGetsText(s) 351abb0f93cSkardel # endif /* _() */ 352abb0f93cSkardel 353abb0f93cSkardel # define OPT_NO_XLAT_CFG_NAMES STMTS(sntpOptions.fOptSet |= \ 354abb0f93cSkardel OPTPROC_NXLAT_OPT_CFG;) 355abb0f93cSkardel # define OPT_NO_XLAT_OPT_NAMES STMTS(sntpOptions.fOptSet |= \ 356abb0f93cSkardel OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;) 357abb0f93cSkardel 358abb0f93cSkardel # define OPT_XLAT_CFG_NAMES STMTS(sntpOptions.fOptSet &= \ 359abb0f93cSkardel ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);) 360abb0f93cSkardel # define OPT_XLAT_OPT_NAMES STMTS(sntpOptions.fOptSet &= \ 361abb0f93cSkardel ~OPTPROC_NXLAT_OPT;) 362abb0f93cSkardel 363abb0f93cSkardel #else /* ENABLE_NLS */ 364abb0f93cSkardel # define OPT_NO_XLAT_CFG_NAMES 365abb0f93cSkardel # define OPT_NO_XLAT_OPT_NAMES 366abb0f93cSkardel 367abb0f93cSkardel # define OPT_XLAT_CFG_NAMES 368abb0f93cSkardel # define OPT_XLAT_OPT_NAMES 369abb0f93cSkardel 370abb0f93cSkardel # ifndef _ 371abb0f93cSkardel # define _(_s) _s 372abb0f93cSkardel # endif 373abb0f93cSkardel #endif /* ENABLE_NLS */ 374abb0f93cSkardel 375*eabc0478Schristos 376abb0f93cSkardel #ifdef __cplusplus 377abb0f93cSkardel } 378abb0f93cSkardel #endif 379abb0f93cSkardel #endif /* AUTOOPTS_SNTP_OPTS_H_GUARD */ 3808585484eSchristos 381abb0f93cSkardel /* sntp-opts.h ends here */ 382