maildir-storage.c revision 162677af0091c924cb7266e23978e342982f7d05
/* Copyright (C) 2002 Timo Sirainen */
#include "lib.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>
typedef struct {
int found;
const char *newname;
extern MailStorage maildir_storage;
extern Mailbox maildir_mailbox;
{
/* 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)
{
}
{
}
{
}
/* create or fix maildir, ignore if it already exists */
{
return FALSE;
return FALSE;
}
return TRUE;
}
{
const char *dir;
return TRUE;
"Can't create directory %s: %m", dir);
return FALSE;
}
return TRUE;
}
{
/* first make sure the cur/ new/ and tmp/ dirs exist in root dir */
/* create the .INBOX directory */
"%s: %m", inbox);
return FALSE;
}
/* then symlink the cur/ new/ and tmp/ into the .INBOX/ directory */
return FALSE;
}
}
/* make sure the index directories exist */
}
{
}
}
}
{
/* use same case with all INBOX folders or we'll get
into trouble */
}
return name;
}
{
const char *path;
if (!verify_inbox(storage))
return NULL;
}
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 *path;
return FALSE;
}
return TRUE;
return FALSE;
} else {
"%s: %m", name);
return FALSE;
}
}
{
int count;
return FALSE;
}
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;
}
{
/* newpath points to the destination folder directory, which contains
symlinks to real INBOX directories. unlink() the symlinks and
move the real cur/ directory here. */
"unlink(%s) failed: %m",
newpath);
return FALSE;
}
}
return FALSE;
}
/* create back the cur/ directory for INBOX */
return TRUE;
}
{
return TRUE;
/* Rename it's index. */
return FALSE;
}
return TRUE;
}
{
/* 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. */
else {
}
}
const char *newname)
{
int ret;
return FALSE;
}
/* NOTE: renaming INBOX works just fine with us, it's simply created
the next time it's needed. Only problem with it is that it's not
atomic operation but that can't be really helped.
NOTE: it's possible to rename a nonexisting folder which has
subfolders. In that case we should ignore the rename() error. */
return FALSE;
rename_subfolder, &ctx))
return FALSE;
"Mailbox doesn't exist");
return FALSE;
}
return TRUE;
}
"Target mailbox already exists");
return FALSE;
} else {
return FALSE;
}
}
const char *name,
{
const char *path;
return TRUE;
}
return TRUE;
return TRUE;
} else {
"stat(%s) failed: %m", path);
return FALSE;
}
}
"maildir", /* name */
'.', /* hierarchy_sep - can't be changed */
NULL,
NULL,
NULL,
NULL,
NULL,
0
};
NULL, /* name */
NULL, /* storage */
};