mail-index-sync-keywords.c revision 16c89b1260c9d07c01c83a9219424d3727069b2e
/* Copyright (C) 2004 Timo Sirainen */
#include "lib.h"
#include "buffer.h"
#include "mail-index-view-private.h"
#include "mail-index-sync-private.h"
#include "mail-transaction-log.h"
static const char *const *
{
const unsigned char *p, *end;
const char *name;
sizeof(const char *));
if (p >= end)
return NULL;
for (i = 0; i < rec->keywords_count; i++) {
return NULL;
}
if (diff != 0)
p += 4 - diff;
}
const char *const *keywords,
const char *const **missing_r)
{
const char *name;
unsigned int i;
return -1;
for (i = 0; i < map->keywords_count; i++) {
break;
}
if (i == map->keywords_count)
}
if (missing_buf->used == 0)
else {
}
return 0;
}
static buffer_t *
const struct mail_index_ext *ext,
unsigned int new_count, unsigned int *keywords_count_r,
{
const struct mail_index_keyword_header *kw_hdr;
const struct mail_index_keyword_header_rec *kw_rec;
const char *name;
struct mail_index_keyword_header new_kw_hdr;
if (kw_hdr->keywords_count == 0)
return NULL;
new_kw_hdr = *kw_hdr;
*name_offset_r = offset;
return buf;
}
{
struct mail_transaction_ext_intro *u;
sizeof(*u) + sizeof("keywords")-1);
u = buffer_append_space_unsafe(ext_intro_buf, sizeof(*u));
if ((u->record_size % 4) != 0) {
/* since we aren't properly aligned anyway,
reserve one extra byte for future */
u->record_size++;
}
u->record_align = 1;
}
return mail_index_sync_ext_intro(ctx, u);
}
static int
const char *const *keywords)
{
struct mail_index_keyword_header *kw_hdr;
struct mail_index_keyword_header_rec kw_rec;
unsigned int keywords_count;
int ret = 0;
/* make sure all keywords exist in the header */
/* update existing header */
&name_offset);
}
}
/* create new / replace broken header */
name_offset = 0;
}
return 1;
/* missing some keywords - add them */
rec_offset += sizeof(kw_rec);
name_offset_root += len;
}
/* if we need to grow the buffer, add some padding */
if (ret <= 0)
return ret;
/* map may have changed */
}
}
return 1;
}
static const unsigned char *
const char *const *keywords)
{
const struct mail_index_keyword_header *kw_hdr;
const struct mail_index_keyword_header_rec *kw_rec;
const char *name, *const *n;
unsigned char *mask;
unsigned int i;
for (i = 0; i < kw_hdr->keywords_count; i++) {
break;
}
}
}
return mask;
}
static int
const struct mail_index_ext *ext,
const unsigned char *mask,
enum modify_type type,
{
struct mail_index_record *rec;
unsigned char *data;
unsigned int i;
return -1;
if (seq1 == 0)
return 1;
switch (type) {
case MODIFY_ADD:
for (i = 0; i < ext->record_size; i++)
break;
case MODIFY_REMOVE:
for (i = 0; i < ext->record_size; i++)
break;
case MODIFY_REPLACE:
break;
default:
i_unreached();
}
}
return 1;
}
const struct mail_transaction_header *hdr,
const struct mail_transaction_keyword_update *rec)
{
const char *const *keywords;
const struct mail_index_ext *ext;
const unsigned char *mask;
int ret;
"Keyword header ended unexpectedly");
return -1;
}
if (ret <= 0)
return ret;
}
/* nothing to do */
return 1;
}
if (ret <= 0)
return ret;
uid += 2;
}
return 1;
}