mail-search-build.c revision 896093ae6961612ac6ef8722d79dd457f1b43dd0
/* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "imap-date.h"
#include "imap-parser.h"
#include "imap-seqset.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;
}
#define ARG_NEW_INTERVAL(type) \
static bool
struct mail_search_arg **next_sarg,
enum mail_search_arg_type type)
{
struct mail_search_arg *sarg;
const char *value;
unsigned long interval;
char *p;
return FALSE;
if (interval == 0 || *p != '\0') {
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;
/* <interval> - WITHIN extension */
if (!ARG_NEW_INTERVAL(SEARCH_BEFORE))
return FALSE;
/* we need to match also equal, but standard BEFORE
compares with "<" */
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;
/* SEARCHRES: delay initialization */
return TRUE;
}
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 'Y':
/* <interval> - WITHIN extension */
return ARG_NEW_INTERVAL(SEARCH_SINCE);
}
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;
return FALSE;
}
return TRUE;
/* SEARCHRES: delay initialization */
if (!ARG_NEW_SINGLE(SEARCH_UIDSET))
return FALSE;
return TRUE;
}
break;
}
return FALSE;
}
const char *charset,
struct mail_search_args **args_r,
const char **error_r)
{
struct search_build_data data;
struct mail_search_args *args;
struct mail_search_arg **sargs;
return -1;
}
}
return 0;
}
struct mail_search_args *mail_search_build_init(void)
{
struct mail_search_args *args;
return args;
}
{
struct mail_search_arg *arg;
}
{
struct mail_search_arg *arg;
}