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 *
get_lame_version(void)54 get_lame_version(void)
55 { /* 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 static /*@observer@ */ const char *const str =
64 STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) " "
65 "(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 return str;
75 }
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 *
get_lame_short_version(void)86 get_lame_short_version(void)
87 {
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 static /*@observer@ */ const char *const str =
96 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 return str;
106 }
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 *
get_lame_very_short_version(void)116 get_lame_very_short_version(void)
117 {
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 #define P "b"
124 #elif LAME_RELEASE_VERSION && (LAME_PATCH_VERSION > 0)
125 #define P "r"
126 #else
127 #define P " "
128 #endif
129 static /*@observer@ */ const char *const str =
130 #if (LAME_PATCH_VERSION > 0)
131 "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 ;
136 return str;
137 }
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*
get_lame_tag_encoder_short_version(void)148 get_lame_tag_encoder_short_version(void)
149 {
150 static /*@observer@ */ const char *const str =
151 /* FIXME: new scheme / new version counting / drop versioning here ? */
152 "LAME" STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) P
153 ;
154 return str;
155 }
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 *
get_psy_version(void)163 get_psy_version(void)
164 {
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 static /*@observer@ */ const char *const str =
175 STR(PSY_MAJOR_VERSION) "." STR(PSY_MINOR_VERSION);
176 #endif
177
178 return str;
179 }
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 *
get_lame_url(void)188 get_lame_url(void)
189 {
190 static /*@observer@ */ const char *const str = LAME_URL;
191
192 return str;
193 }
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
get_lame_version_numerical(lame_version_t * lvp)204 get_lame_version_numerical(lame_version_t * lvp)
205 {
206 static /*@observer@ */ const char *const features = ""; /* obsolete */
207
208 /* generic version */
209 lvp->major = LAME_MAJOR_VERSION;
210 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 lvp->alpha = 0;
216 lvp->beta = LAME_PATCH_VERSION;
217 #else
218 lvp->alpha = 0;
219 lvp->beta = 0;
220 #endif
221
222 /* psy version */
223 lvp->psy_major = PSY_MAJOR_VERSION;
224 lvp->psy_minor = PSY_MINOR_VERSION;
225 lvp->psy_alpha = PSY_ALPHA_VERSION;
226 lvp->psy_beta = PSY_BETA_VERSION;
227
228 /* compile time features */
229 /*@-mustfree@ */
230 lvp->features = features;
231 /*@=mustfree@ */
232 }
233
234
235 const char *
get_lame_os_bitness(void)236 get_lame_os_bitness(void)
237 {
238 static /*@observer@ */ const char *const strXX = "";
239 static /*@observer@ */ const char *const str32 = "32bits";
240 static /*@observer@ */ const char *const str64 = "64bits";
241
242 switch (sizeof(void *)) {
243 case 4:
244 return str32;
245
246 case 8:
247 return str64;
248
249 default:
250 return strXX;
251 }
252 }
253
254 /* end of version.c */
255