mail-index.c revision 0b38c17fb10e2ad1d081369d34b93d0448d971a2
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen/* Copyright (C) 2003-2004 Timo Sirainen */
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainenstatic int mail_index_try_open_only(struct mail_index *index);
473080c7c0d25ddfdf77e7dfa0ba8f73c6c669d5Timo Sirainenstruct mail_index *mail_index_alloc(const char *dir, const char *prefix)
49e513d090753ccbf95560b2f3a21f081a5b6c51Timo Sirainen index->extension_pool = pool_alloconly_create("extension", 256);
473080c7c0d25ddfdf77e7dfa0ba8f73c6c669d5Timo Sirainen index->extensions = buffer_create_dynamic(index->extension_pool, 64);
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen index->sync_handlers = buffer_create_dynamic(default_pool, 64);
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen index->sync_lost_handlers = buffer_create_dynamic(default_pool, 64);
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen index->expunge_handlers = buffer_create_dynamic(default_pool, 32);
66d2db642fe24d555d113ba463e446b038d476efTimo Sirainenvoid mail_index_set_permissions(struct mail_index *index,
356303df200c991580bd24041996a070ad08c05eTimo Sirainenuint32_t mail_index_ext_register(struct mail_index *index, const char *name,
356303df200c991580bd24041996a070ad08c05eTimo Sirainen unsigned int i;
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen extensions = buffer_get_data(index->extensions, &ext_count);
49e513d090753ccbf95560b2f3a21f081a5b6c51Timo Sirainen sizeof(struct mail_index_sync_handler) == ext_count);
22535a9e685e29214082878e37a267157044618eTimo Sirainen /* see if it's already there */
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen for (i = 0; i < ext_count; i++) {
22535a9e685e29214082878e37a267157044618eTimo Sirainen ext.name = p_strdup(index->extension_pool, name);
9f431ccfb6932746db56245c8a3d3415717ef545Timo Sirainen buffer_append(index->extensions, &ext, sizeof(ext));
1f1e81aab38d833d1c9cdc244c91fd762e0080d4Timo Sirainenvoid mail_index_register_expunge_handler(struct mail_index *index,
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen buffer_write(index->expunge_handlers, ext_id * sizeof(cb),
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainenvoid mail_index_register_sync_handler(struct mail_index *index, uint32_t ext_id,
struct mail_index_sync_handler h;
memset(&h, 0, sizeof(h));
unsigned int initial_count)
for (i = 0; i < size; i++) {
idx = 0;
return idx;
return FALSE;
return TRUE;
unsigned int i, old_count;
const char *name;
for (i = 0; i < old_count; i++)
t_push();
t_pop();
#ifndef WORDS_BIGENDIAN
(int)sizeof(keywords_mask_t));
sizeof(struct mail_index_record));
unsigned int records_count;
int ret;
if (ret > 0)
return ret;
if (ret > 0) {
if (ret < 0) {
if (ret == 0) {
int sync_to_index)
const void *tdata;
if (sync_to_index) {
MAIL_TRANSACTION_TYPE_MASK) < 0) {
&skipped)) > 0) {
&prev_offset);
if (sync_to_index) {
int sync_to_index)
if (ret != 0)
return ret;
for (i = 0; i < size; i++)
for (i = 0; i < MAIL_INDEX_ESTALE_RETRY_COUNT; i++) {
return ret;
if (ret <= 0) {
if (ret == 0) {
int ret;
if (ret != 0)
return ret;
if (ret <= 0) {
return ret;
if (ret < 0) {
if (ret == 0)
struct mail_index_map *
unsigned int i, count;
NULL);
for (i = 0; i < count; i++) {
return mem_map;
unsigned int lock_id;
int ret;
*lock_id_r = 0;
if (ret <= 0)
return ret;
if (ret == 0) {
*lock_id_r = 0;
return ret;
const char *path;
int fd;
return fd;
const char *path;
int ret;
if (ret != 0) {
/* create it fully in index.tmp first */
if (ret == 0) {
if (ret < 0) {
return ret;
#ifndef WORDS_BIGENDIAN
unsigned int lock_id = 0;
int ret;
if (ret > 0)
else if (ret == 0) {
} else if (ret < 0)
if (lock_id != 0) {
lock_id = 0;
if (lock_id == 0) {
int i = 0, ret;
if (ret <= 0)
if (ret == 0) {
if (ret <= 0)
return ret;
ret = 0;
if (ret > 0)
else if (ret == 0) {
if (ret == 0) {
if (lock_id != 0)
if (ret == 0) {
return ret;
unsigned int lock_id;
int ret;
const char *function)
const char *filepath,
const char *function)
return MAIL_INDEX_ERROR_DISKSPACE;
return MAIL_INDEX_ERROR_INTERNAL;
return MAIL_INDEX_ERROR_NONE;