summaryrefslogtreecommitdiffstats
path: root/libsmartcols/src/version.c
diff options
context:
space:
mode:
authorKarel Zak2014-04-07 13:43:50 +0200
committerKarel Zak2014-04-07 13:43:50 +0200
commit4418714f471c9ce5a0054d2c7c51cd6d7ab85fef (patch)
tree771420c820cfef33bbd8125ec94815549271dae2 /libsmartcols/src/version.c
parentlibblkid: remove private function from docs (diff)
downloadkernel-qcow2-util-linux-4418714f471c9ce5a0054d2c7c51cd6d7ab85fef.tar.gz
kernel-qcow2-util-linux-4418714f471c9ce5a0054d2c7c51cd6d7ab85fef.tar.xz
kernel-qcow2-util-linux-4418714f471c9ce5a0054d2c7c51cd6d7ab85fef.zip
libsmartcols: add debug and version functions
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libsmartcols/src/version.c')
-rw-r--r--libsmartcols/src/version.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/libsmartcols/src/version.c b/libsmartcols/src/version.c
new file mode 100644
index 000000000..76ba3ec2c
--- /dev/null
+++ b/libsmartcols/src/version.c
@@ -0,0 +1,62 @@
+/*
+ * version.c - Return the version of the library
+ *
+ * Copyright (C) 2014 Karel Zak <kzak@redhat.com>
+ *
+ * See COPYING.libmount for the License of this software.
+ */
+
+/**
+ * SECTION: version
+ * @title: Version functions
+ * @short_description: functions to get the library version.
+ *
+ * Note that library version is not the same thing as SONAME verison. The
+ * libsmarcols uses symbols versioning and SONAME is not modified for releases.
+ *
+ * The library version and symbols version follow util-linux package versioning.
+ */
+
+#include <ctype.h>
+
+#include "smartcolsP.h"
+
+static const char *lib_version = LIBSMARTCOLS_VERSION;
+
+/**
+ * scols_parse_version_string:
+ * @ver_string: version string (e.g "2.18.0")
+ *
+ * Returns: release version code.
+ */
+int scols_parse_version_string(const char *ver_string)
+{
+ const char *cp;
+ int version = 0;
+
+ assert(ver_string);
+
+ for (cp = ver_string; *cp; cp++) {
+ if (*cp == '.')
+ continue;
+ if (!isdigit(*cp))
+ break;
+ version = (version * 10) + (*cp - '0');
+ }
+ return version;
+}
+
+/**
+ * scols_get_library_version:
+ * @ver_string: return pointer to the static library version string if not NULL
+ *
+ * Returns: release version number.
+ */
+int scols_get_library_version(const char **ver_string)
+{
+ if (ver_string)
+ *ver_string = lib_version;
+
+ return scols_parse_version_string(lib_version);
+}
+