/* Copyright (c) 2004-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "buffer.h"
#include "seq-range-array.h"
#include "mail-index-private.h"
#include "mail-index-view-private.h"
#include "mail-index-transaction-private.h"
struct mail_index_view_transaction {
struct mail_index_transaction *t;
unsigned int record_size;
unsigned int recs_count;
void *recs;
};
{
(struct mail_index_view_transaction *)view;
struct mail_index_transaction *t = tview->t;
void **recs;
unsigned int i, count;
for (i = 0; i < count; i++)
}
}
{
(struct mail_index_view_transaction *)view;
(tview->t->last_new_seq == 0 ? 0 :
}
static const struct mail_index_header *
{
(struct mail_index_view_transaction *)view;
/* FIXME: header counters may not be correct */
}
return hdr;
}
static const struct mail_index_record *
struct mail_index_map *map,
{
struct mail_index_transaction *t = tview->t;
/* see if there are any flag updates */
!array_is_created(&t->updates))
return rec;
return rec;
/* yes, we have flag updates. since we can't modify rec directly and
we want to be able to handle multiple mail_index_lookup() calls
without the second one overriding the first one's data, we'll
create a records array and return data from there.
it's also possible that the record size increases, so we potentially
have to create multiple arrays. they all get eventually freed when
the view gets freed. */
tview->recs_count));
}
return trec;
}
static const struct mail_index_record *
{
(struct mail_index_view_transaction *)view;
/* FIXME: is this right to return index map..?
it's not there yet. */
if (expunged_r != NULL)
*expunged_r = FALSE;
}
if (expunged_r != NULL &&
*expunged_r = TRUE;
return rec;
}
static void
{
(struct mail_index_view_transaction *)view;
else
}
{
(struct mail_index_view_transaction *)view;
} else {
/* index is being reset. we never want to return old
sequences. */
*first_seq_r = *last_seq_r = 0;
}
if (tview->t->last_new_seq == 0) {
/* no new messages, the results are final. */
return;
}
/* new messages don't have UIDs */
return;
}
/* all wanted messages were existing */
return;
}
/* at least some of the wanted messages are newly created */
if (*first_seq_r == 0) {
break;
}
/* no messages in range */
return;
}
*first_seq_r = seq;
/* one seq in range */
*last_seq_r = seq;
return;
}
}
*last_seq_r = seq;
break;
}
}
}
{
(struct mail_index_view_transaction *)view;
unsigned int append_count;
if (*seq_r != 0)
return;
} else {
*seq_r = 0;
}
break;
}
}
}
unsigned int idx)
{
const unsigned int *indexes;
unsigned int i, count;
for (i = 0; i < count; i++) {
return;
}
}
unsigned int idx)
{
const unsigned int *indexes;
unsigned int i, count;
for (i = 0; i < count; i++) {
break;
}
}
}
{
(struct mail_index_view_transaction *)view;
struct mail_index_transaction *t = tview->t;
unsigned int i, count;
/* no keyword updates for this sequence */
return;
}
if (array_is_created(&t->keyword_updates))
else {
count = 0;
}
for (i = 0; i < count; i++) {
}
}
static const void *
{
/* data begins with a 32bit sequence, followed by the actual
extension data */
/* we're adding the extension now. */
} else {
}
/* see if the extension has been resized within this transaction */
}
}
if (record_align <= sizeof(uint32_t)) {
/* data is 32bit aligned already */
return data;
} else {
/* assume we want 64bit alignment - copy the data to
temporary buffer and return it */
record_size + 64);
/* clear the buffer between lookups for different
messages */
}
}
}
static bool
{
unsigned int count;
return FALSE;
}
static bool
const void **data_r)
{
const void *data;
unsigned int idx;
if (!array_is_created(ext_buf) ||
return FALSE;
tview->lookup_map =
}
/* extension doesn't yet exist in the map. add it there with
the preliminary information (mainly its size) so if caller
looks it up, it's going to be found. */
}
return TRUE;
}
static void
const void **data_r, bool *expunged_r)
{
(struct mail_index_view_transaction *)view;
if (expunged_r != NULL)
*expunged_r = FALSE;
/* there are some ext updates in transaction.
see if there's any for this sequence. */
return;
}
/* not updated, return the existing value, unless ext was
already reset */
} else {
}
}
{
(struct mail_index_view_transaction *)view;
/* FIXME: check updates */
}
struct mail_index_map *map,
{
(struct mail_index_view_transaction *)view;
*reset_id_r = *reset_id_p;
return TRUE;
}
}
};
struct mail_index_view *
{
/* transaction view is being synced. while it's done, it's not
possible to add new messages, but the view itself might
change. so we can't make a copy of the view. */
mail_index_view_ref(t->view);
return t->view;
}
tview->t = t;
}