blob: 9d129f7aecef73934bb4872f7e939361383a2a43 [file] [log] [blame]
bigbiff bigbiffe60683a2013-02-22 20:55:50 -05001/*
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
bigbiff7b4c7a62015-01-01 19:44:14 -050019#include <blkid.h>
bigbiff bigbiffe60683a2013-02-22 20:55:50 -050020
21/* LIBBLKID_* defined in the global config.h */
22static const char *lib_version = LIBBLKID_VERSION; /* release version */
23static 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 */
31int 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 relese version (!= SONAME version)
49 * @date_string: returns date
50 *
51 * Returns: release version code.
52 */
53int 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}