3 # $Id: opthead.tpl,v 2.32 2002/09/10 02:10:57 bkorb Exp $
4 # Automated Options copyright 1992-2002 Bruce Korb
8 * This file contains the programmatic interface to the Automated
9 * Options generated for the [=(. prog-name)=] program.
10 * These macros are documented in the AutoGen info file in the
11 * "AutoOpts" chapter. Please refer to that doc for usage help.
13 [= (make-header-guard "autoopts") =]
14 [= Option_Copyright =][=
15 % config-header "\n#include \"%s\""=]
19 * Enumeration of each option:
23 IF (not (exist? "documentation")) =]
24 INDEX_[=(set-flag-names) UP-prefix=]OPT_[=
25 (sprintf "%-16s =%3d," UP-name (for-index)) =][=
29 (define option-ct (count "flag")) =][=
31 IF (exist? "version") =]
32 INDEX_[=(. UP-prefix)=]OPT_VERSION = [=
33 (set! option-ct (+ option-ct 1)) (- option-ct 1)=],[=
35 INDEX_[=(. UP-prefix)=]OPT_HELP = [=
36 (set! option-ct (+ option-ct 1)) (- option-ct 1)=],
37 INDEX_[=(. UP-prefix)=]OPT_MORE_HELP = [=
38 (set! option-ct (+ option-ct 1)) (- option-ct 1)=][=
40 IF (exist? "homerc") =],
41 INDEX_[=(. UP-prefix)=]OPT_SAVE_OPTS = [=
42 (set! option-ct (+ option-ct 1)) (- option-ct 1)=],
43 INDEX_[=(. UP-prefix)=]OPT_LOAD_OPTS = [=
44 (set! option-ct (+ option-ct 1)) (- option-ct 1)=][=
46 } te[=(. Cap-prefix)=]OptIndex;
48 #define [=(. UP-prefix)=]OPTION_CT [= (. option-ct) =][=
49 IF (exist? "version") =]
50 #define [=(. UP-prog)=]_VERSION [=(c-string (get "version"))=]
51 #define [=(. UP-prog)=]_FULL_VERSION "[=
52 (. prog-name) =] - [= % prog_title "%s - " =]Ver. [=version=]"[=
53 ENDIF (exist? version) =]
56 * Interface defines for all options. Replace "n" with
57 * the UPPER_CASED option name (as in the te[=(. Cap-prefix)=]OptIndex
58 * enumeration above). e.g. HAVE_[=(. UP-prefix)=]OPT( [=
59 (string-upcase! (get "flag[].name" ))=] )
63 # define %1$sDESC(n) %2$sOptions.pOptDesc[INDEX_%1$sOPT_ ## n]
65 # define %1$sDESC(n) %2$sOptions.pOptDesc[INDEX_%1$sOPT_/**/n]
67 #define HAVE_%1$sOPT(n) (! UNUSED_OPT(& %1$sDESC(n)))
68 #define %1$sOPT_ARG(n) (%1$sDESC(n).pzLastArg)
69 #define STATE_%1$sOPT(n) (%1$sDESC(n).fOptState & OPTST_SET_MASK)
70 #define COUNT_%1$sOPT(n) (%1$sDESC(n).optOccCt)
71 #define ISSEL_%1$sOPT(n) (SELECTED_OPT(&%1$sDESC(n)))
72 #define ISUNUSED_%1$sOPT(n) (UNUSED_OPT(& %1$sDESC(n)))
73 #define ENABLED_%1$sOPT(n) (! DISABLED_OPT(& %1$sDESC(n)))
74 #define STACKCT_%1$sOPT(n) (((tArgList*)(%1$sDESC(n).optCookie))->useCt)
75 #define STACKLST_%1$sOPT(n) (((tArgList*)(%1$sDESC(n).optCookie))->apzArgs)
76 #define CLEAR_%1$sOPT(n) STMTS( \\
77 %1$sDESC(n).fOptState &= OPTST_PERSISTENT; \\
78 if ( (%1$sDESC(n).fOptState & OPTST_INITENABLED) == 0) \\
79 %1$sDESC(n).fOptState |= OPTST_DISABLED; \\
80 %1$sDESC(n).optCookie = NULL )"
82 UP-prefix (get "prog-name")
86 * Interface defines for specific options.
91 (set! opt-name (string-append UP-prefix "OPT_" UP-name))
92 (set! descriptor (string-append UP-prefix "DESC(" UP-name ")" )) =][=
94 IF (exist? "documentation") =][=
95 IF (or (exist? "call_proc") (exist? "flag_code") (exist? "extract_code"))
97 #define SET_[=(. UP-prefix)=]OPT_[=(. UP-name)=] STMTS( \
98 (*([=(. descriptor)=].pOptProc))( &[=(. pname)=]Options, \
99 [=(. pname)=]Options.pOptDesc + [=(for-index)=] )[=
107 * * * * * * * * * * * * * * * * * * * * * * * * * * * *
109 Autoopts maintained option values.
111 If *any* option flag value is specified,
112 then we provide flag characters for our options.
113 Otherwise, we will use the INDEX_* values for the option value.
115 There are no documentation strings because these defines
116 are used identically to the user-generated VALUE defines.
120 IF (exist? "flag.value") =][=
121 IF (exist? "version") =]
122 #define VALUE_[=(. UP-prefix)=]OPT_VERSION [=
123 IF (not (exist? "version_value")) =]'v'[=
125 CASE (get "version_value") =][=
126 == "" =]INDEX_[=(. UP-prefix)=]OPT_VERSION[=
128 ~~ . =]'[=version_value=]'[=
129 * =][=(error "value (flag) codes must be single characters") =][=
134 IF (exist? "homerc")=]
135 #define VALUE_[=(. UP-prefix)=]OPT_SAVE_OPTS [=
136 IF (not (exist? "save_opts_value")) =]'>'[=
138 CASE (get "save_opts_value") =][=
139 == "" =]INDEX_[=(. UP-prefix)=]OPT_SAVE_OPTS[=
141 ~~ . =]'[=save_opts_value=]'[=
142 * =][=(error "value (flag) codes must be single characters") =][=
145 #define VALUE_[=(. UP-prefix)=]OPT_LOAD_OPTS [=
146 IF (not (exist? "load_opts_value")) =]'<'[=
148 CASE (get "load_opts_value") =][=
149 == "" =]INDEX_[=(. UP-prefix)=]OPT_LOAD_OPTS[=
151 ~~ . =]'[=load_opts_value=]'[=
152 * =][=(error "value (flag) codes must be single characters") =][=
157 #define VALUE_[=(. UP-prefix)=]OPT_HELP [=
158 IF (not (exist? "help_value")) =]'?'[=
160 CASE (get "help_value") =][=
161 == "" =]INDEX_[=(. UP-prefix)=]OPT_HELP[=
163 ~~ . =]'[=help_value=]'[=
164 * =][=(error "value (flag) codes must be single characters") =][=
167 #define VALUE_[=(. UP-prefix)=]OPT_MORE_HELP [=
168 IF (not (exist? "more_help_value")) =]'!'[=
170 CASE (get "more_help_value") =][=
171 == "" =]INDEX_[=(. UP-prefix)=]OPT_MORE_HELP[=
173 ~~ . =]'[=more_help_value=]'[=
174 * =][=(error "value (flag) codes must be single characters") =][=
178 ELSE "flag.value *DOES NOT* exist" =][=
180 IF (exist? "version") =]
181 #define VALUE_[=(. UP-prefix)=]OPT_VERSION INDEX_[=
182 (. UP-prefix)=]OPT_VERSION[=
184 IF (exist? "homerc") =]
185 #define VALUE_[=(. UP-prefix)=]OPT_SAVE_OPTS INDEX_[=
186 (. UP-prefix)=]OPT_SAVE_OPTS
187 #define VALUE_[=(. UP-prefix)=]OPT_LOAD_OPTS INDEX_[=
188 (. UP-prefix)=]OPT_LOAD_OPTS[=
190 #define VALUE_[=(. UP-prefix)=]OPT_HELP INDEX_[=
191 (. UP-prefix)=]OPT_HELP
192 #define VALUE_[=(. UP-prefix)=]OPT_MORE_HELP INDEX_[=
193 (. UP-prefix)=]OPT_MORE_HELP[=
196 IF (exist? "homerc") =]
197 #define SET_[=(. UP-prefix)=]OPT_SAVE_OPTS(a) STMTS( \
198 [=(. UP-prefix)=]DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT; \
199 [=(. UP-prefix)=]DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
200 [=(. UP-prefix)=]DESC(SAVE_OPTS).pzLastArg = (char*)(a) )[=
205 * Interface defines not associated with particular options
207 #define ERRSKIP_[=(. UP-prefix)=]OPTERR STMTS( [=prog_name
208 =]Options.fOptSet &= ~OPTPROC_ERRSTOP )
209 #define ERRSTOP_[=(. UP-prefix)=]OPTERR STMTS( [=prog_name
210 =]Options.fOptSet |= OPTPROC_ERRSTOP )
211 #define RESTART_[=(. UP-prefix)=]OPT(n) STMTS( \
212 [=(. pname)=]Options.curOptIdx = (n); \
213 [=(. pname)=]Options.pzCurOpt = NULL )
214 #define START_[=(. UP-prefix)=]OPT RESTART_[=(. UP-prefix)
216 #define [=(. UP-prefix)=]USAGE(c) (*[=(. pname)
217 =]Options.pUsageProc)( &[=(. pname)=]Options, c )[=#
219 * * * * * * * * * * * * * * * * * * * * * * * * * * * *
224 * Declare the [=(. prog-name)=] option descriptor.
230 extern tOptions [=(. pname)=]Options;[=
232 IF (exist? "export")=]
236 * Globals exported from the [=prog_title=] option definitions
239 [= (get "export") =][=
246 #endif /* [=(. header-guard)=] */