diff options
author | Karel Zak | 2009-11-26 17:27:13 +0100 |
---|---|---|
committer | Karel Zak | 2010-06-03 15:20:10 +0200 |
commit | f4ab4ae8eb49b99e61f9f8ba59de7195342a8a02 (patch) | |
tree | 604a55fbac5917dbaadcae5ad1cc5e1ec22e1682 /shlibs/mount/src/version.c | |
parent | libmount: add basic dirs (diff) | |
download | kernel-qcow2-util-linux-f4ab4ae8eb49b99e61f9f8ba59de7195342a8a02.tar.gz kernel-qcow2-util-linux-f4ab4ae8eb49b99e61f9f8ba59de7195342a8a02.tar.xz kernel-qcow2-util-linux-f4ab4ae8eb49b99e61f9f8ba59de7195342a8a02.zip |
libmount: add version.c
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/mount/src/version.c')
-rw-r--r-- | shlibs/mount/src/version.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/shlibs/mount/src/version.c b/shlibs/mount/src/version.c new file mode 100644 index 000000000..8fd38a3c5 --- /dev/null +++ b/shlibs/mount/src/version.c @@ -0,0 +1,52 @@ +/* + * version.c - Return the version of the blkid library + * + * Copyright (C) 2008 Karel Zak <kzak@redhat.com> + * [Based on libblkid/version.c by Theodore Ts'o] + * + * See COPYING.libmount for the License of this software. + */ + +#include <unistd.h> +#include <string.h> +#include <stdio.h> +#include <ctype.h> + +#include "mountP.h" + +static const char *lib_version = LIBMOUNT_VERSION; + +/** + * mnt_parse_version_string: + * @ver_string: version string (e.g "2.18.0") + * + * Returns: release version code. + */ +int mnt_parse_version_string(const char *ver_string) +{ + const char *cp; + int version = 0; + + for (cp = ver_string; *cp; cp++) { + if (*cp == '.') + continue; + if (!isdigit(*cp)) + break; + version = (version * 10) + (*cp - '0'); + } + return version; +} + +/** + * mnt_get_library_version: + * @ver_string: return pointer to the static library version string + * + * Returns: release version number. + */ +int mnt_get_library_version(const char **ver_string) +{ + if (ver_string) + *ver_string = lib_version; + + return mnt_parse_version_string(lib_version); +} |