]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Dict backend parameters reading changed to use common parsing function
authorSergey Kitov <sergey.kitov@open-xchange.com>
Fri, 19 May 2017 07:58:52 +0000 (10:58 +0300)
committerGitLab <gitlab@git.dovecot.net>
Tue, 23 May 2017 08:14:26 +0000 (11:14 +0300)
src/plugins/quota/quota-dict.c

index 80ff8357bc4421f914efb8d11952166fc941a7cb..1ce980791e76b59a65e53cfc77ef3bd7eeac4a31 100644 (file)
@@ -30,6 +30,11 @@ static struct quota_root *dict_quota_alloc(void)
        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 @@ static int dict_quota_init(struct quota_root *_root, const char *args,
        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 @@ static int dict_quota_init(struct quota_root *_root, const char *args,
        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;