From aeffa4cb5bbb707d7d42eea6d2504a10ed0b798f Mon Sep 17 00:00:00 2001 From: Peter Rajnoha Date: Tue, 25 Jun 2013 12:31:36 +0200 Subject: [PATCH] config: add profile arg to find_config_tree_float --- lib/config/config.c | 14 ++++++++++++-- lib/config/config.h | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/config/config.c b/lib/config/config.c index f7194a7eb..28229f4dd 100644 --- a/lib/config/config.c +++ b/lib/config/config.c @@ -886,15 +886,25 @@ int64_t find_config_tree_int64(struct cmd_context *cmd, int id, struct profile * return i64; } -float find_config_tree_float(struct cmd_context *cmd, int id) +float find_config_tree_float(struct cmd_context *cmd, int id, struct profile *profile) { cfg_def_item_t *item = cfg_def_get_item_p(id); const char *path = cfg_def_get_path(item); + int profile_applied = 0; + float f; if (item->type != CFG_TYPE_FLOAT) log_error(INTERNAL_ERROR "%s cfg tree element not declared as float.", path); - return dm_config_tree_find_float(cmd->cft, path, cfg_def_get_default_value(item, CFG_TYPE_FLOAT)); + if (profile && !cmd->profile_params->global_profile) + profile_applied = override_config_tree_from_profile(cmd, profile); + + f = dm_config_tree_find_float(cmd->cft, path, cfg_def_get_default_value(item, CFG_TYPE_FLOAT)); + + if (profile_applied) + remove_config_tree_by_source(cmd, CONFIG_PROFILE); + + return f; } int find_config_tree_bool(struct cmd_context *cmd, int id) diff --git a/lib/config/config.h b/lib/config/config.h index cf94c035b..ece46133c 100644 --- a/lib/config/config.h +++ b/lib/config/config.h @@ -169,7 +169,7 @@ const char *find_config_tree_str(struct cmd_context *cmd, int id, struct profile const char *find_config_tree_str_allow_empty(struct cmd_context *cmd, int id, struct profile *profile); int find_config_tree_int(struct cmd_context *cmd, int id, struct profile *profile); int64_t find_config_tree_int64(struct cmd_context *cmd, int id, struct profile *profile); -float find_config_tree_float(struct cmd_context *cmd, int id); +float find_config_tree_float(struct cmd_context *cmd, int id, struct profile *profile); int find_config_tree_bool(struct cmd_context *cmd, int id); #endif