From: Timo Sirainen Date: Mon, 21 Sep 2015 13:09:37 +0000 (+0300) Subject: quota: Code cleanup - extract default init() handling to quota_root_default_init() X-Git-Tag: 2.2.19.rc1~29 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a4922fa0c7de2aa332bc1361abf6f93f001fc02e;p=thirdparty%2Fdovecot%2Fcore.git quota: Code cleanup - extract default init() handling to quota_root_default_init() --- diff --git a/src/plugins/quota/quota-private.h b/src/plugins/quota/quota-private.h index bfe1bd801e..f0a08d7626 100644 --- a/src/plugins/quota/quota-private.h +++ b/src/plugins/quota/quota-private.h @@ -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, diff --git a/src/plugins/quota/quota.c b/src/plugins/quota/quota.c index b2b98721ec..c3a278f1c7 100644 --- a/src/plugins/quota/quota.c +++ b/src/plugins/quota/quota.c @@ -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 &&