Upload Tizen:Base source
[framework/base/util-linux-ng.git] / shlibs / blkid / 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 Public
8  * License.
9  * %End-Header%
10  */
11
12 #if 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 int blkid_parse_version_string(const char *ver_string)
26 {
27         const char *cp;
28         int version = 0;
29
30         for (cp = ver_string; *cp; cp++) {
31                 if (*cp == '.')
32                         continue;
33                 if (!isdigit(*cp))
34                         break;
35                 version = (version * 10) + (*cp - '0');
36         }
37         return version;
38 }
39
40 /**
41  * blkid_get_library_version:
42  * @ver_string: returns relese version (!= SONAME version)
43  * @date_string: returns date
44  *
45  * Returns release version code.
46  */
47 int blkid_get_library_version(const char **ver_string,
48                                const char **date_string)
49 {
50         if (ver_string)
51                 *ver_string = lib_version;
52         if (date_string)
53                 *date_string = lib_date;
54
55         return blkid_parse_version_string(lib_version);
56 }