mail-search-build.c revision 0971792800404f89c6751f86265f70ab4840053e
/* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "imap-date.h"
#include "imap-parser.h"
#include "imap-messageset.h"
#include "mail-search.h"
#include "mail-search-build.h"
#include "mail-storage.h"
#include <stdlib.h>
struct search_build_data {
const char *error;
};
static struct mail_search_arg *
{
struct mail_search_arg *arg;
return arg;
}
static bool
const char **value_r)
{
return FALSE;
}
return FALSE;
}
*args += 1;
return TRUE;
}
#define ARG_NEW_SINGLE(type) \
static bool
struct mail_search_arg **next_sarg,
enum mail_search_arg_type type)
{
return TRUE;
}
#define ARG_NEW_STR(type) \
static bool
enum mail_search_arg_type type)
{
struct mail_search_arg *sarg;
const char *value;
return FALSE;
return TRUE;
}
#define ARG_NEW_FLAGS(flags) \
static bool
{
struct mail_search_arg *sarg;
return TRUE;
}
#define ARG_NEW_SIZE(type) \
static bool
enum mail_search_arg_type type)
{
struct mail_search_arg *sarg;
const char *value;
char *p;
return FALSE;
if (*p != '\0') {
return FALSE;
}
return TRUE;
}
#define ARG_NEW_DATE(type) \
static bool
enum mail_search_arg_type type)
{
struct mail_search_arg *sarg;
const char *value;
return FALSE;
return FALSE;
}
return TRUE;
}
static bool
{
struct mail_search_arg *sarg;
const char *value;
return FALSE;
return TRUE;
}
static bool
{
return FALSE;
}
name += 7;
if (*name == '\\') {
/* system flag */
name++;
else {
return FALSE;
}
return TRUE;
}
return TRUE;
}
static bool
{
else {
return FALSE;
}
return TRUE;
}
#define ARG_NEW_MODSEQ() \
static bool
{
struct mail_search_arg *sarg;
const char *value;
return FALSE;
/* <name> <type> */
return FALSE;
return FALSE;
return FALSE;
return FALSE;
}
return FALSE;
}
return TRUE;
}
struct mail_search_arg **next_sarg)
{
const char *str;
return FALSE;
}
/* NIL not allowed */
return FALSE;
}
return FALSE;
}
return FALSE;
}
*args += 1;
return TRUE;
}
/* string argument - get the name and jump to next */
*args += 1;
switch (*str) {
case 'A':
return ARG_NEW_FLAGS(MAIL_ANSWERED);
return ARG_NEW_SINGLE(SEARCH_ALL);
break;
case 'B':
/* <string> */
*args += 1;
return ARG_NEW_SINGLE(SEARCH_ALL);
}
return ARG_NEW_STR(SEARCH_BODY);
/* <date> */
return ARG_NEW_DATE(SEARCH_BEFORE);
/* <string> */
}
break;
case 'C':
/* <string> */
}
break;
case 'D':
return ARG_NEW_FLAGS(MAIL_DELETED);
return ARG_NEW_FLAGS(MAIL_DRAFT);
break;
case 'F':
return ARG_NEW_FLAGS(MAIL_FLAGGED);
/* <string> */
}
break;
case 'H':
/* <field-name> <string> */
const char *key;
return FALSE;
}
return FALSE;
}
*args += 1;
}
break;
case 'K':
return ARG_NEW_STR(SEARCH_KEYWORDS);
}
break;
case 'L':
/* <n> */
return ARG_NEW_SIZE(SEARCH_LARGER);
}
break;
case 'M':
/* [<name> <type>] <n> */
return ARG_NEW_MODSEQ();
}
break;
case 'N':
return FALSE;
return TRUE;
/* NEW == (RECENT UNSEEN) */
return TRUE;
}
break;
case 'O':
/* <search-key1> <search-key2> */
for (;;) {
return FALSE;
/* <key> OR <key> OR ... <key> - put them all
under one SEARCH_OR list. */
break;
"OR") != 0)
break;
*args += 1;
}
return FALSE;
return TRUE;
/* <date> */
return ARG_NEW_DATE(SEARCH_ON);
/* OLD == NOT RECENT */
if (!ARG_NEW_FLAGS(MAIL_RECENT))
return FALSE;
return TRUE;
}
break;
case 'R':
return ARG_NEW_FLAGS(MAIL_RECENT);
break;
case 'S':
return ARG_NEW_FLAGS(MAIL_SEEN);
/* <string> */
/* <date> */
return ARG_NEW_DATE(SEARCH_SENTBEFORE);
/* <date> */
return ARG_NEW_DATE(SEARCH_SENTON);
/* <date> */
return ARG_NEW_DATE(SEARCH_SENTSINCE);
/* <date> */
return ARG_NEW_DATE(SEARCH_SINCE);
/* <n> */
return ARG_NEW_SIZE(SEARCH_SMALLER);
}
break;
case 'T':
/* <string> */
*args += 1;
return ARG_NEW_SINGLE(SEARCH_ALL);
}
return ARG_NEW_STR(SEARCH_TEXT);
/* <string> */
}
break;
case 'U':
/* <message set> */
if (!ARG_NEW_STR(SEARCH_UIDSET))
return FALSE;
return FALSE;
}
return TRUE;
if (!ARG_NEW_FLAGS(MAIL_ANSWERED))
return FALSE;
return TRUE;
if (!ARG_NEW_FLAGS(MAIL_DELETED))
return FALSE;
return TRUE;
if (!ARG_NEW_FLAGS(MAIL_DRAFT))
return FALSE;
return TRUE;
if (!ARG_NEW_FLAGS(MAIL_FLAGGED))
return FALSE;
return TRUE;
if (!ARG_NEW_STR(SEARCH_KEYWORDS))
return FALSE;
return TRUE;
if (!ARG_NEW_FLAGS(MAIL_SEEN))
return FALSE;
return TRUE;
}
break;
case 'X':
/* <string> */
*args += 1;
return ARG_NEW_SINGLE(SEARCH_ALL);
}
return ARG_NEW_STR(SEARCH_BODY_FAST);
/* <string> */
*args += 1;
return ARG_NEW_SINGLE(SEARCH_ALL);
}
return ARG_NEW_STR(SEARCH_TEXT_FAST);
}
break;
default:
/* <message-set> */
if (!ARG_NEW_SINGLE(SEARCH_SEQSET))
return FALSE;
str) < 0) {
return FALSE;
}
return TRUE;
}
break;
}
return FALSE;
}
struct mail_search_arg *
const char **error_r)
{
struct search_build_data data;
first_sarg = NULL;
break;
}
}
return first_sarg;
}
static void
{
unsigned int i, count;
/* make a copy of the UIDs */
/* put them back to the range as sequences */
for (i = 0; i < count; i++) {
if (seq1 != 0) {
}
/* make sure the last message is in the range */
}
}
}
{
const char *keywords[2];
case SEARCH_UIDSET:
if (change_uidsets) T_BEGIN {
} T_END;
break;
case SEARCH_MODSEQ:
break;
/* modseq with keyword */
case SEARCH_KEYWORDS:
break;
case SEARCH_SUB:
case SEARCH_OR:
break;
default:
break;
}
}
}
{
case SEARCH_MODSEQ:
case SEARCH_KEYWORDS:
break;
break;
case SEARCH_SUB:
case SEARCH_OR:
break;
default:
break;
}
}
}