dovecot-2.2: quota: Code cleanup - extract default init() handli...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Sep 21 13:25:57 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/ff5c34d62daf
changeset: 19165:ff5c34d62daf
user: Timo Sirainen <tss at iki.fi>
date: Mon Sep 21 16:09:37 2015 +0300
description:
quota: Code cleanup - extract default init() handling to quota_root_default_init()
diffstat:
src/plugins/quota/quota-private.h | 2 +
src/plugins/quota/quota.c | 48 ++++++++++++++++++++++++--------------
2 files changed, 32 insertions(+), 18 deletions(-)
diffs (83 lines):
diff -r e937b8e7a6a3 -r ff5c34d62daf src/plugins/quota/quota-private.h
--- a/src/plugins/quota/quota-private.h Mon Sep 21 15:41:49 2015 +0300
+++ b/src/plugins/quota/quota-private.h Mon Sep 21 16:09:37 2015 +0300
@@ -172,6 +172,8 @@
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 -r e937b8e7a6a3 -r ff5c34d62daf src/plugins/quota/quota.c
--- a/src/plugins/quota/quota.c Mon Sep 21 15:41:49 2015 +0300
+++ b/src/plugins/quota/quota.c Mon Sep 21 16:09:37 2015 +0300
@@ -277,12 +277,39 @@
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 @@
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 &&
More information about the dovecot-cvs
mailing list