shared-storage.c revision f1743785713e7632459d623d5df2108f4b93accb
/* Copyright (c) 2008 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "str.h"
#include "var-expand.h"
#include "shared-storage.h"
#define SHARED_LIST_CONTEXT(obj) \
extern struct mail_storage shared_storage;
extern struct mailbox shared_mailbox;
static struct mail_storage *shared_alloc(void)
{
struct shared_storage *storage;
}
const char **error_r)
{
struct mailbox_list_settings list_set;
const char *driver, *p;
bool have_username;
/* data must begin with the actual mailbox driver */
if (p == NULL) {
*error_r = "Shared mailbox location not prefixed with driver";
return -1;
}
return -1;
}
if (p == NULL) {
*error_r = "Shared namespace prefix doesn't contain %";
return -1;
}
if (*p != '%')
continue;
if (*++p == '\0')
break;
if (*p == 'u' || *p == 'n')
else if (*p != 'd')
break;
}
if (*p != '\0') {
*error_r = "Shared namespace prefix contains unknown variables";
return -1;
}
if (!have_username) {
*error_r = "Shared namespace prefix doesn't contain %u or %n";
return -1;
}
return -1;
return 0;
}
const char **_name,
struct mail_namespace **ns_r)
{
static struct var_expand_table static_tab[] = {
{ 'u', NULL },
{ 'n', NULL },
{ 'd', NULL },
{ '\0', NULL }
};
struct var_expand_table *tab;
struct mail_namespace *ns;
p = storage->ns_prefix_pattern;
if (*p != '%') {
if (*p != *name)
return -1;
p++; name++;
continue;
}
switch (*++p) {
case 'd':
break;
case 'n':
break;
case 'u':
dest = &userdomain;
break;
default:
/* we checked this already above */
i_unreached();
}
p++;
return -1;
}
/* successfully matched the name. */
if (userdomain == NULL) {
} else {
else {
domain++;
}
}
/* expand the namespace prefix and see if it already exists.
this should normally happen only when the mailbox is being opened */
return 0;
}
/* create the new namespace */
return -1;
}
/* FIXME: we could remove namespaces here that don't have usable
mailboxes. otherwise the memory usage could just keep growing. */
return 0;
}
struct mail_namespace *backend_ns)
{
const char *str;
enum mail_error error;
}
static struct mailbox *
{
struct mail_namespace *ns;
"Shared storage doesn't support streamed mailboxes");
return NULL;
}
return NULL;
/* if we call the normal mailbox_open() here the plugins will see
mailbox_open() called twice and they could break. */
return box;
}
{
struct mail_namespace *ns;
int ret;
return -1;
if (ret < 0)
return ret;
}
struct mail_storage shared_storage = {
{
NULL,
NULL,
NULL,
}
};