dbox-storage.c revision 6e1e9e341ffe21a69a23229c2b896d03066a071e
/* Copyright (C) 2005 Timo Sirainen */
#include "lib.h"
#include "mkdir-parents.h"
#include "unlink-directory.h"
#include "index-mail.h"
#include "mail-copy.h"
#include "dbox-uidlist.h"
#include "dbox-sync.h"
#include "dbox-file.h"
#include "dbox-storage.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
const struct dotlock_settings default_uidlist_dotlock_set = {
};
const struct dotlock_settings default_file_dotlock_set = {
};
static const struct dotlock_settings default_new_file_dotlock_set = {
};
extern struct mail_storage dbox_storage;
extern struct mailbox dbox_mailbox;
{
else
return FALSE;
return TRUE;
}
static int
{
const char *p;
/* we won't do any guessing for this format. */
if (debug)
i_info("dbox: mailbox location not given");
return -1;
}
/* <root dir> [:INDEX=<dir>] */
if (debug)
if (p == NULL)
else {
do {
p++;
p = strchr(p, ':');
} while (p != NULL);
}
/* strip trailing '/' */
return 0;
}
static struct mail_storage *
enum mail_storage_flags flags,
enum file_lock_method lock_method)
{
struct dbox_storage *storage;
struct index_storage *istorage;
struct mailbox_list_settings list_set;
struct mailbox_list *list;
const char *error;
return NULL;
if ((flags & MAIL_STORAGE_FLAG_NO_AUTOCREATE) != 0) {
i_error("stat(%s) failed: %m",
}
return NULL;
}
}
return NULL;
}
return NULL;
}
if ((flags & MAIL_STORAGE_FLAG_DOTLOCK_USE_EXCL) != 0) {
}
}
{
}
{
const char *path;
if (debug)
return FALSE;
}
if (debug)
return FALSE;
}
return TRUE;
}
{
if (dbox_handle_errors(storage))
return -1;
path);
return -1;
}
return 0;
}
{
return 0;
return -1;
}
return 0;
}
{
return FALSE;
}
static struct mailbox *
enum mailbox_open_flags flags)
{
struct dbox_mailbox *mbox;
struct mail_index *index;
return NULL;
return NULL;
else
else
else
mailbox_close(&box);
return NULL;
}
}
}
static struct mailbox *
{
const char *path;
"dbox doesn't support streamed mailboxes");
return NULL;
}
return NULL;
}
return NULL;
} else {
path);
return NULL;
}
}
const char *name,
bool directory __attr_unused__)
{
const char *path;
return -1;
}
return -1;
}
}
const char *name)
{
return -1;
}
return -1;
}
/* doesn't exist at all */
return -1;
}
/* exists as a \NoSelect mailbox */
return 0;
"Mailbox has only submailboxes: %s", name);
} else {
"rmdir() failed for %s: %m", path);
}
return -1;
}
/* make sure the indexes are closed before trying to delete the
directory that contains them */
if (!dbox_handle_errors(_storage)) {
"unlink_directory() failed for %s: %m",
}
return -1;
}
/* try also removing the root directory. it can fail if the deleted
mailbox had submailboxes. do it as long as we can. */
if (p == NULL)
break;
}
return 0;
}
{
return -1;
}
/* create the hierarchy */
if (p != NULL) {
p = t_strdup_until(newpath, p);
if (mkdir_parents(p, CREATE_MODE) < 0) {
if (dbox_handle_errors(_storage))
return -1;
"mkdir_parents(%s) failed: %m", p);
return -1;
}
}
/* first check that the destination mailbox doesn't exist.
this is racy, but we need to be atomic and there's hardly any
possibility that someone actually tries to rename two mailboxes
to same new one */
"Target mailbox already exists");
return -1;
"Target mailbox doesn't allow inferior mailboxes");
return -1;
newpath);
return -1;
}
/* NOTE: renaming INBOX works just fine with us, it's simply recreated
the next time it's needed. */
} else if (!dbox_handle_errors(_storage)) {
}
return -1;
}
return 0;
}
{
return 0;
}
static void
{
return;
}
}
enum mailbox_info_flags *flags,
enum mailbox_list_file_type type)
{
int ret = 1;
return 0;
}
/* skip all .lock files */
return 0;
}
/* try to avoid stat() with these checks */
if (type != MAILBOX_LIST_FILE_TYPE_DIR &&
(iter_flags & MAILBOX_LIST_ITER_FAST_FLAGS) != 0) {
/* it's a file */
return 0;
}
/* need to stat() then */
t_push();
/* non-directory */
ret = 0;
}
} else {
/* non-selectable, but may contain subdirs */
*flags |= MAILBOX_NOSELECT;
/* just lost it */
ret = 0;
"stat(%s) failed: %m", path);
ret = -1;
}
}
}
t_pop();
return ret;
}
static void dbox_class_init(void)
{
}
static void dbox_class_deinit(void)
{
}
struct mail_storage dbox_storage = {
{
}
};
struct mailbox dbox_mailbox = {
{
}
};