14af7be4aa26d55c341cd6efe32bb2add2c39830Aki Tuomi#define DOVEADM_CMD_PARAMS_START .parameters = (const struct doveadm_cmd_param[]){
14102a0c5db8828ca8c7751ec96587fadc97a0bcTimo Sirainen#define DOVEADM_CMD_PARAM(optP, nameP, typeP, flagP ) { .short_opt = optP, .name = nameP, .type = typeP, .flags = flagP },
14102a0c5db8828ca8c7751ec96587fadc97a0bcTimo Sirainen#define DOVEADM_CMD_PARAMS_END { .short_opt = '\0', .name = NULL, .type = CMD_PARAM_BOOL, .flags = CMD_PARAM_FLAG_NONE } }
55accf49e32ff93bfdd92961cb54ccc8c329147cTimo Sirainentypedef void doveadm_command_t(int argc, char *argv[]);
14af7be4aa26d55c341cd6efe32bb2add2c39830Aki Tuomitypedef enum {
05128fda80748e107bccdece0a3d23551e99e8f3Timo Sirainen CMD_PARAM_BOOL = 0, /* value will contain 1 (not pointer) */
14af7be4aa26d55c341cd6efe32bb2add2c39830Aki Tuomi CMD_PARAM_INT64, /* ditto but contains number (not pointer) */
14af7be4aa26d55c341cd6efe32bb2add2c39830Aki Tuomi CMD_PARAM_ARRAY, /* value contains const char*[] */
14af7be4aa26d55c341cd6efe32bb2add2c39830Aki Tuomi CMD_PARAM_ISTREAM /* value contains struct istream* */
14af7be4aa26d55c341cd6efe32bb2add2c39830Aki Tuomitypedef enum {
3fd8086f71f25a68e33993e24123b10b671dac67Aki Tuomitypedef enum {
1e11a94ec50fc9b57eb2c859771c6a326ccaf86fAki TuomiARRAY_DEFINE_TYPE(doveadm_cmd_param_arr_t, struct doveadm_cmd_param);
aaa1b6bb4cd2d7f8f4e7977d61176ea1c8f7e32bAki Tuomitypedef void doveadm_command_ver2_t(struct doveadm_cmd_context *cctx);
14af7be4aa26d55c341cd6efe32bb2add2c39830Aki Tuomi struct doveadm_mail_cmd_context *(*mail_cmd)(void);
aaa1b6bb4cd2d7f8f4e7977d61176ea1c8f7e32bAki Tuomi const struct doveadm_cmd_ver2 *cmd; /* for help */
55accf49e32ff93bfdd92961cb54ccc8c329147cTimo SirainenARRAY_DEFINE_TYPE(doveadm_cmd, struct doveadm_cmd);
14af7be4aa26d55c341cd6efe32bb2add2c39830Aki TuomiARRAY_DEFINE_TYPE(doveadm_cmd_ver2, struct doveadm_cmd_ver2);
14af7be4aa26d55c341cd6efe32bb2add2c39830Aki Tuomiextern ARRAY_TYPE(doveadm_cmd_ver2) doveadm_cmds_ver2;
55accf49e32ff93bfdd92961cb54ccc8c329147cTimo Sirainenextern struct doveadm_cmd doveadm_cmd_mailbox_mutf7;
55accf49e32ff93bfdd92961cb54ccc8c329147cTimo Sirainenextern struct doveadm_cmd doveadm_cmd_sis_deduplicate;
55accf49e32ff93bfdd92961cb54ccc8c329147cTimo Sirainenextern struct doveadm_cmd doveadm_cmd_sis_find;
55accf49e32ff93bfdd92961cb54ccc8c329147cTimo Sirainenextern struct doveadm_cmd doveadm_cmd_zlibconnect;
55accf49e32ff93bfdd92961cb54ccc8c329147cTimo Sirainenvoid doveadm_register_cmd(const struct doveadm_cmd *cmd);
36a052b7bd94ccb47abbb6b15c1380f03780ba20Timo Sirainendoveadm_cmd_find_with_args(const char *cmd_name, int *argc,
36a052b7bd94ccb47abbb6b15c1380f03780ba20Timo Sirainen const char *const *argv[]);
55accf49e32ff93bfdd92961cb54ccc8c329147cTimo Sirainenvoid doveadm_register_replicator_commands(void);
aaa1b6bb4cd2d7f8f4e7977d61176ea1c8f7e32bAki Tuomivoid doveadm_cmd_ver2_to_cmd_wrapper(struct doveadm_cmd_context *cctx);
aaa1b6bb4cd2d7f8f4e7977d61176ea1c8f7e32bAki Tuomivoid doveadm_cmd_ver2_to_mail_cmd_wrapper(struct doveadm_cmd_context *cctx);
14af7be4aa26d55c341cd6efe32bb2add2c39830Aki Tuomivoid doveadm_cmd_register_ver2(struct doveadm_cmd_ver2 *cmd);
6a8c95b0693c93601e948e06bfe1f89abdd43307Timo Sirainendoveadm_cmd_find_with_args_ver2(const char *cmd_name, int *argc,
6a8c95b0693c93601e948e06bfe1f89abdd43307Timo Sirainen const char *const *argv[]);
7a8ef11587fd50d5888223fc3d91911775a21ba5Aki Tuomiconst struct doveadm_cmd_ver2 *doveadm_cmd_find_ver2(const char *cmd_name);
14af7be4aa26d55c341cd6efe32bb2add2c39830Aki Tuomi/* Returns FALSE if cmd_name doesn't exist, TRUE if it exists. */
79bbb900ffba886779474dfb04c41408f0ba0602Timo Sirainenbool doveadm_cmd_try_run_ver2(const char *cmd_name,
14af7be4aa26d55c341cd6efe32bb2add2c39830Aki Tuomi/* Returns 0 if success, -1 if parameters were invalid. */
36a052b7bd94ccb47abbb6b15c1380f03780ba20Timo Sirainenint doveadm_cmd_run_ver2(int argc, const char *const argv[],
aaa1b6bb4cd2d7f8f4e7977d61176ea1c8f7e32bAki Tuomibool doveadm_cmd_param_bool(const struct doveadm_cmd_context *cctx,
aaa1b6bb4cd2d7f8f4e7977d61176ea1c8f7e32bAki Tuomibool doveadm_cmd_param_int64(const struct doveadm_cmd_context *cctx,
aaa1b6bb4cd2d7f8f4e7977d61176ea1c8f7e32bAki Tuomibool doveadm_cmd_param_str(const struct doveadm_cmd_context *cctx,
aaa1b6bb4cd2d7f8f4e7977d61176ea1c8f7e32bAki Tuomibool doveadm_cmd_param_ip(const struct doveadm_cmd_context *cctx,
aaa1b6bb4cd2d7f8f4e7977d61176ea1c8f7e32bAki Tuomibool doveadm_cmd_param_array(const struct doveadm_cmd_context *cctx,
4afc67eb96f8d6b7dc94d63d3c7fe4f556c4fceeTimo Sirainen const char *name, const char *const **value_r);
aaa1b6bb4cd2d7f8f4e7977d61176ea1c8f7e32bAki Tuomibool doveadm_cmd_param_istream(const struct doveadm_cmd_context *cctx,
1e8a6a8708b612eee65f83ef6874aab94b15eb50Timo Sirainenvoid doveadm_cmd_params_clean(ARRAY_TYPE(doveadm_cmd_param_arr_t) *pargv);
2029c2cb37d7308e74329c9a15b6cf07a3468314Timo Sirainenvoid doveadm_cmd_params_null_terminate_arrays(ARRAY_TYPE(doveadm_cmd_param_arr_t) *pargv);
53309922d2ec3321e011966e8f2b210821ecd5e3Timo Sirainenextern struct doveadm_cmd_ver2 doveadm_cmd_service_stop_ver2;
eba7f36feec8d02c4c394e55ff4effd47e33d311Timo Sirainenextern struct doveadm_cmd_ver2 doveadm_cmd_service_status_ver2;
d78f1ac9dc0f3e6c64cebe9ee331ec6b3c160e89Timo Sirainenextern struct doveadm_cmd_ver2 doveadm_cmd_process_status_ver2;
68cc278710182485b6c09e9a9ff8db90a727f343Aki Tuomiextern struct doveadm_cmd_ver2 doveadm_cmd_stop_ver2;
68cc278710182485b6c09e9a9ff8db90a727f343Aki Tuomiextern struct doveadm_cmd_ver2 doveadm_cmd_reload_ver2;
285f3c4cf828ebe9ff345080aa1df3755613af29Timo Sirainenextern struct doveadm_cmd_ver2 doveadm_cmd_stats_dump_ver2;
6ef83bcdc4e40d6b387857e5f7d58cd86c71ec50Timo Sirainenextern struct doveadm_cmd_ver2 doveadm_cmd_oldstats_reset_ver2;
6ef83bcdc4e40d6b387857e5f7d58cd86c71ec50Timo Sirainenextern struct doveadm_cmd_ver2 doveadm_cmd_oldstats_dump_ver2;
6ef83bcdc4e40d6b387857e5f7d58cd86c71ec50Timo Sirainenextern struct doveadm_cmd_ver2 doveadm_cmd_oldstats_top_ver2;
7616a1520f0d8ee5cc96f6b044c7fde1a9f9798cAki Tuomiextern struct doveadm_cmd_ver2 doveadm_cmd_penalty_ver2;
6eb1a7a7ae2c1dfff6731956ade08f9a4a7c791aAki Tuomiextern struct doveadm_cmd_ver2 doveadm_cmd_kick_ver2;