From fd3994922cf234a59a83500933a0ac8f132c308d Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Fri, 28 Aug 2015 15:43:45 +0200 Subject: [PATCH] lib-settings: Added settings_var_expand_with_funcs() --- src/lib-settings/settings-parser.c | 25 +++++++++++++++++++------ src/lib-settings/settings-parser.h | 6 ++++++ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/lib-settings/settings-parser.c b/src/lib-settings/settings-parser.c index dc48739e52..6c3e9d5234 100644 --- a/src/lib-settings/settings-parser.c +++ b/src/lib-settings/settings-parser.c @@ -1211,7 +1211,9 @@ void settings_parse_set_keys_expandeded(struct setting_parser_context *ctx, static void ATTR_NULL(3, 4, 5) settings_var_expand_info(const struct setting_parser_info *info, void *set, pool_t pool, - const struct var_expand_table *table, string_t *str) + const struct var_expand_table *table, + const struct var_expand_func_table *func_table, + void *func_context, string_t *str) { const struct setting_define *def; void *value, *const *children; @@ -1242,7 +1244,8 @@ settings_var_expand_info(const struct setting_parser_info *info, void *set, *val += 1; } else if (**val == SETTING_STRVAR_UNEXPANDED[0]) { str_truncate(str, 0); - var_expand(str, *val + 1, table); + var_expand_with_funcs(str, *val + 1, table, + func_table, func_context); *val = p_strdup(pool, str_c(str)); } else { i_assert(**val == SETTING_STRVAR_EXPANDED[0]); @@ -1260,8 +1263,8 @@ settings_var_expand_info(const struct setting_parser_info *info, void *set, children = array_get(val, &count); for (i = 0; i < count; i++) { settings_var_expand_info(def->list_info, - children[i], pool, - table, str); + children[i], pool, table, func_table, + func_context, str); } break; } @@ -1272,12 +1275,22 @@ settings_var_expand_info(const struct setting_parser_info *info, void *set, void settings_var_expand(const struct setting_parser_info *info, void *set, pool_t pool, const struct var_expand_table *table) +{ + return settings_var_expand_with_funcs(info, set, pool, table, NULL, NULL); +} + +void settings_var_expand_with_funcs(const struct setting_parser_info *info, + void *set, pool_t pool, + const struct var_expand_table *table, + const struct var_expand_func_table *func_table, + void *func_context) { string_t *str; T_BEGIN { str = t_str_new(256); - settings_var_expand_info(info, set, pool, table, str); + settings_var_expand_info(info, set, pool, table, + func_table, func_context, str); } T_END; } @@ -1288,7 +1301,7 @@ void settings_parse_var_skip(struct setting_parser_context *ctx) for (i = 0; i < ctx->root_count; i++) { settings_var_expand_info(ctx->roots[i].info, ctx->roots[i].set_struct, - NULL, NULL, NULL); + NULL, NULL, NULL, NULL, NULL); } } diff --git a/src/lib-settings/settings-parser.h b/src/lib-settings/settings-parser.h index 6210c2566c..90b81581cd 100644 --- a/src/lib-settings/settings-parser.h +++ b/src/lib-settings/settings-parser.h @@ -2,6 +2,7 @@ #define SETTINGS_PARSER_H struct var_expand_table; +struct var_expand_func_table; #define SETTINGS_SEPARATOR '/' #define SETTINGS_SEPARATOR_S "/" @@ -178,6 +179,11 @@ void settings_parse_var_skip(struct setting_parser_context *ctx); void settings_var_expand(const struct setting_parser_info *info, void *set, pool_t pool, const struct var_expand_table *table); +void settings_var_expand_with_funcs(const struct setting_parser_info *info, + void *set, pool_t pool, + const struct var_expand_table *table, + const struct var_expand_func_table *func_table, + void *func_context); /* Go through all the settings and return the first one that has an unexpanded setting containing the given %key. */ bool settings_vars_have_key(const struct setting_parser_info *info, void *set, -- 2.47.3