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.
This commit is contained in:
parent
f4e3cae8a7
commit
46d26a0e77
30
lib/smtp.c
30
lib/smtp.c
@ -1796,8 +1796,8 @@ CURLcode Curl_smtp_escape_eob(struct connectdata *conn, ssize_t nread)
|
|||||||
*/
|
*/
|
||||||
ssize_t i;
|
ssize_t i;
|
||||||
ssize_t si;
|
ssize_t si;
|
||||||
struct smtp_conn *smtpc = &conn->proto.smtpc;
|
|
||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
|
struct SMTP *smtp = data->state.proto.smtp;
|
||||||
|
|
||||||
/* Do we need to allocate the scatch buffer? */
|
/* Do we need to allocate the scatch buffer? */
|
||||||
if(!data->state.scratch) {
|
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
|
/* This loop can be improved by some kind of Boyer-Moore style of
|
||||||
approach but that is saved for later... */
|
approach but that is saved for later... */
|
||||||
for(i = 0, si = 0; i < nread; i++) {
|
for(i = 0, si = 0; i < nread; i++) {
|
||||||
if(SMTP_EOB[smtpc->eob] == data->req.upload_fromhere[i])
|
if(SMTP_EOB[smtp->eob] == data->req.upload_fromhere[i])
|
||||||
smtpc->eob++;
|
smtp->eob++;
|
||||||
else if(smtpc->eob) {
|
else if(smtp->eob) {
|
||||||
/* A previous substring matched so output that first */
|
/* A previous substring matched so output that first */
|
||||||
memcpy(&data->state.scratch[si], SMTP_EOB, smtpc->eob);
|
memcpy(&data->state.scratch[si], SMTP_EOB, smtp->eob);
|
||||||
si += smtpc->eob;
|
si += smtp->eob;
|
||||||
|
|
||||||
/* Then compare the first byte */
|
/* Then compare the first byte */
|
||||||
if(SMTP_EOB[0] == data->req.upload_fromhere[i])
|
if(SMTP_EOB[0] == data->req.upload_fromhere[i])
|
||||||
smtpc->eob = 1;
|
smtp->eob = 1;
|
||||||
else
|
else
|
||||||
smtpc->eob = 0;
|
smtp->eob = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Do we have a match for CRLF. as per RFC-2821, sect. 4.5.2 */
|
/* 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 */
|
/* Copy the replacement data to the target buffer */
|
||||||
memcpy(&data->state.scratch[si], SMTP_EOB_REPL, SMTP_EOB_REPL_LEN);
|
memcpy(&data->state.scratch[si], SMTP_EOB_REPL, SMTP_EOB_REPL_LEN);
|
||||||
si += 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];
|
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 */
|
/* A substring matched before processing ended so output that now */
|
||||||
memcpy(&data->state.scratch[si], SMTP_EOB, smtpc->eob);
|
memcpy(&data->state.scratch[si], SMTP_EOB, smtp->eob);
|
||||||
si += smtpc->eob;
|
si += smtp->eob;
|
||||||
smtpc->eob = 0;
|
smtp->eob = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(si != nread) {
|
if(si != nread) {
|
||||||
|
@ -60,6 +60,8 @@ typedef enum {
|
|||||||
struct SMTP {
|
struct SMTP {
|
||||||
curl_pp_transfer transfer;
|
curl_pp_transfer transfer;
|
||||||
struct curl_slist *rcpt; /* Recipient list */
|
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
|
/* 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! */
|
smtpstate state; /* Always use smtp.c:state() to change state! */
|
||||||
bool ssldone; /* Is connect() over SSL done? */
|
bool ssldone; /* Is connect() over SSL done? */
|
||||||
char *domain; /* Client address/name to send in the EHLO */
|
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 authmechs; /* Accepted authentication mechanisms */
|
||||||
unsigned int prefmech; /* Preferred authentication mechanism */
|
unsigned int prefmech; /* Preferred authentication mechanism */
|
||||||
unsigned int authused; /* Auth mechanism used for the connection */
|
unsigned int authused; /* Auth mechanism used for the connection */
|
||||||
|
Loading…
Reference in New Issue
Block a user