mail-hash.h revision c25356d5978632df6203437e1953bcb29e0c736f
#ifndef MAIL_HASH_H
#define MAIL_HASH_H
#include "hash.h"
#define MAIL_HASH_VERSION 1
struct mail_hash;
/* File format:
[header]
[hash_size * (uint32_t idx)]
[record_count * (struct mail_hash_record)]
The indexes start from 1, so 0 means "doesn't exist".
*/
struct mail_hash_header {
/* File format version */
/* Corrupted flag is set while file is being modified. */
/* Full size of each mail_hash_record */
/* Full header size. Currently always the same as base_header_size. */
/* Number of records after the hash table, includes holes */
/* Number of message records (records with non-zero UID) */
/* Number of messages with non-zero hash */
/* UID validity. */
/* The last UID which has been added to this file (but may have been
expunged already) */
/* Holes is a linked list of unused records */
/* Hash size as a number of elements */
};
struct mail_hash_record {
/* Linked list of records for hash collisions. */
/* UID of the mail this record belongs to, or 0 if nothing.
(uint32_t)-1 means this record is deleted */
/* user_data[] */
};
#define MAIL_HASH_RECORD_IS_DELETED(rec) \
enum mail_hash_open_flags {
MAIL_HASH_OPEN_FLAG_CREATE = 0x01,
};
/* Returns 0 if the pointers are equal. */
void *context);
/* map[] contains old -> new index mapping. */
struct mail_hash *
unsigned int initial_count,
void *context);
#ifdef CONTEXT_TYPE_SAFETY
#else
#endif
/* If reset or resize fails, the hash file is closed and the hash is in
unusable state until mail_hash_lock() succeeds. */
void *context);
/* Lock hash file. Returns 1 if we locked the file, 0 if timeouted or hash
is in memory, -1 if error. */
/* Remember that inserting may cause existing returned values to be
invalidated. If key=NULL, it's not inserted into hash table. Note that
hash=0 equals to key=NULL insert, so a valid hash value must never be 0. */
const void **value_r);
const void *value);
#endif