view src/lib-storage/mail-search.h @ 568:f2aa58c2afd0 HEAD

SEARCH CHARSET support. Currently we do it through iconv() and only ASCII characters are compared case-insensitively.
author Timo Sirainen <tss@iki.fi>
date Sun, 03 Nov 2002 10:39:43 +0200
parents 85ab93a7693b
children fd8888f6f037
line wrap: on
line source

#ifndef __MAIL_SEARCH_H
#define __MAIL_SEARCH_H

#include "imap-parser.h"
#include "mail-storage.h"

typedef enum {
	SEARCH_OR,
	SEARCH_SUB,

	/* message sets */
	SEARCH_ALL,
	SEARCH_SET,
	SEARCH_UID,

	/* flags */
	SEARCH_ANSWERED,
	SEARCH_DELETED,
	SEARCH_DRAFT,
	SEARCH_FLAGGED,
	SEARCH_SEEN,
	SEARCH_RECENT,
	SEARCH_KEYWORD,

	/* dates */
	SEARCH_BEFORE,
	SEARCH_ON,
	SEARCH_SINCE,
	SEARCH_SENTBEFORE,
	SEARCH_SENTON,
	SEARCH_SENTSINCE,

	/* sizes */
	SEARCH_SMALLER,
	SEARCH_LARGER,

	/* headers */
	SEARCH_FROM,
	SEARCH_TO,
	SEARCH_CC,
	SEARCH_BCC,
	SEARCH_SUBJECT,
	SEARCH_HEADER,

	/* body */
	SEARCH_BODY,
	SEARCH_TEXT,

	/* our shortcuts for headers */
        SEARCH_IN_REPLY_TO,
        SEARCH_MESSAGE_ID
} MailSearchArgType;

struct _MailSearchArg {
	MailSearchArg *next;

	MailSearchArgType type;
	union {
		MailSearchArg *subargs;
		const char *str;
	} value;

        void *context;
	const char *hdr_field_name; /* for SEARCH_HEADER */
	unsigned int not:1;

	int result;
};

typedef void (*MailSearchForeachFunc)(MailSearchArg *arg, void *context);

/* Builds search arguments based on IMAP arguments. */
MailSearchArg *mail_search_args_build(Pool pool, ImapArg *args,
				      const char **error);

/* Reset the results in search arguments */
void mail_search_args_reset(MailSearchArg *args);

/* goes through arguments in list that don't have a result yet.
   Returns 1 = search matched, -1 = search unmatched, 0 = don't know yet */
int mail_search_args_foreach(MailSearchArg *args, MailSearchForeachFunc func,
			     void *context);

/* Fills have_headers, have_body and have_text based on if such search
   argument exists that needs to be checked. */
void mail_search_args_analyze(MailSearchArg *args, int *have_headers,
			      int *have_body, int *have_text);

#endif