mail-index-update.c revision 468bb8fbe53f28a18a47b8dc6761171d5d8ce706
/* 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-size.h"
#include "imap-envelope.h"
#include "imap-bodystructure.h"
#include "mail-index.h"
#include "mail-index-data.h"
struct _MailIndexUpdate {
unsigned int updated_fields;
char *fields[FIELD_TYPE_MAX_BITS];
unsigned int field_sizes[FIELD_TYPE_MAX_BITS];
unsigned int field_extra_sizes[FIELD_TYPE_MAX_BITS];
};
{
return update;
}
{
unsigned int i, mask;
return i;
}
return -1;
}
{
/* new record */
return TRUE;
}
return TRUE;
}
return FALSE;
}
{
int index;
/* start from the first data field - it's required to exist */
/* 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;
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. */
for (i = 0; i < FIELD_TYPE_MAX_BITS; i++) {
update->field_sizes[i] +
}
pos = 0;
/* value was modified - use it */
update->field_extra_sizes[i];
update->field_sizes[i]);
/* use the old value */
} else {
/* the field doesn't exist, jump to next */
continue;
}
/* memory alignment fix */
}
}
/* append the data at the end of the data file */
if (fpos == -1)
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 */
}
}
}
{
int failed;
/* 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;
}
const char *value, unsigned int extra_space)
{
unsigned int size;
int index;
}
{
return FIELD_TYPE_MESSAGEID;
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;
unsigned int 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 */
return;
}
/* see if we can do anything with this field */
if (field != 0) {
/* do we want to store this? */
}
}
ctx->envelope_pool =
}
}
}
{
const char *value;
/* for body / bodystructure, we need need to
fully parse the message */
/* 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();
}
} else {
/* we need to calculate virtual size of the
body as well. message_parse_header() left the
inbuf point to beginning of the body. */
}
}
t_push();
value, 0);
t_pop();
}
}