From: Stephan Bosch Date: Sat, 16 Mar 2019 15:24:59 +0000 (+0100) Subject: lib-smtp: smtp-server-recipient - Add smtp_server_recipient_get_reply() and use it. X-Git-Tag: 2.3.8~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=76104d4900f082601b4e5483797dba5c6ebab525;p=thirdparty%2Fdovecot%2Fcore.git lib-smtp: smtp-server-recipient - Add smtp_server_recipient_get_reply() and use it. --- diff --git a/src/lib-smtp/smtp-server-recipient.c b/src/lib-smtp/smtp-server-recipient.c index b4b59c84ec..c57adb4aee 100644 --- a/src/lib-smtp/smtp-server-recipient.c +++ b/src/lib-smtp/smtp-server-recipient.c @@ -134,14 +134,9 @@ void smtp_server_recipient_last_data(struct smtp_server_recipient *rcpt, void smtp_server_recipient_data_replied(struct smtp_server_recipient *rcpt) { - unsigned int reply_index = 0; - if (rcpt->replied) return; - if (HAS_ALL_BITS(rcpt->trans->flags, - SMTP_SERVER_TRANSACTION_FLAG_REPLY_PER_RCPT)) - reply_index = rcpt->index; - if (smtp_server_command_get_reply(rcpt->cmd->cmd, reply_index) == NULL) + if (smtp_server_recipient_get_reply(rcpt) == NULL) return; rcpt->replied = TRUE; if (!smtp_server_recipient_call_hooks( @@ -150,6 +145,15 @@ void smtp_server_recipient_data_replied(struct smtp_server_recipient *rcpt) } } +struct smtp_server_reply * +smtp_server_recipient_get_reply(struct smtp_server_recipient *rcpt) +{ + if (!HAS_ALL_BITS(rcpt->trans->flags, + SMTP_SERVER_TRANSACTION_FLAG_REPLY_PER_RCPT)) + return smtp_server_command_get_reply(rcpt->cmd->cmd, 0); + return smtp_server_command_get_reply(rcpt->cmd->cmd, rcpt->index); +} + bool smtp_server_recipient_is_replied(struct smtp_server_recipient *rcpt) { i_assert(rcpt->cmd != NULL); diff --git a/src/lib-smtp/smtp-server.h b/src/lib-smtp/smtp-server.h index 0509bbcc98..e026c0a314 100644 --- a/src/lib-smtp/smtp-server.h +++ b/src/lib-smtp/smtp-server.h @@ -86,6 +86,8 @@ struct smtp_server_recipient { }; ARRAY_DEFINE_TYPE(smtp_server_recipient, struct smtp_server_recipient *); +struct smtp_server_reply * +smtp_server_recipient_get_reply(struct smtp_server_recipient *rcpt); bool smtp_server_recipient_is_replied(struct smtp_server_recipient *rcpt); void smtp_server_recipient_replyv(struct smtp_server_recipient *rcpt, unsigned int status, const char *enh_code,