dovecot-2.0: Settings parser: Fixed overriding settings in strli...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Feb 22 19:10:32 EET 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/ba19f3c077a8
changeset: 10807:ba19f3c077a8
user: Timo Sirainen <tss at iki.fi>
date: Mon Feb 22 19:10:24 2010 +0200
description:
Settings parser: Fixed overriding settings in strlist blocks.
For example plugin {} settings couldn't be overridden by userdb.
diffstat:
src/lib-settings/settings-parser.c | 34 +++++++++++++++++++++++++++-------
1 files changed, 27 insertions(+), 7 deletions(-)
diffs (51 lines):
diff -r c77e71e0c5bd -r ba19f3c077a8 src/lib-settings/settings-parser.c
--- a/src/lib-settings/settings-parser.c Mon Feb 22 18:53:21 2010 +0200
+++ b/src/lib-settings/settings-parser.c Mon Feb 22 19:10:24 2010 +0200
@@ -655,6 +655,32 @@
}
}
+static void
+settings_parse_strlist(struct setting_parser_context *ctx,
+ struct setting_link *link,
+ const char *key, const char *value)
+{
+ void *const *items;
+ void *vkey, *vvalue;
+ unsigned int i, count;
+
+ key = strrchr(key, SETTINGS_SEPARATOR) + 1;
+ vvalue = p_strdup(ctx->set_pool, value);
+
+ /* replace if it already exists */
+ items = array_get(link->array, &count);
+ for (i = 0; i < count; i += 2) {
+ if (strcmp(items[i], key) == 0) {
+ array_idx_set(link->array, i + 1, &vvalue);
+ return;
+ }
+ }
+
+ vkey = p_strdup(ctx->set_pool, key);
+ array_append(link->array, &vkey, 1);
+ array_append(link->array, &vvalue, 1);
+}
+
static int settings_parse_keyvalue(struct setting_parser_context *ctx,
const char *key, const char *value)
{
@@ -663,13 +689,7 @@
if (settings_find_key(ctx, key, &def, &link)) {
if (link->info == &strlist_info) {
- void *vkey, *vvalue;
-
- vkey = p_strdup(ctx->set_pool,
- strrchr(key, SETTINGS_SEPARATOR) + 1);
- vvalue = p_strdup(ctx->set_pool, value);
- array_append(link->array, &vkey, 1);
- array_append(link->array, &vvalue, 1);
+ settings_parse_strlist(ctx, link, key, value);
return 1;
}
More information about the dovecot-cvs
mailing list