1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388
|
[= autogen5 template -*- Mode: Text -*-
#$Id: optcode.tpl,v 2.57 2002/03/29 04:13:03 bkorb Exp $
# Automated Options copyright 1992-2002 Bruce Korb
=]
#include "[=(. header-file)=]"
[=
INCLUDE "optmain.tpl"
=][=
IF (not (exist? "copyright") )
=]
#define zCopyright NULL
#define zCopyrightNotice NULL[=
ELSE =]
tSCC zCopyright[] =
[= (kr-string
(sprintf "%s copyright (c) %s %s, all rights reserved" (. prog-name)
(get "copyright.date") (get "copyright.owner") )) =];
tSCC zCopyrightNotice[] =
[=
CASE (get "copyright.type") =][=
= gpl =][=(kr-string (gpl (. prog-name) "" ))=][=
= lgpl =][=(kr-string (lgpl (. prog-name) (get "copyright.owner")
"" ))=][=
= bsd =][=(kr-string (bsd (. prog-name) (get "copyright.owner")
"" ))=][=
= note =][=(kr-string (get "copyright.text"))=][=
* =]"Copyrighted"[=
ESAC =];[=
ENDIF "copyright notes"=]
[=
FOR flag =][=
IF (exist? "call_proc") =]
extern tOptProc [= call_proc =];[=
ENDIF =][=
ENDFOR flag=]
extern tUsageProc [=
(if (exist? "usage") (get "usage") "optionUsage") =];
[=
IF (exist? "include") =]
/*
* global included definitions
*/[=
FOR include "\n" =]
[=(get "include") =][=
ENDFOR include =]
[=ENDIF "include exists" =]
#ifndef NULL
# define NULL 0x0
#endif
#ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
#endif
#ifndef EXIT_FAILURE
# define EXIT_FAILURE 1
#endif[=
(define number-arg (make-regexp "=.*"))
(define cap-name "")
=][=
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
=][=
FOR FLAG "\n" =][=
Option_Strings =][=
ENDFOR FLAG
=]
/*
* Help option description:
*/
tSCC zHelpText[] = "Display usage information and exit";
tSCC zHelp_Name[] = "help";
/*
* More_Help option description:
*/
tSCC zMore_HelpText[] = "Extended usage information passed thru pager";
tSCC zMore_Help_Name[] = "more-help";[=
IF (exist? "version")
=]
/*
* Version option description:
*/
tSCC zVersionText[] = "Output version information and exit";
tSCC zVersion_Name[] = "version";[=
ENDIF (exist? "version") =][=
IF (exist? "homerc")
=]
/*
* Save_Opts option description:
*/
tSCC zSave_OptsText[] = "Save the option state to an rc file";
tSCC zSave_Opts_Name[] = "save-opts";
/*
* Load_Opts option description:
*/
extern tOptProc doLoadOpt;
tSCC zLoad_OptsText[] = "Load options from an rc file";
tSCC zLoad_Opts_NAME[] = "LOAD_OPTS";
tSCC zNotLoad_Opts_Name[] = "no-load-opts";
tSCC zNotLoad_Opts_Pfx[] = "no";
#define zLoad_Opts_Name (zNotLoad_Opts_Name + 3)[=
ENDIF (exist? "homerc") =][=
IF (or (exist? "flag.flag_code")
(exist? "flag.extract_code")
(exist? "flag.call_proc")
(exist? "flag.arg_range")
(match-value? =* "flag.arg_type" "key") ) =][=
invoke declare-option-callbacks =][=
ENDIF =]
/*
* These are always callable, whether
* TEST_[=(. pname-up)=]_OPTS is defined or not
*/
static tOptProc doUsageOpt;[=
IF (exist? "version") =]
extern tOptProc doVersion;[=
ENDIF =]
extern tOptProc doPagedUsage;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Define the [=(. pname-cap)=] Option Descriptions.
*/
static tOptDesc optDesc[ [=(. UP-prefix)=]OPTION_CT ] = {[=
(define default-opt-index -1)
(define up-name "") =][=
FOR flag "\n" =][=
Option_Descriptor =][=
;; IF this is the default option AND we already have one,...
;; THEN remember this index
;;
(if (and (exist? "default") (>= default-opt-index 0))
(error (sprintf "\n\tDefault argument %d duplicates %d\n"
(for-index) default-opt-index) ))
;; IF this is the default option then remember this index
;;
(if (and (exist? "default"))
(set! default-opt-index (for-index)) ) =][=
ENDFOR flag
=][=
IF (exist? "version") =]
{ /* entry idx, value */ INDEX_[= (. UP-prefix) =]OPT_VERSION, VALUE_[=
(. UP-prefix) =]OPT_VERSION,
/* equiv idx value */ NO_EQUIVALENT, 0,
/* option argument */ ARG_MAY,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max act ct */ 0, 1, 0,
/* opt state flags */ OPTST_INIT,
/* last opt argumnt */ NULL,
/* arg list/cookie */ NULL,
/* must/cannot opts */ NULL, NULL,
/* option proc */ doVersion,
/* desc, NAME, name */ zVersionText, NULL, zVersion_Name,
/* disablement strs */ NULL, NULL },[=
ENDIF=]
{ /* entry idx, value */ INDEX_[= (. UP-prefix) =]OPT_HELP, VALUE_[=
(. UP-prefix) =]OPT_HELP,
/* equiv idx value */ NO_EQUIVALENT, 0,
/* option argument */ ARG_NONE,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max act ct */ 0, 1, 0,
/* opt state flags */ OPTST_IMM,
/* last opt argumnt */ NULL,
/* arg list/cookie */ NULL,
/* must/cannot opts */ NULL, NULL,
/* option proc */ doUsageOpt,
/* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
/* disablement strs */ NULL, NULL },
{ /* entry idx, value */ INDEX_[= (. UP-prefix) =]OPT_MORE_HELP, VALUE_[=
(. UP-prefix) =]OPT_MORE_HELP,
/* equiv idx value */ NO_EQUIVALENT, 0,
/* option argument */ ARG_NONE,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max act ct */ 0, 1, 0,
/* opt state flags */ OPTST_IMM,
/* last opt argumnt */ NULL,
/* arg list/cookie */ NULL,
/* must/cannot opts */ NULL, NULL,
/* option proc */ doPagedUsage,
/* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name,
/* disablement strs */ NULL, NULL }[=
IF (exist? "homerc")
=],
{ /* entry idx, value */ INDEX_[= (. UP-prefix) =]OPT_SAVE_OPTS, VALUE_[=
(. UP-prefix) =]OPT_SAVE_OPTS,
/* equiv idx value */ NO_EQUIVALENT, 0,
/* option argument */ '?',
/* equivalenced to */ NO_EQUIVALENT,
/* min, max act ct */ 0, 1, 0,
/* opt state flags */ OPTST_INIT,
/* last opt argumnt */ NULL,
/* arg list/cookie */ NULL,
/* must/cannot opts */ NULL, NULL,
/* option proc */ NULL,
/* desc, NAME, name */ zSave_OptsText, NULL, zSave_Opts_Name,
/* disablement strs */ NULL, NULL },
{ /* entry idx, value */ INDEX_[= (. UP-prefix) =]OPT_LOAD_OPTS, VALUE_[=
(. UP-prefix) =]OPT_LOAD_OPTS,
/* equiv idx value */ NO_EQUIVALENT, 0,
/* option argument */ ARG_MUST,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, NOLIMIT, 0,
/* opt state flags */ OPTST_DISABLE_IMM,
/* last opt argumnt */ NULL,
/* arg list/cookie */ NULL,
/* must/cannot opts */ NULL, NULL,
/* option proc */ doLoadOpt,
/* desc, NAME, name */ zLoad_OptsText, zLoad_Opts_NAME, zLoad_Opts_Name,
/* disablement strs */ zNotLoad_Opts_Name, zNotLoad_Opts_Pfx }[=
ENDIF=]
};
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Define the [= (. pname-cap) =] Option Environment
*/
tSCC zPROGNAME[] = "[= (. pname-up) =]";
tSCC zUsageTitle[] =
[= USAGE_LINE =];[=
IF (exist? "homerc") =]
tSCC zRcName[] = "[=
IF (> (string-length (get "rcfile")) 0)
=][=rcfile=][=
ELSE =].[=(. pname-down)=]rc[=
ENDIF =]";
tSCC* apzHomeList[] = {[=
FOR homerc=]
[= (kr-string (get "homerc")) =],[=
ENDFOR homerc=]
NULL };[=
ELSE=]
#define zRcName NULL
#define apzHomeList NULL[=
ENDIF=][=
IF (exist? "explain") =]
tSCC zExplain[] = [=
(kr-string (string-append "\n" (get "explain") "\n") ) =];[=
ELSE=]
#define zExplain NULL[=
ENDIF=]
[=
IF (exist? "detail") =]
tSCC zDetail[] = [=
(kr-string (string-append "\n" (get "detail") "\n")) =];
[=
ELSE
=]
#define zDetail NULL[=
ENDIF=][=
IF (not (exist? "usage")) =]
extern tUsageProc optionUsage;[=
ENDIF=][=
IF (exist? "version") =]
tSCC zFullVersion[] = [=(. pname-up)=]_FULL_VERSION;[=
ELSE=]
#define zFullVersion NULL[=
ENDIF=]
tOptions [=(. pname)=]Options = {
OPTIONS_STRUCT_VERSION,
NULL, NULL, zPROGNAME,
zRcName, zCopyright, zCopyrightNotice,
zFullVersion, apzHomeList, zUsageTitle,
zExplain, zDetail, NULL,
[=IF (exist? "usage")=][=usage=][=
ELSE =]optionUsage[=ENDIF=],
( OPTPROC_NONE[= IF (not (exist? "allow_errors")) =]
+ OPTPROC_ERRSTOP[= ENDIF=][=IF (exist? "flag.value") =]
+ OPTPROC_SHORTOPT[= ENDIF=][=IF (exist? "long_opts") =]
+ OPTPROC_LONGOPT[= ENDIF=][=IF (not (exist? "flag.min")) =]
+ OPTPROC_NO_REQ_OPT[= ENDIF=][=IF (exist? "flag.disable") =]
+ OPTPROC_NEGATIONS[= ENDIF=][=IF (>= number-opt-index 0) =]
+ OPTPROC_NUM_OPT[= ENDIF=][=IF (exist? "environrc") =]
+ OPTPROC_ENVIRON[= ENDIF=][=IF (and (exist? "plus_marks")
(exist? "flag.disable")) =]
+ OPTPROC_PLUSMARKS[= ENDIF=][=IF (not (exist? "argument")) =]
+ OPTPROC_NO_ARGS[= ELIF (not (==* (get "argument") "[" )) =]
+ OPTPROC_ARGS_REQ[= ENDIF=][=IF (exist? "reorder-opts") =]
+ OPTPROC_REORDER[= ENDIF=] ),
0, NULL,
{ INDEX_[= (. UP-prefix) =]OPT_MORE_HELP,
[=IF (exist? "homerc")
=]INDEX_[= (. UP-prefix) =]OPT_SAVE_OPTS[=
ELSE =] 0 /* no option state saving */[=
ENDIF=],
[= IF (>= number-opt-index 0)
=][= (. number-opt-index) =] /* index of '-#' option */[=
ELSE =]NO_EQUIVALENT /* no '-#' option */[=
ENDIF =],
[=
IF (>= default-opt-index 0)
=][= (. default-opt-index) =] /* index of default opt */[=
ELSE =]NO_EQUIVALENT /* no default option */[=
ENDIF =] },
[= (. UP-prefix) =]OPTION_CT, [=(count "flag")=] /* user option count */,
optDesc
};
/*
* Create the static procedure(s) declared above.
*/
static void
#ifdef __cplusplus
doUsageOpt(
tOptions* pOptions,
tOptDesc* pOptDesc )
#else
doUsageOpt( pOpts, pOD )
tOptions* pOpts;
tOptDesc* pOD;
#endif
{
[= (. UP-prefix) =]USAGE( EXIT_SUCCESS );
}[=
IF (or (exist? "flag.flag_code")
(exist? "flag.extract_code")
(exist? "flag.arg_range")
(match-value? =* "flag.arg_type" "key")) =][=
invoke define-option-callbacks =][=
ENDIF =][=
IF (exist? "test_main") =][=
IF (exist? "guile-main") =][=
(error "both ``test_main'' and ``guile-main'' have been defined") =][=
ELSE =][=
invoke build-test-main =][=
ENDIF =][=
ELIF (exist? "guile-main") =][=
`echo invoking build-guile-main >&2` =][=
invoke build-guile-main =][=
ENDIF "test/guile main"
=]
|