blob: ea30d0c9fdd46b863977c902bb75609a425a4e04 [file] [log] [blame]
Mike Frysinger38a33f92005-05-09 22:13:22 +00001/*
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"
Mike Frysinger38a33f92005-05-09 22:13:22 +000020
21static const char *lib_version = E2FSPROGS_VERSION;
22static const char *lib_date = E2FSPROGS_DATE;
23
24int blkid_parse_version_string(const char *ver_string)
25{
26 const char *cp;
27 int version = 0;
28
29 for (cp = ver_string; *cp; cp++) {
30 if (*cp == '.')
31 continue;
32 if (!isdigit(*cp))
33 break;
34 version = (version * 10) + (*cp - '0');
35 }
36 return version;
37}
38
39int blkid_get_library_version(const char **ver_string,
40 const char **date_string)
41{
42 if (ver_string)
43 *ver_string = lib_version;
44 if (date_string)
45 *date_string = lib_date;
46
47 return blkid_parse_version_string(lib_version);
48}