]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Code cleanup.
authorTimo Sirainen <tss@iki.fi>
Fri, 4 Jun 2010 15:36:24 +0000 (16:36 +0100)
committerTimo Sirainen <tss@iki.fi>
Fri, 4 Jun 2010 15:36:24 +0000 (16:36 +0100)
--HG--
branch : HEAD

src/lib-storage/mail-storage.c
src/lib-storage/mailbox-list-private.h
src/lib-storage/mailbox-list.c

index f85137bdd42ace3c3830604b8d1810544100670e..2ac68de2daa89a5a4bde05e44e4f852364dc5a7d 100644 (file)
@@ -277,7 +277,7 @@ int mail_storage_create(struct mail_namespace *ns, const char *driver,
        } 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;
        }
index 165bcf0512bb625ffab099bb1f8da1138166e5fa..4278c17f89d3b8c24de81d55d0ca32d0f7319803 100644 (file)
@@ -137,9 +137,8 @@ extern struct mailbox_list_module_register mailbox_list_module_register;
 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,
index 47e2ea253e904d665bed627db98b0656f815a8ed..2c65e48027aac9a3e6a19632763806fa06cb2fe7 100644 (file)
@@ -197,7 +197,7 @@ int mailbox_list_create(const char *driver, struct mail_namespace *ns,
        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 @@ static int fix_path(struct mail_namespace *ns, const char *path,
                        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 @@ static const char *split_next_arg(const char *const **_args)
        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 @@ int mailbox_list_settings_parse(const char *data,
                }
 
                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;
 }