aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2013-04-12 23:15:51 +0100
committerSteve Holme <steve_holme@hotmail.com>2013-04-12 23:15:51 +0100
commit73cbd21b5ee6e3fc1acfea8529d4292b73a5e9d6 (patch)
tree9651e5ec4b93a18ca462dd772930b7c311e2d5ba /lib
parentc5ba0c2f5446532798ff68b598326f5f994616c1 (diff)
smtp: Moved parsing of url path into separate function
Diffstat (limited to 'lib')
-rw-r--r--lib/smtp.c42
1 files changed, 30 insertions, 12 deletions
diff --git a/lib/smtp.c b/lib/smtp.c
index 594d09a14..ed7264b6d 100644
--- a/lib/smtp.c
+++ b/lib/smtp.c
@@ -99,6 +99,7 @@ static int smtp_getsock(struct connectdata *conn, curl_socket_t *socks,
int numsocks);
static CURLcode smtp_doing(struct connectdata *conn, bool *dophase_done);
static CURLcode smtp_setup_connection(struct connectdata *conn);
+static CURLcode smtp_parse_url_path(struct connectdata *conn);
/*
* SMTP protocol handler.
@@ -1300,8 +1301,6 @@ static CURLcode smtp_connect(struct connectdata *conn, bool *done)
CURLcode result = CURLE_OK;
struct smtp_conn *smtpc = &conn->proto.smtpc;
struct pingpong *pp = &smtpc->pp;
- const char *path = conn->data->state.path;
- char localhost[HOSTNAME_MAX + 1];
*done = FALSE; /* default to not done yet */
@@ -1326,16 +1325,8 @@ static CURLcode smtp_connect(struct connectdata *conn, bool *done)
/* Initialise the pingpong layer */
Curl_pp_init(pp);
- /* Calculate the path if necessary */
- if(!*path) {
- if(!Curl_gethostname(localhost, sizeof(localhost)))
- path = localhost;
- else
- path = "localhost";
- }
-
- /* URL decode the path and use it as the domain in our EHLO */
- result = Curl_urldecode(conn->data, path, 0, &smtpc->domain, NULL, TRUE);
+ /* Parse the URL path */
+ result = smtp_parse_url_path(conn);
if(result)
return result;
@@ -1640,6 +1631,33 @@ static CURLcode smtp_setup_connection(struct connectdata *conn)
return CURLE_OK;
}
+/***********************************************************************
+ *
+ * smtp_parse_url_path()
+ *
+ * Parse the URL path into separate path components.
+ */
+static CURLcode smtp_parse_url_path(struct connectdata *conn)
+{
+ /* The SMTP struct is already initialised in smtp_connect() */
+ struct SessionHandle *data = conn->data;
+ struct SMTP *smtp = data->state.proto.smtp;
+ struct smtp_conn *smtpc = &conn->proto.smtpc;
+ const char *path = data->state.path;
+ char localhost[HOSTNAME_MAX + 1];
+
+ /* Calculate the path if necessary */
+ if(!*path) {
+ if(!Curl_gethostname(localhost, sizeof(localhost)))
+ path = localhost;
+ else
+ path = "localhost";
+ }
+
+ /* URL decode the path and use it as the domain in our EHLO */
+ return Curl_urldecode(conn->data, path, 0, &smtpc->domain, NULL, TRUE);
+}
+
CURLcode Curl_smtp_escape_eob(struct connectdata *conn, ssize_t nread)
{
/* When sending a SMTP payload we must detect CRLF. sequences making sure