doveadm-mail.h revision 42681892b206d13cb87a5f526d2bf4ff3f2f4af7
431c0aba57fba2fd6eb398acd6ef4e73b5dc1b86Timo Sirainen /* Parse one getopt() parameter. This is called for each parameter. */
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen bool (*parse_arg)(struct doveadm_mail_cmd_context *ctx, int c);
431c0aba57fba2fd6eb398acd6ef4e73b5dc1b86Timo Sirainen /* Usually not needed. The preinit() is called just after parsing all
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen parameters, but before any userdb lookups are done. This allows the
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen preinit() to alter the userdb lookup behavior (especially
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen service_flags). */
431c0aba57fba2fd6eb398acd6ef4e73b5dc1b86Timo Sirainen void (*preinit)(struct doveadm_mail_cmd_context *ctx);
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen /* Initialize the command. Most importantly if the function prints
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen anything, this should initialize the headers. It shouldn't however
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen do any actual work. The init() is called also when doveadm is
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen performing the work via doveadm-server, which could be running
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen remotely with completely different Dovecot configuration. */
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen void (*init)(struct doveadm_mail_cmd_context *ctx,
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen const char *const args[]);
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen /* Usually not needed. When iterating through multiple users, use this
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen function to get the next username. Overriding this is usually done
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen only when there's a known username filter, such as the expire
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen int (*get_next_user)(struct doveadm_mail_cmd_context *ctx,
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen const char **username_r);
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen /* Usually not needed. This is called between
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen mail_storage_service_lookup() and mail_storage_service_next() for
431c0aba57fba2fd6eb398acd6ef4e73b5dc1b86Timo Sirainen each user. */
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen int (*prerun)(struct doveadm_mail_cmd_context *ctx,
431c0aba57fba2fd6eb398acd6ef4e73b5dc1b86Timo Sirainen struct mail_storage_service_user *service_user,
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen const char **error_r);
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen /* This is the main function which performs all the work for the
431c0aba57fba2fd6eb398acd6ef4e73b5dc1b86Timo Sirainen command. This is called once per each user. */
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen int (*run)(struct doveadm_mail_cmd_context *ctx,
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen /* Deinitialize the command. Called once at the end. */
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen void (*deinit)(struct doveadm_mail_cmd_context *ctx);
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen unsigned int id;
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen const char *const *args;
e93184a9055c2530366dfe617e07199603c399ddMartti Rannanjärvi /* args including -options */
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen const char *const *full_args;
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen /* connection via doveadm-server */
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen enum mail_storage_service_flags service_flags;
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen struct mail_storage_service_ctx *storage_service;
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen struct mail_storage_service_input storage_service_input;
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen /* search args aren't set for all mail commands */
431c0aba57fba2fd6eb398acd6ef4e73b5dc1b86Timo Sirainen struct mail_storage_service_user *cur_service_user;
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen ARRAY(union doveadm_mail_cmd_module_context *) module_contexts;
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen /* if non-zero, exit with this code */
25ec868bd8b5375e1c1c4c3331d761667ddfe26cTimo Sirainen /* This command is being called by a remote doveadm client. */
378e6cb162b355d6f103526505bc00b9a78962e7Timo Sirainen /* We're handling only a single user */
431c0aba57fba2fd6eb398acd6ef4e73b5dc1b86Timo Sirainen /* We're going through all users (not set for wildcard usernames) */
25ec868bd8b5375e1c1c4c3331d761667ddfe26cTimo Sirainen struct doveadm_mail_cmd_context *(*alloc)(void);
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo SirainenARRAY_DEFINE_TYPE(doveadm_mail_cmd, struct doveadm_mail_cmd);
378e6cb162b355d6f103526505bc00b9a78962e7Timo Sirainenextern ARRAY_TYPE(doveadm_mail_cmd) doveadm_mail_cmds;
431c0aba57fba2fd6eb398acd6ef4e73b5dc1b86Timo Sirainenextern void (*hook_doveadm_mail_init)(struct doveadm_mail_cmd_context *ctx);
431c0aba57fba2fd6eb398acd6ef4e73b5dc1b86Timo Sirainenextern struct doveadm_mail_cmd_module_register doveadm_mail_cmd_module_register;
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainenbool doveadm_mail_try_run(const char *cmd_name, int argc, char *argv[]);
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainenvoid doveadm_mail_register_cmd(const struct doveadm_mail_cmd *cmd);
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainenconst struct doveadm_mail_cmd *doveadm_mail_cmd_find(const char *cmd_name);
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainenvoid doveadm_mail_help(const struct doveadm_mail_cmd *cmd) ATTR_NORETURN;
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainenvoid doveadm_mail_help_name(const char *cmd_name) ATTR_NORETURN;
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainenvoid doveadm_mail_try_help_name(const char *cmd_name);
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainenbool doveadm_mail_has_subcommands(const char *cmd_name);
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainendoveadm_mail_cmd_find_from_argv(const char *cmd_name, int *argc,
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen const char *const **argv);
struct doveadm_mail_cmd_context *
const char **error_r);
const char **error_r);
void doveadm_mail_server_flush(void);
struct mailbox *
struct mail_search_args *
struct mail_search_args *
struct doveadm_mail_cmd_context *