]> wimlib.net Git - wimlib/commitdiff
Add wimlib_get_version()
authorEric Biggers <ebiggers3@gmail.com>
Fri, 17 Jan 2014 03:19:05 +0000 (21:19 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Fri, 17 Jan 2014 03:19:05 +0000 (21:19 -0600)
This allows an application to query the version number at runtime.

include/wimlib.h
src/wim.c

index 5b164b6d6364577865cfcfdd47e9545e7c77d707..d039895e6439e3d4439683c7a6c779f8181d7e5c 100644 (file)
@@ -2677,6 +2677,19 @@ wimlib_get_image_description(const WIMStruct *wim, int image);
 extern const wimlib_tchar *
 wimlib_get_image_name(const WIMStruct *wim, int image);
 
 extern const wimlib_tchar *
 wimlib_get_image_name(const WIMStruct *wim, int image);
 
+/**
+ * @ingroup G_general
+ *
+ * Returns the version of wimlib as a 32-bit number whose top 12 bits contain
+ * the major version, the next 10 bits contain the minor version, and the low 10
+ * bits contain the patch version.
+ *
+ * In other words, the returned value is equal to <code>((WIMLIB_MAJOR_VERSION
+ * << 22) | (WIMLIB_MINOR_VERSION << 10) | WIMLIB_PATCH_VERSION)</code> for the
+ * corresponding header file.
+ */
+extern uint32_t
+wimlib_get_version(void);
 
 /**
  * @ingroup G_wim_information
 
 /**
  * @ingroup G_wim_information
index febc68aac69bfd122dc55084ab173c1ebfc201e8..292f4cd7b92622c8e2583c2389ed2d956d1c8799 100644 (file)
--- a/src/wim.c
+++ b/src/wim.c
@@ -40,6 +40,7 @@
 #include "wimlib/xml.h"
 #include "wimlib/compressor_ops.h"
 #include "wimlib/decompressor_ops.h"
 #include "wimlib/xml.h"
 #include "wimlib/compressor_ops.h"
 #include "wimlib/decompressor_ops.h"
+#include "wimlib/version.h"
 
 #ifdef __WIN32__
 #  include "wimlib/win32.h" /* for realpath() replacement */
 
 #ifdef __WIN32__
 #  include "wimlib/win32.h" /* for realpath() replacement */
@@ -977,6 +978,13 @@ test_locale_ctype_utf8(void)
 #endif
 }
 
 #endif
 }
 
+/* API function documented in wimlib.h  */
+WIMLIBAPI u32
+wimlib_get_version(void)
+{
+       return WIMLIB_VERSION_CODE;
+}
+
 /* API function documented in wimlib.h  */
 WIMLIBAPI int
 wimlib_global_init(int init_flags)
 /* API function documented in wimlib.h  */
 WIMLIBAPI int
 wimlib_global_init(int init_flags)