mail-index-view.c revision 06a5ffa611efd86ffb9acc8beb0fe66e7bd844e4
/* 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)
{
}
}
{
}
{
}
}
#ifdef DEBUG
{
struct mail_index_record *rec;
return;
}
#endif
{
unsigned int lock_id;
#ifdef DEBUG
#endif
return 0;
return -1;
return -1;
}
/* index was rebuilt */
return -1;
}
} else if (update_index) {
return -1;
}
return 0;
}
{
return -1;
/* not head mapping, no need to lock */
#ifdef DEBUG
#endif
return 0;
}
}
{
#ifdef DEBUG
#endif
}
}
{
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++)
}
{
}
static const struct mail_index_header *
{
if (view->broken_counters)
}
struct mail_index_map **map_r,
const struct mail_index_record **rec_r)
{
struct mail_index_map *map;
if (mail_index_view_lock(view) < 0)
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;
}
}
{
if (mail_index_view_lock(view) < 0)
return -1;
return 0;
}
int nearest_side)
{
if (uid == 1) {
/* optimization: the message can be only the first one */
return 0;
*left_idx_p = 1;
return 1;
}
else
break;
}
/* no messages available */
return 0;
}
*left_idx_p = left_idx;
if (nearest_side > 0) {
/* we want uid or larger */
} else {
/* we want uid or smaller */
}
}
return idx+1;
}
{
if (mail_index_view_lock(view) < 0)
return -1;
left_idx = 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;
return 0;
}
/* optimization - binary lookup only from right side: */
return 0;
}
{
#define LOW_UPDATE(x) \
const struct mail_index_record *rec;
*seq_r = 0;
if (mail_index_view_lock(view) < 0)
return -1;
if (low_uid == 1)
seq = 1;
else {
return -1;
if (seq == 0)
return 0;
}
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;
/* if we have a mapping, the view where it's from is already locked */
/* no mapping given, use head mapping */
return -1;
}
/* extension doesn't exist in this index file */
*data_size_r = 0;
return 0;
}
return 0;
}
{
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 */
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 *view;
view->v = view_vfuncs;
return view;
}
const struct mail_index_ext *
{
return 0;
}