mail-search-build.h revision 5c2d695acf9f95ae0dcdda89c4d2391ceda4d672
1176124297af5c56e932c0863c6637ff21d8a0efTimo Sirainen#ifndef MAIL_SEARCH_BUILD_H
1176124297af5c56e932c0863c6637ff21d8a0efTimo Sirainen#define MAIL_SEARCH_BUILD_H
1176124297af5c56e932c0863c6637ff21d8a0efTimo Sirainen
c4b376dd6e0c423006d7ac83a39253bcaf8e7c47Timo Sirainen#include "mail-search.h"
4fc52b7b25c3d3f42348903e0154840f8761f306Timo Sirainen#include "mail-search-register.h"
c4b376dd6e0c423006d7ac83a39253bcaf8e7c47Timo Sirainen
1176124297af5c56e932c0863c6637ff21d8a0efTimo Sirainenstruct mailbox;
1176124297af5c56e932c0863c6637ff21d8a0efTimo Sirainen
20b2d47ed762ca2c009aa37e360af6f223ac71bdTimo Sirainenstruct mail_search_build_context {
20b2d47ed762ca2c009aa37e360af6f223ac71bdTimo Sirainen pool_t pool;
20b2d47ed762ca2c009aa37e360af6f223ac71bdTimo Sirainen struct mail_search_register *reg;
5c2d695acf9f95ae0dcdda89c4d2391ceda4d672Timo Sirainen struct mail_search_parser *parser;
4fc52b7b25c3d3f42348903e0154840f8761f306Timo Sirainen
4fc52b7b25c3d3f42348903e0154840f8761f306Timo Sirainen struct mail_search_arg *parent;
5c2d695acf9f95ae0dcdda89c4d2391ceda4d672Timo Sirainen /* error is either here or in parser */
5c2d695acf9f95ae0dcdda89c4d2391ceda4d672Timo Sirainen const char *_error;
20b2d47ed762ca2c009aa37e360af6f223ac71bdTimo Sirainen};
20b2d47ed762ca2c009aa37e360af6f223ac71bdTimo Sirainen
7327394e30c1020b9a2a49c72a7e3d0f7803e680Timo Sirainen/* Start building a new search query. Use mail_search_args_unref() to
7327394e30c1020b9a2a49c72a7e3d0f7803e680Timo Sirainen free it. */
c4b376dd6e0c423006d7ac83a39253bcaf8e7c47Timo Sirainenstruct mail_search_args *mail_search_build_init(void);
c4b376dd6e0c423006d7ac83a39253bcaf8e7c47Timo Sirainen
7327394e30c1020b9a2a49c72a7e3d0f7803e680Timo Sirainen/* Convert IMAP SEARCH command compatible parameters to mail_search_args. */
5c2d695acf9f95ae0dcdda89c4d2391ceda4d672Timo Sirainenint mail_search_build(struct mail_search_register *reg,
5c2d695acf9f95ae0dcdda89c4d2391ceda4d672Timo Sirainen struct mail_search_parser *parser, const char *charset,
5c2d695acf9f95ae0dcdda89c4d2391ceda4d672Timo Sirainen struct mail_search_args **args_r, const char **error_r);
1176124297af5c56e932c0863c6637ff21d8a0efTimo Sirainen
7327394e30c1020b9a2a49c72a7e3d0f7803e680Timo Sirainen/* Add SEARCH_ALL to search args. */
c4b376dd6e0c423006d7ac83a39253bcaf8e7c47Timo Sirainenvoid mail_search_build_add_all(struct mail_search_args *args);
7327394e30c1020b9a2a49c72a7e3d0f7803e680Timo Sirainen/* Add a sequence set to search args. */
c4b376dd6e0c423006d7ac83a39253bcaf8e7c47Timo Sirainenvoid mail_search_build_add_seqset(struct mail_search_args *args,
c4b376dd6e0c423006d7ac83a39253bcaf8e7c47Timo Sirainen uint32_t seq1, uint32_t seq2);
1176124297af5c56e932c0863c6637ff21d8a0efTimo Sirainen
4fc52b7b25c3d3f42348903e0154840f8761f306Timo Sirainenstruct mail_search_arg *
4fc52b7b25c3d3f42348903e0154840f8761f306Timo Sirainenmail_search_build_new(struct mail_search_build_context *ctx,
4fc52b7b25c3d3f42348903e0154840f8761f306Timo Sirainen enum mail_search_arg_type type);
4fc52b7b25c3d3f42348903e0154840f8761f306Timo Sirainenstruct mail_search_arg *
4fc52b7b25c3d3f42348903e0154840f8761f306Timo Sirainenmail_search_build_str(struct mail_search_build_context *ctx,
4fc52b7b25c3d3f42348903e0154840f8761f306Timo Sirainen enum mail_search_arg_type type);
5c2d695acf9f95ae0dcdda89c4d2391ceda4d672Timo Sirainen/* Returns 0 if arg is returned, -1 if error. */
5c2d695acf9f95ae0dcdda89c4d2391ceda4d672Timo Sirainenint mail_search_build_key(struct mail_search_build_context *ctx,
5c2d695acf9f95ae0dcdda89c4d2391ceda4d672Timo Sirainen struct mail_search_arg *parent,
5c2d695acf9f95ae0dcdda89c4d2391ceda4d672Timo Sirainen struct mail_search_arg **arg_r);
20b2d47ed762ca2c009aa37e360af6f223ac71bdTimo Sirainen
1176124297af5c56e932c0863c6637ff21d8a0efTimo Sirainen#endif