From: Stephan Bosch Date: Fri, 28 Sep 2018 22:19:05 +0000 (+0200) Subject: lib-smtp: server: Add ability to determine whether command reply was created using... X-Git-Tag: 2.3.9~1268 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46a6901cd14512db2455c9562beecb9f857dbbb6;p=thirdparty%2Fdovecot%2Fcore.git lib-smtp: server: Add ability to determine whether command reply was created using smtp_server_reply_create_forward(). --- diff --git a/src/lib-smtp/smtp-server-command.c b/src/lib-smtp/smtp-server-command.c index 7c9adea357..aeb097d0cc 100644 --- a/src/lib-smtp/smtp-server-command.c +++ b/src/lib-smtp/smtp-server-command.c @@ -506,6 +506,25 @@ bool smtp_server_command_is_replied(struct smtp_server_command *cmd) return TRUE; } +bool smtp_server_command_reply_is_forwarded(struct smtp_server_command *cmd) +{ + unsigned int i; + + if (!array_is_created(&cmd->replies)) + return FALSE; + + for (i = 0; i < cmd->replies_expected; i++) { + const struct smtp_server_reply *reply = + array_idx(&cmd->replies, i); + if (!reply->submitted) + return FALSE; + if (reply->forwarded) + return TRUE; + } + + return FALSE; +} + struct smtp_server_reply * smtp_server_command_get_reply(struct smtp_server_command *cmd, unsigned int idx) diff --git a/src/lib-smtp/smtp-server-private.h b/src/lib-smtp/smtp-server-private.h index c9d060af41..dad37cdfe1 100644 --- a/src/lib-smtp/smtp-server-private.h +++ b/src/lib-smtp/smtp-server-private.h @@ -71,6 +71,7 @@ struct smtp_server_reply { bool submitted:1; bool sent:1; + bool forwarded:1; }; struct smtp_server_command_reg { diff --git a/src/lib-smtp/smtp-server-reply.c b/src/lib-smtp/smtp-server-reply.c index d5c4e0c658..780cb2ba09 100644 --- a/src/lib-smtp/smtp-server-reply.c +++ b/src/lib-smtp/smtp-server-reply.c @@ -70,6 +70,7 @@ static void smtp_server_reply_clear(struct smtp_server_reply *reply) reply->command->replies_submitted--; } reply->submitted = FALSE; + reply->forwarded = FALSE; } static struct smtp_server_reply * @@ -156,6 +157,7 @@ smtp_server_reply_create_forward(struct smtp_server_command *cmd, reply = smtp_server_reply_create_index(cmd, index, from->status, smtp_reply_get_enh_code(from)); smtp_reply_write(reply->content->text, from); + reply->forwarded = TRUE; return reply; } diff --git a/src/lib-smtp/smtp-server.h b/src/lib-smtp/smtp-server.h index fae54b316c..c65f2165bc 100644 --- a/src/lib-smtp/smtp-server.h +++ b/src/lib-smtp/smtp-server.h @@ -466,6 +466,7 @@ smtp_server_command_get_reply(struct smtp_server_command *cmd, bool smtp_server_command_reply_status_equals(struct smtp_server_command *cmd, unsigned int status); bool smtp_server_command_is_replied(struct smtp_server_command *cmd); +bool smtp_server_command_reply_is_forwarded(struct smtp_server_command *cmd); bool smtp_server_command_replied_success(struct smtp_server_command *cmd); void smtp_server_command_input_lock(struct smtp_server_cmd_ctx *cmd);