]> 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)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 20 May 2020 07:21:19 +0000 (07:21 +0000)
src/lib-smtp/smtp-server-command.c
src/lib-smtp/smtp-server-connection.c
src/lib-smtp/smtp-server-private.h

index c9b551b6ac687b8a37d1c9b72052e552f6389edf..c250ac169dc50881d63cda77ac57eacf30c348ac 100644 (file)
@@ -184,7 +184,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;
@@ -200,6 +200,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
 
@@ -256,7 +264,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 77380a0f729b2b93a28650ddc3d371c28c36bbfe..ff8f04864aa8d4730b36bfd0a2bd452ca08bcc4a 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 640d6d6c05991cff5b17ac0d35d886da3f10c524..ef593f9dd24d781aec672f9afb27303ed037fd39 100644 (file)
@@ -242,8 +242,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);