]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
quota: Code cleanup - extract default init() handling to quota_root_default_init()
authorTimo Sirainen <tss@iki.fi>
Mon, 21 Sep 2015 13:09:37 +0000 (16:09 +0300)
committerTimo Sirainen <tss@iki.fi>
Mon, 21 Sep 2015 13:09:37 +0000 (16:09 +0300)
src/plugins/quota/quota-private.h
src/plugins/quota/quota.c

index bfe1bd801e0e07803bbb99e6a8f03fe286113c7a..f0a08d7626d3a85b9f5d3ff333e1d89e52494f99 100644 (file)
@@ -172,6 +172,8 @@ struct quota_transaction_context {
 void quota_add_user_namespace(struct quota *quota, struct mail_namespace *ns);
 void quota_remove_user_namespace(struct mail_namespace *ns);
 
+int quota_root_default_init(struct quota_root *root, const char *args,
+                           const char **error_r);
 struct quota *quota_get_mail_user_quota(struct mail_user *user);
 
 bool quota_root_is_namespace_visible(struct quota_root *root,
index b2b98721ec54c0c7b2e9be8a754c95c84e36cde6..c3a278f1c757774b2d6a4bcf4f76b65bab8aa410 100644 (file)
@@ -277,12 +277,39 @@ static void quota_root_deinit(struct quota_root *root)
        pool_unref(&pool);
 }
 
+int quota_root_default_init(struct quota_root *root, const char *args,
+                           const char **error_r)
+{
+       const char *const *tmp;
+
+       if (args == NULL)
+               return 0;
+
+       tmp = t_strsplit_spaces(args, " ");
+       for (; *tmp != NULL; tmp++) {
+               if (strcmp(*tmp, "noenforcing") == 0)
+                       root->no_enforcing = TRUE;
+               else if (strcmp(*tmp, "hidden") == 0)
+                       root->hidden = TRUE;
+               else if (strcmp(*tmp, "ignoreunlimited") == 0)
+                       root->disable_unlimited_tracking = TRUE;
+               else
+                       break;
+       }
+       if (*tmp != NULL) {
+               *error_r = t_strdup_printf(
+                       "Unknown parameter for backend %s: %s",
+                       root->backend.name, *tmp);
+               return -1;
+       }
+       return 0;
+}
+
 static int
 quota_root_init(struct quota_root_settings *root_set, struct quota *quota,
                struct quota_root **root_r, const char **error_r)
 {
        struct quota_root *root;
-       const char *const *tmp;
 
        root = root_set->backend->v.alloc();
        root->resource_ret = -1;
@@ -302,24 +329,9 @@ quota_root_init(struct quota_root_settings *root_set, struct quota *quota,
                                        root->backend.name, *error_r);
                        return -1;
                }
-       } else if (root_set->args != NULL) {
-               tmp = t_strsplit_spaces(root_set->args, " ");
-               for (; *tmp != NULL; tmp++) {
-                       if (strcmp(*tmp, "noenforcing") == 0)
-                               root->no_enforcing = TRUE;
-                       else if (strcmp(*tmp, "hidden") == 0)
-                               root->hidden = TRUE;
-                       else if (strcmp(*tmp, "ignoreunlimited") == 0)
-                               root->disable_unlimited_tracking = TRUE;
-                       else
-                               break;
-               }
-               if (*tmp != NULL) {
-                       *error_r = t_strdup_printf(
-                               "Unknown parameter for backend %s: %s",
-                               root->backend.name, *tmp);
+       } else {
+               if (quota_root_default_init(root, root_set->args, error_r) < 0)
                        return -1;
-               }
        }
        if (root_set->default_rule.bytes_limit == 0 &&
            root_set->default_rule.count_limit == 0 &&