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