mail-search-build.h revision 4fc52b7b25c3d3f42348903e0154840f8761f306
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 imap_arg;
1176124297af5c56e932c0863c6637ff21d8a0efTimo Sirainenstruct mailbox;
1176124297af5c56e932c0863c6637ff21d8a0efTimo Sirainen
20b2d47ed762ca2c009aa37e360af6f223ac71bdTimo Sirainenstruct mail_search_build_context {
20b2d47ed762ca2c009aa37e360af6f223ac71bdTimo Sirainen pool_t pool;
20b2d47ed762ca2c009aa37e360af6f223ac71bdTimo Sirainen struct mail_search_register *reg;
4fc52b7b25c3d3f42348903e0154840f8761f306Timo Sirainen
4fc52b7b25c3d3f42348903e0154840f8761f306Timo Sirainen struct mail_search_arg *parent;
20b2d47ed762ca2c009aa37e360af6f223ac71bdTimo 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. */
4fc52b7b25c3d3f42348903e0154840f8761f306Timo Sirainenint mail_search_build_from_imap_args(struct mail_search_register *reg,
4fc52b7b25c3d3f42348903e0154840f8761f306Timo Sirainen const struct imap_arg *imap_args,
c4b376dd6e0c423006d7ac83a39253bcaf8e7c47Timo Sirainen const char *charset,
c4b376dd6e0c423006d7ac83a39253bcaf8e7c47Timo Sirainen struct mail_search_args **args_r,
c4b376dd6e0c423006d7ac83a39253bcaf8e7c47Timo Sirainen 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 Sirainenint mail_search_build_next_astring(struct mail_search_build_context *ctx,
4fc52b7b25c3d3f42348903e0154840f8761f306Timo Sirainen const struct imap_arg **imap_args,
4fc52b7b25c3d3f42348903e0154840f8761f306Timo Sirainen const char **value_r);
4fc52b7b25c3d3f42348903e0154840f8761f306Timo 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 const struct imap_arg **imap_args,
4fc52b7b25c3d3f42348903e0154840f8761f306Timo Sirainen enum mail_search_arg_type type);
20b2d47ed762ca2c009aa37e360af6f223ac71bdTimo Sirainenstruct mail_search_arg *
20b2d47ed762ca2c009aa37e360af6f223ac71bdTimo Sirainenmail_search_build_next(struct mail_search_build_context *ctx,
4fc52b7b25c3d3f42348903e0154840f8761f306Timo Sirainen struct mail_search_arg *parent,
20b2d47ed762ca2c009aa37e360af6f223ac71bdTimo Sirainen const struct imap_arg **imap_args);
4fc52b7b25c3d3f42348903e0154840f8761f306Timo Sirainenstruct mail_search_arg *
4fc52b7b25c3d3f42348903e0154840f8761f306Timo Sirainenmail_search_build_list(struct mail_search_build_context *ctx,
4fc52b7b25c3d3f42348903e0154840f8761f306Timo Sirainen const struct imap_arg *imap_args);
20b2d47ed762ca2c009aa37e360af6f223ac71bdTimo Sirainen
1176124297af5c56e932c0863c6637ff21d8a0efTimo Sirainen#endif