From ef6614a0ce6eba2a06bb9237dcd06a412bf419a3 Mon Sep 17 00:00:00 2001 From: Timo Sirainen <timo.sirainen@open-xchange.com> Date: Thu, 2 May 2019 16:01:42 +0300 Subject: [PATCH] plugins: imap-filter-sieve: Cleanup - write FILTERED reply to string first Simplifies the next commit. --- src/plugins/imap-filter-sieve/imap-filter.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/plugins/imap-filter-sieve/imap-filter.c b/src/plugins/imap-filter-sieve/imap-filter.c index 8baadafcf..65c0bf7d1 100644 --- a/src/plugins/imap-filter-sieve/imap-filter.c +++ b/src/plugins/imap-filter-sieve/imap-filter.c @@ -37,6 +37,7 @@ imap_filter_mail(struct client_command_context *cmd, struct mail *mail) struct client *client = cmd->client; string_t *errors = NULL; bool have_warnings = FALSE; + string_t *reply = t_str_new(128); int ret; // FIXME: return fatal error status when no mail filter activity will @@ -44,20 +45,18 @@ imap_filter_mail(struct client_command_context *cmd, struct mail *mail) ret = imap_sieve_filter_run_mail(ctx->sieve, mail, &errors, &have_warnings); - o_stream_nsend_str(client->output, - t_strdup_printf("* %u FILTERED (TAG %s) UID %u ", - mail->seq, cmd->tag, mail->uid)); + str_printfa(reply, "* %u FILTERED (TAG %s) UID %u ", + mail->seq, cmd->tag, mail->uid); if (ret < 0 || have_warnings) { - o_stream_nsend_str(client->output, - t_strdup_printf("%s {%"PRIuSIZE_T"}\r\n", - (ret < 0 ? "ERRORS" : "WARNINGS"), - str_len(errors))); - o_stream_nsend(client->output, - str_data(errors), str_len(errors)); - o_stream_nsend_str(client->output, "\r\n"); + str_printfa(reply, "%s {%"PRIuSIZE_T"}\r\n", + (ret < 0 ? "ERRORS" : "WARNINGS"), + str_len(errors)); + str_append_str(reply, errors); + str_append(reply, "\r\n"); } else { - o_stream_nsend_str(client->output, "OK\r\n"); + str_append(reply, "OK\r\n"); } + o_stream_nsend(client->output, str_data(reply), str_len(reply)); /* Handle the result */ if (ret < 0) { -- GitLab