mail->mail_callback = NULL;
- /* call the callback */
+ /* Call the callback */
if (mail_callback != NULL)
mail_callback(reply, context);
const char *to = smtp_address_encode(rcpt->rcpt_to);
event_set_append_log_prefix(rcpt->event,
- t_strdup_printf("rcpt <%s>: ", str_sanitize(to, 128)));
+ t_strdup_printf("rcpt <%s>: ",
+ str_sanitize(to, 128)));
event_add_str(rcpt->event, "rcpt_to", to);
smtp_params_rcpt_add_to_event(&rcpt->rcpt_params, rcpt->event);
}
static struct smtp_client_transaction_rcpt *
-smtp_client_transaction_rcpt_new(
- struct smtp_client_transaction *trans, pool_t pool,
- const struct smtp_address *rcpt_to,
- const struct smtp_params_rcpt *rcpt_params)
+smtp_client_transaction_rcpt_new(struct smtp_client_transaction *trans,
+ pool_t pool,
+ const struct smtp_address *rcpt_to,
+ const struct smtp_params_rcpt *rcpt_params)
{
struct smtp_client_transaction_rcpt *rcpt;
trans->rcpts_aborted++;
smtp_reply_init(&failure,
- SMTP_CLIENT_COMMAND_ERROR_ABORTED,
- "Aborted");
+ SMTP_CLIENT_COMMAND_ERROR_ABORTED, "Aborted");
failure.enhanced_code = SMTP_REPLY_ENH_CODE(9, 0, 0);
struct event_passthrough *e =
i_assert(prcpt->queued);
if (prcpt->external_pool) {
- /* allocated externally; just remove it from the queue */
+ /* Allocated externally; just remove it from the queue */
prcpt->queued = FALSE;
if (trans->rcpts_send == prcpt)
trans->rcpts_send = prcpt->next;
rcpt = prcpt;
} else {
- /* move to transaction pool */
+ /* Move to transaction pool */
pool = trans->pool;
rcpt = p_new(pool, struct smtp_client_transaction_rcpt, 1);
rcpt->trans = trans;
rcpt->event = prcpt->event;
event_ref(rcpt->event);
- /* free the old object, thereby removing it from the queue */
+ /* Free the old object, thereby removing it from the queue */
smtp_client_transaction_rcpt_free(&prcpt);
}
- /* recipient is approved */
+ /* Recipient is approved */
DLLIST2_APPEND(&trans->rcpts_head, &trans->rcpts_tail, rcpt);
trans->rcpts_count++;
if (trans->rcpts_data == NULL)
smtp_reply_add_to_event(reply, e);
e_debug(e->event(), "Denied");
- /* not pending anymore */
+ /* Not pending anymore */
smtp_client_transaction_rcpt_free(&prcpt);
}
else
smtp_client_transaction_rcpt_denied(_rcpt, reply);
- /* call the callback */
+ /* Call the callback */
if (rcpt_callback != NULL)
rcpt_callback(reply, context);
}
const struct smtp_reply *reply)
{
struct event_passthrough *e;
- unsigned int rcpts_aborted = trans->rcpts_aborted +
- trans->rcpts_queue_count;
+ unsigned int rcpts_aborted = (trans->rcpts_aborted +
+ trans->rcpts_queue_count);
e = event_create_passthrough(trans->event)->
set_name("smtp_client_transaction_finished")->
#undef smtp_client_transaction_create
struct smtp_client_transaction *
smtp_client_transaction_create(struct smtp_client_connection *conn,
- const struct smtp_address *mail_from,
- const struct smtp_params_mail *mail_params,
- enum smtp_client_transaction_flags flags,
- smtp_client_transaction_callback_t *callback, void *context)
+ const struct smtp_address *mail_from,
+ const struct smtp_params_mail *mail_params,
+ enum smtp_client_transaction_flags flags,
+ smtp_client_transaction_callback_t *callback,
+ void *context)
{
struct smtp_client_transaction *trans;
e_debug(trans->event, "Abort");
- /* clean up */
+ /* Clean up */
i_stream_unref(&trans->data_input);
timeout_remove(&trans->to_send);
timeout_remove(&trans->to_finish);
trans->cmd_last = NULL;
- /* abort any pending commands */
+ /* Abort any pending commands */
while (trans->mail_head != NULL) {
struct smtp_client_transaction_mail *mail = trans->mail_head;
smtp_client_connection_abort_transaction(conn, trans);
- /* abort if not finished */
+ /* Abort if not finished */
if (trans->state < SMTP_CLIENT_TRANSACTION_STATE_FINISHED) {
struct event_passthrough *e;
}
void smtp_client_transaction_fail_reply(struct smtp_client_transaction *trans,
- const struct smtp_reply *reply)
+ const struct smtp_reply *reply)
{
struct smtp_client_transaction_rcpt *rcpt, *rcpt_next;
e_debug(trans->event, "Returning failure: %s", smtp_reply_log(reply));
- /* hold a reference to prevent early destruction in a callback */
+ /* Hold a reference to prevent early destruction in a callback */
smtp_client_transaction_ref(trans);
trans->cmd_last = NULL;
/* DATA / RSET */
if (!trans->data_provided && !trans->reset) {
- /* none of smtp_client_transaction_send() and
+ /* None of smtp_client_transaction_send() and
smtp_client_transaction_reset() was called so far
*/
} else if (trans->cmd_data != NULL) {
- /* the DATA command is still pending; handle the failure by
+ /* The DATA command is still pending; handle the failure by
failing the DATA command. */
smtp_client_command_fail_reply(&trans->cmd_data, reply);
} else if (trans->cmd_rset != NULL) {
- /* the RSET command is still pending; handle the failure by
+ /* The RSET command is still pending; handle the failure by
failing the RSET command. */
smtp_client_command_fail_reply(&trans->cmd_rset, reply);
} else {
i_assert(!trans->reset);
- /* the DATA command was not sent yet; call all DATA callbacks
+ /* The DATA command was not sent yet; call all DATA callbacks
for the recipients that were previously accepted. */
rcpt = trans->rcpts_data;
while (rcpt != NULL) {
trans->data_callback = NULL;
}
- /* plug */
+ /* Plug */
if (trans->failure == NULL)
trans->failure = smtp_reply_clone(trans->pool, reply);
if (trans->cmd_plug != NULL)
trans->failing = FALSE;
if (trans->data_provided || trans->reset) {
- /* abort the transaction only if smtp_client_transaction_send()
+ /* Abort the transaction only if smtp_client_transaction_send()
or smtp_client_transaction_reset() was called (and if it is
not aborted already) */
smtp_client_transaction_abort(trans);
}
- /* drop reference held earlier in this function */
+ /* Drop reference held earlier in this function */
smtp_client_transaction_unref(&trans);
}
void smtp_client_transaction_fail(struct smtp_client_transaction *trans,
- unsigned int status, const char *error)
+ unsigned int status, const char *error)
{
struct smtp_reply reply;
{
struct smtp_reply reply;
- smtp_reply_printf(&reply, 451,
- "Remote server not answering "
+ smtp_reply_printf(
+ &reply, 451, "Remote server not answering "
"(transaction timed out while %s)",
smtp_client_transaction_get_state_destription(trans));
reply.enhanced_code = SMTP_REPLY_ENH_CODE(4, 4, 0);
}
void smtp_client_transaction_set_timeout(struct smtp_client_transaction *trans,
- unsigned int timeout_msecs)
+ unsigned int timeout_msecs)
{
i_assert(trans->state < SMTP_CLIENT_TRANSACTION_STATE_FINISHED);
trans->finish_timeout_msecs = timeout_msecs;
if (trans->data_input != NULL && timeout_msecs > 0) {
- /* adjust timeout if it is already started */
+ /* Adjust timeout if it is already started */
timeout_remove(&trans->to_finish);
trans->to_finish = timeout_add(trans->finish_timeout_msecs,
- smtp_client_transaction_timeout, trans);
+ smtp_client_transaction_timeout,
+ trans);
}
}
trans->sender_accepted = TRUE;
}
- /* plug command line pipeline if no RCPT commands are yet issued */
+ /* Plug command line pipeline if no RCPT commands are yet issued */
if (!trans->immediate && mail->next == NULL &&
mail->cmd_mail_from == trans->cmd_last) {
trans->cmd_plug = trans->cmd_last =
if (!success && !trans->sender_accepted) {
if (trans->state > SMTP_CLIENT_TRANSACTION_STATE_MAIL_FROM)
smtp_client_transaction_fail_reply(trans, reply);
- else if (trans->mail_failure == NULL)
- trans->mail_failure = smtp_reply_clone(trans->pool, reply);
+ else if (trans->mail_failure == NULL) {
+ trans->mail_failure =
+ smtp_reply_clone(trans->pool, reply);
+ }
}
}
return mail;
}
-static void smtp_client_transaction_connection_ready(
- struct smtp_client_transaction *trans)
+static void
+smtp_client_transaction_connection_ready(struct smtp_client_transaction *trans)
{
if (trans->state != SMTP_CLIENT_TRANSACTION_STATE_PENDING)
return;
e_debug(trans->event, "Got RCPT reply: %s", smtp_reply_log(reply));
- /* plug command line pipeline if DATA command is not yet issued */
+ /* Plug command line pipeline if DATA command is not yet issued */
if (!trans->immediate && !trans->reset &&
rcpt->cmd_rcpt_to == trans->cmd_last && trans->cmd_data == NULL) {
trans->cmd_plug = trans->cmd_last =
i_assert(trans->state < SMTP_CLIENT_TRANSACTION_STATE_FINISHED);
if (trans->mail_head == NULL &&
- trans->state == SMTP_CLIENT_TRANSACTION_STATE_MAIL_FROM)
+ trans->state == SMTP_CLIENT_TRANSACTION_STATE_MAIL_FROM)
trans->state = SMTP_CLIENT_TRANSACTION_STATE_RCPT_TO;
pool = pool_alloconly_create("smtp transaction rcpt", 512);
i_assert(trans->state < SMTP_CLIENT_TRANSACTION_STATE_FINISHED);
if (trans->mail_head == NULL &&
- trans->state == SMTP_CLIENT_TRANSACTION_STATE_MAIL_FROM)
+ trans->state == SMTP_CLIENT_TRANSACTION_STATE_MAIL_FROM)
trans->state = SMTP_CLIENT_TRANSACTION_STATE_RCPT_TO;
rcpt = smtp_client_transaction_rcpt_new(trans, pool,
/* finished */
smtp_client_transaction_finish(
- trans, (trans->data_failure == NULL ? reply :
- trans->data_failure));
+ trans, (trans->data_failure == NULL ?
+ reply : trans->data_failure));
smtp_client_transaction_unref(&trans);
}
if (trans->finish_timeout_msecs > 0) {
i_assert(trans->to_finish == NULL);
trans->to_finish = timeout_add(trans->finish_timeout_msecs,
- smtp_client_transaction_timeout, trans);
+ smtp_client_transaction_timeout,
+ trans);
}
smtp_client_transaction_submit(trans, TRUE);
trans->reset_callback(reply, trans->reset_context);
trans->reset_callback = NULL;
- /* finished */
+ /* Finished */
smtp_client_transaction_finish(trans, reply);
smtp_client_transaction_unref(&trans);
if (trans->finish_timeout_msecs > 0) {
i_assert(trans->to_finish == NULL);
trans->to_finish = timeout_add(trans->finish_timeout_msecs,
- smtp_client_transaction_timeout, trans);
+ smtp_client_transaction_timeout,
+ trans);
}
smtp_client_transaction_submit(trans, TRUE);
if (trans->mail_send != NULL) {
e_debug(trans->event, "Sending MAIL command");
- i_assert(trans->state == SMTP_CLIENT_TRANSACTION_STATE_MAIL_FROM);
+ i_assert(trans->state ==
+ SMTP_CLIENT_TRANSACTION_STATE_MAIL_FROM);
if (trans->cmd_last != NULL)
smtp_client_command_unlock(trans->cmd_last);
trans->mail_send = trans->mail_send->next;
mail->cmd_mail_from = trans->cmd_last =
- smtp_client_command_mail_submit(trans->conn, 0,
+ smtp_client_command_mail_submit(
+ trans->conn, 0,
mail->mail_from, &mail->mail_params,
smtp_client_transaction_mail_cb, trans);
}
smtp_client_transaction_get_state_name(struct smtp_client_transaction *trans)
{
i_assert(trans->state >= SMTP_CLIENT_TRANSACTION_STATE_NEW &&
- trans->state <= SMTP_CLIENT_TRANSACTION_STATE_ABORTED);
+ trans->state <= SMTP_CLIENT_TRANSACTION_STATE_ABORTED);
return smtp_client_transaction_state_names[trans->state];
}