add function sf_load_cluster_config1

vote_node
YuQing 2022-05-06 15:12:19 +08:00
parent 07bbf65847
commit 00faf7e637
2 changed files with 31 additions and 11 deletions

View File

@ -116,19 +116,19 @@ int sf_load_cluster_config_by_file(SFClusterConfig *cluster,
return 0;
}
int sf_load_cluster_config_ex(SFClusterConfig *cluster, IniFullContext
*ini_ctx, const int default_port, char *full_cluster_filename,
const int size)
int sf_load_cluster_config_ex1(SFClusterConfig *cluster,
IniFullContext *ini_ctx, const char *cluster_config_item_name,
const int default_port, char *full_cluster_filename, const int size)
{
const bool share_between_groups = true;
char *cluster_config_filename;
cluster_config_filename = iniGetStrValue(ini_ctx->section_name,
"cluster_config_filename", ini_ctx->context);
cluster_config_item_name, ini_ctx->context);
if (cluster_config_filename == NULL || *cluster_config_filename == '\0') {
logError("file: "__FILE__", line: %d, "
"config file: %s, item \"cluster_config_filename\" "
"not exist or empty", __LINE__, ini_ctx->filename);
"config file: %s, item \"%s\" not exist or empty",
__LINE__, cluster_config_item_name, ini_ctx->filename);
return ENOENT;
}

View File

@ -23,9 +23,29 @@
extern "C" {
#endif
int sf_load_cluster_config_ex(SFClusterConfig *cluster, IniFullContext
*ini_ctx, const int default_port, char *full_cluster_filename,
const int size);
int sf_load_cluster_config_ex1(SFClusterConfig *cluster,
IniFullContext *ini_ctx, const char *cluster_config_item_name,
const int default_port, char *full_cluster_filename, const int size);
static inline int sf_load_cluster_config_ex(SFClusterConfig *cluster,
IniFullContext *ini_ctx, const int default_port,
char *full_cluster_filename, const int size)
{
const char *cluster_config_item_name = "cluster_config_filename";
return sf_load_cluster_config_ex1(cluster, ini_ctx,
cluster_config_item_name, default_port,
full_cluster_filename, PATH_MAX);
}
static inline int sf_load_cluster_config1(SFClusterConfig *cluster,
IniFullContext *ini_ctx, const char *cluster_config_item_name,
const int default_port)
{
char full_cluster_filename[PATH_MAX];
return sf_load_cluster_config_ex1(cluster, ini_ctx,
cluster_config_item_name, default_port,
full_cluster_filename, PATH_MAX);
}
static inline int sf_load_cluster_config(SFClusterConfig *cluster,
IniFullContext *ini_ctx, const int default_port)