]>
Commit | Line | Data |
---|---|---|
32923fa4 TT |
1 | /* |
2 | * version.c --- Return the version of the blkid library | |
3 | * | |
4 | * Copyright (C) 2004 Theodore Ts'o. | |
5 | * | |
6 | * %Begin-Header% | |
711da486 TT |
7 | * This file may be redistributed under the terms of the |
8 | * GNU Lesser General Public License. | |
32923fa4 TT |
9 | * %End-Header% |
10 | */ | |
11 | ||
d1154eb4 | 12 | #include "config.h" |
32923fa4 TT |
13 | #if HAVE_UNISTD_H |
14 | #include <unistd.h> | |
15 | #endif | |
16 | #include <string.h> | |
17 | #include <stdio.h> | |
18 | #include <ctype.h> | |
19 | ||
e1f08507 | 20 | #include <blkid/blkid.h> |
32923fa4 TT |
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 | } |