mail-cache.h revision 6f73af3a3a6ee900c7e736874587968d76a20bc0
#ifndef MAIL_CACHE_H
#define MAIL_CACHE_H
#include "mail-index.h"
#define MAIL_CACHE_FILE_SUFFIX ".cache"
struct mail_cache;
struct mail_cache_view;
struct mail_cache_transaction_ctx;
enum mail_cache_decision_type {
/* Not needed currently */
MAIL_CACHE_DECISION_NO = 0x00,
/* Needed only for new mails. Drop when compressing. */
MAIL_CACHE_DECISION_TEMP = 0x01,
/* Needed. */
MAIL_CACHE_DECISION_YES = 0x02,
/* This decision has been forced manually, don't change it. */
MAIL_CACHE_DECISION_FORCED = 0x80
};
enum mail_cache_field_type {
};
struct mail_cache_field {
const char *name;
unsigned int idx;
enum mail_cache_field_type type;
unsigned int field_size;
};
/* Register fields. fields[].idx is updated to contain field index. */
struct mail_cache_field *fields,
unsigned int fields_count);
/* Returns registered field index, or (unsigned int)-1 if not found. */
unsigned int
/* Returns a list of all registered fields */
const struct mail_cache_field *
unsigned int *count_r);
/* Returns TRUE if cache should be compressed. */
/* Compress cache file. Offsets are updated to given transaction. */
struct mail_index_transaction *trans);
struct mail_cache_view *
/* Get index transaction specific cache transaction. */
struct mail_cache_transaction_ctx *
struct mail_index_transaction *t);
/* Add new field to given record. Updates are not allowed. Fixed size fields
must be exactly the expected size. */
/* Returns TRUE if field is wanted to be added and it doesn't already exist.
If current caching decisions say not to cache this field, FALSE is returned.
If seq is 0, the existence isn't checked. */
/* Like mail_cache_field_want_add(), but in caching decisions FALSE is
returned only if the decision is a forced no. */
/* Retursn 1 if field exists, 0 if not, -1 if error. */
unsigned int field_idx);
/* Returns current caching decision for given field. */
/* Set data_r and size_r to point to wanted field in cache file.
Returns 1 if field was found, 0 if not, -1 if error. */
/* Return specified cached headers. Returns 1 if all fields were found,
0 if not, -1 if error. dest is updated only if all fields were found. */
unsigned int fields_count);
/* "Error in index cache file %s: ...". */
#endif