]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: server: Add ability to determine whether command reply was created using...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Fri, 28 Sep 2018 22:19:05 +0000 (00:19 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Tue, 12 Feb 2019 13:40:48 +0000 (15:40 +0200)
src/lib-smtp/smtp-server-command.c
src/lib-smtp/smtp-server-private.h
src/lib-smtp/smtp-server-reply.c
src/lib-smtp/smtp-server.h

index 7c9adea357372c462d747b45a8fe5697de2121b7..aeb097d0cc2e203cf4dd6067b76654f92ecb1d57 100644 (file)
@@ -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)
index c9d060af4161f977919a83b734962bcd7040dae0..dad37cdfe1f4e1010c73f9bf9a907c5940bdd105 100644 (file)
@@ -71,6 +71,7 @@ struct smtp_server_reply {
 
        bool submitted:1;
        bool sent:1;
+       bool forwarded:1;
 };
 
 struct smtp_server_command_reg {
index d5c4e0c658bb0baf2c606ae1bc9d3b538b51da53..780cb2ba0986dcf971ccf5f7b7bc3743f342bdc2 100644 (file)
@@ -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;
 }
index fae54b316cc9a992236f0e97bca798b278d7f0ee..c65f2165bccc26e87fce79a43c2fad867ea31e30 100644 (file)
@@ -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);