mail-index.c revision d562b19ab5d69e0352281d84da7d28b563d8bf19
5394bed8aaef2a6c1c870a34a23a7824e1f370bbStephan Bosch/* Copyright (C) 2003-2004 Timo Sirainen */
5394bed8aaef2a6c1c870a34a23a7824e1f370bbStephan Boschstatic int mail_index_try_open_only(struct mail_index *index);
5394bed8aaef2a6c1c870a34a23a7824e1f370bbStephan Boschstruct mail_index *mail_index_alloc(const char *dir, const char *prefix)
5394bed8aaef2a6c1c870a34a23a7824e1f370bbStephan Bosch pool_alloconly_create("extra_record_pool", 256);
5394bed8aaef2a6c1c870a34a23a7824e1f370bbStephan Bosch buffer_create_dynamic(index->extra_records_pool,
5394bed8aaef2a6c1c870a34a23a7824e1f370bbStephan Bosch index->max_record_size = sizeof(struct mail_index_record);
e641c9f656f1788ca6226ef0d60b2d592e2ca6d1Stephan Boschuint32_t mail_index_register_record_extra(struct mail_index *index,
d82ad7143c057c565e1fd5f3580645556ed0bcc9Stephan Bosch unsigned int i;
d82ad7143c057c565e1fd5f3580645556ed0bcc9Stephan Bosch /* see if it's there already */
4356563bc3261a4043ec736cb1009373d37a617cStephan Bosch for (i = 0; i < index->extra_records_count; i++) {
4356563bc3261a4043ec736cb1009373d37a617cStephan Bosch if (strcmp(index->extra_records[i].name, name) == 0) {
4356563bc3261a4043ec736cb1009373d37a617cStephan Bosch i_assert(index->extra_records[i].size == size);
d82ad7143c057c565e1fd5f3580645556ed0bcc9Stephan Bosch i_assert(index->max_record_size + size <= 65535);
92c2272787b74eb000f05a926e9103a25a6a0dc0Stephan Bosch if (index->extra_records_count >= MAIL_INDEX_MAX_EXTRA_RECORDS) {
d82ad7143c057c565e1fd5f3580645556ed0bcc9Stephan Bosch i_panic("Maximum extra record count reached, "
5394bed8aaef2a6c1c870a34a23a7824e1f370bbStephan Bosch "you'll need to recompile with larger limit. "
5394bed8aaef2a6c1c870a34a23a7824e1f370bbStephan Bosch "MAIL_INDEX_MAX_EXTRA_RECORDS = %d",
d82ad7143c057c565e1fd5f3580645556ed0bcc9Stephan Bosch info.name = p_strdup(index->extra_records_pool, name);
a952a4444e46e107b15ab1bd0e8b63a29f94b123Timo Sirainen buffer_append(index->extra_records_buf, &info, sizeof(info));
c911297407bdcc7c7936305eb8f791b450d6375cTimo Sirainen buffer_get_data(index->extra_records_buf, &buf_size);
5394bed8aaef2a6c1c870a34a23a7824e1f370bbStephan Bosch index->extra_records_count = buf_size / sizeof(info);
#ifndef WORDS_BIGENDIAN
(int)sizeof(keywords_mask_t));
sizeof(struct mail_index_record));
unsigned int records_count;
if (ret > 0)
if (ret < 0) {
if (ret == 0) {
int i, ret;
for (i = 0; i < MAIL_INDEX_ESTALE_RETRY_COUNT; i++) {
if (ret != 0)
return ret;
if (ret <= 0) {
if (ret == 0) {
int ret;
return ret;
if (ret < 0) {
if (ret == 0)
struct mail_index_map *
return map;
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;
const char *function)
const char *filepath,
const char *function)
return MAIL_INDEX_ERROR_DISKSPACE;
return MAIL_INDEX_ERROR_INTERNAL;
return MAIL_INDEX_ERROR_NONE;