dovecot-2.0: config: When reporting errors in variable-strings, ...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Sep 9 01:45:33 EEST 2009
details: http://hg.dovecot.org/dovecot-2.0/rev/5f61efdc9f35
changeset: 9910:5f61efdc9f35
user: Timo Sirainen <tss at iki.fi>
date: Tue Sep 08 18:45:27 2009 -0400
description:
config: When reporting errors in variable-strings, skip over the "0" prefix.
diffstat:
4 files changed, 47 insertions(+), 27 deletions(-)
src/config/config-parser.c | 1
src/config/config-request.c | 1
src/lib-settings/settings-parser.c | 68 +++++++++++++++++++++---------------
src/lib-settings/settings-parser.h | 4 ++
diffs (128 lines):
diff -r 6d3732cf8b3c -r 5f61efdc9f35 src/config/config-parser.c
--- a/src/config/config-parser.c Tue Sep 08 18:16:27 2009 -0400
+++ b/src/config/config-parser.c Tue Sep 08 18:45:27 2009 -0400
@@ -261,6 +261,7 @@ config_filter_parser_check(struct parser
const char **error_r)
{
for (; p->module_name != NULL; p++) {
+ settings_parse_var_skip(p->parser);
if (!settings_parser_check(p->parser, ctx->pool, error_r))
return -1;
}
diff -r 6d3732cf8b3c -r 5f61efdc9f35 src/config/config-request.c
--- a/src/config/config-request.c Tue Sep 08 18:16:27 2009 -0400
+++ b/src/config/config-request.c Tue Sep 08 18:45:27 2009 -0400
@@ -271,6 +271,7 @@ int config_request_handle(const struct c
settings_parser_get_changes(parser->parser));
if (check_settings) {
+ settings_parse_var_skip(parser->parser);
if (!settings_parser_check(parser->parser, ctx.pool,
&error)) {
i_error("%s", error);
diff -r 6d3732cf8b3c -r 5f61efdc9f35 src/lib-settings/settings-parser.c
--- a/src/lib-settings/settings-parser.c Tue Sep 08 18:16:27 2009 -0400
+++ b/src/lib-settings/settings-parser.c Tue Sep 08 18:45:27 2009 -0400
@@ -743,6 +743,42 @@ void settings_parse_set_expanded(struct
ctx->str_vars_are_expanded = is_expanded;
}
+void settings_parse_set_key_expandeded(struct setting_parser_context *ctx,
+ pool_t pool, const char *key)
+{
+ const struct setting_define *def;
+ struct setting_link *link;
+ const char **val;
+
+ if (!settings_find_key(ctx, key, &def, &link))
+ return;
+
+ val = PTR_OFFSET(link->set_struct, def->offset);
+ if (def->type == SET_STR_VARS && *val != NULL) {
+ i_assert(**val == SETTING_STRVAR_UNEXPANDED[0] ||
+ **val == SETTING_STRVAR_EXPANDED[0]);
+ *val = p_strconcat(pool, SETTING_STRVAR_EXPANDED,
+ *val + 1, NULL);
+ }
+}
+
+void settings_parse_set_keys_expandeded(struct setting_parser_context *ctx,
+ pool_t pool, const char *const *keys)
+{
+ for (; *keys != NULL; keys++)
+ settings_parse_set_key_expandeded(ctx, pool, *keys);
+}
+
+void settings_parse_var_skip(struct setting_parser_context *ctx)
+{
+ unsigned int i;
+
+ for (i = 0; i < ctx->root_count; i++) {
+ settings_var_expand(ctx->roots[i].info,
+ ctx->roots[i].set_struct, NULL, NULL);
+ }
+}
+
static void
settings_var_expand_info(const struct setting_parser_info *info,
pool_t pool, void *set,
@@ -761,7 +797,11 @@ settings_var_expand_info(const struct se
if (*val == NULL)
break;
- if (**val == SETTING_STRVAR_UNEXPANDED[0]) {
+ if (table == NULL) {
+ i_assert(**val == SETTING_STRVAR_EXPANDED[0] ||
+ **val == SETTING_STRVAR_UNEXPANDED[0]);
+ *val += 1;
+ } else if (**val == SETTING_STRVAR_UNEXPANDED[0]) {
str_truncate(str, 0);
var_expand(str, *val + 1, table);
*val = p_strdup(pool, str_c(str));
@@ -789,32 +829,6 @@ settings_var_expand_info(const struct se
break;
}
}
-}
-
-void settings_parse_set_key_expandeded(struct setting_parser_context *ctx,
- pool_t pool, const char *key)
-{
- const struct setting_define *def;
- struct setting_link *link;
- const char **val;
-
- if (!settings_find_key(ctx, key, &def, &link))
- return;
-
- val = PTR_OFFSET(link->set_struct, def->offset);
- if (def->type == SET_STR_VARS && *val != NULL) {
- i_assert(**val == SETTING_STRVAR_UNEXPANDED[0] ||
- **val == SETTING_STRVAR_EXPANDED[0]);
- *val = p_strconcat(pool, SETTING_STRVAR_EXPANDED,
- *val + 1, NULL);
- }
-}
-
-void settings_parse_set_keys_expandeded(struct setting_parser_context *ctx,
- pool_t pool, const char *const *keys)
-{
- for (; *keys != NULL; keys++)
- settings_parse_set_key_expandeded(ctx, pool, *keys);
}
void settings_var_expand(const struct setting_parser_info *info,
diff -r 6d3732cf8b3c -r 5f61efdc9f35 src/lib-settings/settings-parser.h
--- a/src/lib-settings/settings-parser.h Tue Sep 08 18:16:27 2009 -0400
+++ b/src/lib-settings/settings-parser.h Tue Sep 08 18:45:27 2009 -0400
@@ -135,6 +135,10 @@ void settings_parse_set_key_expandeded(s
pool_t pool, const char *key);
void settings_parse_set_keys_expandeded(struct setting_parser_context *ctx,
pool_t pool, const char *const *keys);
+/* Update variable string pointers to skip over the '1' or '0'.
+ This is mainly useful when you want to run settings_parser_check() without
+ actually knowing what the variables are. */
+void settings_parse_var_skip(struct setting_parser_context *ctx);
/* Expand all unexpanded variables using the given table. Update the string
pointers so that they can be used without skipping over the '1'. */
void settings_var_expand(const struct setting_parser_info *info,
More information about the dovecot-cvs
mailing list