mail-index.c revision 9fc077d3886b1584019bcc9b92c717cfffce5c67
bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (C) 2003-2004 Timo Sirainen */
b565a6a7a66fb9f224d00c06a950e3c1c585c18eTimo Sirainenstatic int mail_index_try_open_only(struct mail_index *index);
b565a6a7a66fb9f224d00c06a950e3c1c585c18eTimo Sirainenstatic void mail_index_create_in_memory(struct mail_index *index,
b565a6a7a66fb9f224d00c06a950e3c1c585c18eTimo Sirainenstruct mail_index *mail_index_alloc(const char *dir, const char *prefix)
b565a6a7a66fb9f224d00c06a950e3c1c585c18eTimo Sirainen index->extension_pool = pool_alloconly_create("extension", 512);
b565a6a7a66fb9f224d00c06a950e3c1c585c18eTimo Sirainen ARRAY_CREATE(&index->extensions, index->extension_pool,
9929820d587fb6aa527a6baf89267b06950921c2Timo Sirainen ARRAY_CREATE(&index->expunge_handlers, default_pool,
b565a6a7a66fb9f224d00c06a950e3c1c585c18eTimo Sirainen ARRAY_CREATE(&index->sync_handlers, default_pool,
9929820d587fb6aa527a6baf89267b06950921c2Timo Sirainen ARRAY_CREATE(&index->sync_lost_handlers, default_pool,
9929820d587fb6aa527a6baf89267b06950921c2Timo Sirainen mail_index_ext_register(index, "keywords", 128, 2, 1);
b565a6a7a66fb9f224d00c06a950e3c1c585c18eTimo Sirainen index->keywords_pool = pool_alloconly_create("keywords", 512);
b565a6a7a66fb9f224d00c06a950e3c1c585c18eTimo Sirainen ARRAY_CREATE(&index->keywords, default_pool, const char *, 16);
b565a6a7a66fb9f224d00c06a950e3c1c585c18eTimo Sirainen hash_create(default_pool, index->keywords_pool, 0,
b565a6a7a66fb9f224d00c06a950e3c1c585c18eTimo Sirainen strcase_hash, (hash_cmp_callback_t *)strcasecmp);
b565a6a7a66fb9f224d00c06a950e3c1c585c18eTimo Sirainenvoid mail_index_set_permissions(struct mail_index *index,
b565a6a7a66fb9f224d00c06a950e3c1c585c18eTimo Sirainenuint32_t mail_index_ext_register(struct mail_index *index, const char *name,
unsigned int i, ext_count;
for (i = 0; i < ext_count; i++) {
return ext_count;
*p = cb;
*p = NULL;
struct mail_index_sync_handler *h;
struct mail_index_sync_handler *h;
h->type = 0;
unsigned int i, count;
for (i = 0; i < count; i++) {
unsigned int initial_count)
sizeof(struct mail_index_ext) +
sizeof(uint32_t));
unsigned int i, size;
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();
t_pop();
t_pop();
unsigned int *idx_r)
char *keyword_dup;
void *value;
return TRUE;
if (!autocreate) {
return FALSE;
return TRUE;
const char *name;
#ifdef DEBUG
const unsigned int *old_idx;
unsigned int idx;
unsigned int idx;
#ifndef WORDS_BIGENDIAN
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)
unsigned int i, count;
if (ret != 0)
return ret;
for (i = 0; i < count; 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) {
if (ret < 0)
ret = 0;
else if (ret == 0) {
if (ret <= 0) {
return ret;
int ret;
if (ret > 0)
return ret;
struct mail_index_map *
unsigned int i, count;
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;
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;