#ifndef IMAP_FETCH_H
#define IMAP_FETCH_H
struct imap_fetch_context;
enum imap_fetch_handler_flags {
};
/* Returns 1 = ok, 0 = client output buffer full, call again, -1 = error.
mail = NULL for deinit. */
struct imap_fetch_init_context {
const char *name;
const char *error;
};
struct imap_fetch_handler {
const char *name;
/* Returns FALSE and sets ctx->error if arg is invalid */
};
struct imap_fetch_context_handler {
void *context;
const char *name;
const char *nil_reply;
};
struct imap_fetch_qresync_args {
};
struct imap_fetch_state {
unsigned int cur_handler;
const char *cur_human_name;
bool skip_cr;
/* TRUE if the first FETCH parameter result hasn't yet been sent to
the IMAP client. Note that this doesn't affect buffered content in
cur_str until it gets flushed out. */
/* TRUE if the cur_str prefix has been flushed. More data may still
be added to it. */
};
struct imap_fetch_context {
const char *reason;
unsigned int buffered_handlers_count;
unsigned int fetched_mails_count;
const char *errstr;
};
void imap_fetch_handler_unregister(const char *name);
const char *nil_reply,
CALLBACK_TYPECHECK(handler, int (*)( \
struct imap_fetch_context *, struct mail *, \
struct imap_fetch_context **fetch_ctx_r,
const char **error_r);
struct imap_fetch_context *
bool (*init)(struct imap_fetch_init_context *));
struct mail_search_args *search_args);
const struct mail_search_args *search_args,
const struct imap_fetch_qresync_args *qresync_args);
/* Returns 1 if finished, 0 if more data is needed, -1 if error.
When 0 is returned, line_partial=TRUE if literal is open and must be
finished before anything else to client. */
struct client_command_context *cmd);
The caller must handle this itself. */
struct client_command_context *cmd);
void imap_fetch_handlers_init(void);
void imap_fetch_handlers_deinit(void);
#endif