Mercurial > dovecot > core-2.2
changeset 21893:5511ffac2ca4
imap: Add imap_client_command_get_reason()
All the command -> reason string conversions now go through this function.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Tue, 04 Apr 2017 15:38:00 +0300 |
parents | 22c5f005625a |
children | cb05b557fd74 |
files | src/imap/cmd-fetch.c src/imap/imap-commands-util.c src/imap/imap-commands-util.h |
diffstat | 3 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap/cmd-fetch.c Tue Apr 04 13:28:44 2017 +0300 +++ b/src/imap/cmd-fetch.c Tue Apr 04 15:38:00 2017 +0300 @@ -310,7 +310,7 @@ return ret < 0; ctx = imap_fetch_alloc(client, cmd->pool, - t_strdup_printf("%s %s", cmd->name, cmd->args)); + imap_client_command_get_reason(cmd)); if (!fetch_parse_args(ctx, cmd, &args[1], &next_arg) || (imap_arg_get_list(next_arg, &list_arg) &&
--- a/src/imap/imap-commands-util.c Tue Apr 04 13:28:44 2017 +0300 +++ b/src/imap/imap-commands-util.c Tue Apr 04 15:38:00 2017 +0300 @@ -132,11 +132,16 @@ return 0; } +const char *imap_client_command_get_reason(struct client_command_context *cmd) +{ + return cmd->args[0] == '\0' ? cmd->name : + t_strdup_printf("%s %s", cmd->name, cmd->args); +} + void imap_transaction_set_cmd_reason(struct mailbox_transaction_context *trans, struct client_command_context *cmd) { - mailbox_transaction_set_reason(trans, cmd->args[0] == '\0' ? cmd->name : - t_strdup_printf("%s %s", cmd->name, cmd->args)); + mailbox_transaction_set_reason(trans, imap_client_command_get_reason(cmd)); } const char *
--- a/src/imap/imap-commands-util.h Tue Apr 04 13:28:44 2017 +0300 +++ b/src/imap/imap-commands-util.h Tue Apr 04 15:38:00 2017 +0300 @@ -27,6 +27,8 @@ int client_open_save_dest_box(struct client_command_context *cmd, const char *name, struct mailbox **destbox_r); +/* Returns string based in IMAP command name and parameters. */ +const char *imap_client_command_get_reason(struct client_command_context *cmd); /* Set transaction's reason to the IMAP command name and parameters. */ void imap_transaction_set_cmd_reason(struct mailbox_transaction_context *trans, struct client_command_context *cmd);