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 #ifdef HAVE_ERRNO_H
21 #include <errno.h>
22 #endif
23
24 #include <linux/ext2_fs.h>
25 #include "ext2fs.h"
26
27 #include "../../version.h"
28
29 static const char *lib_version = E2FSPROGS_VERSION;
30 static const char *lib_date = E2FSPROGS_DATE;
31
32 int ext2fs_parse_version_string(const char *ver_string)
33 {
34         const char *cp;
35         int version = 0;
36
37         for (cp = ver_string; *cp; cp++) {
38                 if (!isdigit(*cp))
39                         continue;
40                 version = (version * 10) + (*cp - '0');
41         }
42         return version;
43 }
44
45
46 int ext2fs_get_library_version(const char **ver_string,
47                                const char **date_string)
48 {
49         if (ver_string)
50                 *ver_string = lib_version;
51         if (date_string)
52                 *date_string = lib_date;
53
54         return ext2fs_parse_version_string(lib_version);
55 }