4 /* Id: e21e2bf9958c54e440efbdc7c1026e46ac589f66
5 * Time-stamp: "2008-07-27 10:11:30 bkorb"
7 * This module implements the default usage procedure for
8 * Automated Options. It may be overridden, of course.
12 * This file is part of AutoOpts, a companion to AutoGen.
13 * AutoOpts is free software.
14 * AutoOpts is copyright (c) 1992-2009 by Bruce Korb - all rights reserved
16 * AutoOpts is available under any one of two licenses. The license
17 * in use must be one of these two and the choice is under the control
18 * of the user of the license.
20 * The GNU Lesser General Public License, version 3 or later
21 * See the files "COPYING.lgplv3" and "COPYING.gplv3"
23 * The Modified Berkeley Software Distribution License
24 * See the file "COPYING.mbsd"
26 * These files have the following md5sums:
28 * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3
29 * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3
30 * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd
33 /* = = = START-STATIC-FORWARD = = = */
34 /* static forward declarations maintained by mk-fwd */
36 printVersion( tOptions
* pOpts
, tOptDesc
* pOD
, FILE* fp
);
37 /* = = = END-STATIC-FORWARD = = = */
39 /*=export_func optionVersion
41 * what: return the compiled AutoOpts version number
42 * ret_type: char const*
43 * ret_desc: the version string in constant memory
45 * Returns the full version string compiled into the library.
46 * The returned string cannot be modified.
51 static char const zVersion
[] =
52 STR( AO_CURRENT
.AO_REVISION
);
59 printVersion( tOptions
* pOpts
, tOptDesc
* pOD
, FILE* fp
)
64 * IF the optional argument flag is off, or the argument is not provided,
65 * then just print the version.
67 if ( ((pOD
->fOptState
& OPTST_ARG_OPTIONAL
) == 0)
68 || (pOD
->optArg
.argString
== NULL
))
70 else swCh
= tolower(pOD
->optArg
.argString
[0]);
72 if (pOpts
->pzFullVersion
!= NULL
) {
73 fputs( pOpts
->pzFullVersion
, fp
);
77 char const *pz
= pOpts
->pzUsageTitle
;
78 do { fputc(*pz
, fp
); } while (*(pz
++) != '\n');
82 case NUL
: /* arg provided, but empty */
87 if (pOpts
->pzCopyright
!= NULL
) {
88 fputs( pOpts
->pzCopyright
, fp
);
91 fprintf( fp
, zAO_Ver
, optionVersion() );
92 if (pOpts
->pzBugAddr
!= NULL
)
93 fprintf( fp
, zPlsSendBugs
, pOpts
->pzBugAddr
);
97 if (pOpts
->pzCopyright
!= NULL
) {
98 fputs( pOpts
->pzCopyright
, fp
);
103 if (pOpts
->pzCopyNotice
!= NULL
) {
104 fputs( pOpts
->pzCopyNotice
, fp
);
108 fprintf( fp
, zAO_Ver
, optionVersion() );
109 if (pOpts
->pzBugAddr
!= NULL
)
110 fprintf( fp
, zPlsSendBugs
, pOpts
->pzBugAddr
);
114 fprintf( stderr
, zBadVerArg
, swCh
);
115 exit( EXIT_FAILURE
);
118 exit( EXIT_SUCCESS
);
121 /*=export_func optionPrintVersion
124 * what: Print the program version
125 * arg: + tOptions* + pOpts + program options descriptor +
126 * arg: + tOptDesc* + pOptDesc + the descriptor for this arg +
129 * This routine will print the version to stdout.
132 optionPrintVersion( tOptions
* pOpts
, tOptDesc
* pOD
)
134 printVersion( pOpts
, pOD
, stdout
);
137 /*=export_func optionVersionStderr
140 * what: Print the program version to stderr
141 * arg: + tOptions* + pOpts + program options descriptor +
142 * arg: + tOptDesc* + pOptDesc + the descriptor for this arg +
145 * This routine will print the version to stderr.
148 optionVersionStderr( tOptions
* pOpts
, tOptDesc
* pOD
)
150 printVersion( pOpts
, pOD
, stderr
);
156 * c-file-style: "stroustrup"
157 * indent-tabs-mode: nil
159 * end of autoopts/version.c */