function sf_get_base_path_from_conf_file impl.
parent
f63843765a
commit
3257a5f842
|
|
@ -28,6 +28,7 @@
|
|||
#include <pwd.h>
|
||||
#include "fastcommon/common_define.h"
|
||||
#include "fastcommon/shared_func.h"
|
||||
#include "fastcommon/process_ctrl.h"
|
||||
#include "fastcommon/logger.h"
|
||||
#include "sf_nio.h"
|
||||
#include "sf_global.h"
|
||||
|
|
@ -219,13 +220,30 @@ int sf_load_slow_log_config_ex(IniFullContext *ini_ctx, LogContext *log_ctx,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int sf_get_base_path_from_conf_file(const char *config_filename)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (SF_G_BASE_PATH_INITED) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = get_base_path_from_conf_file(config_filename,
|
||||
SF_G_BASE_PATH_STR, sizeof(SF_G_BASE_PATH_STR));
|
||||
if (result == 0) {
|
||||
SF_G_BASE_PATH_INITED = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int sf_load_global_base_path(IniFullContext *ini_ctx)
|
||||
{
|
||||
char *pBasePath;
|
||||
|
||||
if (!g_sf_global_vars.base_path.inited) {
|
||||
if (!SF_G_BASE_PATH_INITED) {
|
||||
pBasePath = iniGetStrValue(NULL, "base_path", ini_ctx->context);
|
||||
if (pBasePath == NULL) {
|
||||
if (pBasePath == NULL || *pBasePath == '\0') {
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"conf file \"%s\" must have item "
|
||||
"\"base_path\"!", __LINE__, ini_ctx->filename);
|
||||
|
|
|
|||
|
|
@ -205,12 +205,13 @@ 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)
|
||||
|
||||
int sf_get_base_path_from_conf_file(const char *config_filename);
|
||||
int sf_load_global_base_path(IniFullContext *ini_ctx);
|
||||
|
||||
static inline void sf_set_global_base_path(const char *base_path)
|
||||
{
|
||||
snprintf(SF_G_BASE_PATH_STR, sizeof(SF_G_BASE_PATH_STR),
|
||||
"%s", base_path);
|
||||
normalize_path(NULL, base_path, SF_G_BASE_PATH_STR,
|
||||
sizeof(SF_G_BASE_PATH_STR));
|
||||
SF_G_BASE_PATH_INITED = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue