/*! * \internal * \brief Delete the requested mailboxes. * \since 12.1.0 * * \param s AMI session. * \param m AMI message. * * \retval 0 to keep AMI connection. * \retval -1 to disconnect AMI connection. */ static int mwi_mailbox_delete(struct mansession *s, const struct message *m) { const char *mailbox_id = astman_get_header(m, "Mailbox"); if (ast_strlen_zero(mailbox_id)) { astman_send_error(s, m, "Missing mailbox parameter in request"); return 0; } if (*mailbox_id == '/') { struct ast_str *regex_string; regex_string = ast_str_create(strlen(mailbox_id) + 1); if (!regex_string) { astman_send_error(s, m, "Memory Allocation Failure"); return 0; } /* Make "/regex/" into "regex" */ if (ast_regex_string_to_regex_pattern(mailbox_id, ®ex_string) != 0) { astman_send_error_va(s, m, "Mailbox regex format invalid in: %s", mailbox_id); ast_free(regex_string); return 0; } ast_mwi_mailbox_delete_by_regex(ast_str_buffer(regex_string)); ast_free(regex_string); } else { ast_mwi_mailbox_delete(mailbox_id); } astman_send_ack(s, m, NULL); return 0; }
static char *handle_mwi_delete_like(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { const char *regex; switch (cmd) { case CLI_INIT: e->command = "mwi delete like"; e->usage = "Usage: mwi delete like <pattern>\n" " Delete external MWI mailboxes matching a regular expression.\n"; return NULL; case CLI_GENERATE: return NULL; } if (a->argc != 4) { return CLI_SHOWUSAGE; } regex = a->argv[3]; ast_mwi_mailbox_delete_by_regex(regex); ast_cli(a->fd, "Deleted external MWI mailboxes matching '%s'.\n", regex); return CLI_SUCCESS; }