]> git.ipfire.org Git - thirdparty/e2fsprogs.git/blob - lib/blkid/version.c
blkid: adjust copyright license for version.c to be LGPL
[thirdparty/e2fsprogs.git] / lib / blkid / version.c
1 /*
2 * version.c --- Return the version of the blkid library
3 *
4 * Copyright (C) 2004 Theodore Ts'o.
5 *
6 * %Begin-Header%
7 * This file may be redistributed under the terms of the
8 * GNU Lesser General Public License.
9 * %End-Header%
10 */
11
12 #include "config.h"
13 #if HAVE_UNISTD_H
14 #include <unistd.h>
15 #endif
16 #include <string.h>
17 #include <stdio.h>
18 #include <ctype.h>
19
20 #include <blkid/blkid.h>
21 #include "../../version.h"
22
23 static const char *lib_version = E2FSPROGS_VERSION;
24 static const char *lib_date = E2FSPROGS_DATE;
25
26 int blkid_parse_version_string(const char *ver_string)
27 {
28 const char *cp;
29 int version = 0;
30
31 for (cp = ver_string; *cp; cp++) {
32 if (*cp == '.')
33 continue;
34 if (!isdigit(*cp))
35 break;
36 version = (version * 10) + (*cp - '0');
37 }
38 return version;
39 }
40
41 int blkid_get_library_version(const char **ver_string,
42 const char **date_string)
43 {
44 if (ver_string)
45 *ver_string = lib_version;
46 if (date_string)
47 *date_string = lib_date;
48
49 return blkid_parse_version_string(lib_version);
50 }