mail-storage.c revision 642994cd822c404ef60d2ac374a8804bb9076e6e
/* Copyright (c) 2002-2007 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "array.h"
#include "var-expand.h"
#include "mail-index-private.h"
#include "mailbox-list-private.h"
#include "mail-storage-private.h"
#include "mail-namespace.h"
#include "index/index-storage.h"
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
/* Message to show to users when critical error occurs */
#define CRITICAL_MSG \
"Internal error occurred. Refer to server log for more information."
#define DEFAULT_MAX_KEYWORD_LENGTH 50
struct mail_storage_module_register mail_storage_module_register = { 0 };
struct mail_module_register mail_module_register = { 0 };
void mail_storage_init(void)
{
}
void mail_storage_deinit(void)
{
if (array_is_created(&storages))
}
{
storage_class->v.class_init();
/* append it after the list, so the autodetection order is correct */
}
{
struct mail_storage *const *classes;
unsigned int i, count;
for (i = 0; i < count; i++) {
if (classes[i] == storage_class) {
break;
}
}
storage_class->v.class_deinit();
}
enum file_lock_method *lock_method_r)
{
const char *str;
*flags_r = 0;
if ((*flags_r & MAIL_STORAGE_FLAG_MMAP_DISABLE) == 0)
i_fatal("mail_nfs_index=yes requires mmap_disable=yes");
if ((*flags_r & MAIL_STORAGE_FLAG_FSYNC_DISABLE) != 0)
i_fatal("mail_nfs_index=yes requires fsync_disable=no");
}
else
}
{
struct mail_storage *const *classes;
unsigned int i, count;
for (i = 0; i < count; i++) {
return classes[i];
}
return NULL;
}
static struct mail_storage *
{
struct mail_storage *const *classes;
unsigned int i, count;
for (i = 0; i < count; i++) {
return classes[i];
}
return NULL;
}
static void
enum mail_storage_flags *flags)
{
const char *p;
/* check if data is in driver:data format (eg. mbox:~/mail) */
p = *data;
while (i_isalnum(*p)) p++;
if (*p == ':' && p != *data) {
/* no autodetection if the storage format is given. */
*data = p + 1;
}
}
enum mail_storage_flags flags,
enum file_lock_method lock_method,
const char **error_r)
{
struct mail_storage *const *classes;
unsigned int i, count;
data = "";
/* use the first driver that works */
if (storage_class == NULL) {
"Ambiguous mail location setting, "
"don't know what to do with it: %s "
"(try prefixing it with mbox: or maildir:)",
data);
return -1;
}
classes = &storage_class;
count = 1;
} else {
if (storage_class == NULL) {
"Unknown mail storage driver %s", driver);
return -1;
}
classes = &storage_class;
count = 1;
}
for (i = 0; i < count; i++) {
break;
i_info("%s: Couldn't create mail storage %s: %s",
}
/* try the next one */
}
if (i == count) {
if (count <= 1) {
*error_r);
return -1;
}
"Mail storage autodetection failed with home=%s", home);
return -1;
}
if (hook_mail_storage_created != NULL)
return 0;
}
{
}
{
}
{
}
{
char str[256];
}
const char *fmt, ...)
{
/* critical errors may contain sensitive data, so let user
see only "Internal error" with a timestamp to make it
easier to look from log files the actual error message. */
}
}
{
}
{
}
{
}
struct mail_storage_callbacks *callbacks,
void *context)
{
}
bool directory)
{
"Invalid mailbox name");
return -1;
}
}
enum mail_error *error_r)
{
/* We get here only in error situations, so we have to return some
error. If storage->error is NONE, it means we forgot to set it at
some point.. */
"BUG: Unknown internal error";
}
/* This shouldn't happen.. */
i_strdup_printf("BUG: Unknown 0x%x error",
}
return storage->error_string;
}
{
if (*name == '\0')
}
const char *name)
{
if (*name == '\0')
}
const char *name)
{
if (*name == '\0')
}
enum mailbox_list_flags
{
enum mailbox_list_flags list_flags = 0;
if ((storage_flags & MAIL_STORAGE_FLAG_DEBUG) != 0)
if ((storage_flags & MAIL_STORAGE_FLAG_FULL_FS_ACCESS) != 0)
if ((storage_flags & MAIL_STORAGE_FLAG_DOTLOCK_USE_EXCL) != 0)
if ((storage_flags & MAIL_STORAGE_FLAG_NFS_FLUSH_STORAGE) != 0)
return list_flags;
}
{
const char *error_string;
enum mail_error error;
return FALSE;
return TRUE;
}
enum mailbox_open_flags flags)
{
"Invalid mailbox name");
return NULL;
}
t_push();
t_pop();
return box;
}
{
if (box->transaction_count != 0) {
i_panic("Trying to close mailbox %s with open transactions",
}
}
{
}
{
}
{
}
{
}
enum mailbox_status_items items,
struct mailbox_status *status_r)
{
}
struct mailbox_sync_context *
{
}
struct mailbox_sync_rec *sync_rec_r)
{
}
struct mailbox_status *status_r)
{
}
struct mailbox_status *status_r)
{
struct mailbox_sync_context *ctx;
struct mailbox_sync_rec sync_rec;
/* we don't care about mailbox's current state, so we might as well
fix inconsistency state */
;
}
{
}
{
}
struct mail_keywords **keywords_r)
{
const char *empty_keyword_list = NULL;
}
struct mail_keywords *
const char *const keywords[])
{
const char *empty_keyword_list = NULL;
struct mail_keywords *kw;
i_unreached();
return kw;
}
struct mail_keywords **_keywords)
{
}
{
}
struct mailbox_header_lookup_ctx *
{
}
{
}
struct mail_search_context *
mailbox_search_init(struct mailbox_transaction_context *t,
const enum mail_sort_type *sort_program)
{
}
{
}
{
bool tryagain;
int ret;
&tryagain)) == 0) {
if (!tryagain)
break;
}
return ret;
}
{
}
struct mailbox_transaction_context *
{
box->transaction_count++;
}
int mailbox_transaction_commit(struct mailbox_transaction_context **t)
{
}
{
struct mailbox_transaction_context *t = *_t;
t->box->transaction_count--;
}
{
struct mailbox_transaction_context *t = *_t;
t->box->transaction_count--;
t->box->v.transaction_rollback(t);
}
{
return box->transaction_count;
}
int mailbox_save_init(struct mailbox_transaction_context *t,
{
"Saving messages not supported");
return -1;
}
return -1;
return 0;
}
{
}
{
}
{
}
{
}
{
}