dovecot-2.0: lib-storage: Code cleanup.

dovecot at dovecot.org dovecot at dovecot.org
Fri Jun 4 18:36:27 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/e056d42c9711
changeset: 11474:e056d42c9711
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Jun 04 16:36:24 2010 +0100
description:
lib-storage: Code cleanup.

diffstat:

 src/lib-storage/mail-storage.c         |   2 +-
 src/lib-storage/mailbox-list-private.h |   5 ++---
 src/lib-storage/mailbox-list.c         |  36 +++++++++++++++++++-----------------
 3 files changed, 22 insertions(+), 21 deletions(-)

diffs (121 lines):

diff -r b578861bfa40 -r e056d42c9711 src/lib-storage/mail-storage.c
--- a/src/lib-storage/mail-storage.c	Fri Jun 04 16:15:28 2010 +0100
+++ b/src/lib-storage/mail-storage.c	Fri Jun 04 16:36:24 2010 +0100
@@ -277,7 +277,7 @@
 	} else {
 		if (driver == NULL)
 			mail_storage_set_autodetection(&data, &driver);
-		if (mailbox_list_settings_parse(data, &list_set, ns,
+		if (mailbox_list_settings_parse(ns->user, data, &list_set,
 						error_r) < 0)
 			return -1;
 	}
diff -r b578861bfa40 -r e056d42c9711 src/lib-storage/mailbox-list-private.h
--- a/src/lib-storage/mailbox-list-private.h	Fri Jun 04 16:15:28 2010 +0100
+++ b/src/lib-storage/mailbox-list-private.h	Fri Jun 04 16:36:24 2010 +0100
@@ -137,9 +137,8 @@
 void mailbox_lists_init(void);
 void mailbox_lists_deinit(void);
 
-int mailbox_list_settings_parse(const char *data,
-				struct mailbox_list_settings *set,
-				struct mail_namespace *ns,
+int mailbox_list_settings_parse(struct mail_user *user, const char *data,
+				struct mailbox_list_settings *set_r,
 				const char **error_r);
 
 int mailbox_list_delete_index_control(struct mailbox_list *list,
diff -r b578861bfa40 -r e056d42c9711 src/lib-storage/mailbox-list.c
--- a/src/lib-storage/mailbox-list.c	Fri Jun 04 16:15:28 2010 +0100
+++ b/src/lib-storage/mailbox-list.c	Fri Jun 04 16:36:24 2010 +0100
@@ -197,7 +197,7 @@
 	return 0;
 }
 
-static int fix_path(struct mail_namespace *ns, const char *path,
+static int fix_path(struct mail_user *user, const char *path,
 		    const char **path_r, const char **error_r)
 {
 	size_t len = strlen(path);
@@ -214,7 +214,7 @@
 			return -1;
 		}
 	} else {
-		if (mail_user_try_home_expand(ns->user, &path) < 0) {
+		if (mail_user_try_home_expand(user, &path) < 0) {
 			*error_r = "Home directory not set for user. "
 				"Can't expand ~/ for ";
 			return -1;
@@ -243,21 +243,23 @@
 	return str;
 }
 
-int mailbox_list_settings_parse(const char *data,
-				struct mailbox_list_settings *set,
-				struct mail_namespace *ns, const char **error_r)
+int mailbox_list_settings_parse(struct mail_user *user, const char *data,
+				struct mailbox_list_settings *set_r,
+				const char **error_r)
 {
 	const char *const *tmp, *key, *value, **dest, *str, *error;
 
 	*error_r = NULL;
 
+	memset(set_r, 0, sizeof(*set_r));
+
 	if (*data == '\0')
 		return 0;
 
 	/* <root dir> */
 	tmp = t_strsplit(data, ":");
 	str = split_next_arg(&tmp);
-	if (fix_path(ns, str, &set->root_dir, &error) < 0) {
+	if (fix_path(user, str, &set_r->root_dir, &error) < 0) {
 		*error_r = t_strconcat(error, "mail root dir in: ", data, NULL);
 		return -1;
 	}
@@ -274,33 +276,33 @@
 		}
 
 		if (strcmp(key, "INBOX") == 0)
-			dest = &set->inbox_path;
+			dest = &set_r->inbox_path;
 		else if (strcmp(key, "INDEX") == 0)
-			dest = &set->index_dir;
+			dest = &set_r->index_dir;
 		else if (strcmp(key, "CONTROL") == 0)
-			dest = &set->control_dir;
+			dest = &set_r->control_dir;
 		else if (strcmp(key, "ALT") == 0)
-			dest = &set->alt_dir;
+			dest = &set_r->alt_dir;
 		else if (strcmp(key, "LAYOUT") == 0)
-			dest = &set->layout;
+			dest = &set_r->layout;
 		else if (strcmp(key, "SUBSCRIPTIONS") == 0)
-			dest = &set->subscription_fname;
+			dest = &set_r->subscription_fname;
 		else if (strcmp(key, "DIRNAME") == 0)
-			dest = &set->maildir_name;
+			dest = &set_r->maildir_name;
 		else if (strcmp(key, "MAILBOXDIR") == 0)
-			dest = &set->mailbox_dir_name;
+			dest = &set_r->mailbox_dir_name;
 		else {
 			*error_r = t_strdup_printf("Unknown setting: %s", key);
 			return -1;
 		}
-		if (fix_path(ns, value, dest, &error) < 0) {
+		if (fix_path(user, value, dest, &error) < 0) {
 			*error_r = t_strconcat(error, key, " in: ", data, NULL);
 			return -1;
 		}
 	}
 
-	if (set->index_dir != NULL && strcmp(set->index_dir, "MEMORY") == 0)
-		set->index_dir = "";
+	if (set_r->index_dir != NULL && strcmp(set_r->index_dir, "MEMORY") == 0)
+		set_r->index_dir = "";
 	return 0;
 }
 


More information about the dovecot-cvs mailing list