mail-index-map.c revision 7bd72e4deca3cbf757dd1ea298486d9f3bc24226
/* Copyright (c) 2003-2009 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "str-sanitize.h"
#include "mmap-util.h"
#include "mail-index-private.h"
#include "mail-index-modseq.h"
unsigned int initial_count)
{
#define EXTENSION_NAME_APPROX_LEN 20
#define EXT_GLOBAL_ALLOC_SIZE \
#define EXT_PER_ALLOC_SIZE \
sizeof(struct mail_index_ext) + sizeof(uint32_t))
} else {
/* try to use the existing pool's size for initial_count so
we don't grow it unneededly */
}
}
}
{
const struct mail_index_ext *ext;
return FALSE;
ext);
}
return TRUE;
}
}
return FALSE;
}
unsigned int mail_index_map_ext_hdr_offset(unsigned int name_len)
{
return MAIL_INDEX_HEADER_SIZE_ALIGN(size);
}
const struct mail_index_ext_header *ext_hdr)
{
struct mail_index_ext *ext;
idx = 0;
} else {
}
/* Update index ext_id -> map ext_id mapping. Fill non-used
ext_ids with (uint32_t)-1 */
return idx;
}
unsigned int *offset_p,
const struct mail_index_ext_header **ext_hdr_r,
const char **name_r)
{
const struct mail_index_ext_header *ext_hdr;
unsigned int offset, name_offset;
*name_r = "";
/* Extension header contains:
- struct mail_index_ext_header
- name (not 0-terminated)
- 64bit alignment padding
- extension header contents
- 64bit alignment padding
*/
return -1;
return -1;
/* we allow only plain ASCII names, so this extension
is most likely broken */
*name_r = "";
}
/* finally make sure that the hdr_size is small enough.
do this last so that we could return a usable name. */
return -1;
return 0;
}
const struct mail_index_ext_header *ext_hdr,
{
*error_r = "Invalid field values";
return -1;
}
if (*name == '\0') {
*error_r = "Broken name";
return -1;
}
/* if we get here from extension introduction, record_offset=0 and
hdr->record_size hasn't been updated yet */
if (ext_hdr->record_offset != 0 &&
"outside record size (%u+%u > %u)",
hdr->record_size);
return -1;
}
if (ext_hdr->record_size > 0 &&
return -1;
}
if (ext_hdr->record_offset != 0 &&
"as required by extension",
return -1;
}
return -1;
}
return 0;
}
struct mail_index_header *hdr)
{
#if !WORDS_BIGENDIAN
#endif
}
{
struct mail_index_map tmp_map;
/* a bit kludgy way to do this, but it initializes everything
nicely and correctly */
return mail_index_map_clone(&tmp_map);
}
struct mail_index_record_map *rec_map)
{
}
}
{
struct mail_index_map *const *maps;
unsigned int idx = -1U;
break;
}
}
}
}
{
return;
}
const struct mail_index_record_map *src,
unsigned int record_size)
{
/* if the map is ever written back to disk, we need to keep track of
what has changed. */
}
const struct mail_index_map *src)
{
/* use src->hdr copy directly, because if we got here
from syncing it has the latest changes. */
return;
} else {
dest->hdr_copy_buf =
}
}
}
static struct mail_index_record_map *
{
struct mail_index_record_map *rec_map;
return rec_map;
}
{
struct mail_index_map *mem_map;
struct mail_index_ext *ext;
unsigned int count;
} else {
}
/* copy extensions */
/* fix the name pointers to use our own pool */
}
}
/* copy keyword map */
&map->keyword_idx_map);
}
return mem_map;
}
{
struct mail_index_record_map *new_map;
const struct mail_index_record *rec;
} else {
}
if (new_map->records_count == 0)
new_map->last_appended_uid = 0;
else {
}
}
}
{
struct mail_index_record_map *new_map;
return;
else {
}
} else {
}
}
{
return FALSE;
}
int nearest_side)
{
else
break;
}
if (nearest_side > 0) {
/* we want uid or larger */
} else {
/* we want uid or smaller */
}
}
return idx+1;
}
{
*first_seq_r = *last_seq_r = 0;
return;
}
if (*first_seq_r == 0 ||
*first_seq_r = *last_seq_r = 0;
return;
}
/* we want the last message */
*first_seq_r = *last_seq_r = 0;
return;
}
return;
}
*last_seq_r = *first_seq_r;
else {
/* optimization - binary lookup only from right side: */
}
}