diff options
author | Steve Holme <steve_holme@hotmail.com> | 2013-04-30 22:22:22 +0100 |
---|---|---|
committer | Steve Holme <steve_holme@hotmail.com> | 2013-04-30 22:25:23 +0100 |
commit | 46d26a0e77d9c93482413027b7b140140269fa2e (patch) | |
tree | 2c7c5dcbb45334581ebfbf4092464510bfe043ea /lib | |
parent | f4e3cae8a792e10259398f4eeec9348fdda690df (diff) |
smtp: Tidy up to move the eob counter to the per-request structure
Move the eob counter from the smtp_conn structure to the SMTP structure
as it is associated with a SMTP payload on a per-request basis.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/smtp.c | 30 | ||||
-rw-r--r-- | lib/smtp.h | 4 |
2 files changed, 17 insertions, 17 deletions
diff --git a/lib/smtp.c b/lib/smtp.c index 9d304850c..e33999d58 100644 --- a/lib/smtp.c +++ b/lib/smtp.c @@ -1796,8 +1796,8 @@ CURLcode Curl_smtp_escape_eob(struct connectdata *conn, ssize_t nread) */ ssize_t i; ssize_t si; - struct smtp_conn *smtpc = &conn->proto.smtpc; struct SessionHandle *data = conn->data; + struct SMTP *smtp = data->state.proto.smtp; /* Do we need to allocate the scatch buffer? */ if(!data->state.scratch) { @@ -1812,36 +1812,36 @@ CURLcode Curl_smtp_escape_eob(struct connectdata *conn, ssize_t nread) /* 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) { + if(SMTP_EOB[smtp->eob] == data->req.upload_fromhere[i]) + smtp->eob++; + else if(smtp->eob) { /* A previous substring matched so output that first */ - memcpy(&data->state.scratch[si], SMTP_EOB, smtpc->eob); - si += smtpc->eob; + memcpy(&data->state.scratch[si], SMTP_EOB, smtp->eob); + si += smtp->eob; /* Then compare the first byte */ if(SMTP_EOB[0] == data->req.upload_fromhere[i]) - smtpc->eob = 1; + smtp->eob = 1; else - smtpc->eob = 0; + smtp->eob = 0; } /* Do we have a match for CRLF. as per RFC-2821, sect. 4.5.2 */ - if(SMTP_EOB_FIND_LEN == smtpc->eob) { + if(SMTP_EOB_FIND_LEN == smtp->eob) { /* Copy the replacement data to the target buffer */ memcpy(&data->state.scratch[si], SMTP_EOB_REPL, SMTP_EOB_REPL_LEN); si += SMTP_EOB_REPL_LEN; - smtpc->eob = 0; + smtp->eob = 0; } - else if(!smtpc->eob) + else if(!smtp->eob) data->state.scratch[si++] = data->req.upload_fromhere[i]; } - if(smtpc->eob) { + if(smtp->eob) { /* A substring matched before processing ended so output that now */ - memcpy(&data->state.scratch[si], SMTP_EOB, smtpc->eob); - si += smtpc->eob; - smtpc->eob = 0; + memcpy(&data->state.scratch[si], SMTP_EOB, smtp->eob); + si += smtp->eob; + smtp->eob = 0; } if(si != nread) { diff --git a/lib/smtp.h b/lib/smtp.h index ed704abd6..7a03e51ce 100644 --- a/lib/smtp.h +++ b/lib/smtp.h @@ -60,6 +60,8 @@ typedef enum { struct SMTP { curl_pp_transfer transfer; struct curl_slist *rcpt; /* Recipient list */ + size_t eob; /* Number of bytes of the EOB (End Of Body) that + have been received so far */ }; /* smtp_conn is used for struct connection-oriented data in the connectdata @@ -69,8 +71,6 @@ struct smtp_conn { smtpstate state; /* Always use smtp.c:state() to change state! */ bool ssldone; /* Is connect() over SSL done? */ char *domain; /* Client address/name to send in the EHLO */ - size_t eob; /* Number of bytes of the EOB (End Of Body) that - have been received so far */ unsigned int authmechs; /* Accepted authentication mechanisms */ unsigned int prefmech; /* Preferred authentication mechanism */ unsigned int authused; /* Auth mechanism used for the connection */ |