mbox-storage.c revision a6fb32ab244ac12ba3d1f091a1a53d12b710ada6
/* Copyright (C) 2002 Timo Sirainen */
#include "lib.h"
#include "unlink-directory.h"
#include "subscription-file/subscription-file.h"
#include "mail-custom-flags.h"
#include "mbox-index.h"
#include "mbox-lock.h"
#include "mbox-storage.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
extern MailStorage mbox_storage;
extern Mailbox mbox_mailbox;
static int mbox_autodetect(const char *data)
{
const char *path;
return TRUE;
return TRUE;
return TRUE;
return FALSE;
}
{
/* we'll need to figure out the mail location ourself.
it's root dir if we've already chroot()ed, otherwise
if (mbox_autodetect(""))
data = "/";
else {
else {
}
}
}
}
return NULL;
return storage;
}
{
}
{
const char *p;
int newdir;
return FALSE;
/* make sure there's no "../" or "..\" stuff */
for (p = name; *p != '\0'; p++) {
(p[2] == '/' || p[2] == '\\'))
return FALSE;
}
return TRUE;
}
static const char *mbox_get_index_dir(const char *mbox_path)
{
const char *p, *rootpath;
if (p == NULL)
else {
}
}
{
return FALSE;
return FALSE;
return TRUE;
}
{
char path[1024];
int fd;
/* make sure inbox file itself exists */
if (fd != -1)
/* make sure the index directories exist */
}
{
}
}
}
{
char path[1024];
/* INBOX is always case-insensitive */
/* make sure inbox exists */
}
return FALSE;
}
/* exists - make sure the required directories are also there */
name);
return NULL;
} else {
name);
return NULL;
}
}
{
char path[1024];
int fd;
name = "inbox";
return FALSE;
}
/* make sure it doesn't exist already */
return FALSE;
}
"file %s: %m", path);
return FALSE;
}
/* create the mailbox file */
if (fd != -1) {
return TRUE;
/* mailbox was just created between stat() and open() call.. */
return FALSE;
} else {
"%s: %m", name);
return FALSE;
}
}
{
const char *index_dir;
char path[1024];
return FALSE;
}
return FALSE;
}
/* first unlink the mbox file */
"Mailbox doesn't exist: %s",
name);
} else {
"file %s: %m", path);
}
return FALSE;
}
/* next delete the index directory */
"failed: %m", index_dir);
return FALSE;
}
return TRUE;
}
const char *newname)
{
const char *old_indexdir, *new_indexdir;
return FALSE;
}
oldname = "inbox";
/* NOTE: renaming INBOX works just fine with us, it's simply created
the next time it's needed. */
/* ... */
"Target mailbox already exists");
return FALSE;
} else {
return FALSE;
}
/* we need to rename the index directory as well */
return TRUE;
}
{
char path[1024];
name = "inbox";
return TRUE;
}
return TRUE;
return TRUE;
} else {
"stat(%s) failed: %m", path);
return FALSE;
}
}
{
/* update flags by rewrite mbox file */
}
}
"mbox", /* name */
'/', /* hierarchy_sep - can't be changed */
NULL,
NULL,
};
Mailbox mbox_mailbox = {
NULL, /* name */
NULL, /* storage */
};