Coverage Report

Created: 2023-03-26 06:17

/src/lame/libmp3lame/version.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 *      Version numbering for LAME.
3
 *
4
 *      Copyright (c) 1999 A.L. Faber
5
 *
6
 * This library is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU Library General Public
8
 * License as published by the Free Software Foundation; either
9
 * version 2 of the License, or (at your option) any later version.
10
 *
11
 * This library is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * Library General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Library General Public
17
 * License along with this library; if not, write to the
18
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19
 * Boston, MA 02111-1307, USA.
20
 */
21
22
/*!
23
  \file   version.c
24
  \brief  Version numbering for LAME.
25
26
  Contains functions which describe the version of LAME.
27
28
  \author A.L. Faber
29
  \version \$Id$
30
  \ingroup libmp3lame
31
*/
32
33
34
#ifdef HAVE_CONFIG_H
35
# include <config.h>
36
#endif
37
38
39
#include "lame.h"
40
#include "machine.h"
41
42
#include "version.h"    /* macros of version numbers */
43
44
45
46
47
48
/*! Get the LAME version string. */
49
/*!
50
  \param void
51
  \return a pointer to a string which describes the version of LAME.
52
*/
53
const char *
54
get_lame_version(void)
55
1.37k
{                       /* primary to write screen reports */
56
    /* Here we can also add informations about compile time configurations */
57
58
#if   LAME_ALPHA_VERSION
59
    static /*@observer@ */ const char *const str =
60
        STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) " "
61
        "(alpha " STR(LAME_PATCH_VERSION) ", " __DATE__ " " __TIME__ ")";
62
#elif LAME_BETA_VERSION
63
1.37k
    static /*@observer@ */ const char *const str =
64
1.37k
        STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) " "
65
1.37k
        "(beta " STR(LAME_PATCH_VERSION) ", " __DATE__ ")";
66
#elif LAME_RELEASE_VERSION && (LAME_PATCH_VERSION > 0)
67
    static /*@observer@ */ const char *const str =
68
        STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) "." STR(LAME_PATCH_VERSION);
69
#else
70
    static /*@observer@ */ const char *const str =
71
        STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION);
72
#endif
73
74
1.37k
    return str;
75
1.37k
}
76
77
78
/*! Get the short LAME version string. */
79
/*!
80
  It's mainly for inclusion into the MP3 stream.
81
82
  \param void   
83
  \return a pointer to the short version of the LAME version string.
84
*/
85
const char *
86
get_lame_short_version(void)
87
15.3k
{
88
    /* adding date and time to version string makes it harder for output
89
       validation */
90
91
#if   LAME_ALPHA_VERSION
92
    static /*@observer@ */ const char *const str =
93
        STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) " (alpha " STR(LAME_PATCH_VERSION) ")";
94
#elif LAME_BETA_VERSION
95
15.3k
    static /*@observer@ */ const char *const str =
96
15.3k
        STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) " (beta " STR(LAME_PATCH_VERSION) ")";
97
#elif LAME_RELEASE_VERSION && (LAME_PATCH_VERSION > 0)
98
    static /*@observer@ */ const char *const str =
99
        STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) "." STR(LAME_PATCH_VERSION);
100
#else
101
    static /*@observer@ */ const char *const str =
102
        STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION);
103
#endif
104
105
15.3k
    return str;
106
15.3k
}
107
108
/*! Get the _very_ short LAME version string. */
109
/*!
110
  It's used in the LAME VBR tag only.
111
112
  \param void   
113
  \return a pointer to the short version of the LAME version string.
114
*/
115
const char *
116
get_lame_very_short_version(void)
117
0
{
118
    /* adding date and time to version string makes it harder for output
119
       validation */
120
#if   LAME_ALPHA_VERSION
121
#define P "a"
122
#elif LAME_BETA_VERSION
123
0
#define P "b"
124
#elif LAME_RELEASE_VERSION && (LAME_PATCH_VERSION > 0)
125
#define P "r"
126
#else
127
#define P " "
128
#endif
129
0
    static /*@observer@ */ const char *const str =
130
0
#if (LAME_PATCH_VERSION > 0)
131
0
      "LAME" STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) P STR(LAME_PATCH_VERSION)
132
#else
133
      "LAME" STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) P
134
#endif
135
0
      ;
136
0
    return str;
137
0
}
138
139
/*! Get the _very_ short LAME version string. */
140
/*!
141
  It's used in the LAME VBR tag only, limited to 9 characters max.
142
  Due to some 3rd party HW/SW decoders, it has to start with LAME.
143
144
  \param void   
145
  \return a pointer to the short version of the LAME version string.
146
 */
147
const char*
148
get_lame_tag_encoder_short_version(void)
149
0
{
150
0
    static /*@observer@ */ const char *const str =
151
            /* FIXME: new scheme / new version counting / drop versioning here ? */
152
0
    "LAME" STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) P
153
0
    ;
154
0
    return str;
155
0
}
156
157
/*! Get the version string for GPSYCHO. */
158
/*!
159
  \param void
160
  \return a pointer to a string which describes the version of GPSYCHO.
161
*/
162
const char *
163
get_psy_version(void)
164
0
{
165
#if   PSY_ALPHA_VERSION > 0
166
    static /*@observer@ */ const char *const str =
167
        STR(PSY_MAJOR_VERSION) "." STR(PSY_MINOR_VERSION)
168
        " (alpha " STR(PSY_ALPHA_VERSION) ", " __DATE__ " " __TIME__ ")";
169
#elif PSY_BETA_VERSION > 0
170
    static /*@observer@ */ const char *const str =
171
        STR(PSY_MAJOR_VERSION) "." STR(PSY_MINOR_VERSION)
172
        " (beta " STR(PSY_BETA_VERSION) ", " __DATE__ ")";
173
#else
174
0
    static /*@observer@ */ const char *const str =
175
0
        STR(PSY_MAJOR_VERSION) "." STR(PSY_MINOR_VERSION);
176
0
#endif
177
178
0
    return str;
179
0
}
180
181
182
/*! Get the URL for the LAME website. */
183
/*!
184
  \param void
185
  \return a pointer to a string which is a URL for the LAME website.
186
*/
187
const char *
188
get_lame_url(void)
189
1.37k
{
190
1.37k
    static /*@observer@ */ const char *const str = LAME_URL;
191
192
1.37k
    return str;
193
1.37k
}
194
195
196
/*! Get the numerical representation of the version. */
197
/*!
198
  Writes the numerical representation of the version of LAME and
199
  GPSYCHO into lvp.
200
201
  \param lvp    
202
*/
203
void
204
get_lame_version_numerical(lame_version_t * lvp)
205
0
{
206
0
    static /*@observer@ */ const char *const features = ""; /* obsolete */
207
208
    /* generic version */
209
0
    lvp->major = LAME_MAJOR_VERSION;
210
0
    lvp->minor = LAME_MINOR_VERSION;
211
#if LAME_ALPHA_VERSION
212
    lvp->alpha = LAME_PATCH_VERSION;
213
    lvp->beta = 0;
214
#elif LAME_BETA_VERSION
215
0
    lvp->alpha = 0;
216
0
    lvp->beta = LAME_PATCH_VERSION;
217
#else
218
    lvp->alpha = 0;
219
    lvp->beta = 0;
220
#endif
221
222
    /* psy version */
223
0
    lvp->psy_major = PSY_MAJOR_VERSION;
224
0
    lvp->psy_minor = PSY_MINOR_VERSION;
225
0
    lvp->psy_alpha = PSY_ALPHA_VERSION;
226
0
    lvp->psy_beta = PSY_BETA_VERSION;
227
228
    /* compile time features */
229
    /*@-mustfree@ */
230
0
    lvp->features = features;
231
    /*@=mustfree@ */
232
0
}
233
234
235
const char *
236
get_lame_os_bitness(void)
237
1.37k
{
238
1.37k
    static /*@observer@ */ const char *const strXX = "";
239
1.37k
    static /*@observer@ */ const char *const str32 = "32bits";
240
1.37k
    static /*@observer@ */ const char *const str64 = "64bits";
241
242
1.37k
    switch (sizeof(void *)) {
243
0
    case 4:
244
0
        return str32;
245
246
1.37k
    case 8:
247
1.37k
        return str64;
248
249
0
    default:
250
0
        return strXX;
251
1.37k
    }
252
1.37k
}
253
254
/* end of version.c */