]> err.no Git - util-linux/commitdiff
libmount: add version.c
authorKarel Zak <kzak@redhat.com>
Thu, 26 Nov 2009 16:27:13 +0000 (17:27 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 3 Jun 2010 13:20:10 +0000 (15:20 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
configure.ac
shlibs/mount/src/Makefile.am
shlibs/mount/src/mount.h.in
shlibs/mount/src/mount.sym
shlibs/mount/src/mountP.h [new file with mode: 0644]
shlibs/mount/src/version.c [new file with mode: 0644]

index 286703b5eedb97c42041de89f82a8a72161d17fa..af92980ecae2d91adfb674d850c9947074d5efae 100644 (file)
@@ -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)
 
 
index 5d6c32df1611f23a41ac7127bdd29b1b9c605d43..7b3aaaf09901b0ab007eb827bf62cd7f4465506d 100644 (file)
@@ -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)
 
index e9b0425c1d82ecfe087d9fbab86d338c1e2e6c84..9767a0a9887595412ab78eb078590afc4f0d6420 100644 (file)
@@ -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
index 5922560b172079d6da2990a6c14d6367fd228fc4..cf6907a9823553318f7656dc2439ebb017c22c70 100644 (file)
@@ -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 (file)
index 0000000..2a486f0
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * mountP.h - private library header file
+ *
+ * Copyright (C) 2008-2009 Karel Zak <kzak@redhat.com>
+ *
+ * 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 <assert.h>
+#endif
+
+#include "mount.h"
+#endif
diff --git a/shlibs/mount/src/version.c b/shlibs/mount/src/version.c
new file mode 100644 (file)
index 0000000..8fd38a3
--- /dev/null
@@ -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);
+}