comparison src/lib-storage/index/shared/shared-storage.c @ 8446:1c13cf0f8bb5 HEAD

Added mail_namespace_destroy().
author Timo Sirainen <tss@iki.fi>
date Wed, 19 Nov 2008 18:45:46 +0200
parents 118e07fdfe11
children 4cf249042df6
comparison
equal deleted inserted replaced
8445:33dc554bd33f 8446:1c13cf0f8bb5
43 const char **error_r) 43 const char **error_r)
44 { 44 {
45 struct shared_storage *storage = (struct shared_storage *)_storage; 45 struct shared_storage *storage = (struct shared_storage *)_storage;
46 struct mailbox_list_settings list_set; 46 struct mailbox_list_settings list_set;
47 const char *driver, *p; 47 const char *driver, *p;
48 char *wildcardp;
48 bool have_username; 49 bool have_username;
49 50
50 /* data must begin with the actual mailbox driver */ 51 /* data must begin with the actual mailbox driver */
51 p = strchr(data, ':'); 52 p = strchr(data, ':');
52 if (p == NULL) { 53 if (p == NULL) {
61 driver, NULL); 62 driver, NULL);
62 return -1; 63 return -1;
63 } 64 }
64 _storage->mailbox_is_file = storage->storage_class->mailbox_is_file; 65 _storage->mailbox_is_file = storage->storage_class->mailbox_is_file;
65 66
66 p = strchr(_storage->ns->prefix, '%'); 67 wildcardp = strchr(_storage->ns->prefix, '%');
67 if (p == NULL) { 68 if (wildcardp == NULL) {
68 *error_r = "Shared namespace prefix doesn't contain %"; 69 *error_r = "Shared namespace prefix doesn't contain %";
69 return -1; 70 return -1;
70 } 71 }
71 storage->ns_prefix_pattern = p_strdup(_storage->pool, p); 72 storage->ns_prefix_pattern = p_strdup(_storage->pool, wildcardp);
72 _storage->ns->prefix = p_strdup_until(_storage->ns->user->pool, 73 *wildcardp = '\0';
73 _storage->ns->prefix, p);
74 74
75 have_username = FALSE; 75 have_username = FALSE;
76 for (p = storage->ns_prefix_pattern; *p != '\0'; p++) { 76 for (p = storage->ns_prefix_pattern; *p != '\0'; p++) {
77 if (*p != '%') 77 if (*p != '%')
78 continue; 78 continue;
263 return -1; 263 return -1;
264 } 264 }
265 } 265 }
266 266
267 /* create the new namespace */ 267 /* create the new namespace */
268 ns = p_new(user->pool, struct mail_namespace, 1); 268 ns = i_new(struct mail_namespace, 1);
269 ns->type = NAMESPACE_SHARED; 269 ns->type = NAMESPACE_SHARED;
270 ns->user = user; 270 ns->user = user;
271 ns->prefix = p_strdup(user->pool, str_c(prefix)); 271 ns->prefix = i_strdup(str_c(prefix));
272 ns->flags = NAMESPACE_FLAG_LIST | NAMESPACE_FLAG_HIDDEN | 272 ns->flags = NAMESPACE_FLAG_LIST | NAMESPACE_FLAG_HIDDEN |
273 NAMESPACE_FLAG_AUTOCREATED; 273 NAMESPACE_FLAG_AUTOCREATED;
274 ns->sep = _storage->ns->sep; 274 ns->sep = _storage->ns->sep;
275 275
276 location = t_str_new(256); 276 location = t_str_new(256);