1159b3361Sopenharmony_ci/*
2159b3361Sopenharmony_ci *      Version numbering for LAME.
3159b3361Sopenharmony_ci *
4159b3361Sopenharmony_ci *      Copyright (c) 1999 A.L. Faber
5159b3361Sopenharmony_ci *
6159b3361Sopenharmony_ci * This library is free software; you can redistribute it and/or
7159b3361Sopenharmony_ci * modify it under the terms of the GNU Library General Public
8159b3361Sopenharmony_ci * License as published by the Free Software Foundation; either
9159b3361Sopenharmony_ci * version 2 of the License, or (at your option) any later version.
10159b3361Sopenharmony_ci *
11159b3361Sopenharmony_ci * This library is distributed in the hope that it will be useful,
12159b3361Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of
13159b3361Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14159b3361Sopenharmony_ci * Library General Public License for more details.
15159b3361Sopenharmony_ci *
16159b3361Sopenharmony_ci * You should have received a copy of the GNU Library General Public
17159b3361Sopenharmony_ci * License along with this library; if not, write to the
18159b3361Sopenharmony_ci * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19159b3361Sopenharmony_ci * Boston, MA 02111-1307, USA.
20159b3361Sopenharmony_ci */
21159b3361Sopenharmony_ci
22159b3361Sopenharmony_ci/*!
23159b3361Sopenharmony_ci  \file   version.c
24159b3361Sopenharmony_ci  \brief  Version numbering for LAME.
25159b3361Sopenharmony_ci
26159b3361Sopenharmony_ci  Contains functions which describe the version of LAME.
27159b3361Sopenharmony_ci
28159b3361Sopenharmony_ci  \author A.L. Faber
29159b3361Sopenharmony_ci  \version \$Id$
30159b3361Sopenharmony_ci  \ingroup libmp3lame
31159b3361Sopenharmony_ci*/
32159b3361Sopenharmony_ci
33159b3361Sopenharmony_ci
34159b3361Sopenharmony_ci#ifdef HAVE_CONFIG_H
35159b3361Sopenharmony_ci# include <config.h>
36159b3361Sopenharmony_ci#endif
37159b3361Sopenharmony_ci
38159b3361Sopenharmony_ci
39159b3361Sopenharmony_ci#include "lame.h"
40159b3361Sopenharmony_ci#include "machine.h"
41159b3361Sopenharmony_ci
42159b3361Sopenharmony_ci#include "version.h"    /* macros of version numbers */
43159b3361Sopenharmony_ci
44159b3361Sopenharmony_ci
45159b3361Sopenharmony_ci
46159b3361Sopenharmony_ci
47159b3361Sopenharmony_ci
48159b3361Sopenharmony_ci/*! Get the LAME version string. */
49159b3361Sopenharmony_ci/*!
50159b3361Sopenharmony_ci  \param void
51159b3361Sopenharmony_ci  \return a pointer to a string which describes the version of LAME.
52159b3361Sopenharmony_ci*/
53159b3361Sopenharmony_ciconst char *
54159b3361Sopenharmony_ciget_lame_version(void)
55159b3361Sopenharmony_ci{                       /* primary to write screen reports */
56159b3361Sopenharmony_ci    /* Here we can also add informations about compile time configurations */
57159b3361Sopenharmony_ci
58159b3361Sopenharmony_ci#if   LAME_ALPHA_VERSION
59159b3361Sopenharmony_ci    static /*@observer@ */ const char *const str =
60159b3361Sopenharmony_ci        STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) " "
61159b3361Sopenharmony_ci        "(alpha " STR(LAME_PATCH_VERSION) ", " __DATE__ " " __TIME__ ")";
62159b3361Sopenharmony_ci#elif LAME_BETA_VERSION
63159b3361Sopenharmony_ci    static /*@observer@ */ const char *const str =
64159b3361Sopenharmony_ci        STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) " "
65159b3361Sopenharmony_ci        "(beta " STR(LAME_PATCH_VERSION) ", " __DATE__ ")";
66159b3361Sopenharmony_ci#elif LAME_RELEASE_VERSION && (LAME_PATCH_VERSION > 0)
67159b3361Sopenharmony_ci    static /*@observer@ */ const char *const str =
68159b3361Sopenharmony_ci        STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) "." STR(LAME_PATCH_VERSION);
69159b3361Sopenharmony_ci#else
70159b3361Sopenharmony_ci    static /*@observer@ */ const char *const str =
71159b3361Sopenharmony_ci        STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION);
72159b3361Sopenharmony_ci#endif
73159b3361Sopenharmony_ci
74159b3361Sopenharmony_ci    return str;
75159b3361Sopenharmony_ci}
76159b3361Sopenharmony_ci
77159b3361Sopenharmony_ci
78159b3361Sopenharmony_ci/*! Get the short LAME version string. */
79159b3361Sopenharmony_ci/*!
80159b3361Sopenharmony_ci  It's mainly for inclusion into the MP3 stream.
81159b3361Sopenharmony_ci
82159b3361Sopenharmony_ci  \param void
83159b3361Sopenharmony_ci  \return a pointer to the short version of the LAME version string.
84159b3361Sopenharmony_ci*/
85159b3361Sopenharmony_ciconst char *
86159b3361Sopenharmony_ciget_lame_short_version(void)
87159b3361Sopenharmony_ci{
88159b3361Sopenharmony_ci    /* adding date and time to version string makes it harder for output
89159b3361Sopenharmony_ci       validation */
90159b3361Sopenharmony_ci
91159b3361Sopenharmony_ci#if   LAME_ALPHA_VERSION
92159b3361Sopenharmony_ci    static /*@observer@ */ const char *const str =
93159b3361Sopenharmony_ci        STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) " (alpha " STR(LAME_PATCH_VERSION) ")";
94159b3361Sopenharmony_ci#elif LAME_BETA_VERSION
95159b3361Sopenharmony_ci    static /*@observer@ */ const char *const str =
96159b3361Sopenharmony_ci        STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) " (beta " STR(LAME_PATCH_VERSION) ")";
97159b3361Sopenharmony_ci#elif LAME_RELEASE_VERSION && (LAME_PATCH_VERSION > 0)
98159b3361Sopenharmony_ci    static /*@observer@ */ const char *const str =
99159b3361Sopenharmony_ci        STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) "." STR(LAME_PATCH_VERSION);
100159b3361Sopenharmony_ci#else
101159b3361Sopenharmony_ci    static /*@observer@ */ const char *const str =
102159b3361Sopenharmony_ci        STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION);
103159b3361Sopenharmony_ci#endif
104159b3361Sopenharmony_ci
105159b3361Sopenharmony_ci    return str;
106159b3361Sopenharmony_ci}
107159b3361Sopenharmony_ci
108159b3361Sopenharmony_ci/*! Get the _very_ short LAME version string. */
109159b3361Sopenharmony_ci/*!
110159b3361Sopenharmony_ci  It's used in the LAME VBR tag only.
111159b3361Sopenharmony_ci
112159b3361Sopenharmony_ci  \param void
113159b3361Sopenharmony_ci  \return a pointer to the short version of the LAME version string.
114159b3361Sopenharmony_ci*/
115159b3361Sopenharmony_ciconst char *
116159b3361Sopenharmony_ciget_lame_very_short_version(void)
117159b3361Sopenharmony_ci{
118159b3361Sopenharmony_ci    /* adding date and time to version string makes it harder for output
119159b3361Sopenharmony_ci       validation */
120159b3361Sopenharmony_ci#if   LAME_ALPHA_VERSION
121159b3361Sopenharmony_ci#define P "a"
122159b3361Sopenharmony_ci#elif LAME_BETA_VERSION
123159b3361Sopenharmony_ci#define P "b"
124159b3361Sopenharmony_ci#elif LAME_RELEASE_VERSION && (LAME_PATCH_VERSION > 0)
125159b3361Sopenharmony_ci#define P "r"
126159b3361Sopenharmony_ci#else
127159b3361Sopenharmony_ci#define P " "
128159b3361Sopenharmony_ci#endif
129159b3361Sopenharmony_ci    static /*@observer@ */ const char *const str =
130159b3361Sopenharmony_ci#if (LAME_PATCH_VERSION > 0)
131159b3361Sopenharmony_ci      "LAME" STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) P STR(LAME_PATCH_VERSION)
132159b3361Sopenharmony_ci#else
133159b3361Sopenharmony_ci      "LAME" STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) P
134159b3361Sopenharmony_ci#endif
135159b3361Sopenharmony_ci      ;
136159b3361Sopenharmony_ci    return str;
137159b3361Sopenharmony_ci}
138159b3361Sopenharmony_ci
139159b3361Sopenharmony_ci/*! Get the _very_ short LAME version string. */
140159b3361Sopenharmony_ci/*!
141159b3361Sopenharmony_ci  It's used in the LAME VBR tag only, limited to 9 characters max.
142159b3361Sopenharmony_ci  Due to some 3rd party HW/SW decoders, it has to start with LAME.
143159b3361Sopenharmony_ci
144159b3361Sopenharmony_ci  \param void
145159b3361Sopenharmony_ci  \return a pointer to the short version of the LAME version string.
146159b3361Sopenharmony_ci */
147159b3361Sopenharmony_ciconst char*
148159b3361Sopenharmony_ciget_lame_tag_encoder_short_version(void)
149159b3361Sopenharmony_ci{
150159b3361Sopenharmony_ci    static /*@observer@ */ const char *const str =
151159b3361Sopenharmony_ci            /* FIXME: new scheme / new version counting / drop versioning here ? */
152159b3361Sopenharmony_ci    "LAME" STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) P
153159b3361Sopenharmony_ci    ;
154159b3361Sopenharmony_ci    return str;
155159b3361Sopenharmony_ci}
156159b3361Sopenharmony_ci
157159b3361Sopenharmony_ci/*! Get the version string for GPSYCHO. */
158159b3361Sopenharmony_ci/*!
159159b3361Sopenharmony_ci  \param void
160159b3361Sopenharmony_ci  \return a pointer to a string which describes the version of GPSYCHO.
161159b3361Sopenharmony_ci*/
162159b3361Sopenharmony_ciconst char *
163159b3361Sopenharmony_ciget_psy_version(void)
164159b3361Sopenharmony_ci{
165159b3361Sopenharmony_ci#if   PSY_ALPHA_VERSION > 0
166159b3361Sopenharmony_ci    static /*@observer@ */ const char *const str =
167159b3361Sopenharmony_ci        STR(PSY_MAJOR_VERSION) "." STR(PSY_MINOR_VERSION)
168159b3361Sopenharmony_ci        " (alpha " STR(PSY_ALPHA_VERSION) ", " __DATE__ " " __TIME__ ")";
169159b3361Sopenharmony_ci#elif PSY_BETA_VERSION > 0
170159b3361Sopenharmony_ci    static /*@observer@ */ const char *const str =
171159b3361Sopenharmony_ci        STR(PSY_MAJOR_VERSION) "." STR(PSY_MINOR_VERSION)
172159b3361Sopenharmony_ci        " (beta " STR(PSY_BETA_VERSION) ", " __DATE__ ")";
173159b3361Sopenharmony_ci#else
174159b3361Sopenharmony_ci    static /*@observer@ */ const char *const str =
175159b3361Sopenharmony_ci        STR(PSY_MAJOR_VERSION) "." STR(PSY_MINOR_VERSION);
176159b3361Sopenharmony_ci#endif
177159b3361Sopenharmony_ci
178159b3361Sopenharmony_ci    return str;
179159b3361Sopenharmony_ci}
180159b3361Sopenharmony_ci
181159b3361Sopenharmony_ci
182159b3361Sopenharmony_ci/*! Get the URL for the LAME website. */
183159b3361Sopenharmony_ci/*!
184159b3361Sopenharmony_ci  \param void
185159b3361Sopenharmony_ci  \return a pointer to a string which is a URL for the LAME website.
186159b3361Sopenharmony_ci*/
187159b3361Sopenharmony_ciconst char *
188159b3361Sopenharmony_ciget_lame_url(void)
189159b3361Sopenharmony_ci{
190159b3361Sopenharmony_ci    static /*@observer@ */ const char *const str = LAME_URL;
191159b3361Sopenharmony_ci
192159b3361Sopenharmony_ci    return str;
193159b3361Sopenharmony_ci}
194159b3361Sopenharmony_ci
195159b3361Sopenharmony_ci
196159b3361Sopenharmony_ci/*! Get the numerical representation of the version. */
197159b3361Sopenharmony_ci/*!
198159b3361Sopenharmony_ci  Writes the numerical representation of the version of LAME and
199159b3361Sopenharmony_ci  GPSYCHO into lvp.
200159b3361Sopenharmony_ci
201159b3361Sopenharmony_ci  \param lvp
202159b3361Sopenharmony_ci*/
203159b3361Sopenharmony_civoid
204159b3361Sopenharmony_ciget_lame_version_numerical(lame_version_t * lvp)
205159b3361Sopenharmony_ci{
206159b3361Sopenharmony_ci    static /*@observer@ */ const char *const features = ""; /* obsolete */
207159b3361Sopenharmony_ci
208159b3361Sopenharmony_ci    /* generic version */
209159b3361Sopenharmony_ci    lvp->major = LAME_MAJOR_VERSION;
210159b3361Sopenharmony_ci    lvp->minor = LAME_MINOR_VERSION;
211159b3361Sopenharmony_ci#if LAME_ALPHA_VERSION
212159b3361Sopenharmony_ci    lvp->alpha = LAME_PATCH_VERSION;
213159b3361Sopenharmony_ci    lvp->beta = 0;
214159b3361Sopenharmony_ci#elif LAME_BETA_VERSION
215159b3361Sopenharmony_ci    lvp->alpha = 0;
216159b3361Sopenharmony_ci    lvp->beta = LAME_PATCH_VERSION;
217159b3361Sopenharmony_ci#else
218159b3361Sopenharmony_ci    lvp->alpha = 0;
219159b3361Sopenharmony_ci    lvp->beta = 0;
220159b3361Sopenharmony_ci#endif
221159b3361Sopenharmony_ci
222159b3361Sopenharmony_ci    /* psy version */
223159b3361Sopenharmony_ci    lvp->psy_major = PSY_MAJOR_VERSION;
224159b3361Sopenharmony_ci    lvp->psy_minor = PSY_MINOR_VERSION;
225159b3361Sopenharmony_ci    lvp->psy_alpha = PSY_ALPHA_VERSION;
226159b3361Sopenharmony_ci    lvp->psy_beta = PSY_BETA_VERSION;
227159b3361Sopenharmony_ci
228159b3361Sopenharmony_ci    /* compile time features */
229159b3361Sopenharmony_ci    /*@-mustfree@ */
230159b3361Sopenharmony_ci    lvp->features = features;
231159b3361Sopenharmony_ci    /*@=mustfree@ */
232159b3361Sopenharmony_ci}
233159b3361Sopenharmony_ci
234159b3361Sopenharmony_ci
235159b3361Sopenharmony_ciconst char *
236159b3361Sopenharmony_ciget_lame_os_bitness(void)
237159b3361Sopenharmony_ci{
238159b3361Sopenharmony_ci    static /*@observer@ */ const char *const strXX = "";
239159b3361Sopenharmony_ci    static /*@observer@ */ const char *const str32 = "32bits";
240159b3361Sopenharmony_ci    static /*@observer@ */ const char *const str64 = "64bits";
241159b3361Sopenharmony_ci
242159b3361Sopenharmony_ci    switch (sizeof(void *)) {
243159b3361Sopenharmony_ci    case 4:
244159b3361Sopenharmony_ci        return str32;
245159b3361Sopenharmony_ci
246159b3361Sopenharmony_ci    case 8:
247159b3361Sopenharmony_ci        return str64;
248159b3361Sopenharmony_ci
249159b3361Sopenharmony_ci    default:
250159b3361Sopenharmony_ci        return strXX;
251159b3361Sopenharmony_ci    }
252159b3361Sopenharmony_ci}
253159b3361Sopenharmony_ci
254159b3361Sopenharmony_ci/* end of version.c */
255