genshell.h revision 285612
1109737Ssimokawa/*   -*- buffer-read-only: t -*- vi: set ro:
2109737Ssimokawa *
3109737Ssimokawa *  DO NOT EDIT THIS FILE   (genshell.h)
4163712Simp *
5109737Ssimokawa *  It has been AutoGen-ed
6109737Ssimokawa *  From the definitions    genshell.def
7109737Ssimokawa *  and the template file   options
8109737Ssimokawa *
9109737Ssimokawa * Generated from AutoOpts 41:0:16 templates.
10109737Ssimokawa *
11109737Ssimokawa *  AutoOpts is a copyrighted work.  This header file is not encumbered
12109737Ssimokawa *  by AutoOpts licensing, but is provided under the licensing terms chosen
13109737Ssimokawa *  by the genshellopt author or copyright holder.  AutoOpts is
14109737Ssimokawa *  licensed under the terms of the LGPL.  The redistributable library
15109737Ssimokawa *  (``libopts'') is licensed under the terms of either the LGPL or, at the
16109737Ssimokawa *  users discretion, the BSD license.  See the AutoOpts and/or libopts sources
17109737Ssimokawa *  for details.
18109737Ssimokawa *
19109737Ssimokawa * The genshellopt program is copyrighted and licensed
20109737Ssimokawa * under the following terms:
21163712Simp *
22109737Ssimokawa *  Copyright (C) 1999-2014 Bruce Korb, all rights reserved.
23109737Ssimokawa *  This is free software. It is licensed for use, modification and
24109737Ssimokawa *  redistribution under the terms of the GNU Lesser General Public License,
25109737Ssimokawa *  version 2 or later <http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html>
26109737Ssimokawa *
27109737Ssimokawa *  The genshellopt library is free software; you can redistribute it and/or
28109737Ssimokawa *  modify it under the terms of the GNU Library General Public License as
29109737Ssimokawa *  published by the Free Software Foundation; either version 2 of the
30109737Ssimokawa *  License, or (at your option) any later version.
31109737Ssimokawa *
32109737Ssimokawa *  This library is distributed in the hope that it will be useful, but
33163712Simp *  WITHOUT ANY WARRANTY; without even the implied warranty of
34109737Ssimokawa *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
35109737Ssimokawa *  Library General Public License for more details.
36109737Ssimokawa *
37109737Ssimokawa *  You should have received a copy of the GNU Library General Public
38109737Ssimokawa *  License along with this library; if not, see
39109737Ssimokawa *  <http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html>
40109737Ssimokawa */
41109737Ssimokawa/**
42109737Ssimokawa *  This file contains the programmatic interface to the Automated
43109737Ssimokawa *  Options generated for the genshellopt program.
44109737Ssimokawa *  These macros are documented in the AutoGen info file in the
45109737Ssimokawa *  "AutoOpts" chapter.  Please refer to that doc for usage help.
46109737Ssimokawa */
47109737Ssimokawa#ifndef AUTOOPTS_GENSHELL_H_GUARD
48109737Ssimokawa#define AUTOOPTS_GENSHELL_H_GUARD 1
49109737Ssimokawa#include <autoopts/options.h>
50109737Ssimokawa
51109737Ssimokawa/**
52109737Ssimokawa *  Ensure that the library used for compiling this generated header is at
53163712Simp *  least as new as the version current when the header template was released
54109737Ssimokawa *  (not counting patch version increments).  Also ensure that the oldest
55109737Ssimokawa *  tolerable version is at least as old as what was current when the header
56109737Ssimokawa *  template was released.
57109737Ssimokawa */
58163712Simp#define AO_TEMPLATE_VERSION 167936
59163712Simp#if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
60111112Ssimokawa || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
61111112Ssimokawa# error option template version mismatches autoopts/options.h header
62109737Ssimokawa  Choke Me.
63109737Ssimokawa#endif
64163712Simp
65109737Ssimokawa/**
66109737Ssimokawa *  Enumeration of each option type for genshellopt
67109737Ssimokawa */
68109737Ssimokawatypedef enum {
69109737Ssimokawa    INDEX_GENSHELL_OPT_SCRIPT      =  0,
70109737Ssimokawa    INDEX_GENSHELL_OPT_SHELL       =  1,
71109737Ssimokawa    INDEX_GENSHELL_OPT_VERSION     =  2,
72109737Ssimokawa    INDEX_GENSHELL_OPT_HELP        =  3,
73109737Ssimokawa    INDEX_GENSHELL_OPT_MORE_HELP   =  4
74109737Ssimokawa} teGenshell_OptIndex;
75109737Ssimokawa/** count of all options for genshellopt */
76109737Ssimokawa#define GENSHELL_OPTION_CT    5
77109737Ssimokawa/** genshellopt version */
78109737Ssimokawa#define GENSHELLOPT_VERSION       "1"
79111112Ssimokawa/** Full genshellopt version text */
80111112Ssimokawa#define GENSHELLOPT_FULL_VERSION  "genshellopt 1"
81109737Ssimokawa
82109737Ssimokawa/**
83109737Ssimokawa *  Interface defines for all options.  Replace "n" with the UPPER_CASED
84170878Ssimokawa *  option name (as in the teGenshell_OptIndex enumeration above).
85109991Ssimokawa *  e.g. HAVE_GENSHELL_OPT(SCRIPT)
86109991Ssimokawa */
87109991Ssimokawa#define GENSHELL_DESC(n) (genshelloptOptions.pOptDesc[INDEX_GENSHELL_OPT_## n])
88111112Ssimokawa/** 'true' if an option has been specified in any way */
89111112Ssimokawa#define     HAVE_GENSHELL_OPT(n) (! UNUSED_OPT(& GENSHELL_DESC(n)))
90111112Ssimokawa/** The string argument to an option. The argument type must be \"string\". */
91109991Ssimokawa#define      GENSHELL_OPT_ARG(n) (GENSHELL_DESC(n).optArg.argString)
92109737Ssimokawa/** Mask the option state revealing how an option was specified.
93109737Ssimokawa *  It will be one and only one of \a OPTST_SET, \a OPTST_PRESET,
94163712Simp * \a OPTST_DEFINED, \a OPTST_RESET or zero.
95163712Simp */
96109737Ssimokawa#define    STATE_GENSHELL_OPT(n) (GENSHELL_DESC(n).fOptState & OPTST_SET_MASK)
97109737Ssimokawa/** Count of option's occurrances *on the command line*. */
98109737Ssimokawa#define    COUNT_GENSHELL_OPT(n) (GENSHELL_DESC(n).optOccCt)
99109737Ssimokawa/** mask of \a OPTST_SET and \a OPTST_DEFINED. */
100109737Ssimokawa#define    ISSEL_GENSHELL_OPT(n) (SELECTED_OPT(&GENSHELL_DESC(n)))
101109737Ssimokawa/** 'true' if \a HAVE_OPT would yield 'false'. */
102109737Ssimokawa#define ISUNUSED_GENSHELL_OPT(n) (UNUSED_OPT(& GENSHELL_DESC(n)))
103109737Ssimokawa/** 'true' if OPTST_DISABLED bit not set. */
104111112Ssimokawa#define  ENABLED_GENSHELL_OPT(n) (! DISABLED_OPT(& GENSHELL_DESC(n)))
105109991Ssimokawa/** number of stacked option arguments.
106109991Ssimokawa *  Valid only for stacked option arguments. */
107109737Ssimokawa#define  STACKCT_GENSHELL_OPT(n) (((tArgList*)(GENSHELL_DESC(n).optCookie))->useCt)
108163712Simp/** stacked argument vector.
109163712Simp *  Valid only for stacked option arguments. */
110163712Simp#define STACKLST_GENSHELL_OPT(n) (((tArgList*)(GENSHELL_DESC(n).optCookie))->apzArgs)
111163712Simp/** Reset an option. */
112163712Simp#define    CLEAR_GENSHELL_OPT(n) STMTS( \
113216948Semaste                GENSHELL_DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
114163712Simp                if ((GENSHELL_DESC(n).fOptState & OPTST_INITENABLED) == 0) \
115163712Simp                    GENSHELL_DESC(n).fOptState |= OPTST_DISABLED; \
116163712Simp                GENSHELL_DESC(n).optCookie = NULL )
117111112Ssimokawa/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
118109737Ssimokawa/**
119109737Ssimokawa *  Enumeration of genshellopt exit codes
120109991Ssimokawa */
121109991Ssimokawatypedef enum {
122109737Ssimokawa    GENSHELLOPT_EXIT_SUCCESS         = 0,
123109737Ssimokawa    GENSHELLOPT_EXIT_FAILURE         = 1,
124109737Ssimokawa    GENSHELLOPT_EXIT_USAGE_ERROR     = 64,
125109737Ssimokawa    GENSHELLOPT_EXIT_LIBOPTS_FAILURE = 70
126163712Simp}   genshellopt_exit_code_t;
127163712Simp/**
128109737Ssimokawa *  Interface defines for specific options.
129109737Ssimokawa * @{
130109737Ssimokawa */
131109737Ssimokawa#define VALUE_GENSHELL_OPT_SCRIPT 'o'
132163712Simp#define VALUE_GENSHELL_OPT_SHELL 's'
133109737Ssimokawa/** option flag (value) for help-value option */
134109737Ssimokawa#define VALUE_GENSHELL_OPT_HELP '?'
135109737Ssimokawa/** option flag (value) for more-help-value option */
136109737Ssimokawa#define VALUE_GENSHELL_OPT_MORE_HELP '!'
137109991Ssimokawa/** option flag (value) for version-value option */
138109991Ssimokawa#define VALUE_GENSHELL_OPT_VERSION 'v'
139109991Ssimokawa/*
140111112Ssimokawa *  Interface defines not associated with particular options
141109991Ssimokawa */
142109991Ssimokawa#define ERRSKIP_GENSHELL_OPTERR  STMTS(genshelloptOptions.fOptSet &= ~OPTPROC_ERRSTOP)
143109991Ssimokawa#define ERRSTOP_GENSHELL_OPTERR  STMTS(genshelloptOptions.fOptSet |= OPTPROC_ERRSTOP)
144109991Ssimokawa#define RESTART_GENSHELL_OPT(n)  STMTS( \
145109991Ssimokawa                genshelloptOptions.curOptIdx = (n); \
146109991Ssimokawa                genshelloptOptions.pzCurOpt  = NULL )
147109991Ssimokawa#define START_GENSHELL_OPT       RESTART_GENSHELL_OPT(1)
148109991Ssimokawa#define GENSHELL_USAGE(c)        (*genshelloptOptions.pUsageProc)(&genshelloptOptions, c)
149109991Ssimokawa
150109991Ssimokawa#ifdef  __cplusplus
151111112Ssimokawaextern "C" {
152109991Ssimokawa#endif
153109991Ssimokawa
154109991Ssimokawa
155111112Ssimokawa/* * * * * *
156109737Ssimokawa *
157109787Ssimokawa *  Declare the genshellopt option descriptor.
158163712Simp */
159109787Ssimokawaextern tOptions genshelloptOptions;
160109991Ssimokawa
161109991Ssimokawa#if defined(ENABLE_NLS)
162109991Ssimokawa# ifndef _
163109991Ssimokawa#   include <stdio.h>
164109737Ssimokawa#   ifndef HAVE_GETTEXT
165109991Ssimokawa      extern char * gettext(char const *);
166109991Ssimokawa#   else
167109737Ssimokawa#     include <libintl.h>
168109737Ssimokawa#   endif
169163712Simp
170111112Ssimokawa# ifndef ATTRIBUTE_FORMAT_ARG
171109787Ssimokawa#   define ATTRIBUTE_FORMAT_ARG(_a)
172109737Ssimokawa# endif
173109737Ssimokawa
174109737Ssimokawastatic inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1);
175109737Ssimokawastatic inline char* aoGetsText(char const* pz) {
176109737Ssimokawa    if (pz == NULL) return NULL;
177109991Ssimokawa    return (char*)gettext(pz);
178109737Ssimokawa}
179111112Ssimokawa#   define _(s)  aoGetsText(s)
180109737Ssimokawa# endif /* _() */
181109737Ssimokawa
182109737Ssimokawa# define OPT_NO_XLAT_CFG_NAMES  STMTS(genshelloptOptions.fOptSet |= \
183109737Ssimokawa                                    OPTPROC_NXLAT_OPT_CFG;)
184113584Ssimokawa# define OPT_NO_XLAT_OPT_NAMES  STMTS(genshelloptOptions.fOptSet |= \
185109991Ssimokawa                                    OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
186109991Ssimokawa
187109737Ssimokawa# define OPT_XLAT_CFG_NAMES     STMTS(genshelloptOptions.fOptSet &= \
188109737Ssimokawa                                  ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
189109991Ssimokawa# define OPT_XLAT_OPT_NAMES     STMTS(genshelloptOptions.fOptSet &= \
190109737Ssimokawa                                  ~OPTPROC_NXLAT_OPT;)
191111112Ssimokawa
192109787Ssimokawa#else   /* ENABLE_NLS */
193109737Ssimokawa# define OPT_NO_XLAT_CFG_NAMES
194109737Ssimokawa# define OPT_NO_XLAT_OPT_NAMES
195111112Ssimokawa
196111112Ssimokawa# define OPT_XLAT_CFG_NAMES
197163712Simp# define OPT_XLAT_OPT_NAMES
198111112Ssimokawa
199111112Ssimokawa# ifndef _
200111112Ssimokawa#   define _(_s)  _s
201111112Ssimokawa# endif
202111112Ssimokawa#endif  /* ENABLE_NLS */
203111112Ssimokawa
204111112Ssimokawa#ifdef  __cplusplus
205188029Ssbruno}
206188029Ssbruno#endif
207188029Ssbruno#endif /* AUTOOPTS_GENSHELL_H_GUARD */
208188029Ssbruno
209188029Ssbruno/* genshell.h ends here */
210188029Ssbruno