From f95716e01e9237f722b52edfff5638755ace3007 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Thu, 16 Jan 2014 21:19:05 -0600 Subject: [PATCH] Add wimlib_get_version() This allows an application to query the version number at runtime. --- include/wimlib.h | 13 +++++++++++++ src/wim.c | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/include/wimlib.h b/include/wimlib.h index 5b164b6d..d039895e 100644 --- a/include/wimlib.h +++ b/include/wimlib.h @@ -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); +/** + * @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 ((WIMLIB_MAJOR_VERSION + * << 22) | (WIMLIB_MINOR_VERSION << 10) | WIMLIB_PATCH_VERSION) for the + * corresponding header file. + */ +extern uint32_t +wimlib_get_version(void); /** * @ingroup G_wim_information diff --git a/src/wim.c b/src/wim.c index febc68aa..292f4cd7 100644 --- 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/version.h" #ifdef __WIN32__ # include "wimlib/win32.h" /* for realpath() replacement */ @@ -977,6 +978,13 @@ test_locale_ctype_utf8(void) #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) -- 2.43.0