mail-cache-lookup.c revision 65a5fb2343f9870713bfca0b24abb58dcade605e
/* 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
struct mail_cache_record *
{
struct mail_cache_record *cache_rec;
if (offset == 0)
return NULL;
sizeof(*cache_rec) + CACHE_PREFETCH) < 0)
return NULL;
return NULL;
}
return NULL;
}
return NULL;
}
return NULL;
}
return cache_rec;
}
{
const struct mail_index_record *rec;
struct mail_index_map *map;
int i, ret;
for (i = 0; i < 2; i++) {
return -1;
return 1;
}
return ret;
}
return 0;
}
static int
const struct mail_cache_record *cache_rec,
{
unsigned int field;
int ret;
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");
return -1;
}
}
if (data_size == (unsigned int)-1) {
}
"Record continues outside it's allocated size");
return -1;
}
if (ret != 1)
return ret;
}
return 1;
}
{
const struct mail_cache_record *cache_rec;
int ret;
return 0;
else {
return ret;
}
if (ret <= 0)
return ret;
}
}
}
return 1;
}
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 {
};
static int
{
return 1;
return 0;
}
{
struct mail_cache_lookup_context ctx;
int ret;
return ret;
/* should exist. find it. */
&ctx) == 0;
}
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;
/* FIXME: this relies on mmap() too heavily */
for (i = 0; i < lines_count; i++) {
}
return 1;
}
{
}
{
struct header_lookup_context ctx;
struct header_lookup_data *data;
unsigned int field_idx;
int ret;
if (fields_count == 0)
return 1;
t_push();
/* @UNSAFE */
for (i = 0; i < fields_count; i++) {
if (field_idx == (unsigned int)-1) {
/* 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;
}