From 5befb9d61660ef32211dae5c9f39ee9865b84763 Mon Sep 17 00:00:00 2001 From: YuQing <384681@qq.com> Date: Tue, 25 May 2021 18:48:33 +0800 Subject: [PATCH] add function sf_set_global_base_path --- src/sf_global.c | 3 +-- src/sf_global.h | 6 ++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/sf_global.c b/src/sf_global.c index ff0c05d..65b643b 100644 --- a/src/sf_global.c +++ b/src/sf_global.c @@ -236,8 +236,7 @@ int sf_load_global_config_ex(const char *server_name, "\"base_path\"!", __LINE__, ini_ctx->filename); return ENOENT; } - snprintf(SF_G_BASE_PATH, sizeof(SF_G_BASE_PATH), "%s", pBasePath); - g_sf_global_vars.base_path.inited = true; + sf_set_global_base_path(pBasePath); } chopPath(SF_G_BASE_PATH); diff --git a/src/sf_global.h b/src/sf_global.h index 0fc0d8a..d372aa9 100644 --- a/src/sf_global.h +++ b/src/sf_global.h @@ -199,6 +199,12 @@ void sf_log_config_ex(const char *other_config); #define sf_log_config_to_string(log_cfg, caption, output, size) \ sf_log_config_to_string_ex(log_cfg, caption, NULL, output, size) +static inline void sf_set_global_base_path(const char *base_path) +{ + snprintf(SF_G_BASE_PATH, sizeof(SF_G_BASE_PATH), "%s", base_path); + g_sf_global_vars.base_path.inited = true; +} + #ifdef __cplusplus } #endif