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