2 /* $Id: version.c,v 4.10 2007/04/28 22:19:23 bkorb Exp $
3 * Time-stamp: "2007-04-28 10:08:34 bkorb"
5 * This module implements the default usage procedure for
6 * Automated Options. It may be overridden, of course.
9 static char const zAOV
[] =
10 "Automated Options version %s, copyright (c) 1999-2007 Bruce Korb\n";
12 /* Automated Options is free software.
13 * You may redistribute it and/or modify it under the terms of the
14 * GNU General Public License, as published by the Free Software
15 * Foundation; either version 2, or (at your option) any later version.
17 * Automated Options is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with Automated Options. See the file "COPYING". If not,
24 * write to: The Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor,
26 * Boston, MA 02110-1301, USA.
28 * As a special exception, Bruce Korb gives permission for additional
29 * uses of the text contained in his release of AutoOpts.
31 * The exception is that, if you link the AutoOpts library with other
32 * files to produce an executable, this does not by itself cause the
33 * resulting executable to be covered by the GNU General Public License.
34 * Your use of that executable is in no way restricted on account of
35 * linking the AutoOpts library code into it.
37 * This exception does not however invalidate any other reasons why
38 * the executable file might be covered by the GNU General Public License.
40 * This exception applies only to the code released by Bruce Korb under
41 * the name AutoOpts. If you copy code from other sources under the
42 * General Public License into a copy of AutoOpts, as the General Public
43 * License permits, the exception does not apply to the code that you add
44 * in this way. To avoid misleading anyone as to the status of such
45 * modified files, you must delete this exception notice from them.
47 * If you write modifications of your own for AutoOpts, it is your choice
48 * whether to permit this exception to apply to your modifications.
49 * If you do not wish that, delete this exception notice.
52 /* = = = START-STATIC-FORWARD = = = */
53 /* static forward declarations maintained by :mkfwd */
55 printVersion( tOptions
* pOpts
, tOptDesc
* pOD
, FILE* fp
);
56 /* = = = END-STATIC-FORWARD = = = */
58 /*=export_func optionVersion
60 * what: return the compiled AutoOpts version number
61 * ret_type: char const*
62 * ret_desc: the version string in constant memory
64 * Returns the full version string compiled into the library.
65 * The returned string cannot be modified.
70 static char const zVersion
[] =
71 STR( AO_CURRENT
.AO_REVISION
);
78 printVersion( tOptions
* pOpts
, tOptDesc
* pOD
, FILE* fp
)
83 * IF the optional argument flag is off, or the argument is not provided,
84 * then just print the version.
86 if ( ((pOD
->fOptState
& OPTST_ARG_OPTIONAL
) == 0)
87 || (pOD
->optArg
.argString
== NULL
))
89 else swCh
= tolower(pOD
->optArg
.argString
[0]);
91 if (pOpts
->pzFullVersion
!= NULL
) {
92 fputs( pOpts
->pzFullVersion
, fp
);
96 char const *pz
= pOpts
->pzUsageTitle
;
97 do { fputc(*pz
, fp
); } while (*(pz
++) != '\n');
101 case NUL
: /* arg provided, but empty */
106 if (pOpts
->pzCopyright
!= NULL
) {
107 fputs( pOpts
->pzCopyright
, fp
);
110 fprintf( fp
, zAOV
, optionVersion() );
111 if (pOpts
->pzBugAddr
!= NULL
)
112 fprintf( fp
, zPlsSendBugs
, pOpts
->pzBugAddr
);
116 if (pOpts
->pzCopyright
!= NULL
) {
117 fputs( pOpts
->pzCopyright
, fp
);
122 if (pOpts
->pzCopyNotice
!= NULL
) {
123 fputs( pOpts
->pzCopyNotice
, fp
);
127 fprintf( fp
, zAOV
, optionVersion() );
128 if (pOpts
->pzBugAddr
!= NULL
)
129 fprintf( fp
, zPlsSendBugs
, pOpts
->pzBugAddr
);
133 fprintf( stderr
, zBadVerArg
, swCh
);
134 exit( EXIT_FAILURE
);
137 exit( EXIT_SUCCESS
);
140 /*=export_func optionPrintVersion
143 * what: Print the program version
144 * arg: + tOptions* + pOpts + program options descriptor +
145 * arg: + tOptDesc* + pOptDesc + the descriptor for this arg +
148 * This routine will print the version to stdout.
151 optionPrintVersion( tOptions
* pOpts
, tOptDesc
* pOD
)
153 printVersion( pOpts
, pOD
, stdout
);
156 /*=export_func optionVersionStderr
159 * what: Print the program version to stderr
160 * arg: + tOptions* + pOpts + program options descriptor +
161 * arg: + tOptDesc* + pOptDesc + the descriptor for this arg +
164 * This routine will print the version to stderr.
167 optionVersionStderr( tOptions
* pOpts
, tOptDesc
* pOD
)
169 printVersion( pOpts
, pOD
, stderr
);
175 * c-file-style: "stroustrup"
176 * indent-tabs-mode: nil
178 * end of autoopts/version.c */