mail-index-update.c revision d14de73e30d5d0e06a5b28508b6a44e888edd2d1
/* Copyright (C) 2002 Timo Sirainen */
#include "lib.h"
#include "iobuffer.h"
#include "ioloop.h"
#include "rfc822-date.h"
#include "rfc822-tokenize.h"
#include "message-parser.h"
#include "message-part-serialize.h"
#include "message-size.h"
#include "imap-envelope.h"
#include "imap-bodystructure.h"
#include "mail-index.h"
#include "mail-index-data.h"
#include "mail-index-util.h"
struct _MailIndexUpdate {
unsigned int updated_fields;
void *fields[FIELD_TYPE_MAX_BITS];
};
{
return update;
}
{
unsigned int i, mask;
return i;
}
return -1;
}
{
/* new record */
return TRUE;
}
return TRUE;
}
return FALSE;
}
{
unsigned int size_left;
int index;
/* start from the first data field - it's required to exist */
/* corrupted */
return TRUE;
}
/* field was changed */
return TRUE;
}
}
return FALSE;
}
/* Append all the data at the end of the data file and update
the index's data position */
{
void *mem;
const void *src;
int i;
/* allocate the old size + also the new size of all changed or added
fields. this is more than required, but it's much easier than
calculating the exact size.
If this calculation overflows (no matter what value), it doesn't
really matter as it's later checked anyway. */
for (i = 0; i < FIELD_TYPE_MAX_BITS; i++) {
update->field_sizes[i] +
}
/* rec->data_size most likely corrupted */
"data_size points outside file");
return FALSE;
}
/* allocate two extra records to avoid overflows in case of bad
rec->full_field_size which itself fits into max_size, but
either the record part would make it point ouside allocate memory,
or the next field's record would do that */
pos = 0;
/* value was modified - use it */
update->field_extra_sizes[i];
/* use the old value */
} else {
/* the field doesn't exist, jump to next */
continue;
}
/* corrupted data file - old value had a field
larger than expected */
"full_field_size points outside "
"data_size (field %d?)",
return FALSE;
}
/* memory alignment fix */
}
}
/* append the data at the end of the data file */
if (fpos == 0)
return FALSE;
/* update index file position - it's mmap()ed so it'll be writte
into disk when index is unlocked. */
return TRUE;
}
/* Replace the modified fields in the file - assumes there's enough
space to do it */
{
int index;
/* start from the first data field - it's required to exist */
/* field was changed */
}
}
}
{
if (update->updated_fields != 0) {
/* if any of the fields were newly added, or have grown larger
than their old max. size, we need to move the record to end
of file. */
else
if (!failed) {
/* update cached fields mask */
}
}
return !failed;
}
{
int index;
}
{
}
{
}
{
return FIELD_TYPE_SUBJECT;
return FIELD_TYPE_FROM;
return FIELD_TYPE_TO;
return FIELD_TYPE_CC;
return FIELD_TYPE_BCC;
return 0;
}
{
char *ret, *p;
size_t i;
/* compress the long headers (remove \r?\n before space or tab) */
i++;
if (value[i] == '\n') {
} else {
*p++ = value[i];
}
}
*p = '\0';
return ret;
}
typedef struct {
void *context;
void *context)
{
const char *str;
return;
}
/* date is stored into index record itself */
}
/* see if we can do anything with this field */
if (field != 0) {
/* do we want to store this? */
}
}
ctx->envelope_pool =
}
}
}
{
const char *value;
if (cache_fields == 0)
if (IS_BODYSTRUCTURE_FIELD(cache_fields)) {
/* for body / bodystructure, we need need to
fully parse the message. unless it's already parsed
and cached. */
&size);
else {
/* corrupted, rebuild it */
"Corrupted cached MessagePart data");
}
}
} else {
/* cached, construct the bodystructure using it.
also we need to parse the header.. */
}
/* update our sizes */
if (cache_fields & FIELD_TYPE_BODY) {
t_push();
value, 0);
t_pop();
}
if (cache_fields & FIELD_TYPE_BODYSTRUCTURE) {
t_push();
value, 0);
t_pop();
}
if (cache_fields & FIELD_TYPE_MESSAGEPART) {
t_push();
t_pop();
}
} else {
}
t_push();
value, 0);
t_pop();
}
}