aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2013-02-12 18:08:48 +0000
committerSteve Holme <steve_holme@hotmail.com>2013-02-12 18:08:48 +0000
commitb56c9eb48e3cad89d35963f0934571bf5de48ab2 (patch)
tree18f562555fbb0892ce15b25d293ea1edef9a0c95 /lib
parent586f5d36147478d58ea6204bfe8368364663d926 (diff)
pingpong: Optimised the endofresp() function
Reworked the pp->endofresp() function so that the conndata, line and line length are passed down to it just as with Curl_client_write() rather than each implementation of the function having to query these values. Additionally changed the int return type to bool as this is more representative of the function's usage.
Diffstat (limited to 'lib')
-rw-r--r--lib/ftp.c12
-rw-r--r--lib/imap.c7
-rw-r--r--lib/pingpong.c2
-rw-r--r--lib/pingpong.h2
-rw-r--r--lib/pop3.c6
-rw-r--r--lib/smtp.c6
6 files changed, 15 insertions, 20 deletions
diff --git a/lib/ftp.c b/lib/ftp.c
index 469b88749..228d834a2 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -598,17 +598,17 @@ static CURLcode AllowServerConnect(struct connectdata *conn, bool *connected)
/* macro to check for the last line in an FTP server response */
#define LASTLINE(line) (STATUSCODE(line) && (' ' == line[3]))
-static int ftp_endofresp(struct pingpong *pp,
- int *code)
+static bool ftp_endofresp(struct connectdata *conn, char *line, size_t len,
+ int *code)
{
- char *line = pp->linestart_resp;
- size_t len = pp->nread_resp;
+ (void)conn;
if((len > 3) && LASTLINE(line)) {
*code = curlx_sltosi(strtol(line, NULL, 10));
- return 1;
+ return TRUE;
}
- return 0;
+
+ return FALSE;
}
static CURLcode ftp_readresp(curl_socket_t sockfd,
diff --git a/lib/imap.c b/lib/imap.c
index 9a5894755..c4bddab7a 100644
--- a/lib/imap.c
+++ b/lib/imap.c
@@ -327,11 +327,10 @@ static char* imap_atom(const char* str)
/* Function that checks for an ending IMAP status code at the start of the
given string but also detects various capabilities from the CAPABILITY
response including the supported authentication mechanisms. */
-static int imap_endofresp(struct pingpong *pp, int *resp)
+static bool imap_endofresp(struct connectdata *conn, char *line, size_t len,
+ int *resp)
{
- char *line = pp->linestart_resp;
- size_t len = pp->nread_resp;
- struct imap_conn *imapc = &pp->conn->proto.imapc;
+ struct imap_conn *imapc = &conn->proto.imapc;
const char *id = imapc->resptag;
size_t id_len = strlen(id);
size_t wordlen;
diff --git a/lib/pingpong.c b/lib/pingpong.c
index 16b4ad37e..330b47f76 100644
--- a/lib/pingpong.c
+++ b/lib/pingpong.c
@@ -395,7 +395,7 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd,
if(result)
return result;
- if(pp->endofresp(pp, code)) {
+ if(pp->endofresp(conn, pp->linestart_resp, perline, code)) {
/* This is the end of the last line, copy the last line to the
start of the buffer and zero terminate, for old times sake (and
krb4)! */
diff --git a/lib/pingpong.h b/lib/pingpong.h
index b48c1ed61..b99070f4f 100644
--- a/lib/pingpong.h
+++ b/lib/pingpong.h
@@ -64,7 +64,7 @@ struct pingpong {
CURLcode (*statemach_act)(struct connectdata *conn);
- int (*endofresp)(struct pingpong *pp, int *code);
+ bool (*endofresp)(struct connectdata *conn, char *ptr, size_t len, int *code);
};
/*
diff --git a/lib/pop3.c b/lib/pop3.c
index 398db01db..263d8703a 100644
--- a/lib/pop3.c
+++ b/lib/pop3.c
@@ -220,11 +220,9 @@ static void pop3_to_pop3s(struct connectdata *conn)
given string, but also detects the APOP timestamp from the server greeting
as well as the supported authentication types and allowed SASL mechanisms
from the CAPA response. */
-static int pop3_endofresp(struct pingpong *pp, int *resp)
+static bool pop3_endofresp(struct connectdata *conn, char *line, size_t len,
+ int *resp)
{
- char *line = pp->linestart_resp;
- size_t len = strlen(pp->linestart_resp);
- struct connectdata *conn = pp->conn;
struct pop3_conn *pop3c = &conn->proto.pop3c;
size_t wordlen;
size_t i;
diff --git a/lib/smtp.c b/lib/smtp.c
index 3c82a4f19..68dbf9a26 100644
--- a/lib/smtp.c
+++ b/lib/smtp.c
@@ -216,11 +216,9 @@ static void smtp_to_smtps(struct connectdata *conn)
/* Function that checks for an ending SMTP status code at the start of the
given string, but also detects various capabilities from the EHLO response
including the supported authentication mechanisms. */
-static int smtp_endofresp(struct pingpong *pp, int *resp)
+static bool smtp_endofresp(struct connectdata *conn, char *line, size_t len,
+ int *resp)
{
- char *line = pp->linestart_resp;
- size_t len = strlen(pp->linestart_resp);
- struct connectdata *conn = pp->conn;
struct smtp_conn *smtpc = &conn->proto.smtpc;
int result = FALSE;
size_t wordlen;