mail-cache.h revision 56f45b3f3ae20e5c933701f4657dda5ef1916855
#ifndef __MAIL_CACHE_H
#define __MAIL_CACHE_H
#include "mail-index.h"
#define MAIL_CACHE_FILE_PREFIX ".cache"
#define MAIL_CACHE_HEADERS_COUNT 4
struct mail_cache;
struct mail_cache_view;
struct mail_cache_transaction_ctx;
enum mail_cache_record_flag {
/* If binary flags are set, it's not checked whether mail is
missing CRs. So this flag may be set as an optimization for
regular non-binary mails as well if it's known that it contains
valid CR+LF line breaks. */
MAIL_INDEX_FLAG_BINARY_HEADER = 0x0001,
MAIL_INDEX_FLAG_BINARY_BODY = 0x0002,
/* Mail header or body is known to contain NUL characters. */
MAIL_INDEX_FLAG_HAS_NULS = 0x0004,
/* Mail header or body is known to not contain NUL characters. */
MAIL_INDEX_FLAG_HAS_NO_NULS = 0x0008
};
enum mail_cache_field {
/* fixed size fields */
MAIL_CACHE_INDEX_FLAGS = 0x00000001,
MAIL_CACHE_SENT_DATE = 0x00000008,
MAIL_CACHE_RECEIVED_DATE = 0x00000010,
MAIL_CACHE_VIRTUAL_FULL_SIZE = 0x00000020,
/* variable sized field */
MAIL_CACHE_HEADERS1 = 0x40000000,
MAIL_CACHE_HEADERS2 = 0x20000000,
MAIL_CACHE_HEADERS3 = 0x10000000,
MAIL_CACHE_HEADERS4 = 0x08000000,
MAIL_CACHE_LOCATION = 0x04000000,
MAIL_CACHE_BODY = 0x02000000,
MAIL_CACHE_BODYSTRUCTURE = 0x01000000,
MAIL_CACHE_ENVELOPE = 0x00800000,
MAIL_CACHE_MESSAGEPART = 0x00400000,
};
struct mail_sent_date {
};
/* Compress cache file. */
/* Reset the cache file, clearing all data. */
/* Explicitly lock the cache file. Returns -1 if error, 1 if ok,
0 if we couldn't lock (nonblock = TRUE or index file needs a cache reset) */
/* Returns TRUE if cache file is locked. */
/* Returns TRUE if index's cache_file_seq doesn't match the latest cache file */
struct mail_cache_view *
/* Begin transaction. Cache transaction may be committed or rollbacked multiple
times. It will finish when index transaction is committed or rollbacked.
The transaction might also be partially committed automatically, so this
is kind of fake transaction, it's only purpose being optimizing writes.
Returns same as mail_cache_lock(). */
struct mail_index_transaction *t,
struct mail_cache_transaction_ctx **ctx_r);
/* Should be called only by mail_transaction_commit/rollback: */
/* Return NULL-terminated list of headers for given index, or NULL if
header index isn't used. */
unsigned int idx);
/* Set list of headers for given index. */
/* Add new field to given record. Updates are not allowed. Fixed size fields
must be exactly the expected size and they're converted to network byte
order in disk. */
enum mail_cache_field field,
/* Mark the given record deleted. */
/* Return all fields that are currently cached for record. */
enum mail_cache_field
/* Set data_r and size_r to point to wanted field in cache file.
Returns TRUE if field was found. If field contains multiple fields,
first one found is returned. This is mostly useful for finding headers. */
enum mail_cache_field field,
/* Return string field. */
const char *
enum mail_cache_field field);
/* Copy fixed size field to given buffer. buffer_size must be exactly the
expected size. The result will be converted to host byte order.
Returns TRUE if field was found. */
enum mail_cache_field field,
/* Mark given fields as missing, ie. they should be cached when possible. */
enum mail_cache_field fields);
/* Return record flags. */
/* Update record flags. The cache file must be locked and the flags must be
already inserted to the record. */
enum mail_cache_record_flag flags);
/* "Error in index cache file %s: ...". */
#endif