src/api/: Use intended license header
[libquvi.git] / src / api / version.c
blobbe2e267079d207245aee2e320fad30bba71ce56b
1 /* libquvi
2 * Copyright (C) 2012 Toni Gundogdu <legatvs@gmail.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301 USA
20 /** @file version.c */
22 #include "config.h"
24 #include <string.h>
25 #include <glib.h>
27 #include "quvi.h"
28 /* -- */
29 #include "_quvi_s.h"
31 static const gchar *_version[] =
33 #ifdef VN
35 #else
36 PACKAGE_VERSION
37 #endif
39 CANONICAL_TARGET,
40 BUILD_TIME
43 static gchar version_scripts[32];
45 static gchar *read_scripts_version()
47 gchar *c = NULL;
49 if (g_file_get_contents(VERSIONFILE, &c, NULL, NULL) == TRUE)
51 gchar *s;
53 s = g_strescape(g_strstrip(c), NULL);
54 g_snprintf(version_scripts, sizeof(version_scripts), "%s", s);
56 g_free(s);
57 s = NULL;
59 g_free(c);
60 c = NULL;
62 else
63 version_scripts[0] = '\0';
65 return ((gchar*) version_scripts);
68 /** @return NULL-terminated version string
69 @note Do not attempt to free the returned string
70 @ingroup convenience
72 const char *quvi_version(QuviVersion version)
74 switch (version)
76 case QUVI_VERSION_SCRIPTS:
77 return (read_scripts_version());
78 case QUVI_VERSION_BUILD_TARGET:
79 return ((gchar*) _version[QUVI_VERSION_BUILD_TARGET]);
80 case QUVI_VERSION_BUILD_TIME:
81 return ((gchar*) _version[QUVI_VERSION_BUILD_TIME]);
82 default:
83 break;
85 return (_version[QUVI_VERSION]);
88 /* vim: set ts=2 sw=2 tw=72 expandtab: */