mail-cache-fields.c revision be889d9b142fbb5604a922c6955bd7f6ea32f163
/* Copyright (C) 2004 Timo Sirainen */
#include "lib.h"
#include "buffer.h"
#include "hash.h"
#include "file-cache.h"
#include "write-full.h"
#include "mail-cache-private.h"
#include <stddef.h>
#define CACHE_HDR_PREFETCH 1024
struct mail_cache_field *fields,
unsigned int fields_count)
{
void *orig_key, *orig_value;
unsigned int new_idx;
unsigned int i, j;
for (i = 0; i < fields_count; i++) {
&orig_key, &orig_value)) {
POINTER_CAST_TO(orig_value, unsigned int);
continue;
}
/* check if the same header is being registered in the
same field array */
for (j = 0; j < i; j++) {
break;
}
}
if (j == i)
}
return;
/* @UNSAFE */
for (i = 0; i < fields_count; i++) {
continue;
/* new index - save it */
case MAIL_CACHE_FIELD_BITMASK:
break;
case MAIL_CACHE_FIELD_STRING:
case MAIL_CACHE_FIELD_HEADER:
break;
}
POINTER_CAST(idx));
}
}
unsigned int
{
void *orig_key, *orig_value;
&orig_key, &orig_value))
return POINTER_CAST_TO(orig_value, unsigned int);
else
return (unsigned int)-1;
}
const struct mail_cache_field *
unsigned int *count_r)
{
struct mail_cache_field *list;
unsigned int i;
for (i = 0; i < cache->fields_count; i++) {
}
return list;
}
{
const struct mail_cache_header_fields *field_hdr;
if (MAIL_CACHE_IS_UNUSABLE(cache)) {
*offset_r = 0;
return 0;
}
/* find the latest header */
offset = 0;
while (next_offset != 0) {
if (next_offset == offset) {
"next_offset in field header loops");
return -1;
}
/* we can't trust that the cached data is valid */
sizeof(*field_hdr) +
}
sizeof(*field_hdr) + CACHE_HDR_PREFETCH) < 0)
return -1;
}
return 0;
}
{
struct mail_cache_field field;
void *orig_key, *orig_value;
return -1;
if (offset == 0) {
/* no fields - the file is empty */
return 0;
}
"field header points outside file");
return -1;
}
/* check the fixed size of the header. name[] has to be checked
separately */
return -1;
}
/* we can't trust that the cached data is valid */
sizeof(*field_hdr) +
}
return -1;
}
cache->file_fields_count * sizeof(unsigned int),
field_hdr->fields_count * sizeof(unsigned int));
/* clear the old mapping */
for (i = 0; i < cache->fields_count; i++)
for (i = 0; i < field_hdr->fields_count; i++) {
"field header names corrupted");
return -1;
}
&orig_key, &orig_value)) {
/* already exists, see if decision can be updated */
decisions[i];
}
"registered field type changed");
return -1;
}
} else {
}
"Duplicated field in header: %s", names);
return -1;
}
/* update last_used if it's newer than ours */
names = p + 1;
}
return 0;
}
{
const void *data;
unsigned int i, field;
for (i = 0; i < cache->file_fields_count; i++) {
}
for (i = 0; i < cache->fields_count; i++) {
continue;
}
}
{
const int *data;
unsigned int i, field;
for (i = 0; i < cache->file_fields_count; i++) {
}
for (i = 0; i < cache->fields_count; i++) {
continue;
}
}
{
int ret = 0;
if (mail_cache_header_fields_read(cache) < 0 ||
return -1;
t_push();
sizeof(uint32_t));
if (ret == 0) {
if (ret == 0) {
for (i = 0; i < cache->file_fields_count; i++)
}
}
t_pop();
if (ret == 0)
return ret;
}
{
int ret;
if (mail_cache_lock(cache) <= 0)
return -1;
if (mail_cache_unlock(cache) < 0)
ret = -1;
return ret;
}
{
struct mail_cache_header_fields hdr;
unsigned int field;
const char *name;
uint32_t i;
/* we have to keep the field order for the existing fields. */
sizeof(uint32_t));
sizeof(uint32_t));
for (i = 0; i < cache->file_fields_count; i++) {
}
for (i = 0; i < cache->fields_count; i++) {
continue;
}
}
{
return -1;
if (*offset_r == 0) {
} else {
}
return 0;
}