xref: /netbsd-src/external/bsd/ntp/dist/sntp/libopts/genshell.h (revision a5847cc334d9a7029f6352b847e9e8d71a0f9e0c)
1 /*	$NetBSD: genshell.h,v 1.1.1.1 2009/12/13 16:57:19 kardel 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  November  8, 2009 at 08:41:09 AM by AutoGen 5.9.10pre13
8  *  From the definitions    genshell.def
9  *  and the template file   options
10  *
11  * Generated from AutoOpts @AO_CURRENT@:@AO_REVISION@:@AO_AGE@ templates.
12  */
13 
14 /*
15  *  This file was produced by an AutoOpts template.  AutoOpts is a
16  *  copyrighted work.  This header file is not encumbered by AutoOpts
17  *  licensing, but is provided under the licensing terms chosen by the
18  *  genshellopt author or copyright holder.  AutoOpts is licensed under
19  *  the terms of the LGPL.  The redistributable library (``libopts'') is
20  *  licensed under the terms of either the LGPL or, at the users discretion,
21  *  the BSD license.  See the AutoOpts and/or libopts sources for details.
22  *
23  * This source file is copyrighted and licensed under the following terms:
24  *
25  * genshellopt copyright (c) 1999-2009 Bruce Korb - all rights reserved
26  *
27  * genshellopt is free software: you can redistribute it and/or modify it
28  * under the terms of the GNU General Public License as published by the
29  * Free Software Foundation, either version 3 of the License, or
30  * (at your option) any later version.
31  *
32  * genshellopt 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.
35  * See the GNU General Public License for more details.
36  *
37  * You should have received a copy of the GNU General Public License along
38  * with this program.  If not, see <http://www.gnu.org/licenses/>.
39  */
40 /*
41  *  This file contains the programmatic interface to the Automated
42  *  Options generated for the genshellopt program.
43  *  These macros are documented in the AutoGen info file in the
44  *  "AutoOpts" chapter.  Please refer to that doc for usage help.
45  */
46 #ifndef AUTOOPTS_GENSHELL_H_GUARD
47 #define AUTOOPTS_GENSHELL_H_GUARD 1
48 #include <autoopts/options.h>
49 
50 /*
51  *  Ensure that the library used for compiling this generated header is at
52  *  least as new as the version current when the header template was released
53  *  (not counting patch version increments).  Also ensure that the oldest
54  *  tolerable version is at least as old as what was current when the header
55  *  template was released.
56  */
57 #define AO_TEMPLATE_VERSION 135168
58 #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
59  || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
60 # error option template version mismatches autoopts/options.h header
61   Choke Me.
62 #endif
63 
64 /*
65  *  Enumeration of each option:
66  */
67 typedef enum {
68     INDEX_OPT_SCRIPT      =  0,
69     INDEX_OPT_SHELL       =  1,
70     INDEX_OPT_VERSION     =  2,
71     INDEX_OPT_HELP        =  3,
72     INDEX_OPT_MORE_HELP   =  4
73 } teOptIndex;
74 
75 #define OPTION_CT    5
76 #define GENSHELLOPT_VERSION       "1"
77 #define GENSHELLOPT_FULL_VERSION  "genshellopt - Generate Shell Option Processing Script - Ver. 1"
78 
79 /*
80  *  Interface defines for all options.  Replace "n" with the UPPER_CASED
81  *  option name (as in the teOptIndex enumeration above).
82  *  e.g. HAVE_OPT( SCRIPT )
83  */
84 #define         DESC(n) (genshelloptOptions.pOptDesc[INDEX_OPT_## n])
85 #define     HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
86 #define      OPT_ARG(n) (DESC(n).optArg.argString)
87 #define    STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
88 #define    COUNT_OPT(n) (DESC(n).optOccCt)
89 #define    ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
90 #define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
91 #define  ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
92 #define  STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
93 #define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
94 #define    CLEAR_OPT(n) STMTS( \
95                 DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
96                 if ( (DESC(n).fOptState & OPTST_INITENABLED) == 0) \
97                     DESC(n).fOptState |= OPTST_DISABLED; \
98                 DESC(n).optCookie = NULL )
99 
100 /* * * * * *
101  *
102  *  Interface defines for specific options.
103  */
104 #define VALUE_OPT_SCRIPT         'o'
105 #define VALUE_OPT_SHELL          's'
106 #define VALUE_OPT_HELP          '?'
107 #define VALUE_OPT_MORE_HELP     '!'
108 #define VALUE_OPT_VERSION       'v'
109 /*
110  *  Interface defines not associated with particular options
111  */
112 #define ERRSKIP_OPTERR  STMTS( genshelloptOptions.fOptSet &= ~OPTPROC_ERRSTOP )
113 #define ERRSTOP_OPTERR  STMTS( genshelloptOptions.fOptSet |= OPTPROC_ERRSTOP )
114 #define RESTART_OPT(n)  STMTS( \
115                 genshelloptOptions.curOptIdx = (n); \
116                 genshelloptOptions.pzCurOpt  = NULL )
117 #define START_OPT       RESTART_OPT(1)
118 #define USAGE(c)        (*genshelloptOptions.pUsageProc)( &genshelloptOptions, c )
119 /* extracted from opthead.tpl near line 409 */
120 
121 /* * * * * *
122  *
123  *  Declare the genshellopt option descriptor.
124  */
125 #ifdef  __cplusplus
126 extern "C" {
127 #endif
128 
129 extern tOptions   genshelloptOptions;
130 
131 #if defined(ENABLE_NLS)
132 # ifndef _
133 #   include <stdio.h>
134     static inline char* aoGetsText( char const* pz ) {
135         if (pz == NULL) return NULL;
136         return (char*)gettext( pz );
137     }
138 #   define _(s)  aoGetsText(s)
139 # endif /* _() */
140 
141 # define OPT_NO_XLAT_CFG_NAMES  STMTS(genshelloptOptions.fOptSet |= \
142                                     OPTPROC_NXLAT_OPT_CFG;)
143 # define OPT_NO_XLAT_OPT_NAMES  STMTS(genshelloptOptions.fOptSet |= \
144                                     OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
145 
146 # define OPT_XLAT_CFG_NAMES     STMTS(genshelloptOptions.fOptSet &= \
147                                   ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
148 # define OPT_XLAT_OPT_NAMES     STMTS(genshelloptOptions.fOptSet &= \
149                                   ~OPTPROC_NXLAT_OPT;)
150 
151 #else   /* ENABLE_NLS */
152 # define OPT_NO_XLAT_CFG_NAMES
153 # define OPT_NO_XLAT_OPT_NAMES
154 
155 # define OPT_XLAT_CFG_NAMES
156 # define OPT_XLAT_OPT_NAMES
157 
158 # ifndef _
159 #   define _(_s)  _s
160 # endif
161 #endif  /* ENABLE_NLS */
162 
163 #ifdef  __cplusplus
164 }
165 #endif
166 #endif /* AUTOOPTS_GENSHELL_H_GUARD */
167 /* genshell.h ends here */
168