fts-storage.c revision 3d4450c252790b03bb5ce054987ac91110f1ff62
/* Copyright (C) 2006 Timo Sirainen */
#include "lib.h"
#include "array.h"
#include "str.h"
#include "istream.h"
#include "message-parser.h"
#include "message-decoder.h"
#include "mail-search.h"
#include "mail-storage-private.h"
#include "fts-api-private.h"
#include "fts-plugin.h"
#include <stdlib.h>
#define FTS_CONTEXT(obj) \
struct fts_mailbox {
struct mailbox_vfuncs super;
struct fts_backend *backend;
};
struct fts_search_context {
unsigned int result_pos;
unsigned int locked:1;
};
struct fts_transaction_context {
bool expunges;
};
struct fts_mail {
struct mail_vfuncs super;
};
static unsigned int fts_storage_module_id = 0;
static bool fts_storage_module_id_set = FALSE;
{
int ret;
return ret;
}
{
unsigned int i, count;
for (i = 0; i < count; i++) {
return -1;
}
}
return 0;
}
struct fts_storage_build_context {
struct fts_backend_build_context *build;
bool save_part;
};
{
return 1;
return -1;
return 1;
}
const struct message_block *block)
{
MESSAGE_PART_FLAG_MESSAGE_RFC822)) == 0)
return FALSE;
return TRUE;
}
const struct message_block *block)
{
/* hdr->full_value is always set because we get the block from
message_decoder */
if (!hdr->no_newline)
return 0;
}
return 1;
}
return fts_build_mail_flush(ctx);
}
static int
{
struct message_parser_ctx *parser;
struct message_decoder_context *decoder;
int ret;
return -1;
for (;;) {
if (ret < 0) {
if (input->stream_errno == 0)
ret = 0;
break;
}
continue;
&block))
continue;
}
if (ret < 0)
break;
if (ret == 0)
/* end of headers */
if (ret < 0)
break;
}
} else {
ret = -1;
break;
}
}
}
(void)message_parser_deinit(&parser);
return ret;
}
static int fts_build_new(struct mailbox_transaction_context *t)
{
struct fts_storage_build_context ctx;
struct mail_search_context *search_ctx;
struct mail_search_seqset seqset;
struct mail_search_arg search_arg;
int ret = 0;
return -1;
return -1;
/* no new messages */
return 0;
}
if (last_uid != last_uid_locked) {
/* changed, need to get again the sequences */
return -1;
}
/* no new messages */
return 0;
}
}
ret = -1;
break;
}
}
if (mailbox_search_deinit(&search_ctx) < 0)
ret = -1;
ret = -1;
return ret;
}
static struct mail_search_context *
const enum mail_sort_type *sort_program)
{
struct mail_search_context *ctx;
struct fts_search_context *fctx;
if (fts_build_new(t) < 0)
return ctx;
return ctx;
&uid_result) < 0) {
/* failed, fallback to reading everything */
}
}
}
&uid_result) < 0) {
/* failed, but we already have limited
the search, so just ignore this */
break;
}
}
}
if (array_is_created(&uid_result)) {
}
}
return ctx;
}
{
unsigned int count;
int ret;
do {
fctx->result_pos++;
return 0;
else {
fctx->result_pos++;
else
}
return ret;
}
{
}
{
return -1;
return 0;
}
static struct mail *
fts_mail_alloc(struct mailbox_transaction_context *t,
struct mailbox_header_lookup_ctx *wanted_headers)
{
struct mail_private *mail;
return _mail;
}
static struct mailbox_transaction_context *
{
struct mailbox_transaction_context *t;
struct fts_transaction_context *ft;
return t;
}
static void fts_transaction_rollback(struct mailbox_transaction_context *t)
{
}
static int fts_transaction_commit(struct mailbox_transaction_context *t,
enum mailbox_sync_flags flags)
{
int ret;
return ret;
}
{
struct fts_mailbox *fbox;
struct fts_backend *backend;
const char *env;
if (fts_next_hook_mailbox_opened != NULL)
return;
return;
if (!fts_storage_module_id_set) {
}
}