c116e589182c258b463850327755e6dd9a731616Stephan Bosch/* Copyright (c) 2018 Dovecot authors, see the included COPYING file */
c116e589182c258b463850327755e6dd9a731616Stephan Bosch
c116e589182c258b463850327755e6dd9a731616Stephan Bosch#include "lib.h"
c116e589182c258b463850327755e6dd9a731616Stephan Bosch#include "smtp-server.h"
c116e589182c258b463850327755e6dd9a731616Stephan Bosch#include "lmtp-common.h"
c116e589182c258b463850327755e6dd9a731616Stephan Bosch
c116e589182c258b463850327755e6dd9a731616Stephan Boschvoid lmtp_recipient_init(struct lmtp_recipient *rcpt,
c116e589182c258b463850327755e6dd9a731616Stephan Bosch struct client *client,
11c80f46431050af464b044126887e81cb91e929Stephan Bosch enum lmtp_recipient_type type,
c116e589182c258b463850327755e6dd9a731616Stephan Bosch struct smtp_server_cmd_ctx *cmd,
c116e589182c258b463850327755e6dd9a731616Stephan Bosch struct smtp_server_cmd_rcpt *data)
c116e589182c258b463850327755e6dd9a731616Stephan Bosch{
c116e589182c258b463850327755e6dd9a731616Stephan Bosch rcpt->client = client;
11c80f46431050af464b044126887e81cb91e929Stephan Bosch rcpt->type = type;
c116e589182c258b463850327755e6dd9a731616Stephan Bosch rcpt->rcpt_cmd = cmd;
c116e589182c258b463850327755e6dd9a731616Stephan Bosch rcpt->path = data->path;
c116e589182c258b463850327755e6dd9a731616Stephan Bosch}
c116e589182c258b463850327755e6dd9a731616Stephan Bosch
c116e589182c258b463850327755e6dd9a731616Stephan Boschvoid lmtp_recipient_finish(struct lmtp_recipient *rcpt,
c116e589182c258b463850327755e6dd9a731616Stephan Bosch struct smtp_server_recipient *trcpt,
c116e589182c258b463850327755e6dd9a731616Stephan Bosch unsigned int index)
c116e589182c258b463850327755e6dd9a731616Stephan Bosch{
c116e589182c258b463850327755e6dd9a731616Stephan Bosch trcpt->context = rcpt;
c116e589182c258b463850327755e6dd9a731616Stephan Bosch
c116e589182c258b463850327755e6dd9a731616Stephan Bosch rcpt->rcpt = trcpt;
c116e589182c258b463850327755e6dd9a731616Stephan Bosch rcpt->index = index;
c116e589182c258b463850327755e6dd9a731616Stephan Bosch rcpt->rcpt_cmd = NULL;
c116e589182c258b463850327755e6dd9a731616Stephan Bosch}
80f5e1ea615677c1c37be6e7abb888c9cc22de3bStephan Bosch
80f5e1ea615677c1c37be6e7abb888c9cc22de3bStephan Boschstruct lmtp_recipient *
80f5e1ea615677c1c37be6e7abb888c9cc22de3bStephan Boschlmtp_recipient_find_duplicate(struct lmtp_recipient *rcpt,
80f5e1ea615677c1c37be6e7abb888c9cc22de3bStephan Bosch struct smtp_server_transaction *trans)
80f5e1ea615677c1c37be6e7abb888c9cc22de3bStephan Bosch{
80f5e1ea615677c1c37be6e7abb888c9cc22de3bStephan Bosch struct smtp_server_recipient *drcpt;
80f5e1ea615677c1c37be6e7abb888c9cc22de3bStephan Bosch struct lmtp_recipient *dup_rcpt;
80f5e1ea615677c1c37be6e7abb888c9cc22de3bStephan Bosch
80f5e1ea615677c1c37be6e7abb888c9cc22de3bStephan Bosch i_assert(rcpt->rcpt != NULL);
80f5e1ea615677c1c37be6e7abb888c9cc22de3bStephan Bosch drcpt = smtp_server_transaction_find_rcpt_duplicate(trans, rcpt->rcpt);
80f5e1ea615677c1c37be6e7abb888c9cc22de3bStephan Bosch if (drcpt == NULL)
80f5e1ea615677c1c37be6e7abb888c9cc22de3bStephan Bosch return NULL;
80f5e1ea615677c1c37be6e7abb888c9cc22de3bStephan Bosch
80f5e1ea615677c1c37be6e7abb888c9cc22de3bStephan Bosch dup_rcpt = drcpt->context;
80f5e1ea615677c1c37be6e7abb888c9cc22de3bStephan Bosch i_assert(dup_rcpt->rcpt == drcpt);
80f5e1ea615677c1c37be6e7abb888c9cc22de3bStephan Bosch i_assert(dup_rcpt->type == rcpt->type);
80f5e1ea615677c1c37be6e7abb888c9cc22de3bStephan Bosch
80f5e1ea615677c1c37be6e7abb888c9cc22de3bStephan Bosch return dup_rcpt;
80f5e1ea615677c1c37be6e7abb888c9cc22de3bStephan Bosch}
80f5e1ea615677c1c37be6e7abb888c9cc22de3bStephan Bosch