1 /* $NetBSD: version.c,v 1.1.1.2 2007/06/24 15:49:28 kardel Exp $ */
4 /* Id: version.c,v 4.10 2007/04/28 22:19:23 bkorb Exp
5 * Time-stamp: "2007-04-28 10:08:34 bkorb"
7 * This module implements the default usage procedure for
8 * Automated Options. It may be overridden, of course.
11 static char const zAOV
[] =
12 "Automated Options version %s, copyright (c) 1999-2007 Bruce Korb\n";
14 /* Automated Options is free software.
15 * You may redistribute it and/or modify it under the terms of the
16 * GNU General Public License, as published by the Free Software
17 * Foundation; either version 2, or (at your option) any later version.
19 * Automated Options is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with Automated Options. See the file "COPYING". If not,
26 * write to: The Free Software Foundation, Inc.,
27 * 51 Franklin Street, Fifth Floor,
28 * Boston, MA 02110-1301, USA.
30 * As a special exception, Bruce Korb gives permission for additional
31 * uses of the text contained in his release of AutoOpts.
33 * The exception is that, if you link the AutoOpts library with other
34 * files to produce an executable, this does not by itself cause the
35 * resulting executable to be covered by the GNU General Public License.
36 * Your use of that executable is in no way restricted on account of
37 * linking the AutoOpts library code into it.
39 * This exception does not however invalidate any other reasons why
40 * the executable file might be covered by the GNU General Public License.
42 * This exception applies only to the code released by Bruce Korb under
43 * the name AutoOpts. If you copy code from other sources under the
44 * General Public License into a copy of AutoOpts, as the General Public
45 * License permits, the exception does not apply to the code that you add
46 * in this way. To avoid misleading anyone as to the status of such
47 * modified files, you must delete this exception notice from them.
49 * If you write modifications of your own for AutoOpts, it is your choice
50 * whether to permit this exception to apply to your modifications.
51 * If you do not wish that, delete this exception notice.
54 /* = = = START-STATIC-FORWARD = = = */
55 /* static forward declarations maintained by :mkfwd */
57 printVersion( tOptions
* pOpts
, tOptDesc
* pOD
, FILE* fp
);
58 /* = = = END-STATIC-FORWARD = = = */
60 /*=export_func optionVersion
62 * what: return the compiled AutoOpts version number
63 * ret_type: char const*
64 * ret_desc: the version string in constant memory
66 * Returns the full version string compiled into the library.
67 * The returned string cannot be modified.
72 static char const zVersion
[] =
73 STR( AO_CURRENT
.AO_REVISION
);
80 printVersion( tOptions
* pOpts
, tOptDesc
* pOD
, FILE* fp
)
85 * IF the optional argument flag is off, or the argument is not provided,
86 * then just print the version.
88 if ( ((pOD
->fOptState
& OPTST_ARG_OPTIONAL
) == 0)
89 || (pOD
->optArg
.argString
== NULL
))
91 else swCh
= tolower((int)pOD
->optArg
.argString
[0]);
93 if (pOpts
->pzFullVersion
!= NULL
) {
94 fputs( pOpts
->pzFullVersion
, fp
);
98 char const *pz
= pOpts
->pzUsageTitle
;
99 do { fputc(*pz
, fp
); } while (*(pz
++) != '\n');
103 case NUL
: /* arg provided, but empty */
108 if (pOpts
->pzCopyright
!= NULL
) {
109 fputs( pOpts
->pzCopyright
, fp
);
112 fprintf( fp
, zAOV
, optionVersion() );
113 if (pOpts
->pzBugAddr
!= NULL
)
114 fprintf( fp
, zPlsSendBugs
, pOpts
->pzBugAddr
);
118 if (pOpts
->pzCopyright
!= NULL
) {
119 fputs( pOpts
->pzCopyright
, fp
);
124 if (pOpts
->pzCopyNotice
!= NULL
) {
125 fputs( pOpts
->pzCopyNotice
, fp
);
129 fprintf( fp
, zAOV
, optionVersion() );
130 if (pOpts
->pzBugAddr
!= NULL
)
131 fprintf( fp
, zPlsSendBugs
, pOpts
->pzBugAddr
);
135 fprintf( stderr
, zBadVerArg
, swCh
);
136 exit( EXIT_FAILURE
);
139 exit( EXIT_SUCCESS
);
142 /*=export_func optionPrintVersion
145 * what: Print the program version
146 * arg: + tOptions* + pOpts + program options descriptor +
147 * arg: + tOptDesc* + pOptDesc + the descriptor for this arg +
150 * This routine will print the version to stdout.
153 optionPrintVersion( tOptions
* pOpts
, tOptDesc
* pOD
)
155 printVersion( pOpts
, pOD
, stdout
);
158 /*=export_func optionVersionStderr
161 * what: Print the program version to stderr
162 * arg: + tOptions* + pOpts + program options descriptor +
163 * arg: + tOptDesc* + pOptDesc + the descriptor for this arg +
166 * This routine will print the version to stderr.
169 optionVersionStderr( tOptions
* pOpts
, tOptDesc
* pOD
)
171 printVersion( pOpts
, pOD
, stderr
);
177 * c-file-style: "stroustrup"
178 * indent-tabs-mode: nil
180 * end of autoopts/version.c */