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