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