maildir-storage.c revision cbada5b46b27117057d472c4256829f8b092dbff
/* Copyright (C) 2002 Timo Sirainen */
#include "lib.h"
#include "home-expand.h"
#include "unlink-directory.h"
#include "subscription-file/subscription-file.h"
#include "maildir-index.h"
#include "maildir-storage.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
struct rename_context {
int found;
const char *newname;
};
extern struct mail_storage maildir_storage;
extern struct mailbox maildir_mailbox;
{
struct mail_storage *storage;
/* we'll need to figure out the maildir location ourself.
it's either root dir if we've already chroot()ed, or
root_dir = "/";
else {
}
}
} else {
/* <Maildir> [:INDEX=<dir>] */
if (p == NULL)
else {
p++;
}
}
return NULL;
return storage;
}
{
}
static int maildir_autodetect(const char *data)
{
}
const char *name)
{
return FALSE;
return TRUE;
return *name != '~' &&
}
static int maildir_is_valid_existing_name(const char *name)
{
return FALSE;
return TRUE;
return *name != '~' &&
}
static const char *maildir_get_absolute_path(const char *name)
{
const char *p;
/* insert "/" if it's missing */
return name;
}
{
return maildir_get_absolute_path(name);
}
const char *name)
{
return NULL;
return maildir_get_absolute_path(name);
}
/* create or fix maildir, ignore if it already exists */
{
return FALSE;
return FALSE;
}
return TRUE;
}
{
const char *dir;
return TRUE;
return TRUE;
"Can't create directory %s: %m", dir);
return FALSE;
}
return TRUE;
}
{
const char *inbox;
/* first make sure the cur/ new/ and tmp/ dirs exist in root dir */
/* create the .INBOX directory */
"%s: %m", inbox);
return FALSE;
}
/* make sure the index directories exist */
}
static struct mailbox *
{
struct index_mailbox *ibox;
struct mail_index *index;
}
}
const char *name)
{
/* use same case with all INBOX folders or we'll get
into trouble */
}
return name;
}
static struct mailbox *
{
const char *path;
if (!verify_inbox(storage))
return NULL;
}
if (!maildir_is_valid_existing_name(name)) {
return FALSE;
}
/* exists - make sure the required directories are also there */
/* make sure the index directories exist */
name);
return NULL;
} else {
name);
return NULL;
}
}
const char *name)
{
const char *path;
return FALSE;
}
return TRUE;
return FALSE;
} else {
"%s: %m", name);
return FALSE;
}
}
const char *name)
{
int count;
return FALSE;
}
if (!maildir_is_valid_existing_name(name)) {
return FALSE;
}
/* rename the .maildir into ..maildir which marks it as being
deleted. delete indexes before the actual maildir. this way we
never see partially deleted mailboxes. */
name);
return FALSE;
}
"unlink_directory(%s) "
"failed: %m", index_dir);
return FALSE;
}
}
count = 0;
"rename(%s, %s) failed: %m",
return FALSE;
}
/* ..dir already existed? delete it and try again */
"unlink_directory(%s) "
"failed: %m", dest);
return FALSE;
}
count++;
}
"failed: %m", dest);
return FALSE;
}
return TRUE;
}
{
return TRUE;
/* Rename it's index. */
return FALSE;
}
return TRUE;
}
{
struct mailbox_list_context *ctx;
struct mailbox_list *list;
ret = 0;
t_push();
/* FIXME: it's possible to merge two folders if either one of
them doesn't have existing root folder. We could check this
but I'm not sure if it's worth it. It could be even
considered as a feature.
Anyway, the bug with merging is that if both folders have
identically named subfolder they conflict. Just ignore those
and leave them under the old folder. */
ret = 1;
else {
ret = -1;
t_pop();
break;
}
t_pop();
}
if (!maildir_list_mailbox_deinit(ctx))
return -1;
return ret;
}
{
if (!maildir_is_valid_existing_name(oldname) ||
return FALSE;
}
"Renaming INBOX isn't supported.");
return FALSE;
}
/* NOTE: it's possible to rename a nonexisting folder which has
subfolders. In that case we should ignore the rename() error. */
return FALSE;
if (ret < 0)
return FALSE;
"Mailbox doesn't exist");
return FALSE;
}
return TRUE;
}
"Target mailbox already exists");
return FALSE;
} else {
return FALSE;
}
}
const char *name,
enum mailbox_name_status *status)
{
const char *path;
if (!maildir_is_valid_existing_name(name)) {
return TRUE;
}
return TRUE;
}
return TRUE;
}
return TRUE;
} else {
"stat(%s) failed: %m", path);
return FALSE;
}
}
enum mailbox_sync_type sync_type,
unsigned int min_newmail_notify_interval)
{
if (sync_type != MAILBOX_SYNC_NONE) {
}
}
struct mail_storage maildir_storage = {
"maildir", /* name */
'.', /* hierarchy_sep - can't be changed */
NULL,
NULL,
NULL,
NULL,
NULL,
0
};
struct mailbox maildir_mailbox = {
NULL, /* name */
NULL, /* storage */
};