summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2012-02-16 10:43:17 +0000
committerDaniel Stenberg <daniel@haxx.se>2012-02-16 13:20:34 +0100
commit5c409d03ec637e3040ab461ab105dd16740b441e (patch)
treee4cb7d49a1ddcc3717a412c449f8a3339ffd2ccd /lib
parenta053560cfa7d1adb98c833384096fdcf9296b8d2 (diff)
downloadcurl-5c409d03ec637e3040ab461ab105dd16740b441e.tar.gz
SMTP: Code policing and tidy up
Diffstat (limited to 'lib')
-rw-r--r--lib/smtp.c32
-rw-r--r--lib/smtp.h4
2 files changed, 16 insertions, 20 deletions
diff --git a/lib/smtp.c b/lib/smtp.c
index fa5452aff..90afa8a6d 100644
--- a/lib/smtp.c
+++ b/lib/smtp.c
@@ -109,7 +109,7 @@ static int smtp_getsock(struct connectdata *conn,
int numsocks);
static CURLcode smtp_doing(struct connectdata *conn,
bool *dophase_done);
-static CURLcode smtp_setup_connection(struct connectdata * conn);
+static CURLcode smtp_setup_connection(struct connectdata *conn);
static CURLcode smtp_state_upgrade_tls(struct connectdata *conn);
/*
@@ -427,7 +427,7 @@ static CURLcode smtp_authenticate(struct connectdata *conn)
#ifndef CURL_DISABLE_CRYPTO_AUTH
if(smtpc->authmechs & SMTP_AUTH_CRAM_MD5) {
mech = "CRAM-MD5";
- state1 = SMTP_AUTHCRAM;
+ state1 = SMTP_AUTHCRAMMD5;
smtpc->authused = SMTP_AUTH_CRAM_MD5;
}
else
@@ -715,8 +715,8 @@ static CURLcode smtp_state_authcram_resp(struct connectdata *conn,
{
CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data;
- char * chlg64 = data->state.buffer;
- unsigned char * chlg;
+ char *chlg64 = data->state.buffer;
+ unsigned char *chlg;
size_t chlglen;
size_t len = 0;
char *rplyb64 = NULL;
@@ -1146,7 +1146,7 @@ static CURLcode smtp_statemach_act(struct connectdata *conn)
break;
#ifndef CURL_DISABLE_CRYPTO_AUTH
- case SMTP_AUTHCRAM:
+ case SMTP_AUTHCRAMMD5:
result = smtp_state_authcram_resp(conn, smtpcode, smtpc->state);
break;
#endif
@@ -1339,13 +1339,12 @@ static CURLcode smtp_connect(struct connectdata *conn,
path = "localhost";
}
- /* url decode the path and use it as domain with EHLO */
+ /* Url decode the path and use it as the domain in our EHLO */
result = Curl_urldecode(conn->data, path, 0, &smtpc->domain, NULL, TRUE);
if(result)
return result;
- /* When we connect, we start in the state where we await the server greeting
- */
+ /* Set the state as we are waiting the server greeting */
state(conn, SMTP_SERVERGREET);
if(data->state.used_interface == Curl_if_multi)
@@ -1387,7 +1386,7 @@ static CURLcode smtp_done(struct connectdata *conn, CURLcode status,
if(status) {
conn->bits.close = TRUE; /* marked for closure */
- result = status; /* use the already set error code */
+ result = status; /* use the already set error code */
}
else if(!data->set.connect_only) {
struct smtp_conn *smtpc = &conn->proto.smtpc;
@@ -1430,7 +1429,6 @@ static CURLcode smtp_done(struct connectdata *conn, CURLcode status,
* This is the actual DO function for SMTP. Get a file/directory according to
* the options previously setup.
*/
-
static
CURLcode smtp_perform(struct connectdata *conn,
bool *connected, /* connect status after PASV / PORT */
@@ -1604,9 +1602,8 @@ static CURLcode smtp_doing(struct connectdata *conn,
* Performs all commands done before a regular transfer between a local and a
* remote host.
*/
-static
-CURLcode smtp_regular_transfer(struct connectdata *conn,
- bool *dophase_done)
+static CURLcode smtp_regular_transfer(struct connectdata *conn,
+ bool *dophase_done)
{
CURLcode result = CURLE_OK;
bool connected = FALSE;
@@ -1654,8 +1651,8 @@ static CURLcode smtp_setup_connection(struct connectdata *conn)
return CURLE_UNSUPPORTED_PROTOCOL;
#endif
}
- /*
- * We explicitly mark this connection as persistent here as we're doing
+
+ /* We explicitly mark this connection as persistent here as we're doing
* SMTP over HTTP and thus we accidentally avoid setting this value
* otherwise.
*/
@@ -1688,10 +1685,10 @@ CURLcode Curl_smtp_escape_eob(struct connectdata *conn, ssize_t nread)
failf (data, "Failed to alloc scratch buffer!");
return CURLE_OUT_OF_MEMORY;
}
+
/* This loop can be improved by some kind of Boyer-Moore style of
approach but that is saved for later... */
for(i = 0, si = 0; i < nread; i++) {
-
if(SMTP_EOB[smtpc->eob] == data->req.upload_fromhere[i])
smtpc->eob++;
else if(smtpc->eob) {
@@ -1719,8 +1716,7 @@ CURLcode Curl_smtp_escape_eob(struct connectdata *conn, ssize_t nread)
}
else if(!smtpc->eob)
data->state.scratch[si++] = data->req.upload_fromhere[i];
-
- } /* for() */
+ }
if(si != nread) {
/* only use the new buffer if we replaced something */
diff --git a/lib/smtp.h b/lib/smtp.h
index 144d49615..8164037db 100644
--- a/lib/smtp.h
+++ b/lib/smtp.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2009 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2009 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -39,7 +39,7 @@ typedef enum {
SMTP_AUTHPLAIN,
SMTP_AUTHLOGIN,
SMTP_AUTHPASSWD,
- SMTP_AUTHCRAM,
+ SMTP_AUTHCRAMMD5,
SMTP_AUTHNTLM,
SMTP_AUTHNTLM_TYPE2MSG,
SMTP_AUTH,