mail-index-private.h revision 1b3bb8d39686ed24730cbc31cc9a33dc62c8c6c3
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano/* Make sure F_RDLCK, F_WRLCK and F_UNLCK get defined */
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano/* How many seconds to wait a lock for index file. */
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano/* Index file is grown exponentially when we're adding less than this many
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano records. */
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano#define MAIL_INDEX_MAX_POWER_GROW (1024*1024 / sizeof(struct mail_index_record))
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano/* How many times to retry opening index files if read/fstat returns ESTALE.
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano This happens with NFS when the file has been deleted (ie. index file was
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano rewritten by another computer than us). */
99e4008cad9e959b683c6f48411fcf15a92be3b5Michel Normand PTR_OFFSET((map)->records, (idx) * (map)->hdr.record_size))
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanotypedef int mail_index_expunge_handler_t(struct mail_index_sync_map_ctx *ctx,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanotypedef int mail_index_sync_handler_t(struct mail_index_sync_map_ctx *ctx,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano const char *name;
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano /* unsigned char name[] */
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano const void *hdr_base;
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano buffer_t *extensions; /* struct mail_index_ext[] */
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano buffer_t *ext_id_map; /* uint32_t[] (index -> file) */
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano buffer_t *extensions; /* struct mail_index_ext[] */
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano buffer_t *expunge_handlers; /* mail_index_expunge_handler_t*[] */
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano buffer_t *sync_handlers; /* mail_index_sync_handler_t*[] */
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano unsigned int lock_id;
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano/* Add/replace sync handler for specified extra record. */
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanovoid mail_index_register_expunge_handler(struct mail_index *index,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanovoid mail_index_register_sync_handler(struct mail_index *index, uint32_t ext_id,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoint mail_index_write_base_header(struct mail_index *index,
99e4008cad9e959b683c6f48411fcf15a92be3b5Michel Normandint mail_index_reopen(struct mail_index *index, int fd);
99e4008cad9e959b683c6f48411fcf15a92be3b5Michel Normandint mail_index_create_tmp_file(struct mail_index *index, const char **path_r);
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano/* Returns 0 = ok, -1 = error. If update_index is TRUE, reopens the index
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano file if needed to get later version of it (not necessarily latest due to
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano races, unless transaction log is exclusively locked). */
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoint mail_index_lock_shared(struct mail_index *index, int update_index,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano unsigned int *lock_id_r);
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano/* Returns 0 = ok, -1 = error. */
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoint mail_index_lock_exclusive(struct mail_index *index,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano unsigned int *lock_id_r);
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanovoid mail_index_unlock(struct mail_index *index, unsigned int lock_id);
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano/* Returns 1 if given lock_id is valid, 0 if not. */
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoint mail_index_is_locked(struct mail_index *index, unsigned int lock_id);
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoint mail_index_lock_fd(struct mail_index *index, int fd, int lock_type,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano unsigned int timeout_secs);
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano/* Map index file to memory, replacing the previous mapping for index.
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano Returns 1 = ok, 0 = corrupted, -1 = error. If index needs fscking, it
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano returns 1 but sets index->fsck = TRUE. */
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoint mail_index_map(struct mail_index *index, int force);
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano/* Unreference given mapping and unmap it if it's dropped to zero. */
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanovoid mail_index_unmap(struct mail_index *index, struct mail_index_map *map);
const char *name);
const struct mail_index_ext *
const char *function);
const char *filepath,
const char *function);