cydir-storage.c revision d22301419109ed4a38351715e6760011421dadec
/* Copyright (c) 2007-2010 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "str.h"
#include "mkdir-parents.h"
#include "index-mail.h"
#include "mail-copy.h"
#include "cydir-sync.h"
#include "cydir-storage.h"
#include <unistd.h>
#include <dirent.h>
#define CYDIR_LIST_CONTEXT(obj) \
struct cydir_mailbox_list {
};
extern struct mail_storage cydir_storage;
extern struct mailbox cydir_mailbox;
static struct mail_storage *cydir_storage_alloc(void)
{
struct cydir_storage *storage;
}
static void
struct mailbox_list_settings *set)
{
}
static struct mailbox *
enum mailbox_flags flags)
{
struct cydir_mailbox *mbox;
struct index_mailbox_context *ibox;
/* cydir can't work without index files */
}
{
"cydir doesn't support streamed mailboxes");
return -1;
}
/* exists, open it */
/* INBOX always exists, create it */
return -1;
return -1;
return -1;
} else {
return -1;
}
}
static int
bool directory)
{
if (directory &&
return 0;
}
static int
const char *name)
{
struct dirent *d;
unsigned int dir_len;
bool unlinked_something = FALSE;
if (!mailbox_list_set_error_from_errno(list)) {
"opendir(%s) failed: %m", path);
}
return -1;
}
errno = 0;
if (d->d_name[0] == '.') {
/* skip . and .. */
continue;
continue;
}
/* trying to unlink() a directory gives either EPERM or EISDIR
(non-POSIX). it doesn't really work anywhere in practise,
so don't bother stat()ing the file first */
}
}
path);
}
return -1;
}
if (!unlinked_something) {
t_strdup_printf("Directory %s isn't empty, "
"can't delete it.", name));
return -1;
}
return 0;
}
static int
{
const char *src;
/* delete the index and control directories */
return -1;
/* check if the mailbox actually exists */
return -1;
}
}
{
else
}
const char *mailbox_name ATTR_UNUSED,
enum mailbox_list_file_type type,
enum mailbox_info_flags *flags)
{
const char *mail_path;
int ret = 1;
/* try to avoid stat() with these checks */
if (type != MAILBOX_LIST_FILE_TYPE_DIR &&
/* it's a file */
return 0;
}
/* need to stat() then */
/* non-directory */
ret = 0;
/* no subdirectories */
*flags |= MAILBOX_NOCHILDREN;
/* non-default configuration: we have one directory
containing the mailboxes. if there are 3 links,
either this is a selectable mailbox without children
or non-selectable mailbox with children */
*flags |= MAILBOX_CHILDREN;
} else {
/* default configuration: all subdirectories are
child mailboxes. */
*flags |= MAILBOX_CHILDREN;
}
/* doesn't exist - probably a non-existing subscribed mailbox */
*flags |= MAILBOX_NONEXISTENT;
} else {
/* non-selectable. probably either access denied, or symlink
destination not found. don't bother logging errors. */
*flags |= MAILBOX_NOSELECT;
}
return ret;
}
struct mailbox_list *list)
{
struct cydir_mailbox_list *mlist;
}
struct mail_storage cydir_storage = {
.class_flags = 0,
.v = {
NULL,
NULL,
NULL,
NULL,
}
};
struct mailbox cydir_mailbox = {
.v = {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
}
};