maildir-storage.c revision 07a7ff803d52a39ffd568a2466c04097ef4a47e1
/* Copyright (C) 2002 Timo Sirainen */
#include "lib.h"
#include "home-expand.h"
#include "mkdir-parents.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> [:INBOX=<dir>] [:INDEX=<dir>] [:CONTROL=<dir>] */
if (p == NULL)
else {
do {
p++;
p = strchr(p, ':');
} while (p != NULL);
}
}
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 != '~' &&
}
{
const char *p;
if (p == NULL)
return name;
}
{
}
}
static const char *
{
}
const char *name)
{
return NULL;
return storage->inbox_file;
}
const char *name)
{
}
{
if (verify) {
return TRUE;
"lstat(%s) failed: %m", dir);
return FALSE;
}
}
"mkdir(%s) failed: %m", dir);
}
return FALSE;
}
return TRUE;
}
/* create or fix maildir, ignore if it already exists */
{
return FALSE;
return FALSE;
/* small optimization. if we're verifying, we don't
check that the root dir actually exists unless we
fail here. */
return FALSE;
return FALSE;
}
}
return TRUE;
}
{
const char *dir;
return TRUE;
return TRUE;
return FALSE;
}
return TRUE;
}
{
const char *dir;
return TRUE;
return FALSE;
}
return TRUE;
}
{
const char *inbox;
/* first make sure the cur/ new/ and tmp/ dirs exist
in root dir */
return FALSE;
/* create the .INBOX directory */
return FALSE;
} else {
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 */
return FALSE;
name);
return NULL;
} else {
return NULL;
}
}
const char *name, int only_hierarchy)
{
const char *path;
return FALSE;
}
if (only_hierarchy) {
/* no need to do anything */
return TRUE;
}
"Mailbox already exists");
}
return FALSE;
}
return TRUE;
}
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;
}
/* it can fail with some NFS implementations if indexes are
opened by another session.. can't really help it. */
"unlink_directory(%s) failed: %m", index_dir);
return FALSE;
}
}
count = 0;
return FALSE;
}
/* ..dir already existed? delete it and try again */
"unlink_directory(%s) failed: %m", dest);
return FALSE;
}
count++;
}
"unlink_directory(%s) failed: %m", dest);
/* it's already renamed to ..dir, which means it's deleted
as far as client is concerned. Report success. */
}
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 {
"rename(%s, %s) failed: %m",
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. */
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 {
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 */
};