doveadm-mail.h revision e09c7dc961cb9cab04ec7cc79215c2f6318fbde0
5f5870385cff47efd2f58e7892f251cf13761528Timo Sirainen#ifndef DOVEADM_MAIL_H
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen#define DOVEADM_MAIL_H
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen#include "doveadm.h"
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainenstruct mail_user;
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainenstruct doveadm_mail_cmd_context;
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainenstruct doveadm_mail_cmd_context {
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen pool_t pool;
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen const char *getopt_args;
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen bool (*parse_arg)(struct doveadm_mail_cmd_context *ctx,int c);
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen void (*init)(struct doveadm_mail_cmd_context *ctx,
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen const char *const args[]);
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen void (*run)(struct doveadm_mail_cmd_context *ctx,
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen struct mail_user *mail_user);
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen void (*deinit)(struct doveadm_mail_cmd_context *ctx);
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen};
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainenstruct doveadm_mail_cmd {
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen struct doveadm_mail_cmd_context *(*alloc)(void);
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen const char *name;
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen const char *usage_args;
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen};
01435c38e7d671d5a892c4b802cfb204881cd454Timo SirainenARRAY_DEFINE_TYPE(doveadm_mail_cmd, struct doveadm_mail_cmd);
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainenextern ARRAY_TYPE(doveadm_mail_cmd) doveadm_mail_cmds;
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainenbool doveadm_mail_try_run(const char *cmd_name, int argc, char *argv[]);
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainenvoid doveadm_mail_register_cmd(const struct doveadm_mail_cmd *cmd);
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainenvoid doveadm_mail_usage(void);
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainenvoid doveadm_mail_help(const struct doveadm_mail_cmd *cmd) ATTR_NORETURN;
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainenvoid doveadm_mail_help_name(const char *cmd_name) ATTR_NORETURN;
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainenvoid doveadm_mail_try_help_name(const char *cmd_name);
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainenvoid doveadm_mail_init(void);
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainenvoid doveadm_mail_deinit(void);
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainenstruct mailbox *
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainendoveadm_mailbox_find_and_sync(struct mail_user *user, const char *mailbox);
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainenstruct mail_search_args *
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainendoveadm_mail_build_search_args(const char *const args[]);
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainenstruct doveadm_mail_cmd_context *
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainendoveadm_mail_cmd_alloc_size(size_t size);
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen#define doveadm_mail_cmd_alloc(type) \
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen (type *)doveadm_mail_cmd_alloc_size(sizeof(type))
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainenstruct doveadm_mail_cmd cmd_expunge;
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainenstruct doveadm_mail_cmd cmd_search;
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainenstruct doveadm_mail_cmd cmd_fetch;
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainenstruct doveadm_mail_cmd cmd_altmove;
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainenstruct doveadm_mail_cmd cmd_mailbox_list;
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainenstruct doveadm_mail_cmd cmd_mailbox_create;
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainenstruct doveadm_mail_cmd cmd_mailbox_delete;
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainenstruct doveadm_mail_cmd cmd_mailbox_rename;
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen#endif
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen