changeset 9143:675f0df22f24 HEAD

mail_location: Allow using ":" characters in dir names by escaping it as "::".
author Timo Sirainen <tss@iki.fi>
date Sun, 21 Jun 2009 22:22:57 -0400
parents 5ee5def4f0ff
children a0fcbb79ef66
files src/lib-storage/mailbox-list.c
diffstat 1 files changed, 27 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/mailbox-list.c	Wed Jun 17 13:05:40 2009 -0400
+++ b/src/lib-storage/mailbox-list.c	Sun Jun 21 22:22:57 2009 -0400
@@ -118,13 +118,32 @@
 	return 0;
 }
 
+static const char *split_next_arg(const char *const **_args)
+{
+	const char *const *args = *_args;
+	const char *str = args[0];
+
+	args++;
+	while (*args != NULL && **args == '\0') {
+		args++;
+		if (*args == NULL) {
+			str = t_strconcat(str, ":", NULL);
+			break;
+		}
+		str = t_strconcat(str, ":", *args, NULL);
+		args++;
+	}
+	*_args = args;
+	return str;
+}
+
 int mailbox_list_settings_parse(const char *data,
 				struct mailbox_list_settings *set,
 				struct mail_namespace *ns,
 				const char **layout, const char **alt_dir_r,
 				const char **error_r)
 {
-	const char *const *tmp, *key, *value, **dest;
+	const char *const *tmp, *key, *value, **dest, *str;
 
 	i_assert(*data != '\0');
 
@@ -134,21 +153,22 @@
 
 	/* <root dir> */
 	tmp = t_strsplit(data, ":");
-	if (fix_path(ns, *tmp, &set->root_dir) < 0) {
+	str = split_next_arg(&tmp);
+	if (fix_path(ns, str, &set->root_dir) < 0) {
 		*error_r = t_strdup_printf(
 			"Home directory not set, can't expand ~/ for "
 			"mail root dir in: %s", data);
 		return -1;
 	}
-	tmp++;
 
-	for (; *tmp != NULL; tmp++) {
-		value = strchr(*tmp, '=');
+	while (*tmp != NULL) {
+		str = split_next_arg(&tmp);
+		value = strchr(str, '=');
 		if (value == NULL) {
-			key = *tmp;
+			key = str;
 			value = "";
 		} else {
-			key = t_strdup_until(*tmp, value);
+			key = t_strdup_until(str, value);
 			value++;
 		}