From eb13fe4fcbe425559aac0bed96ad1a3b02d5fe3c Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sun, 21 Jan 2018 13:47:09 -0800 Subject: [PATCH] Allow retrieving PACKAGE_VERSION from the library Otherwise the output of 'wimlib-imagex --version' for beta versions would be confusing. --- include/wimlib.h | 10 ++++++++++ programs/imagex.c | 12 ++++-------- src/wim.c | 6 ++++++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/include/wimlib.h b/include/wimlib.h index 9966b524..047716c0 100644 --- a/include/wimlib.h +++ b/include/wimlib.h @@ -3273,6 +3273,16 @@ wimlib_get_image_property(const WIMStruct *wim, int image, extern uint32_t wimlib_get_version(void); +/** + * @ingroup G_general + * + * Since wimlib v1.13.0: like wimlib_get_version(), but returns the full + * PACKAGE_VERSION string that was set at build time. (This allows a beta + * release to be distinguished from an official release.) + */ +extern const wimlib_tchar * +wimlib_get_version_string(void); + /** * @ingroup G_wim_information * diff --git a/programs/imagex.c b/programs/imagex.c index 28f02663..10f54556 100644 --- a/programs/imagex.c +++ b/programs/imagex.c @@ -6,7 +6,7 @@ */ /* - * Copyright (C) 2012-2017 Eric Biggers + * Copyright (C) 2012-2018 Eric Biggers * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -4520,23 +4520,19 @@ static const tchar *get_cmd_string(int cmd, bool only_short_form) static void version(void) { - uint32_t vers = wimlib_get_version(); - static const tchar * const fmt = T( -"wimlib-imagex " PACKAGE_VERSION " (using wimlib %u.%u.%u)\n" -"Copyright (C) 2012-2017 Eric Biggers\n" +"wimlib-imagex " PACKAGE_VERSION " (using wimlib %"TS")\n" +"Copyright (C) 2012-2018 Eric Biggers\n" "License GPLv3+; GNU GPL version 3 or later .\n" "This is free software: you are free to change and redistribute it.\n" "There is NO WARRANTY, to the extent permitted by law.\n" "\n" "Report bugs to "PACKAGE_BUGREPORT".\n" ); - tfprintf(stdout, fmt, - vers >> 20, (vers >> 10) & 0x3ff, vers & 0x3ff); + tfprintf(stdout, fmt, wimlib_get_version_string()); } - static void do_common_options(int *argc_p, tchar **argv, int cmd) { diff --git a/src/wim.c b/src/wim.c index ec345a93..ca40e53a 100644 --- a/src/wim.c +++ b/src/wim.c @@ -935,6 +935,12 @@ wimlib_get_version(void) WIMLIB_PATCH_VERSION; } +WIMLIBAPI const tchar * +wimlib_get_version_string(void) +{ + return T(PACKAGE_VERSION); +} + static bool lib_initialized = false; static pthread_mutex_t lib_initialization_mutex = PTHREAD_MUTEX_INITIALIZER; -- 2.43.0