sf_version() return combined integer version

master
YuQing 2026-06-24 08:22:54 +08:00
parent eabc5d52ac
commit 01069c99ed
3 changed files with 14 additions and 6 deletions

View File

@ -1030,6 +1030,8 @@ void sf_global_config_to_string_ex(const char *max_pkg_size_item_nm,
int max_buff_size; int max_buff_size;
Version fc_ver; Version fc_ver;
Version sf_ver; Version sf_ver;
int fc_ver_int;
int sf_ver_int;
char pkg_buff[256]; char pkg_buff[256];
max_pkg_size = g_sf_global_vars.net_buffer_cfg.max_pkg_size - max_pkg_size = g_sf_global_vars.net_buffer_cfg.max_pkg_size -
@ -1049,17 +1051,19 @@ void sf_global_config_to_string_ex(const char *max_pkg_size_item_nm,
min_buff_size / 1024, max_buff_size / 1024); min_buff_size / 1024, max_buff_size / 1024);
} }
fc_version(&fc_ver); fc_ver_int = fc_version(&fc_ver);
sf_version(&sf_ver); sf_ver_int = sf_version(&sf_ver);
len = snprintf(output, size, "libfastcommon version " len = snprintf(output, size, "libfastcommon version "
"{compile: %d.%d.%d, runtime: %d.%d.%d}, " "{compile: %d.%d.%d %s runtime: %d.%d.%d}, "
"libserverframe version " "libserverframe version "
"{compile: %d.%d.%d, runtime: %d.%d.%d}, " "{compile: %d.%d.%d %s runtime: %d.%d.%d}, "
"base_path=%s, max_connections=%d, connect_timeout=%d, " "base_path=%s, max_connections=%d, connect_timeout=%d, "
"network_timeout=%d, thread_stack_size=%d KB, %s, ", "network_timeout=%d, thread_stack_size=%d KB, %s, ",
FC_MAJOR_VERSION, FC_MINOR_VERSION, FC_PATCH_VERSION, FC_MAJOR_VERSION, FC_MINOR_VERSION, FC_PATCH_VERSION,
FC_COMPARE_INT_VERSIONS_TO_OPERATOR_STR(FC_VERSION_INT, fc_ver_int),
fc_ver.major, fc_ver.minor, fc_ver.patch, fc_ver.major, fc_ver.minor, fc_ver.patch,
SF_MAJOR_VERSION, SF_MINOR_VERSION, SF_PATCH_VERSION, SF_MAJOR_VERSION, SF_MINOR_VERSION, SF_PATCH_VERSION,
FC_COMPARE_INT_VERSIONS_TO_OPERATOR_STR(SF_VERSION_INT, sf_ver_int),
sf_ver.major, sf_ver.minor, sf_ver.patch, sf_ver.major, sf_ver.minor, sf_ver.patch,
SF_G_BASE_PATH_STR, SF_G_BASE_PATH_STR,
g_sf_global_vars.net_buffer_cfg.max_connections, g_sf_global_vars.net_buffer_cfg.max_connections,

View File

@ -15,9 +15,10 @@
#include "sf_version.h" #include "sf_version.h"
void sf_version(Version *version) int sf_version(Version *version)
{ {
version->major = SF_MAJOR_VERSION; version->major = SF_MAJOR_VERSION;
version->minor = SF_MINOR_VERSION; version->minor = SF_MINOR_VERSION;
version->patch = SF_PATCH_VERSION; version->patch = SF_PATCH_VERSION;
return FC_VERSION_TO_INT1(*version);
} }

View File

@ -24,11 +24,14 @@
#define SF_MINOR_VERSION 2 #define SF_MINOR_VERSION 2
#define SF_PATCH_VERSION 13 #define SF_PATCH_VERSION 13
#define SF_VERSION_INT FC_VERSION_TO_INT(SF_MAJOR_VERSION, \
SF_MINOR_VERSION, SF_PATCH_VERSION)
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
void sf_version(Version *version); int sf_version(Version *version);
#ifdef __cplusplus #ifdef __cplusplus
} }