~ubuntu-branches/ubuntu/gutsy/ntp/gutsy

« back to all changes in this revision

Viewing changes to libopts/version.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2007-05-18 22:41:56 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070518224156-563ruqxsxvqvoy8h
Tags: 1:4.2.4p0+dfsg-1ubuntu1
* Merge from Debian unstable.
* Remaining Ubuntu changes:
  - Update version in conflicts/replaces to that which was shipped in edgy,
    which was later than that in Debian (due to the ubuntuX).
  - Change default server to ntp.ubuntu.com.
  - Remove stop links from rc0 and rc6
  - Call dh_installinit with --error-handler
  - Set Ubuntu maintainer address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/*  $Id: version.c,v 4.9 2006/09/24 02:11:16 bkorb Exp $
 
3
 * Time-stamp:      "2006-09-22 18:15:00 bkorb"
 
4
 *
 
5
 *  This module implements the default usage procedure for
 
6
 *  Automated Options.  It may be overridden, of course.
 
7
 */
 
8
 
 
9
static char const zAOV[] =
 
10
    "Automated Options version %s, copyright (c) 1999-2006 Bruce Korb\n";
 
11
 
 
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.
 
16
 *
 
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.
 
21
 *
 
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.
 
27
 *
 
28
 * As a special exception, Bruce Korb gives permission for additional
 
29
 * uses of the text contained in his release of AutoOpts.
 
30
 *
 
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.
 
36
 *
 
37
 * This exception does not however invalidate any other reasons why
 
38
 * the executable file might be covered by the GNU General Public License.
 
39
 *
 
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.
 
46
 *
 
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.
 
50
 */
 
51
 
 
52
/* = = = START-STATIC-FORWARD = = = */
 
53
/* static forward declarations maintained by :mkfwd */
 
54
static void
 
55
printVersion( tOptions* pOpts, tOptDesc* pOD, FILE* fp );
 
56
/* = = = END-STATIC-FORWARD = = = */
 
57
 
 
58
/*=export_func  optionVersion
 
59
 *
 
60
 * what:     return the compiled AutoOpts version number
 
61
 * ret_type: char const*
 
62
 * ret_desc: the version string in constant memory
 
63
 * doc:
 
64
 *  Returns the full version string compiled into the library.
 
65
 *  The returned string cannot be modified.
 
66
=*/
 
67
char const*
 
68
optionVersion( void )
 
69
{
 
70
    static char const zVersion[] =
 
71
        STR( AO_CURRENT.AO_REVISION );
 
72
 
 
73
    return zVersion;
 
74
}
 
75
 
 
76
 
 
77
static void
 
78
printVersion( tOptions* pOpts, tOptDesc* pOD, FILE* fp )
 
79
{
 
80
    char swCh;
 
81
 
 
82
    if (pOD->optArg.argString == NULL)
 
83
         swCh = 'v';
 
84
    else swCh = pOD->optArg.argString[0];
 
85
 
 
86
    if (pOpts->pzFullVersion != NULL) {
 
87
        fputs( pOpts->pzFullVersion, fp );
 
88
        fputc( '\n', fp );
 
89
 
 
90
    } else {
 
91
        char const *pz = pOpts->pzUsageTitle;
 
92
        do { fputc( *pz, fp ); } while (*(pz++) != '\n');
 
93
    }
 
94
 
 
95
    switch (swCh) {
 
96
    case NUL:
 
97
    case 'v':
 
98
    case 'V':
 
99
        break;
 
100
 
 
101
    case 'c':
 
102
    case 'C':
 
103
        if (pOpts->pzCopyright != NULL) {
 
104
            fputs( pOpts->pzCopyright, fp );
 
105
            fputc( '\n', fp );
 
106
        }
 
107
        fprintf( fp, zAOV, optionVersion() );
 
108
        if (pOpts->pzBugAddr != NULL)
 
109
            fprintf( fp, zPlsSendBugs, pOpts->pzBugAddr );
 
110
        break;
 
111
 
 
112
    case 'n':
 
113
    case 'N':
 
114
        if (pOpts->pzCopyright != NULL) {
 
115
            fputs( pOpts->pzCopyright, fp );
 
116
            fputc( '\n', fp );
 
117
            fputc( '\n', fp );
 
118
        }
 
119
 
 
120
        if (pOpts->pzCopyNotice != NULL) {
 
121
            fputs( pOpts->pzCopyNotice, fp );
 
122
            fputc( '\n', fp );
 
123
        }
 
124
 
 
125
        fprintf( fp, zAOV, optionVersion() );
 
126
        if (pOpts->pzBugAddr != NULL)
 
127
            fprintf( fp, zPlsSendBugs, pOpts->pzBugAddr );
 
128
        break;
 
129
 
 
130
    default:
 
131
        fprintf( stderr, zBadVerArg, swCh );
 
132
        exit( EXIT_FAILURE );
 
133
    }
 
134
 
 
135
    exit( EXIT_SUCCESS );
 
136
}
 
137
 
 
138
/*=export_func  optionPrintVersion
 
139
 * private:
 
140
 *
 
141
 * what:  Print the program version
 
142
 * arg:   + tOptions* + pOpts    + program options descriptor +
 
143
 * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
 
144
 *
 
145
 * doc:
 
146
 *  This routine will print the version to stdout.
 
147
=*/
 
148
void
 
149
optionPrintVersion( tOptions*  pOpts, tOptDesc*  pOD )
 
150
{
 
151
    printVersion( pOpts, pOD, stdout );
 
152
}
 
153
 
 
154
/*=export_func  optionVersionStderr
 
155
 * private:
 
156
 *
 
157
 * what:  Print the program version to stderr
 
158
 * arg:   + tOptions* + pOpts    + program options descriptor +
 
159
 * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
 
160
 *
 
161
 * doc:
 
162
 *  This routine will print the version to stderr.
 
163
=*/
 
164
void
 
165
optionVersionStderr( tOptions*  pOpts, tOptDesc*  pOD )
 
166
{
 
167
    printVersion( pOpts, pOD, stderr );
 
168
}
 
169
 
 
170
/*
 
171
 * Local Variables:
 
172
 * mode: C
 
173
 * c-file-style: "stroustrup"
 
174
 * indent-tabs-mode: nil
 
175
 * End:
 
176
 * end of autoopts/version.c */