]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: smtp-server-command - Perform initial command execution in separate function.
authorStephan Bosch <stephan.bosch@open-xchange.com>
Tue, 24 Mar 2020 11:23:32 +0000 (12:23 +0100)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 1 Apr 2020 08:49:25 +0000 (11:49 +0300)
src/lib-smtp/smtp-server-command.c
src/lib-smtp/smtp-server-connection.c
src/lib-smtp/smtp-server-private.h

index b5cdf992bf67c2797fa4432667402ee427088eda..67424b60a7492f4a1f9968517d4428a01a135a85 100644 (file)
@@ -179,7 +179,7 @@ smtp_server_command_new_invalid(struct smtp_server_connection *conn)
 
 struct smtp_server_command *
 smtp_server_command_new(struct smtp_server_connection *conn,
-                       const char *name, const char *params)
+                       const char *name)
 {
        struct smtp_server *server = conn->server;
        struct smtp_server_command *cmd;
@@ -195,6 +195,14 @@ smtp_server_command_new(struct smtp_server_connection *conn,
                set_name("smtp_server_command_started");
        e_debug(e->event(), "New command");
 
+       return cmd;
+}
+
+void smtp_server_command_execute(struct smtp_server_command *cmd,
+                                const char *params)
+{
+       struct smtp_server_connection *conn = cmd->context.conn;
+
        if (cmd->reg == NULL) {
                /* RFC 5321, Section 4.2.4: Reply Code 502
 
@@ -251,7 +259,6 @@ smtp_server_command_new(struct smtp_server_connection *conn,
                if (!smtp_server_command_unref(&tmp_cmd))
                        cmd = NULL;
        }
-       return cmd;
 }
 
 void smtp_server_command_ref(struct smtp_server_command *cmd)
index 1bfb72859145a814013549a09e39ded942b6c2dc..24843088fc7929c7be8be3ac96e1b204302428ce 100644 (file)
@@ -295,7 +295,8 @@ smtp_server_connection_handle_command(struct smtp_server_connection *conn,
        struct smtp_server_command *cmd;
 
        smtp_server_connection_ref(tmp_conn);
-       cmd = smtp_server_command_new(tmp_conn, cmd_name, cmd_params);
+       cmd = smtp_server_command_new(tmp_conn, cmd_name);
+       smtp_server_command_execute(cmd, cmd_params);
        if (!smtp_server_connection_unref(&tmp_conn)) {
                /* the command start callback managed to get this connection
                   destroyed */
index e0f2d8d27410ffaa33f66c578bb326345f802ede..aa0d30a5eaf3d9435dc9d8753088de5d49e116a0 100644 (file)
@@ -241,8 +241,11 @@ void smtp_server_command_debug(struct smtp_server_cmd_ctx *cmd,
 struct smtp_server_command *
 smtp_server_command_new_invalid(struct smtp_server_connection *conn);
 struct smtp_server_command *
-smtp_server_command_new(struct smtp_server_connection *conn,
-       const char *name, const char *params);
+smtp_server_command_new(struct smtp_server_connection *conn, const char *name);
+
+void smtp_server_command_execute(struct smtp_server_command *cmd,
+                                const char *params);
+
 void smtp_server_command_ref(struct smtp_server_command *cmd);
 bool smtp_server_command_unref(struct smtp_server_command **_cmd);
 void smtp_server_command_abort(struct smtp_server_command **_cmd);