imap-search.c revision 3a508ab3b10ff08889f3046a6bbf8553b55e3d44
/* Copyright (c) 2002-2009 Dovecot authors, see the included COPYING file */
#include "common.h"
#include "ostream.h"
#include "str.h"
#include "seq-range-array.h"
#include "imap-resp-code.h"
#include "imap-quote.h"
#include "imap-seqset.h"
#include "imap-util.h"
#include "mail-search-build.h"
#include "commands.h"
#include "imap-search-args.h"
#include "imap-search.h"
static int
{
return -1;
return -1;
}
return 0;
}
static bool
{
unsigned int idx;
"SEARCH return options contain non-atoms.");
return FALSE;
}
args++;
"PARTIAL can be used only once.");
return FALSE;
}
"PARTIAL range missing.");
return FALSE;
}
"PARTIAL range broken.");
return FALSE;
}
args++;
} else {
"Unknown SEARCH return option");
return FALSE;
}
}
return FALSE;
}
return FALSE;
}
if (ctx->return_options == 0)
return TRUE;
}
const struct mail_search_arg *sargs)
{
case SEARCH_SEQSET:
break;
case SEARCH_MODSEQ:
break;
case SEARCH_OR:
case SEARCH_SUB:
break;
default:
break;
}
}
}
{
struct mail_search_result *result;
struct imap_search_update *update;
/* too many updates */
return;
}
}
{
unsigned int i, count;
for (i = 0; i < count; i++) {
str_truncate(str, 0);
}
}
if (ctx->highest_seen_modseq != 0) {
(unsigned long long)ctx->highest_seen_modseq);
}
}
static void
{
unsigned int i, count, delete_count;
/* we need to be able to handle non-sorted seq ranges, so do this
ourself instead of using seq_range_array_*() functions. */
delete_count = 0;
for (i = n = 0; i < count; i++) {
delete_count = i;
break;
}
n += diff + 1;
}
break;
}
n += diff + 1;
}
/* no results (in range) */
} else {
}
}
{
unsigned int count;
return;
}
if (ctx->return_options ==
/* we only wanted to save the result, don't return
ESEARCH result. */
return;
}
if (count > 0) {
}
}
if (ctx->highest_seen_modseq != 0) {
(unsigned long long)ctx->highest_seen_modseq);
}
}
{
}
}
}
{
unsigned int count;
/* only append the data. this is especially important when we're
returning a sort result. */
} else {
}
}
{
enum mailbox_sync_flags sync_flags;
unsigned int count;
const char *ok_reply;
(void)imap_search_deinit(ctx);
return TRUE;
}
if (count == 0) {
id_min = 0;
id_max = 0;
} else {
}
(opts & ~(SEARCH_RETURN_NORESULTS |
SEARCH_RETURN_MIN | SEARCH_RETURN_MAX)) == 0;
&tryagain) > 0) {
ctx->result_count++;
if (minmax) {
if ((opts & SEARCH_RETURN_MAX) != 0)
/* return option updates are delayed until
}
continue;
}
if ((opts & ~(SEARCH_RETURN_NORESULTS |
SEARCH_RETURN_COUNT)) == 0) {
/* we only want to count (and get modseqs) */
continue;
}
}
if (tryagain)
return FALSE;
if ((opts & SEARCH_RETURN_MIN) != 0) {
i_unreached();
} else {
}
}
if ((opts & SEARCH_RETURN_MAX) != 0) {
i_unreached();
} else {
}
}
}
if (imap_search_deinit(ctx) < 0) {
return TRUE;
}
}
}
{
bool finished;
if (!finished)
(void)client_handle_unfinished_cmd(cmd);
else
(void)cmd_sync_delayed(client);
}
{
return 1;
}
args++;
return -1;
args++;
/* wait if there is another SEARCH SAVE command running. */
return 0;
/* make sure the search result gets cleared if SEARCH fails */
else
}
return 1;
}
const enum mail_sort_type *sort_program,
enum mail_fetch_field *wanted_fields_r,
struct mailbox_header_lookup_ctx **headers_ctx_r)
{
const char *headers[2];
*wanted_fields_r = 0;
*headers_ctx_r = NULL;
if (sort_program == NULL)
return;
switch (sort_program[0] & MAIL_SORT_MASK) {
case MAIL_SORT_ARRIVAL:
break;
case MAIL_SORT_CC:
headers[0] = "Cc";
break;
case MAIL_SORT_DATE:
break;
case MAIL_SORT_FROM:
headers[0] = "From";
break;
case MAIL_SORT_SIZE:
break;
case MAIL_SORT_SUBJECT:
headers[0] = "Subject";
break;
case MAIL_SORT_TO:
headers[0] = "To";
break;
}
}
struct mail_search_args *sargs,
const enum mail_sort_type *sort_program)
{
struct mailbox_header_lookup_ctx *wanted_headers;
if (ctx->have_modseqs) {
}
if (cmd_search_more(cmd))
return TRUE;
/* we may have moved onto syncing by now */
return FALSE;
}
{
int ret = 0;
ret = -1;
else {
/* search failed */
}
return ret;
}