mail-cache-lookup.c revision 287ba82a8da3eaa473b5735d4eeac2fb4c5d8117
/* Copyright (C) 2003-2004 Timo Sirainen */
#include "lib.h"
#include "buffer.h"
#include "str.h"
#include "mail-cache-private.h"
#include <stdlib.h>
#define CACHE_PREFETCH 1024
const struct mail_cache_record **rec_r)
{
const struct mail_cache_record *cache_rec;
if (offset == 0)
return 0;
sizeof(*cache_rec) + CACHE_PREFETCH) < 0)
return -1;
return -1;
}
return -1;
}
return -1;
}
return -1;
}
return 0;
}
static int
{
struct mail_index_map *map;
const struct mail_index_ext *ext;
const void *data;
int i, ret;
return -1;
return 0;
/* no cache */
return 0;
}
for (i = 0; i < 2; i++) {
return 1;
}
return ret;
}
return 0;
}
static int
{
const struct mail_cache_record *cache_rec;
unsigned int data_size;
unsigned int field;
int ret;
return -1;
*offset = 0;
return 1;
}
return -1;
}
/* new field, have to re-read fields header to figure
out it's size */
if (mail_cache_header_fields_read(cache) < 0)
return -1;
"field index too large (%u >= %u)",
return -1;
}
/* field reading might have re-mmaped the file and
caused cache_rec to break. need to get it again. */
&cache_rec) < 0)
return -1;
}
if (data_size == (unsigned int)-1) {
}
"record continues outside it's allocated size");
return -1;
}
if (ret != 1)
return ret;
}
return 1;
}
{
unsigned int i, count;
for (i = 0; i < count; i++) {
return TRUE;
}
return FALSE;
}
{
int ret;
return 0;
else {
return ret;
}
ret = 1;
"record list is circular");
return -1;
}
}
"record list is circular");
return -1;
}
}
}
return ret;
}
static int
const void *data __attr_unused__,
void *context __attr_unused__)
{
return 1;
}
{
int ret;
if (++view->cached_exists_value == 0) {
/* wrapped, we'll have to clear the buffer */
NULL), 0,
}
return ret < 0 ? -1 : 0;
}
unsigned int field)
{
return 0;
return -1;
}
}
{
}
struct mail_cache_lookup_context {
int found;
};
static int
{
return 1;
return 0;
}
static int
{
unsigned char *dest;
size_t i;
return 1;
/* merge all bits */
for (i = 0; i < data_size; i++)
return 1;
}
{
struct mail_cache_lookup_context ctx;
unsigned int data_size;
int ret;
return ret;
/* should exist. find it. */
&ctx);
} else {
/* make sure we're cleared first */
0, data_size);
&ctx);
}
}
struct header_lookup_data_rec {
};
struct header_lookup_data {
struct header_lookup_data_rec *data;
};
struct header_lookup_context {
unsigned int *fields;
unsigned int max_field;
};
static int
{
struct header_lookup_data hdr_data;
struct header_lookup_data_rec *hdr_data_rec;
unsigned int i, lines_count;
/* a) don't want it, b) duplicate */
return 1;
}
/* data = { line_nums[], 0, "headers" } */
if (lines[i] == 0)
break;
}
lines_count = i;
for (i = 0; i < lines_count; i++) {
}
return 1;
}
{
}
{
struct header_lookup_context ctx;
struct header_lookup_data *data;
int ret;
if (fields_count == 0)
return 1;
t_push();
/* @UNSAFE */
for (i = 0; i < fields_count; i++) {
/* not cached at all */
t_pop();
return 0;
}
}
/* we need to return them in sorted order. create array:
{ line number -> cache file offset } */
if (ret <= 0) {
t_pop();
return ret;
}
/* check that all fields were found */
t_pop();
return 0;
}
}
/* then start filling dest buffer from the headers */
for (i = 0; i < size; i++) {
if (*p == '\n' &&
p++;
break;
}
}
}
t_pop();
return 1;
}