From: Stephan Bosch Date: Mon, 11 Feb 2019 23:01:39 +0000 (+0100) Subject: lib-smtp: smtp-server-reply - Add smtp_server_reply_is_success() and use it. X-Git-Tag: 2.3.9~700 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=03ba35df5bb88c3df1d8772cb9f3ee3a5012880f;p=thirdparty%2Fdovecot%2Fcore.git lib-smtp: smtp-server-reply - Add smtp_server_reply_is_success() and use it. --- diff --git a/src/lib-smtp/smtp-server-command.c b/src/lib-smtp/smtp-server-command.c index 0e7ecf8a6d..a7f2d49795 100644 --- a/src/lib-smtp/smtp-server-command.c +++ b/src/lib-smtp/smtp-server-command.c @@ -613,8 +613,7 @@ bool smtp_server_command_replied_success(struct smtp_server_command *cmd) array_idx(&cmd->replies, i); if (!reply->submitted) return FALSE; - i_assert(reply->content != NULL); - if (reply->content->status / 100 == 2) + if (smtp_server_reply_is_success(reply)) success = TRUE; } diff --git a/src/lib-smtp/smtp-server-reply.c b/src/lib-smtp/smtp-server-reply.c index ac926099bd..2069116d9a 100644 --- a/src/lib-smtp/smtp-server-reply.c +++ b/src/lib-smtp/smtp-server-reply.c @@ -488,6 +488,12 @@ int smtp_server_reply_send(struct smtp_server_reply *reply) return ret; } +bool smtp_server_reply_is_success(const struct smtp_server_reply *reply) +{ + i_assert(reply->content != NULL); + return (reply->content->status / 100 == 2); +} + /* * EHLO reply */ diff --git a/src/lib-smtp/smtp-server.h b/src/lib-smtp/smtp-server.h index 152508d801..d1d6414483 100644 --- a/src/lib-smtp/smtp-server.h +++ b/src/lib-smtp/smtp-server.h @@ -650,6 +650,8 @@ void smtp_server_reply_early(struct smtp_server_cmd_ctx *_cmd, /* Reply the command with a 221 bye message */ void smtp_server_reply_quit(struct smtp_server_cmd_ctx *_cmd); +bool smtp_server_reply_is_success(const struct smtp_server_reply *reply); + /* EHLO */ struct smtp_server_reply *