telnet: Prefer 'CURLcode result' for curl result codes
This commit is contained in:
parent
0ebe2c15d1
commit
cfc6d460cb
82
lib/telnet.c
82
lib/telnet.c
@ -5,7 +5,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -1282,7 +1282,7 @@ static CURLcode telnet_done(struct connectdata *conn,
|
|||||||
|
|
||||||
static CURLcode telnet_do(struct connectdata *conn, bool *done)
|
static CURLcode telnet_do(struct connectdata *conn, bool *done)
|
||||||
{
|
{
|
||||||
CURLcode code;
|
CURLcode result;
|
||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
|
curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
|
||||||
#ifdef USE_WINSOCK
|
#ifdef USE_WINSOCK
|
||||||
@ -1315,24 +1315,24 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
|
|||||||
|
|
||||||
*done = TRUE; /* unconditionally */
|
*done = TRUE; /* unconditionally */
|
||||||
|
|
||||||
code = init_telnet(conn);
|
result = init_telnet(conn);
|
||||||
if(code)
|
if(result)
|
||||||
return code;
|
return result;
|
||||||
|
|
||||||
tn = (struct TELNET *)data->req.protop;
|
tn = (struct TELNET *)data->req.protop;
|
||||||
|
|
||||||
code = check_telnet_options(conn);
|
result = check_telnet_options(conn);
|
||||||
if(code)
|
if(result)
|
||||||
return code;
|
return result;
|
||||||
|
|
||||||
#ifdef USE_WINSOCK
|
#ifdef USE_WINSOCK
|
||||||
/*
|
/*
|
||||||
** This functionality only works with WinSock >= 2.0. So,
|
** This functionality only works with WinSock >= 2.0. So,
|
||||||
** make sure have it.
|
** make sure have it.
|
||||||
*/
|
*/
|
||||||
code = check_wsock2(data);
|
result = check_wsock2(data);
|
||||||
if(code)
|
if(result)
|
||||||
return code;
|
return result;
|
||||||
|
|
||||||
/* OK, so we have WinSock 2.0. We need to dynamically */
|
/* OK, so we have WinSock 2.0. We need to dynamically */
|
||||||
/* load ws2_32.dll and get the function pointers we need. */
|
/* load ws2_32.dll and get the function pointers we need. */
|
||||||
@ -1429,27 +1429,27 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
|
|||||||
for(;;) {
|
for(;;) {
|
||||||
if(obj_count == 1) {
|
if(obj_count == 1) {
|
||||||
/* read from user-supplied method */
|
/* read from user-supplied method */
|
||||||
code = (int)conn->fread_func(buf, 1, BUFSIZE - 1, conn->fread_in);
|
result = (int) conn->fread_func(buf, 1, BUFSIZE - 1, conn->fread_in);
|
||||||
if(code == CURL_READFUNC_ABORT) {
|
if(result == CURL_READFUNC_ABORT) {
|
||||||
keepon = FALSE;
|
keepon = FALSE;
|
||||||
code = CURLE_READ_ERROR;
|
result = CURLE_READ_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(code == CURL_READFUNC_PAUSE)
|
if(result == CURL_READFUNC_PAUSE)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if(code == 0) /* no bytes */
|
if(result == 0) /* no bytes */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
readfile_read = code; /* fall thru with number of bytes read */
|
readfile_read = result; /* fall thru with number of bytes read */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* read from stdin */
|
/* read from stdin */
|
||||||
if(!PeekNamedPipe(stdin_handle, NULL, 0, NULL,
|
if(!PeekNamedPipe(stdin_handle, NULL, 0, NULL,
|
||||||
&readfile_read, NULL)) {
|
&readfile_read, NULL)) {
|
||||||
keepon = FALSE;
|
keepon = FALSE;
|
||||||
code = CURLE_READ_ERROR;
|
result = CURLE_READ_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1459,13 +1459,13 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
|
|||||||
if(!ReadFile(stdin_handle, buf, sizeof(data->state.buffer),
|
if(!ReadFile(stdin_handle, buf, sizeof(data->state.buffer),
|
||||||
&readfile_read, NULL)) {
|
&readfile_read, NULL)) {
|
||||||
keepon = FALSE;
|
keepon = FALSE;
|
||||||
code = CURLE_READ_ERROR;
|
result = CURLE_READ_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
code = send_telnet_data(conn, buf, readfile_read);
|
result = send_telnet_data(conn, buf, readfile_read);
|
||||||
if(code) {
|
if(result) {
|
||||||
keepon = FALSE;
|
keepon = FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1478,12 +1478,12 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
|
|||||||
if(!ReadFile(stdin_handle, buf, sizeof(data->state.buffer),
|
if(!ReadFile(stdin_handle, buf, sizeof(data->state.buffer),
|
||||||
&readfile_read, NULL)) {
|
&readfile_read, NULL)) {
|
||||||
keepon = FALSE;
|
keepon = FALSE;
|
||||||
code = CURLE_READ_ERROR;
|
result = CURLE_READ_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = send_telnet_data(conn, buf, readfile_read);
|
result = send_telnet_data(conn, buf, readfile_read);
|
||||||
if(code) {
|
if(result) {
|
||||||
keepon = FALSE;
|
keepon = FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1497,18 +1497,18 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
|
|||||||
if((err = SOCKERRNO) != EINPROGRESS) {
|
if((err = SOCKERRNO) != EINPROGRESS) {
|
||||||
infof(data,"WSAEnumNetworkEvents failed (%d)", err);
|
infof(data,"WSAEnumNetworkEvents failed (%d)", err);
|
||||||
keepon = FALSE;
|
keepon = FALSE;
|
||||||
code = CURLE_READ_ERROR;
|
result = CURLE_READ_ERROR;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(events.lNetworkEvents & FD_READ) {
|
if(events.lNetworkEvents & FD_READ) {
|
||||||
/* read data from network */
|
/* read data from network */
|
||||||
code = Curl_read(conn, sockfd, buf, BUFSIZE - 1, &nread);
|
result = Curl_read(conn, sockfd, buf, BUFSIZE - 1, &nread);
|
||||||
/* read would've blocked. Loop again */
|
/* read would've blocked. Loop again */
|
||||||
if(code == CURLE_AGAIN)
|
if(result == CURLE_AGAIN)
|
||||||
break;
|
break;
|
||||||
/* returned not-zero, this an error */
|
/* returned not-zero, this an error */
|
||||||
else if(code) {
|
else if(result) {
|
||||||
keepon = FALSE;
|
keepon = FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1519,8 +1519,8 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = telrcv(conn, (unsigned char *)buf, nread);
|
result = telrcv(conn, (unsigned char *) buf, nread);
|
||||||
if(code) {
|
if(result) {
|
||||||
keepon = FALSE;
|
keepon = FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1544,7 +1544,7 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
|
|||||||
now = Curl_tvnow();
|
now = Curl_tvnow();
|
||||||
if(Curl_tvdiff(now, conn->created) >= data->set.timeout) {
|
if(Curl_tvdiff(now, conn->created) >= data->set.timeout) {
|
||||||
failf(data, "Time-out");
|
failf(data, "Time-out");
|
||||||
code = CURLE_OPERATION_TIMEDOUT;
|
result = CURLE_OPERATION_TIMEDOUT;
|
||||||
keepon = FALSE;
|
keepon = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1592,12 +1592,12 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
|
|||||||
default: /* read! */
|
default: /* read! */
|
||||||
if(pfd[0].revents & POLLIN) {
|
if(pfd[0].revents & POLLIN) {
|
||||||
/* read data from network */
|
/* read data from network */
|
||||||
code = Curl_read(conn, sockfd, buf, BUFSIZE - 1, &nread);
|
result = Curl_read(conn, sockfd, buf, BUFSIZE - 1, &nread);
|
||||||
/* read would've blocked. Loop again */
|
/* read would've blocked. Loop again */
|
||||||
if(code == CURLE_AGAIN)
|
if(result == CURLE_AGAIN)
|
||||||
break;
|
break;
|
||||||
/* returned not-zero, this an error */
|
/* returned not-zero, this an error */
|
||||||
else if(code) {
|
else if(result) {
|
||||||
keepon = FALSE;
|
keepon = FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1610,8 +1610,8 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
|
|||||||
|
|
||||||
total_dl += nread;
|
total_dl += nread;
|
||||||
Curl_pgrsSetDownloadCounter(data, total_dl);
|
Curl_pgrsSetDownloadCounter(data, total_dl);
|
||||||
code = telrcv(conn, (unsigned char *)buf, nread);
|
result = telrcv(conn, (unsigned char *)buf, nread);
|
||||||
if(code) {
|
if(result) {
|
||||||
keepon = FALSE;
|
keepon = FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1643,8 +1643,8 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(nread > 0) {
|
if(nread > 0) {
|
||||||
code = send_telnet_data(conn, buf, nread);
|
result = send_telnet_data(conn, buf, nread);
|
||||||
if(code) {
|
if(result) {
|
||||||
keepon = FALSE;
|
keepon = FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1661,13 +1661,13 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
|
|||||||
now = Curl_tvnow();
|
now = Curl_tvnow();
|
||||||
if(Curl_tvdiff(now, conn->created) >= data->set.timeout) {
|
if(Curl_tvdiff(now, conn->created) >= data->set.timeout) {
|
||||||
failf(data, "Time-out");
|
failf(data, "Time-out");
|
||||||
code = CURLE_OPERATION_TIMEDOUT;
|
result = CURLE_OPERATION_TIMEDOUT;
|
||||||
keepon = FALSE;
|
keepon = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Curl_pgrsUpdate(conn)) {
|
if(Curl_pgrsUpdate(conn)) {
|
||||||
code = CURLE_ABORTED_BY_CALLBACK;
|
result = CURLE_ABORTED_BY_CALLBACK;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1675,6 +1675,6 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
|
|||||||
/* mark this as "no further transfer wanted" */
|
/* mark this as "no further transfer wanted" */
|
||||||
Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
|
Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
|
||||||
|
|
||||||
return code;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user