mail-index-private.h revision 9bc6e10d9c6d6ffb4a2ed49a3b3d2a180f2a87a3
#ifndef __MAIL_INDEX_PRIVATE_H
#define __MAIL_INDEX_PRIVATE_H
#include "file-lock.h"
#include "mail-index.h"
#include "mail-index-view-private.h"
#include "mail-index-transaction-private.h"
struct mail_transaction_header;
struct mail_transaction_log_view;
struct mail_index_sync_map_ctx;
/* How large index files to mmap() instead of reading to memory. */
/* How many seconds to wait a lock for index file. */
#define MAIL_INDEX_LOCK_SECS 120
This happens with NFS when the file has been deleted (ie. index file was
rewritten by another computer than us). */
#define MAIL_INDEX_IS_IN_MEMORY(index) \
#define MAIL_INDEX_MAP_IS_IN_MEMORY(map) \
((struct mail_index_record *) \
void **sync_context, void *context);
#define MAIL_INDEX_HEADER_SIZE_ALIGN(size) \
struct mail_index_ext {
const char *name;
};
struct mail_index_ext_header {
/* unsigned char name[name_size] */
/* unsigned char data[hdr_size] (starting 64bit aligned) */
};
struct mail_index_keyword_header {
/* struct mail_index_keyword_header_rec[] */
/* char name[][] */
};
struct mail_index_keyword_header_rec {
};
enum mail_index_sync_handler_type {
MAIL_INDEX_SYNC_HANDLER_FILE = 0x01,
MAIL_INDEX_SYNC_HANDLER_HEAD = 0x02,
MAIL_INDEX_SYNC_HANDLER_VIEW = 0x04
};
struct mail_index_sync_handler {
};
struct mail_index_registered_ext {
const char *name;
struct mail_index_sync_handler sync_handler;
void *expunge_context;
unsigned int expunge_handler_call_always:1;
};
struct mail_index_map {
int refcount;
struct mail_index_header hdr;
const void *hdr_base;
void *records; /* struct mail_index_record[] */
unsigned int records_count;
void *mmap_base;
/* If this mapping is written to disk and write_atomic=FALSE,
write_seq_* specify the message sequence range that needs to be
written. */
unsigned int keywords_read:1;
unsigned int write_base_header:1;
unsigned int write_ext_header:1;
};
struct mail_index_module_register {
unsigned int id;
};
union mail_index_module_context {
struct mail_index_module_register *reg;
};
struct mail_index {
struct mail_cache *cache;
struct mail_transaction_log *log;
char *filepath;
int fd;
const struct mail_index_header *hdr;
struct mail_index_map *map;
/* last known log_file_tail_offset in main index file. used for
optimizing main index updates. */
unsigned int lock_id;
enum file_lock_method lock_method;
/* Module-specific contexts. */
char *error;
unsigned int nodiskspace:1;
unsigned int index_lock_timeout:1;
unsigned int opened:1;
unsigned int log_locked:1;
unsigned int mmap_disable:1;
unsigned int fsync_disable:1;
unsigned int use_excl_dotlocks:1;
unsigned int readonly:1;
unsigned int fsck:1;
unsigned int mapping:1;
};
extern struct mail_index_module_register mail_index_module_register;
void *context);
enum mail_index_sync_handler_type type);
const struct mail_index_header *hdr);
/* Returns 0 = ok, -1 = error. */
/* Returns 1 = ok, 0 = already locked, -1 = error. */
unsigned int *lock_id_r);
/* Returns TRUE if given lock_id is valid. */
int lock_type, unsigned int timeout_secs,
/* Allocate a new empty map. */
/* Replace index->map with the latest index changes. This may reopen the index
read up to EOF, but non-synced expunges are skipped.
If mapping required reading the index file, it's shared locked and lock_id
is returned. Otherwise returned lock_id is 0.
Returns 1 = ok, 0 = corrupted, -1 = error. If non-fatal problems were found,
1 is returned but index->fsck=TRUE is set. */
unsigned int *lock_id_r);
/* Return the latest index file's header. This should be used only when you
don't want to see later changes from transaction log.
Returns 1 = ok, 0 = corrupted, -1 = error. */
struct mail_index_header *hdr_r);
/* Unreference given mapping and unmap it if it's dropped to zero. */
const char *name);
const struct mail_index_ext *
struct mail_index_map *map);
/* "%s failed with index file %s: %m" */
const char *function);
/* "%s failed with file %s: %m" */
const char *filepath,
const char *function);
#endif