index-storage.c revision 83befbf24132d0c5780605652a8c2c3f0d35a62d
/* Copyright (C) 2002 Timo Sirainen */
#include "lib.h"
#include "ioloop.h"
#include "mail-index.h"
#include "mail-index-util.h"
#include "mail-custom-flags.h"
#include "index-storage.h"
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
/* How many seconds to keep index opened for reuse after it's been closed */
#define INDEX_CACHE_TIMEOUT 10
/* How many closed indexes to keep */
#define INDEX_CACHE_MAX 3
#define LOCK_NOTIFY_INTERVAL 30
struct index_list {
struct index_list *next;
struct mail_index *index;
int refcount;
};
{
struct index_list *list;
}
{
struct mail_index *match;
int destroy_count;
return NULL;
/* compare inodes so we don't break even with symlinks */
}
}
destroy_count >= INDEX_CACHE_MAX) {
continue;
} else {
}
}
}
return match;
}
{
struct index_list *list;
return;
}
}
i_unreached();
}
void index_storage_destroy_unrefed(void)
{
} else {
}
}
}
{
static const char *field_names[] = {
"Location",
"Envelope",
"Body",
"Bodystructure",
"MD5",
"MessagePart",
};
const char *const *arr;
enum mail_data_field ret;
int i;
return 0;
ret = 0;
if (*arr == '\0')
continue;
for (i = 0; field_names[i] != NULL; i++) {
ret |= 1 << i;
break;
}
}
if (field_names[i] == NULL) {
i_error("Invalid cache field name '%s', ignoring ",
*arr);
}
}
return ret;
}
static enum mail_data_field get_default_cache_fields(void)
{
static enum mail_data_field ret = 0;
if (ret_set)
return ret;
return ret;
}
static enum mail_data_field get_never_cache_fields(void)
{
static enum mail_data_field ret = 0;
if (ret_set)
return ret;
return ret;
}
{
const char *str;
if ((secs_left % 15) != 0) {
/* update alarm() so that we get back here around the same
time we want the next notify. also try to use somewhat
rounded times. this affects only fcntl() locking, dotlock
and flock() calls should be calling us constantly */
}
/* if notify type changes, print the message immediately */
/* first override notification, show it */
} else {
return;
}
}
switch (notify_type) {
"%u seconds", secs_left);
break;
"will override in %u seconds", secs_left);
break;
"%u seconds", secs_left);
break;
}
}
{
}
enum mail_lock_type lock_type)
{
int ret;
may be used by multiple IndexMailboxes. */
if (!ret)
return mail_storage_set_index_error(ibox);
return TRUE;
}
struct index_mailbox *
{
struct index_mailbox *ibox;
enum mail_index_open_flags flags;
do {
/* open the index first */
if (fast)
if (!readonly)
break;
if (INDEX_IS_IN_MEMORY(index) &&
"Couldn't use index files",
}
}
break;
break;
return ibox;
} while (0);
return NULL;
}
{
/* make sure we're unlocked */
return TRUE;
}
struct mail_storage_callbacks *callbacks,
void *context)
{
sizeof(struct mail_storage_callbacks));
}
{
case MAIL_INDEX_ERROR_NONE:
break;
break;
break;
"Timeout while waiting for lock to index of mailbox %s",
break;
"Timeout while waiting for lock to mailbox %s",
break;
}
return FALSE;
}
enum mail_flags *flags,
const char *custom_flags[],
unsigned int custom_flags_count)
{
int ret;
switch (ret) {
case 1:
return TRUE;
case 0:
"Maximum number of different custom flags exceeded");
return FALSE;
default:
return mail_storage_set_index_error(ibox);
}
}
{
struct mail_index_header *hdr;
struct mail_index_record *rec;
unsigned int seq;
/* all are recent */
return hdr->messages_count;
}
/* get the first recent message */
return 0;
}