1 /* -*- buffer-read-only: t -*- vi: set ro: 2 * 3 * DO NOT EDIT THIS FILE (genshell.h) 4 * 5 * It has been AutoGen-ed 6 * From the definitions genshell.def 7 * and the template file options 8 * 9 * Generated from AutoOpts 42:1:17 templates. 10 * 11 * AutoOpts is a copyrighted work. This header file is not encumbered 12 * by AutoOpts licensing, but is provided under the licensing terms chosen 13 * by the genshellopt author or copyright holder. AutoOpts is 14 * licensed under the terms of the LGPL. The redistributable library 15 * (``libopts'') is licensed under the terms of either the LGPL or, at the 16 * users discretion, the BSD license. See the AutoOpts and/or libopts sources 17 * for details. 18 * 19 * The genshellopt program is copyrighted and licensed 20 * under the following terms: 21 * 22 * Copyright (C) 1999-2018 Bruce Korb, all rights reserved. 23 * This is free software. It is licensed for use, modification and 24 * redistribution under the terms of the GNU Lesser General Public License, 25 * version 2 or later <http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html> 26 * 27 * The genshellopt library is free software; you can redistribute it and/or 28 * modify it under the terms of the GNU Library General Public License as 29 * published by the Free Software Foundation; either version 2 of the 30 * License, or (at your option) any later version. 31 * 32 * This library is distributed in the hope that it will be useful, but 33 * WITHOUT ANY WARRANTY; without even the implied warranty of 34 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 35 * Library General Public License for more details. 36 * 37 * You should have received a copy of the GNU Library General Public 38 * License along with this library; if not, see 39 * <http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html> 40 */ 41 /** 42 * This file contains the programmatic interface to the Automated 43 * Options generated for the genshellopt program. 44 * These macros are documented in the AutoGen info file in the 45 * "AutoOpts" chapter. Please refer to that doc for usage help. 46 */ 47 #ifndef AUTOOPTS_GENSHELL_H_GUARD 48 #define AUTOOPTS_GENSHELL_H_GUARD 1 49 #include <autoopts/options.h> 50 #include <stdarg.h> 51 #include <stdnoreturn.h> 52 53 /** 54 * Ensure that the library used for compiling this generated header is at 55 * least as new as the version current when the header template was released 56 * (not counting patch version increments). Also ensure that the oldest 57 * tolerable version is at least as old as what was current when the header 58 * template was released. 59 */ 60 #define AO_TEMPLATE_VERSION 172033 61 #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \ 62 || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION) 63 # error option template version mismatches autoopts/options.h header 64 Choke Me. 65 #endif 66 67 #if GCC_VERSION > 40400 68 #define NOT_REACHED __builtin_unreachable(); 69 #else 70 #define NOT_REACHED 71 #endif 72 73 /** 74 * Enumeration of each option type for genshellopt 75 */ 76 typedef enum { 77 INDEX_GENSHELL_OPT_SCRIPT = 0, 78 INDEX_GENSHELL_OPT_SHELL = 1, 79 INDEX_GENSHELL_OPT_VERSION = 2, 80 INDEX_GENSHELL_OPT_HELP = 3, 81 INDEX_GENSHELL_OPT_MORE_HELP = 4 82 } teGenshell_OptIndex; 83 /** count of all options for genshellopt */ 84 #define GENSHELL_OPTION_CT 5 85 /** genshellopt version */ 86 #define GENSHELLOPT_VERSION "1" 87 /** Full genshellopt version text */ 88 #define GENSHELLOPT_FULL_VERSION "genshellopt 1" 89 90 /** 91 * Interface defines for all options. Replace "n" with the UPPER_CASED 92 * option name (as in the teGenshell_OptIndex enumeration above). 93 * e.g. HAVE_GENSHELL_OPT(SCRIPT) 94 */ 95 #define GENSHELL_DESC(n) (genshelloptOptions.pOptDesc[INDEX_GENSHELL_OPT_## n]) 96 /** 'true' if an option has been specified in any way */ 97 #define HAVE_GENSHELL_OPT(n) (! UNUSED_OPT(& GENSHELL_DESC(n))) 98 /** The string argument to an option. The argument type must be \"string\". */ 99 #define GENSHELL_OPT_ARG(n) (GENSHELL_DESC(n).optArg.argString) 100 /** Mask the option state revealing how an option was specified. 101 * It will be one and only one of \a OPTST_SET, \a OPTST_PRESET, 102 * \a OPTST_DEFINED, \a OPTST_RESET or zero. 103 */ 104 #define STATE_GENSHELL_OPT(n) (GENSHELL_DESC(n).fOptState & OPTST_SET_MASK) 105 /** Count of option's occurrances *on the command line*. */ 106 #define COUNT_GENSHELL_OPT(n) (GENSHELL_DESC(n).optOccCt) 107 /** mask of \a OPTST_SET and \a OPTST_DEFINED. */ 108 #define ISSEL_GENSHELL_OPT(n) (SELECTED_OPT(&GENSHELL_DESC(n))) 109 /** 'true' if \a HAVE_OPT would yield 'false'. */ 110 #define ISUNUSED_GENSHELL_OPT(n) (UNUSED_OPT(& GENSHELL_DESC(n))) 111 /** 'true' if OPTST_DISABLED bit not set. */ 112 #define ENABLED_GENSHELL_OPT(n) (! DISABLED_OPT(& GENSHELL_DESC(n))) 113 /** number of stacked option arguments. 114 * Valid only for stacked option arguments. */ 115 #define STACKCT_GENSHELL_OPT(n) (((tArgList*)(GENSHELL_DESC(n).optCookie))->useCt) 116 /** stacked argument vector. 117 * Valid only for stacked option arguments. */ 118 #define STACKLST_GENSHELL_OPT(n) (((tArgList*)(GENSHELL_DESC(n).optCookie))->apzArgs) 119 /** Reset an option. */ 120 #define CLEAR_GENSHELL_OPT(n) STMTS( \ 121 GENSHELL_DESC(n).fOptState &= OPTST_PERSISTENT_MASK; \ 122 if ((GENSHELL_DESC(n).fOptState & OPTST_INITENABLED) == 0) \ 123 GENSHELL_DESC(n).fOptState |= OPTST_DISABLED; \ 124 GENSHELL_DESC(n).optCookie = NULL ) 125 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 126 /** 127 * Enumeration of genshellopt exit codes 128 */ 129 typedef enum { 130 GENSHELLOPT_EXIT_SUCCESS = 0, 131 GENSHELLOPT_EXIT_FAILURE = 1, 132 GENSHELLOPT_EXIT_USAGE_ERROR = 64, 133 GENSHELLOPT_EXIT_LIBOPTS_FAILURE = 70 134 } genshellopt_exit_code_t; 135 /** 136 * Interface defines for specific options. 137 * @{ 138 */ 139 #define VALUE_GENSHELL_OPT_SCRIPT 'o' 140 #define VALUE_GENSHELL_OPT_SHELL 's' 141 /** option flag (value) for help-value option */ 142 #define VALUE_GENSHELL_OPT_HELP '?' 143 /** option flag (value) for more-help-value option */ 144 #define VALUE_GENSHELL_OPT_MORE_HELP '!' 145 /** option flag (value) for version-value option */ 146 #define VALUE_GENSHELL_OPT_VERSION 'v' 147 /* 148 * Interface defines not associated with particular options 149 */ 150 #define ERRSKIP_GENSHELL_OPTERR STMTS(genshelloptOptions.fOptSet &= ~OPTPROC_ERRSTOP) 151 #define ERRSTOP_GENSHELL_OPTERR STMTS(genshelloptOptions.fOptSet |= OPTPROC_ERRSTOP) 152 #define RESTART_GENSHELL_OPT(n) STMTS( \ 153 genshelloptOptions.curOptIdx = (n); \ 154 genshelloptOptions.pzCurOpt = NULL ) 155 #define START_GENSHELL_OPT RESTART_GENSHELL_OPT(1) 156 #define GENSHELL_USAGE(c) (*genshelloptOptions.pUsageProc)(&genshelloptOptions, c) 157 158 #ifdef __cplusplus 159 extern "C" { 160 #endif 161 /* 162 * global exported definitions 163 */ 164 #define ch_t unsigned char 165 #define cc_t const unsigned char 166 #define cch_t char const 167 168 169 /* * * * * * 170 * 171 * Declare the genshellopt option descriptor. 172 */ 173 extern tOptions genshelloptOptions; 174 175 #if defined(ENABLE_NLS) 176 # ifndef _ 177 # include <stdio.h> 178 # ifndef HAVE_GETTEXT 179 extern char * gettext(char const *); 180 # else 181 # include <libintl.h> 182 # endif 183 184 # ifndef ATTRIBUTE_FORMAT_ARG 185 # define ATTRIBUTE_FORMAT_ARG(_a) 186 # endif 187 188 static inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1); 189 static inline char* aoGetsText(char const* pz) { 190 if (pz == NULL) return NULL; 191 return (char*)gettext(pz); 192 } 193 # define _(s) aoGetsText(s) 194 # endif /* _() */ 195 196 # define OPT_NO_XLAT_CFG_NAMES STMTS(genshelloptOptions.fOptSet |= \ 197 OPTPROC_NXLAT_OPT_CFG;) 198 # define OPT_NO_XLAT_OPT_NAMES STMTS(genshelloptOptions.fOptSet |= \ 199 OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;) 200 201 # define OPT_XLAT_CFG_NAMES STMTS(genshelloptOptions.fOptSet &= \ 202 ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);) 203 # define OPT_XLAT_OPT_NAMES STMTS(genshelloptOptions.fOptSet &= \ 204 ~OPTPROC_NXLAT_OPT;) 205 206 #else /* ENABLE_NLS */ 207 # define OPT_NO_XLAT_CFG_NAMES 208 # define OPT_NO_XLAT_OPT_NAMES 209 210 # define OPT_XLAT_CFG_NAMES 211 # define OPT_XLAT_OPT_NAMES 212 213 # ifndef _ 214 # define _(_s) _s 215 # endif 216 #endif /* ENABLE_NLS */ 217 218 219 #ifdef __cplusplus 220 } 221 #endif 222 #endif /* AUTOOPTS_GENSHELL_H_GUARD */ 223 224 /* genshell.h ends here */ 225