From f4ab4ae8eb49b99e61f9f8ba59de7195342a8a02 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 26 Nov 2009 17:27:13 +0100 Subject: [PATCH] libmount: add version.c Signed-off-by: Karel Zak --- configure.ac | 1 + shlibs/mount/src/Makefile.am | 3 ++- shlibs/mount/src/mount.h.in | 4 +++ shlibs/mount/src/mount.sym | 3 ++- shlibs/mount/src/mountP.h | 21 +++++++++++++++ shlibs/mount/src/version.c | 52 ++++++++++++++++++++++++++++++++++++ 6 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 shlibs/mount/src/mountP.h create mode 100644 shlibs/mount/src/version.c diff --git a/configure.ac b/configure.ac index 286703b5..af92980e 100644 --- a/configure.ac +++ b/configure.ac @@ -404,6 +404,7 @@ AC_ARG_ENABLE([libmount], ) AC_SUBST([LIBMOUNT_VERSION]) AC_SUBST([LIBMOUNT_VERSION_INFO]) +AC_DEFINE_UNQUOTED(LIBMOUNT_VERSION, "$LIBMOUNT_VERSION", [libmount version string]) AM_CONDITIONAL(BUILD_LIBMOUNT, test "x$enable_libmount" = xyes) diff --git a/shlibs/mount/src/Makefile.am b/shlibs/mount/src/Makefile.am index 5d6c32df..7b3aaaf0 100644 --- a/shlibs/mount/src/Makefile.am +++ b/shlibs/mount/src/Makefile.am @@ -11,7 +11,8 @@ nodist_mountinc_HEADERS = mount.h usrlib_exec_LTLIBRARIES = libmount.la libmount_la_SOURCES = $(mountinc_HEADERS) -nodist_libmount_la_SOURCES = mount.h +nodist_libmount_la_SOURCES = mount.h \ + version.c libmount_la_LIBADD = $(ul_libblkid_la) diff --git a/shlibs/mount/src/mount.h.in b/shlibs/mount/src/mount.h.in index e9b0425c..9767a0a9 100644 --- a/shlibs/mount/src/mount.h.in +++ b/shlibs/mount/src/mount.h.in @@ -27,6 +27,10 @@ extern "C" { #define LIBMOUNT_VERSION "@LIBMOUNT_VERSION@" +/* version.c */ +extern int mnt_parse_version_string(const char *ver_string); +extern int mnt_get_library_version(const char **ver_string); + #ifdef __cplusplus } #endif diff --git a/shlibs/mount/src/mount.sym b/shlibs/mount/src/mount.sym index 5922560b..cf6907a9 100644 --- a/shlibs/mount/src/mount.sym +++ b/shlibs/mount/src/mount.sym @@ -5,7 +5,8 @@ */ MOUNT_2.18 { global: - dummy; + mnt_get_library_version; + mnt_parse_version_string; local: *; }; diff --git a/shlibs/mount/src/mountP.h b/shlibs/mount/src/mountP.h new file mode 100644 index 00000000..2a486f02 --- /dev/null +++ b/shlibs/mount/src/mountP.h @@ -0,0 +1,21 @@ +/* + * mountP.h - private library header file + * + * Copyright (C) 2008-2009 Karel Zak + * + * This file may be redistributed under the terms of the + * GNU Lesser General Public License. + */ + +#ifndef _LIBMOUNT_PRIVATE_H +#define _LIBMOUNT_PRIVATE_H + +/* features */ +#define CONFIG_LIBMOUNT_ASSERT + +#ifdef CONFIG_LIBMOUNT_ASSERT +#include +#endif + +#include "mount.h" +#endif diff --git a/shlibs/mount/src/version.c b/shlibs/mount/src/version.c new file mode 100644 index 00000000..8fd38a3c --- /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 + * [Based on libblkid/version.c by Theodore Ts'o] + * + * See COPYING.libmount for the License of this software. + */ + +#include +#include +#include +#include + +#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); +} -- 2.39.5