main.c \
client.c \
commands.c \
+ lmtp-common.c \
lmtp-local.c \
lmtp-proxy.c \
lmtp-settings.c
main.h \
client.h \
commands.h \
+ lmtp-common.h \
lmtp-local.h \
lmtp-proxy.h \
lmtp-settings.h
#define CLIENT_MAIL_DATA_MAX_INMEMORY_SIZE (1024*128)
-struct lmtp_recipient {
- struct client *client;
-
- struct smtp_address *path;
- struct smtp_server_cmd_ctx *rcpt_cmd;
- struct smtp_server_recipient *rcpt;
- unsigned int index;
-};
-
struct client_state {
const char *name;
unsigned int session_id_seq;
--- /dev/null
+/* Copyright (c) 2018 Dovecot authors, see the included COPYING file */
+
+#include "lib.h"
+#include "smtp-server.h"
+#include "lmtp-common.h"
+
+void lmtp_recipient_init(struct lmtp_recipient *rcpt,
+ struct client *client,
+ struct smtp_server_cmd_ctx *cmd,
+ struct smtp_server_cmd_rcpt *data)
+{
+ rcpt->client = client;
+ rcpt->rcpt_cmd = cmd;
+ rcpt->path = data->path;
+}
+
+void lmtp_recipient_finish(struct lmtp_recipient *rcpt,
+ struct smtp_server_recipient *trcpt,
+ unsigned int index)
+{
+ trcpt->context = rcpt;
+
+ rcpt->rcpt = trcpt;
+ rcpt->index = index;
+ rcpt->rcpt_cmd = NULL;
+}
--- /dev/null
+#ifndef LMTP_COMMON_H
+#define LMTP_COMMON_H
+
+struct smtp_address;
+struct smtp_server_cmd_ctx;
+struct smtp_server_cmd_rcpt;
+struct smtp_server_recipient;
+struct client;
+
+struct lmtp_recipient {
+ struct client *client;
+
+ struct smtp_address *path;
+ struct smtp_server_cmd_ctx *rcpt_cmd;
+ struct smtp_server_recipient *rcpt;
+ unsigned int index;
+};
+
+void lmtp_recipient_init(struct lmtp_recipient *rcpt,
+ struct client *client,
+ struct smtp_server_cmd_ctx *cmd,
+ struct smtp_server_cmd_rcpt *data);
+
+void lmtp_recipient_finish(struct lmtp_recipient *rcpt,
+ struct smtp_server_recipient *trcpt,
+ unsigned int index);
+
+#endif
#include "lmtp-settings.h"
#include "client.h"
#include "main.h"
+#include "lmtp-common.h"
#include "lmtp-settings.h"
#include "lmtp-local.h"
return;
}
- trcpt->context = (void *)rcpt;
+ lmtp_recipient_finish(&rcpt->rcpt, trcpt, index);
/* add to local recipients */
array_append(&client->local->rcpt_to, &rcpt, 1);
-
- rcpt->rcpt.rcpt = trcpt;
- rcpt->rcpt.index = index;
- rcpt->rcpt.rcpt_cmd = NULL;
}
static bool
client->local = lmtp_local_init(client);
rcpt = i_new(struct lmtp_local_recipient, 1);
- rcpt->rcpt.client = client;
- rcpt->rcpt.path = data->path;
- rcpt->rcpt.rcpt_cmd = cmd;
+ lmtp_recipient_init(&rcpt->rcpt, client, cmd, data);
+
rcpt->detail = i_strdup(detail);
rcpt->service_user = service_user;
rcpt->session_id = i_strdup(session_id);
#include "lda-settings.h"
#include "client.h"
#include "main.h"
+#include "lmtp-common.h"
#include "lmtp-settings.h"
#include "lmtp-proxy.h"
cmd->hook_destroy = NULL;
- /* copy to transaction */
- trcpt->context = (void *)rcpt;
+ lmtp_recipient_finish(&rcpt->rcpt, trcpt, index);
/* add to local recipients */
array_append(&client->proxy->rcpt_to, &rcpt, 1);
-
- rcpt->rcpt.rcpt = trcpt;
- rcpt->rcpt.index = index;
- rcpt->rcpt.rcpt_cmd = NULL;
}
static void
pool_unref(&auth_pool);
rcpt = i_new(struct lmtp_proxy_recipient, 1);
- rcpt->rcpt.client = client;
- rcpt->rcpt.rcpt_cmd = cmd;
- rcpt->rcpt.path = data->path;
+ lmtp_recipient_init(&rcpt->rcpt, client, cmd, data);
+
rcpt->conn = conn;
cmd->context = (void*)rcpt;