Install msysDTK-1.0.1
[msysgit.git] / share / autogen / opthead.tpl
blob191cb6d2b23a8b21533d91dfe248bc708fa55c7b
1 [= autogen5 template
3 # $Id: opthead.tpl,v 2.32 2002/09/10 02:10:57 bkorb Exp $
4 # Automated Options copyright 1992-2002 Bruce Korb
6 =]
7 /*
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.
12  */
13 [= (make-header-guard "autoopts") =]
14 [= Option_Copyright =][=
15 % config-header "\n#include \"%s\""=]
16 #include <options.h>
19  *  Enumeration of each option:
20  */
21 typedef enum {[=
22 FOR flag    =][=
23   IF (not (exist? "documentation")) =]
24         INDEX_[=(set-flag-names) UP-prefix=]OPT_[=
25                 (sprintf "%-16s =%3d," UP-name (for-index)) =][=
26   ENDIF     =][=
27 ENDFOR flag =][=
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)=],[=
34 ENDIF =]
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)=][=
45 ENDIF =]
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" ))=] )
60  */[=
61 (sprintf "
62 #ifdef __STDC__
63 #  define       %1$sDESC(n) %2$sOptions.pOptDesc[INDEX_%1$sOPT_ ## n]
64 #else
65 #  define       %1$sDESC(n) %2$sOptions.pOptDesc[INDEX_%1$sOPT_/**/n]
66 #endif
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")
83 ) =]
86  *  Interface defines for specific options.
87  */[=
89 FOR flag              =][=
90   (set-flag-names)
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)=] )[=
101    ENDIF              =][=
102  ELSE                 =][=
103    Option_Defines     =][=
104  ENDIF                =][=
105 ENDFOR  flag          =][=#
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'[=
124     ELSE      =][=
125       CASE (get "version_value")  =][=
126       == ""   =]INDEX_[=(. UP-prefix)=]OPT_VERSION[=
127       == "'"  =]'\''[=
128       ~~ .    =]'[=version_value=]'[=
129       *       =][=(error "value (flag) codes must be single characters") =][=
130       ESAC    =][=
131     ENDIF     =][=
132   ENDIF       =][=
134   IF (exist? "homerc")=]
135 #define VALUE_[=(. UP-prefix)=]OPT_SAVE_OPTS      [=
136     IF (not (exist? "save_opts_value")) =]'>'[=
137     ELSE      =][=
138       CASE (get "save_opts_value")  =][=
139       == ""   =]INDEX_[=(. UP-prefix)=]OPT_SAVE_OPTS[=
140       == "'"  =]'\''[=
141       ~~ .    =]'[=save_opts_value=]'[=
142       *       =][=(error "value (flag) codes must be single characters") =][=
143       ESAC    =][=
144     ENDIF     =]
145 #define VALUE_[=(. UP-prefix)=]OPT_LOAD_OPTS      [=
146     IF (not (exist? "load_opts_value")) =]'<'[=
147     ELSE      =][=
148       CASE (get "load_opts_value")  =][=
149       == ""   =]INDEX_[=(. UP-prefix)=]OPT_LOAD_OPTS[=
150       == "'"  =]'\''[=
151       ~~ .    =]'[=load_opts_value=]'[=
152       *       =][=(error "value (flag) codes must be single characters") =][=
153       ESAC    =][=
154     ENDIF     =][=
155   ENDIF
157 #define VALUE_[=(. UP-prefix)=]OPT_HELP           [=
158     IF (not (exist? "help_value")) =]'?'[=
159     ELSE      =][=
160       CASE (get "help_value")  =][=
161       == ""   =]INDEX_[=(. UP-prefix)=]OPT_HELP[=
162       == "'"  =]'\''[=
163       ~~ .    =]'[=help_value=]'[=
164       *       =][=(error "value (flag) codes must be single characters") =][=
165       ESAC    =][=
166     ENDIF     =]
167 #define VALUE_[=(. UP-prefix)=]OPT_MORE_HELP      [=
168     IF (not (exist? "more_help_value")) =]'!'[=
169     ELSE      =][=
170       CASE (get "more_help_value")  =][=
171       == ""   =]INDEX_[=(. UP-prefix)=]OPT_MORE_HELP[=
172       == "'"  =]'\''[=
173       ~~ .    =]'[=more_help_value=]'[=
174       *       =][=(error "value (flag) codes must be single characters") =][=
175       ESAC    =][=
176     ENDIF     =][=
178 ELSE "flag.value *DOES NOT* exist" =][=
180   IF (exist? "version") =]
181 #define VALUE_[=(. UP-prefix)=]OPT_VERSION        INDEX_[=
182                                       (. UP-prefix)=]OPT_VERSION[=
183   ENDIF=][=
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[=
189   ENDIF=]
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[=
194 ENDIF=][=
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) )[=
201 ENDIF
205  *  Interface defines not associated with particular options
206  */
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)
215                 =]OPT(1)
216 #define     [=(. UP-prefix)=]USAGE(c)    (*[=(. pname)
217                  =]Options.pUsageProc)( &[=(. pname)=]Options, c )[=#
219 * * * * * * * * * * * * * * * * * * * * * * * * * * * *
222 /* * * * * *
224  *  Declare the [=(. prog-name)=] option descriptor.
225  */
226 #ifdef  __cplusplus
227 extern "C" {
228 #endif
230 extern tOptions   [=(. pname)=]Options;[=
232 IF (exist? "export")=]
234 /* * * * * *
236  *  Globals exported from the [=prog_title=] option definitions
237  */[=
238   FOR export "\n"=]
239 [= (get "export") =][=
240   ENDFOR export=][=
241 ENDIF=]
243 #ifdef  __cplusplus
245 #endif
246 #endif /* [=(. header-guard)=] */