]> git.ipfire.org Git - thirdparty/util-linux.git/blob - libblkid/src/version.c
Merge branch 'eject-sparc' of https://github.com/mator/util-linux
[thirdparty/util-linux.git] / libblkid / src / 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 GNU Lesser General
8 * Public License.
9 * %End-Header%
10 */
11
12 #ifdef HAVE_UNISTD_H
13 #include <unistd.h>
14 #endif
15 #include <string.h>
16 #include <stdio.h>
17 #include <ctype.h>
18
19 #include "blkid.h"
20
21 /* LIBBLKID_* defined in the global config.h */
22 static const char *lib_version = LIBBLKID_VERSION; /* release version */
23 static const char *lib_date = LIBBLKID_DATE;
24
25 /**
26 * blkid_parse_version_string:
27 * @ver_string: version string (e.g. "2.16.0")
28 *
29 * Returns: release version code.
30 */
31 int blkid_parse_version_string(const char *ver_string)
32 {
33 const char *cp;
34 int version = 0;
35
36 for (cp = ver_string; *cp; cp++) {
37 if (*cp == '.')
38 continue;
39 if (!isdigit(*cp))
40 break;
41 version = (version * 10) + (*cp - '0');
42 }
43 return version;
44 }
45
46 /**
47 * blkid_get_library_version:
48 * @ver_string: returns release version (!= SONAME version)
49 * @date_string: returns date
50 *
51 * Returns: release version code.
52 */
53 int blkid_get_library_version(const char **ver_string,
54 const char **date_string)
55 {
56 if (ver_string)
57 *ver_string = lib_version;
58 if (date_string)
59 *date_string = lib_date;
60
61 return blkid_parse_version_string(lib_version);
62 }