cmd-search.c revision 5543a380177054ea6217272d626332f44edb7c8f
/* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */
#include "common.h"
#include "ostream.h"
#include "str.h"
#include "seq-range-array.h"
#include "commands.h"
#include "mail-search.h"
#include "mail-search-build.h"
#include "imap-quote.h"
#include "imap-util.h"
#include "imap-search.h"
enum search_return_options {
SEARCH_RETURN_ESEARCH = 0x01,
SEARCH_RETURN_MIN = 0x02,
SEARCH_RETURN_MAX = 0x04,
SEARCH_RETURN_ALL = 0x08,
SEARCH_RETURN_COUNT = 0x10,
SEARCH_RETURN_MODSEQ = 0x20
};
struct imap_search_context {
struct client_command_context *cmd;
struct mailbox_transaction_context *trans;
struct mail_search_context *search_ctx;
struct mail_search_arg *sargs;
unsigned int result_count;
struct timeval start_time;
};
{
const char *name;
"SEARCH return options contain non-atoms.");
return FALSE;
}
args++;
else {
"Unknown SEARCH return option");
return FALSE;
}
}
if (ctx->return_options == 0)
return TRUE;
}
{
case SEARCH_MODSEQ:
return TRUE;
case SEARCH_OR:
case SEARCH_SUB:
return TRUE;
break;
default:
break;
}
}
return FALSE;
}
static struct imap_search_context *
struct mail_search_arg *sargs)
{
if (imap_search_args_have_modseq(sargs)) {
}
return ctx;
}
{
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);
}
}
{
unsigned int count;
return;
}
if (count > 0) {
}
}
if (ctx->highest_seen_modseq != 0) {
(unsigned long long)ctx->highest_seen_modseq);
}
}
{
int ret = 0;
ret = -1;
return ret;
}
{
unsigned int count;
bool tryagain;
(void)imap_search_deinit(ctx);
return TRUE;
}
if (count == 0) {
id_max = 0;
} else {
}
&tryagain) > 0) {
ctx->result_count++;
if ((opts & ~(SEARCH_RETURN_EXTRAS |
SEARCH_RETURN_MIN | SEARCH_RETURN_MAX)) == 0) {
/* modseq is looked up when we know the
}
continue;
}
}
if ((opts & ~(SEARCH_RETURN_EXTRAS |
SEARCH_RETURN_COUNT)) == 0) {
/* we only want to count (and get modseqs) */
continue;
}
}
if (tryagain)
return FALSE;
if (ctx->highest_seen_modseq == 0 &&
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;
}
}
t_strdup_printf("OK Search completed (%d.%03d secs).",
}
{
bool finished;
if (!finished)
(void)client_handle_unfinished_cmd(cmd);
else
(void)cmd_sync_delayed(client);
}
{
struct imap_search_context *ctx;
struct mail_search_arg *sargs;
int args_count;
if (args_count < 1) {
if (args_count == -2)
return FALSE;
"Missing SEARCH arguments.");
return TRUE;
}
if (!client_verify_open_mailbox(cmd))
return TRUE;
args++;
return TRUE;
args++;
} else {
}
/* CHARSET specified */
args++;
"Invalid charset argument.");
return TRUE;
}
args++;
} else {
charset = "UTF-8";
}
/* error in search arguments */
return TRUE;
}
if (cmd_search_more(cmd))
return TRUE;
/* we could have moved onto syncing by now */
return FALSE;
}