From: Stephan Bosch Date: Fri, 25 Sep 2020 01:00:31 +0000 (+0200) Subject: lib-smtp: Reformat smtp-client-transaction.c. X-Git-Tag: 2.3.18~133 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=15c98d994b8d5f25a579bfac347e977c501b7260;p=thirdparty%2Fdovecot%2Fcore.git lib-smtp: Reformat smtp-client-transaction.c. --- diff --git a/src/lib-smtp/smtp-client-transaction.c b/src/lib-smtp/smtp-client-transaction.c index ba72059e6b..0c4a58f80c 100644 --- a/src/lib-smtp/smtp-client-transaction.c +++ b/src/lib-smtp/smtp-client-transaction.c @@ -96,7 +96,7 @@ smtp_client_transaction_mail_replied( mail->mail_callback = NULL; - /* call the callback */ + /* Call the callback */ if (mail_callback != NULL) mail_callback(reply, context); @@ -143,16 +143,17 @@ smtp_client_transaction_rcpt_update_event( 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; @@ -208,8 +209,7 @@ smtp_client_transaction_rcpt_free( 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 = @@ -239,7 +239,7 @@ smtp_client_transaction_rcpt_approved( 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; @@ -249,7 +249,7 @@ smtp_client_transaction_rcpt_approved( 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; @@ -262,11 +262,11 @@ smtp_client_transaction_rcpt_approved( 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) @@ -294,7 +294,7 @@ smtp_client_transaction_rcpt_denied( smtp_reply_add_to_event(reply, e); e_debug(e->event(), "Denied"); - /* not pending anymore */ + /* Not pending anymore */ smtp_client_transaction_rcpt_free(&prcpt); } @@ -319,7 +319,7 @@ smtp_client_transaction_rcpt_replied( else smtp_client_transaction_rcpt_denied(_rcpt, reply); - /* call the callback */ + /* Call the callback */ if (rcpt_callback != NULL) rcpt_callback(reply, context); } @@ -427,8 +427,8 @@ smtp_client_transaction_result_event(struct smtp_client_transaction *trans, 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")-> @@ -479,10 +479,11 @@ smtp_client_transaction_create_empty( #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; @@ -533,14 +534,14 @@ void smtp_client_transaction_abort(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; @@ -568,7 +569,7 @@ void smtp_client_transaction_abort(struct smtp_client_transaction *trans) 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; @@ -685,7 +686,7 @@ void smtp_client_transaction_destroy(struct smtp_client_transaction **_trans) } 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; @@ -697,7 +698,7 @@ void smtp_client_transaction_fail_reply(struct smtp_client_transaction *trans, 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; @@ -731,21 +732,21 @@ void smtp_client_transaction_fail_reply(struct smtp_client_transaction *trans, /* 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) { @@ -758,7 +759,7 @@ void smtp_client_transaction_fail_reply(struct smtp_client_transaction *trans, trans->data_callback = NULL; } - /* plug */ + /* Plug */ if (trans->failure == NULL) trans->failure = smtp_reply_clone(trans->pool, reply); if (trans->cmd_plug != NULL) @@ -768,18 +769,18 @@ void smtp_client_transaction_fail_reply(struct smtp_client_transaction *trans, 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; @@ -802,8 +803,8 @@ smtp_client_transaction_timeout(struct smtp_client_transaction *trans) { 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); @@ -812,17 +813,18 @@ smtp_client_transaction_timeout(struct smtp_client_transaction *trans) } 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); } } @@ -849,7 +851,7 @@ smtp_client_transaction_mail_cb(const struct smtp_reply *reply, 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 = @@ -888,8 +890,10 @@ smtp_client_transaction_mail_cb(const struct smtp_reply *reply, 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); + } } } @@ -919,8 +923,8 @@ smtp_client_transaction_add_mail(struct smtp_client_transaction *trans, 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; @@ -1001,7 +1005,7 @@ smtp_client_transaction_rcpt_cb(const struct smtp_reply *reply, 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 = @@ -1046,7 +1050,7 @@ smtp_client_transaction_add_rcpt(struct smtp_client_transaction *trans, 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); @@ -1083,7 +1087,7 @@ smtp_client_transaction_add_pool_rcpt( 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, @@ -1146,8 +1150,8 @@ smtp_client_transaction_data_cb(const struct smtp_reply *reply, /* 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); } @@ -1225,7 +1229,8 @@ void smtp_client_transaction_send( 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); @@ -1243,7 +1248,7 @@ smtp_client_transaction_rset_cb(const struct smtp_reply *reply, trans->reset_callback(reply, trans->reset_context); trans->reset_callback = NULL; - /* finished */ + /* Finished */ smtp_client_transaction_finish(trans, reply); smtp_client_transaction_unref(&trans); @@ -1305,7 +1310,8 @@ void smtp_client_transaction_reset( 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); @@ -1350,7 +1356,8 @@ smtp_client_transaction_do_submit_more(struct smtp_client_transaction *trans) 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); @@ -1361,7 +1368,8 @@ smtp_client_transaction_do_submit_more(struct smtp_client_transaction *trans) 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); } @@ -1551,7 +1559,7 @@ const char * 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]; }