Mercurial > dovecot > core-2.2
changeset 22207:3b76d7f068dc
Dict backend parameters reading changed to use common parsing function
author | Sergey Kitov <sergey.kitov@open-xchange.com> |
---|---|
date | Fri, 19 May 2017 10:58:52 +0300 |
parents | cbc20b8e0bd4 |
children | 92277c2770d2 |
files | src/plugins/quota/quota-dict.c |
diffstat | 1 files changed, 12 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/quota/quota-dict.c Fri May 19 10:57:02 2017 +0300 +++ b/src/plugins/quota/quota-dict.c Fri May 19 10:58:52 2017 +0300 @@ -30,6 +30,11 @@ return &root->root; } +static void handle_nounset_param(struct quota_root *_root, const char *param_value ATTR_UNUSED) +{ + ((struct dict_quota_root *)_root)->disable_unset = TRUE; +} + static int dict_quota_init(struct quota_root *_root, const char *args, const char **error_r) { @@ -37,6 +42,12 @@ struct dict_settings set; const char *username, *p, *error; + const struct quota_param_parser dict_params[] = { + {.param_name = "no-unset", .param_handler = handle_nounset_param}, + quota_param_hidden, quota_param_ignoreunlimited, quota_param_noenforcing, quota_param_ns, + {.param_name = NULL} + }; + p = args == NULL ? NULL : strchr(args, ':'); if (p == NULL) { *error_r = "URI missing from parameters"; @@ -46,33 +57,7 @@ username = t_strdup_until(args, p); args = p+1; - for (;;) { - /* FIXME: pretty ugly in here. the parameters should have - been designed to be extensible. do it in a future version */ - if (strncmp(args, "noenforcing:", 12) == 0) { - _root->no_enforcing = TRUE; - args += 12; - } else if (strncmp(args, "hidden:", 7) == 0) { - _root->hidden = TRUE; - args += 7; - } else if (strncmp(args, "ignoreunlimited:", 16) == 0) { - _root->disable_unlimited_tracking = TRUE; - args += 16; - } else if (strncmp(args, "no-unset:", 9) == 0) { - root->disable_unset = TRUE; - args += 9; - } else if (strncmp(args, "ns=", 3) == 0) { - p = strchr(args, ':'); - if (p == NULL) - break; - - _root->ns_prefix = p_strdup_until(_root->pool, - args + 3, p); - args = p + 1; - } else { - break; - } - } + quota_parse_parameters(_root, &args, error_r, dict_params, TRUE); if (*username == '\0') username = _root->quota->user->username;