From: Sergey Kitov Date: Fri, 19 May 2017 07:52:46 +0000 (+0300) Subject: imapc backend parameter parsing changed to use common function X-Git-Tag: 2.3.0.rc1~1575 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bbd51f171bb2f4abd437910c720579a4eaf65c85;p=thirdparty%2Fdovecot%2Fcore.git imapc backend parameter parsing changed to use common function --- diff --git a/src/plugins/quota/quota-imapc.c b/src/plugins/quota/quota-imapc.c index a3d64941dd..0aea5ea122 100644 --- a/src/plugins/quota/quota-imapc.c +++ b/src/plugins/quota/quota-imapc.c @@ -46,26 +46,30 @@ static struct quota_root *imapc_quota_alloc(void) return &root->root; } +static void handle_box_param(struct quota_root *_root, const char *param_value) +{ + ((struct imapc_quota_root *)_root)->box_name = p_strdup(_root->pool, param_value); +} + +static void handle_root_param(struct quota_root *_root, const char *param_value) +{ + ((struct imapc_quota_root *)_root)->root_name = p_strdup(_root->pool, param_value); +} + static int imapc_quota_init(struct quota_root *_root, const char *args, const char **error_r) { struct imapc_quota_root *root = (struct imapc_quota_root *)_root; - const char *const *tmp; - - if (args == NULL) - args = ""; - for (tmp = t_strsplit(args, ":"); *tmp != NULL; tmp++) { - if (strncmp(*tmp, "ns=", 3) == 0) - _root->ns_prefix = p_strdup(_root->pool, *tmp + 3); - else if (strncmp(*tmp, "box=", 4) == 0) - root->box_name = p_strdup(_root->pool, *tmp + 4); - else if (strncmp(*tmp, "root=", 5) == 0) - root->root_name = p_strdup(_root->pool, *tmp + 5); - else { - *error_r = t_strdup_printf("Invalid parameter: %s", *tmp); - return -1; - } - } + const struct quota_param_parser imapc_params[] = { + {.param_name = "box=", .param_handler = handle_box_param}, + {.param_name = "root=", .param_handler = handle_root_param}, + quota_param_ns, + {.param_name = NULL} + }; + + if (quota_parse_parameters(_root, &args, error_r, imapc_params, FALSE) < 0) + return -1; + if (root->box_name == NULL && root->root_name == NULL) root->box_name = "INBOX"; /* we'll never try to enforce the quota - it's just a lot of