doveadm-mail.h revision c220c8cd341ee9ba78979397c5d33ccd98b5d19f
#ifndef DOVEADM_MAIL_H
#define DOVEADM_MAIL_H
#include <stdio.h>
#include "doveadm.h"
#include "doveadm-util.h"
#include "module-context.h"
#include "mail-error.h"
#include "mail-storage-service.h"
struct mailbox;
struct mailbox_list;
struct mail_storage;
struct mail_user;
struct doveadm_mail_cmd_context;
struct doveadm_mail_cmd_vfuncs {
/* Parse one getopt() parameter. This is called for each parameter. */
/* Usually not needed. The preinit() is called just after parsing all
parameters, but before any userdb lookups are done. This allows the
preinit() to alter the userdb lookup behavior (especially
service_flags). */
/* Initialize the command. Most importantly if the function prints
anything, this should initialize the headers. It shouldn't however
do any actual work. The init() is called also when doveadm is
performing the work via doveadm-server, which could be running
remotely with completely different Dovecot configuration. */
const char *const args[]);
/* Usually not needed. When iterating through multiple users, use this
function to get the next username. Overriding this is usually done
only when there's a known username filter, such as the expire
plugin. */
const char **username_r);
/* Usually not needed. This is called between
mail_storage_service_lookup() and mail_storage_service_next() for
each user. */
struct mail_storage_service_user *service_user,
const char **error_r);
/* This is the main function which performs all the work for the
command. This is called once per each user. */
/* Deinitialize the command. Called once at the end - even if
preinit() or init() was never called. */
};
struct doveadm_mail_cmd_module_register {
unsigned int id;
};
union doveadm_mail_cmd_module_context {
struct doveadm_mail_cmd_vfuncs super;
struct doveadm_mail_cmd_module_register *reg;
};
struct doveadm_mail_cmd_context {
const struct doveadm_mail_cmd *cmd;
const char *const *args;
/* args including -options */
const char *const *full_args;
/* connection via doveadm-server */
struct client_connection *conn;
const char *getopt_args;
const struct doveadm_settings *set;
struct mail_storage_service_ctx *storage_service;
/* search args aren't set for all mail commands */
struct mail_search_args *search_args;
struct istream *users_list_input;
struct ip_addr cur_client_ip;
const char *cur_username;
struct mail_user *cur_mail_user;
struct doveadm_mail_cmd_vfuncs v;
int cmd_input_fd;
/* if non-zero, exit with this code */
int exit_code;
/* This command is being called by a remote doveadm client. */
unsigned int proxying:1;
/* We're handling only a single user */
unsigned int iterate_single_user:1;
/* We're going through all users (not set for wildcard usernames) */
unsigned int iterate_all_users:1;
/* Running from CLI doveadm (not doveadm-server) */
unsigned int cli:1;
};
struct doveadm_mail_cmd {
struct doveadm_mail_cmd_context *(*alloc)(void);
const char *name;
const char *usage_args;
};
extern struct doveadm_mail_cmd_module_register doveadm_mail_cmd_module_register;
extern char doveadm_mail_cmd_hide;
bool doveadm_is_killed(void);
int doveadm_killed_signo(void);
void doveadm_mail_try_help_name(const char *cmd_name);
bool doveadm_mail_has_subcommands(const char *cmd_name);
void doveadm_mail_init(void);
void doveadm_mail_deinit(void);
const struct doveadm_mail_cmd *
const char *const **argv);
struct doveadm_mail_cmd_context *
const struct doveadm_settings *set);
const struct doveadm_cmd_context *cctx,
const char **error_r);
const struct mail_storage_service_input *input,
const char **error_r);
void doveadm_mail_server_flush(void);
/* Request input stream to be read (from stdin). This must be called from
the command's init() function. */
struct mailbox *
struct mail_search_args *
doveadm_mail_build_search_args(const char *const args[]);
void doveadm_mailbox_args_check(const char *const args[]);
struct mail_search_args *
doveadm_mail_mailbox_search_args_build(const char *const args[]);
struct doveadm_mail_cmd_context *
#define doveadm_mail_cmd_alloc(type) \
enum mail_error error);
struct mail_storage *storage);
struct mailbox_list *list);
extern struct doveadm_mail_cmd cmd_batch;
extern struct doveadm_cmd_ver2 doveadm_cmd_mailbox_metadata_set_ver2;
extern struct doveadm_cmd_ver2 doveadm_cmd_mailbox_metadata_unset_ver2;
extern struct doveadm_cmd_ver2 doveadm_cmd_mailbox_metadata_get_ver2;
extern struct doveadm_cmd_ver2 doveadm_cmd_mailbox_metadata_list_ver2;
extern struct doveadm_cmd_ver2 doveadm_cmd_mailbox_status_ver2;
extern struct doveadm_cmd_ver2 doveadm_cmd_mailbox_list_ver2;
extern struct doveadm_cmd_ver2 doveadm_cmd_mailbox_create_ver2;
extern struct doveadm_cmd_ver2 doveadm_cmd_mailbox_delete_ver2;
extern struct doveadm_cmd_ver2 doveadm_cmd_mailbox_rename_ver2;
extern struct doveadm_cmd_ver2 doveadm_cmd_mailbox_subscribe_ver2;
extern struct doveadm_cmd_ver2 doveadm_cmd_mailbox_unsubscribe_ver2;
extern struct doveadm_cmd_ver2 doveadm_cmd_fetch_ver2;
extern struct doveadm_cmd_ver2 doveadm_cmd_save_ver2;
extern struct doveadm_cmd_ver2 doveadm_cmd_index_ver2;
extern struct doveadm_cmd_ver2 doveadm_cmd_altmove_ver2;
extern struct doveadm_cmd_ver2 doveadm_cmd_deduplicate_ver2;
extern struct doveadm_cmd_ver2 doveadm_cmd_expunge_ver2;
extern struct doveadm_cmd_ver2 doveadm_cmd_flags_add_ver2;
extern struct doveadm_cmd_ver2 doveadm_cmd_flags_remove_ver2;
extern struct doveadm_cmd_ver2 doveadm_cmd_flags_replace_ver2;
extern struct doveadm_cmd_ver2 doveadm_cmd_import_ver2;
extern struct doveadm_cmd_ver2 doveadm_cmd_search_ver2;
extern struct doveadm_cmd_ver2 doveadm_cmd_copy_ver2;
extern struct doveadm_cmd_ver2 doveadm_cmd_move_ver2;
extern struct doveadm_cmd_ver2 doveadm_cmd_mailbox_update_ver2;
#define DOVEADM_CMD_MAIL_COMMON \
#define DOVEADM_CMD_MAIL_USAGE_PREFIX \
"[-u <user>|-A] [-S <socket_path>] "
#endif