mail-search-build.h revision 0a1ec0f2a38370e8a073a60023b4365491947f6f
fd5a4eacd56700ffb08a73121aeacdc806cb0132Sumit Bose#ifndef MAIL_SEARCH_BUILD_H
fd5a4eacd56700ffb08a73121aeacdc806cb0132Sumit Bose#define MAIL_SEARCH_BUILD_H
6f51c802311fd81a409a26763ed45b28a3234d0dJakub Hrozek
84ae5edab16ad6be5e3be956cb6fa031c1428eb5Stephen Gallagher#include "mail-search.h"
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher#include "mail-search-register.h"
df4cc3a83c5d6700b6a09ff96cb4a6b1949b1aa9Stephen Gallagher
df4cc3a83c5d6700b6a09ff96cb4a6b1949b1aa9Stephen Gallagherstruct mailbox;
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagherstruct mail_search_build_context {
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher pool_t pool;
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher struct mail_search_register *reg;
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher struct mail_search_parser *parser;
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher const char *charset;
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher struct mail_search_arg *parent;
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher /* error is either here or in parser */
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher const char *_error;
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher bool charset_checked;
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher bool unknown_charset;
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher};
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher/* Start building a new search query. Use mail_search_args_unref() to
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher free it. */
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagherstruct mail_search_args *mail_search_build_init(void);
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher
d921c1eba437662437847279f251a0a5d8f70127Maxim/* Convert IMAP SEARCH command compatible parameters to mail_search_args.
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher If charset is unknown, it's changed to NULL. */
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagherint mail_search_build(struct mail_search_register *reg,
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher struct mail_search_parser *parser, const char **charset,
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher struct mail_search_args **args_r, const char **error_r);
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher/* Add new search arg with given type. */
2a5790216f57e9bdfb2930d52860bb5300366536Jakub Hrozekstruct mail_search_arg *
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallaghermail_search_build_add(struct mail_search_args *args,
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher enum mail_search_arg_type type);
4dd615c01357b8715711aad6820ba9595d3ad377Stephen Gallagher/* Add SEARCH_ALL to search args. */
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallaghervoid mail_search_build_add_all(struct mail_search_args *args);
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher/* Add a sequence set to search args. */
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallaghervoid mail_search_build_add_seqset(struct mail_search_args *args,
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher uint32_t seq1, uint32_t seq2);
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher/* Convert input string into UTF-8 decomposed titlecase, suitable for
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher message_search_init() */
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagherint mail_search_build_get_utf8_dtc(struct mail_search_build_context *ctx,
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher const char *input, const char **output_r);
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagherstruct mail_search_arg *
4dd615c01357b8715711aad6820ba9595d3ad377Stephen Gallaghermail_search_build_new(struct mail_search_build_context *ctx,
4dd615c01357b8715711aad6820ba9595d3ad377Stephen Gallagher enum mail_search_arg_type type);
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagherstruct mail_search_arg *
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallaghermail_search_build_str(struct mail_search_build_context *ctx,
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher enum mail_search_arg_type type);
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher/* Returns 0 if arg is returned, -1 if error. */
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagherint mail_search_build_key(struct mail_search_build_context *ctx,
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher struct mail_search_arg *parent,
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher struct mail_search_arg **arg_r);
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher#endif
551aa6c36797ed720487f5974dcadabf19e6ff9fStephen Gallagher