blob: df7236e130e73b4866627c30262de649df12741f [file] [log] [blame]
Theodore Ts'o521e3681997-04-29 17:48:10 +00001/*
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#include <unistd.h>
14#include <stdlib.h>
15#include <string.h>
16#include <stdio.h>
17#include <ctype.h>
18#ifdef HAVE_ERRNO_H
19#include <errno.h>
20#endif
21
22#include <linux/ext2_fs.h>
23#include "ext2fs.h"
24
25#include "../../version.h"
26
27static const char *lib_version = E2FSPROGS_VERSION;
28static const char *lib_date = E2FSPROGS_DATE;
29
30int ext2fs_parse_version_string(const char *ver_string)
31{
32 const char *cp;
33 int version = 0;
34
35 for (cp = lib_version; *cp; cp++) {
36 if (!isdigit(*cp))
37 continue;
38 version = (version * 10) + (*cp - '0');
39 }
40 return version;
41}
42
43
44int ext2fs_get_library_version(const char **ver_string,
45 const char **date_string)
46{
47 if (ver_string)
48 *ver_string = lib_version;
49 if (date_string)
50 *date_string = lib_date;
51
52 return ext2fs_parse_version_string(lib_version);
53}