aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2013-11-15 18:30:04 +0000
committerSteve Holme <steve_holme@hotmail.com>2013-11-15 21:05:45 +0000
commit0ea4a80bb236665f2608fa918df476050aab35fc (patch)
tree467c9d2ceb26034281cd479fc6ee32c0a91360c0
parented4ce23c23b658328f2b62d6321a89effc54b747 (diff)
smtp: Simplified the next RCPT TO logic
-rw-r--r--lib/smtp.c50
1 files changed, 21 insertions, 29 deletions
diff --git a/lib/smtp.c b/lib/smtp.c
index e49984e1b..f397a38cb 100644
--- a/lib/smtp.c
+++ b/lib/smtp.c
@@ -671,16 +671,14 @@ static CURLcode smtp_perform_rcpt_to(struct connectdata *conn)
struct SMTP *smtp = data->req.protop;
/* Send the RCPT TO command */
- if(smtp->rcpt) {
- if(smtp->rcpt->data[0] == '<')
- result = Curl_pp_sendf(&conn->proto.smtpc.pp, "RCPT TO:%s",
- smtp->rcpt->data);
- else
- result = Curl_pp_sendf(&conn->proto.smtpc.pp, "RCPT TO:<%s>",
- smtp->rcpt->data);
- if(!result)
- state(conn, SMTP_RCPT);
- }
+ if(smtp->rcpt->data[0] == '<')
+ result = Curl_pp_sendf(&conn->proto.smtpc.pp, "RCPT TO:%s",
+ smtp->rcpt->data);
+ else
+ result = Curl_pp_sendf(&conn->proto.smtpc.pp, "RCPT TO:<%s>",
+ smtp->rcpt->data);
+ if(!result)
+ state(conn, SMTP_RCPT);
return result;
}
@@ -1324,11 +1322,9 @@ static CURLcode smtp_state_mail_resp(struct connectdata *conn, int smtpcode,
result = CURLE_SEND_ERROR;
state(conn, SMTP_STOP);
}
- else {
- smtp->rcpt = data->set.mail_rcpt;
-
+ else
+ /* Start the RCPT TO command */
result = smtp_perform_rcpt_to(conn);
- }
return result;
}
@@ -1349,17 +1345,14 @@ static CURLcode smtp_state_rcpt_resp(struct connectdata *conn, int smtpcode,
state(conn, SMTP_STOP);
}
else {
- if(smtp->rcpt) {
- smtp->rcpt = smtp->rcpt->next;
- result = smtp_perform_rcpt_to(conn);
+ smtp->rcpt = smtp->rcpt->next;
- /* If we failed or still are sending RCPT data then return */
- if(result || smtp->rcpt)
- return result;
- }
-
- /* Send the DATA command */
- result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", "DATA");
+ if(smtp->rcpt)
+ /* Send the next RCPT TO command */
+ result = smtp_perform_rcpt_to(conn);
+ else
+ /* Send the DATA command */
+ result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", "DATA");
if(!result)
state(conn, SMTP_DATA);
@@ -1747,17 +1740,16 @@ static CURLcode smtp_perform(struct connectdata *conn, bool *connected,
*dophase_done = FALSE; /* not done yet */
+ /* Store the first recipient (or NULL if not specified) */
+ smtp->rcpt = data->set.mail_rcpt;
+
/* Start the first command in the DO phase */
if(data->set.upload && data->set.mail_rcpt)
/* MAIL transfer */
result = smtp_perform_mail(conn);
- else {
- /* Store the first recipient (or NULL if not specified) */
- smtp->rcpt = data->set.mail_rcpt;
-
+ else
/* SMTP based command (VRFY, EXPN, NOOP, RSET or HELP) */
result = smtp_perform_command(conn);
- }
if(result)
return result;