mail-index-view.c revision 5278c93bd7105c32ac7ec37f36015d5950f6cbca
/* Copyright (C) 2003-2004 Timo Sirainen */
#include "lib.h"
#include "array.h"
#include "buffer.h"
#include "mail-index-view-private.h"
#include "mail-transaction-log.h"
const struct mail_index_view *src)
{
}
}
{
}
{
/* we're not unlocking the view, because views could be temporarily
created and closed and the current map should stay locked
(especially syncing) */
}
}
#ifdef DEBUG
{
struct mail_index_record *rec;
return;
}
#endif
{
#ifdef DEBUG
#endif
/* currently this is a no-op. if we unlock any maps, they might get
changed and then it's unspecified what parts of the memory mapping
are up-to-date. we could also copy the map to memory always, but
that kinds of defeats the purpose of mmaps. */
}
{
return view->inconsistent;
}
{
}
{
view->transactions++;
}
{
view->transactions--;
}
struct mail_index_map *map)
{
struct mail_index_map *const *maps;
unsigned int i, count;
/* if map is already referenced, do nothing */
for (i = 0; i < count; i++) {
return;
}
} else {
}
/* reference the given mapping. the reference is dropped when the view
is synchronized or closed. */
}
{
struct mail_index_map **maps;
unsigned int i, count;
return;
for (i = 0; i < count; i++)
mail_index_unmap(&maps[i]);
}
{
}
static const struct mail_index_header *
{
}
struct mail_index_map **map_r,
const struct mail_index_record **rec_r)
{
struct mail_index_map *map;
return -1;
/* look up the record */
return -1;
}
/* view's mapping is latest. we can use it directly. */
return 1;
}
/* look up the record from head mapping. it may contain some changes. */
return -1;
/* start looking up from the same sequence as in the old view.
if there are no expunges, it's there. otherwise it's somewhere
before (since records can't be inserted).
usually there are only a few expunges, so just going downwards from
our initial sequence position is probably faster than binary
search. */
if (seq == 0) {
/* everything is expunged from head. use the old record. */
return 0;
}
do {
seq--;
break;
} while (seq > 0);
/* found it. use it. reference the index mapping so that the
returned record doesn't get invalidated after next sync. */
return 1;
} else {
/* expuned from head. use the old record. */
return 0;
}
}
{
/* UID lookups don't require the view to be locked. only expunges
change them, and expunges will recreate the file */
return 0;
}
int nearest_side)
{
if (uid == 1) {
/* optimization: the message can be only the first one */
return 1;
}
else
break;
}
if (nearest_side > 0) {
/* we want uid or larger */
0 : idx+2);
} else {
/* we want uid or smaller */
}
}
return idx+1;
}
{
/* no locking needed for UIDs, see _view_lookup_uid() */
*first_seq_r = *last_seq_r = 0;
return 0;
}
if (*first_seq_r == 0 ||
*first_seq_r = *last_seq_r = 0;
return 0;
}
/* we want the last message */
*first_seq_r = *last_seq_r = 0;
return 0;
}
return 0;
}
*last_seq_r = *first_seq_r;
else {
/* optimization - binary lookup only from right side: */
}
return 0;
}
{
#define LOW_UPDATE(x) \
const struct mail_index_record *rec;
*seq_r = 0;
if (low_uid == 1)
seq = 1;
else {
return -1;
if (seq == 0)
return 0;
}
/* we can delay locking until we're looking at the flags */
return -1;
break;
}
}
return 0;
}
const void **data_r)
{
const struct mail_index_ext *ext;
const struct mail_index_record *rec;
int ret;
return -1;
return ret;
}
return ret;
}
{
const struct mail_index_ext *ext;
/* no mapping given, use head mapping */
}
if (mail_index_map_lock(map) < 0)
return -1;
/* extension doesn't exist in this index file */
*data_size_r = 0;
return 0;
}
return 0;
}
{
const struct mail_index_ext *ext;
return FALSE;
return TRUE;
}
{
return;
}
{
}
const struct mail_index_header *
{
}
const struct mail_index_record **rec_r)
{
struct mail_index_map *map;
}
struct mail_index_map **map_r,
const struct mail_index_record **rec_r)
{
}
{
struct mail_index_map *map;
const void *data;
const unsigned char *keyword_data;
const unsigned int *keyword_idx_map;
unsigned int i, j, keyword_count, index_idx;
int ret;
/* get the keywords data. */
if (ret < 0)
return -1;
/* no keywords at all in index */
return ret;
}
&record_size, NULL);
/* keyword_idx_map[] contains file => index keyword mapping */
keyword_count = 0;
} else {
}
keyword_data = data;
for (i = 0, idx = 0; i < record_size; i++) {
/* first do the quick check to see if there's keywords at all */
if (keyword_data[i] == 0)
continue;
if ((keyword_data[i] & (1 << j)) == 0)
continue;
if (idx >= keyword_count) {
/* keyword header was updated, parse it again
it so we know what this keyword is called */
if (mail_index_map_parse_keywords(map) < 0)
return -1;
return ret;
/* pointer may have changed. update it. */
if (idx >= keyword_count) {
/* extra bits set in keyword bytes.
shouldn't happen, but just ignore. */
break;
}
}
}
}
return ret;
}
{
}
{
}
{
}
{
struct mail_index_map *map;
}
const void **data_r)
{
}
{
}
{
}
{
}
{
const struct mail_index_ext *ext;
/* extension doesn't exist in this index file */
if (hdr_size_r != NULL)
*hdr_size_r = 0;
if (record_size_r != NULL)
*record_size_r = 0;
if (record_align_r != NULL)
*record_align_r = 0;
return 0;
}
if (hdr_size_r != NULL)
if (record_size_r != NULL)
if (record_align_r != NULL)
return 0;
}
static struct mail_index_view_vfuncs view_vfuncs = {
};
struct mail_index_view *
struct mail_index_map *map)
{
struct mail_index_view *view;
view->v = view_vfuncs;
return view;
}
{
}
const struct mail_index_ext *
{
return NULL;
}