Whamcloud - gitweb
Many files:
[tools/e2fsprogs.git] / lib / ext2fs / version.c
1 /*
2  * version.c --- Return the version of the ext2 library
3  *
4  * Copyright (C) 1997 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 #include <et/com_err.h>
13 #if HAVE_UNISTD_H
14 #include <unistd.h>
15 #endif
16 #include <stdlib.h>
17 #include <string.h>
18 #include <stdio.h>
19 #include <ctype.h>
20
21 #include <linux/ext2_fs.h>
22 #include "ext2fs.h"
23
24 #include "../../version.h"
25
26 static const char *lib_version = E2FSPROGS_VERSION;
27 static const char *lib_date = E2FSPROGS_DATE;
28
29 int ext2fs_parse_version_string(const char *ver_string)
30 {
31         const char *cp;
32         int version = 0;
33
34         for (cp = ver_string; *cp; cp++) {
35                 if (!isdigit(*cp))
36                         continue;
37                 version = (version * 10) + (*cp - '0');
38         }
39         return version;
40 }
41
42
43 int ext2fs_get_library_version(const char **ver_string,
44                                const char **date_string)
45 {
46         if (ver_string)
47                 *ver_string = lib_version;
48         if (date_string)
49                 *date_string = lib_date;
50
51         return ext2fs_parse_version_string(lib_version);
52 }