1
0
mirror of https://github.com/moparisthebest/curl synced 2024-08-13 17:03:50 -04:00

ftp: get rid of the PPSENDF macro

The use of such a macro hides some of what's actually going on to the
reader and is generally disapproved of in the project.

Closes #5971
This commit is contained in:
Daniel Stenberg 2020-09-17 15:15:08 +02:00
parent 83cc966708
commit cc372af1e9
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

306
lib/ftp.c
View File

@ -137,14 +137,10 @@ static int ftp_domore_getsock(struct connectdata *conn, curl_socket_t *socks);
static CURLcode ftp_doing(struct connectdata *conn, static CURLcode ftp_doing(struct connectdata *conn,
bool *dophase_done); bool *dophase_done);
static CURLcode ftp_setup_connection(struct connectdata *conn); static CURLcode ftp_setup_connection(struct connectdata *conn);
static CURLcode init_wc_data(struct connectdata *conn); static CURLcode init_wc_data(struct connectdata *conn);
static CURLcode wc_statemach(struct connectdata *conn); static CURLcode wc_statemach(struct connectdata *conn);
static void wc_data_dtor(void *ptr); static void wc_data_dtor(void *ptr);
static CURLcode ftp_state_retr(struct connectdata *conn, curl_off_t filesize); static CURLcode ftp_state_retr(struct connectdata *conn, curl_off_t filesize);
static CURLcode ftp_readresp(curl_socket_t sockfd, static CURLcode ftp_readresp(curl_socket_t sockfd,
struct pingpong *pp, struct pingpong *pp,
int *ftpcode, int *ftpcode,
@ -152,12 +148,6 @@ static CURLcode ftp_readresp(curl_socket_t sockfd,
static CURLcode ftp_dophase_done(struct connectdata *conn, static CURLcode ftp_dophase_done(struct connectdata *conn,
bool connected); bool connected);
/* easy-to-use macro: */
#define PPSENDF(x,y,z) result = Curl_pp_sendf(x,y,z); \
if(result) \
return result
/* /*
* FTP protocol handler. * FTP protocol handler.
*/ */
@ -775,25 +765,22 @@ static void _state(struct connectdata *conn,
static CURLcode ftp_state_user(struct connectdata *conn) static CURLcode ftp_state_user(struct connectdata *conn)
{ {
CURLcode result; CURLcode result = Curl_pp_sendf(&conn->proto.ftpc.pp, "USER %s",
/* send USER */ conn->user?conn->user:"");
PPSENDF(&conn->proto.ftpc.pp, "USER %s", conn->user?conn->user:""); if(!result) {
state(conn, FTP_USER);
state(conn, FTP_USER); conn->data->state.ftp_trying_alternative = FALSE;
conn->data->state.ftp_trying_alternative = FALSE; }
return result;
return CURLE_OK;
} }
static CURLcode ftp_state_pwd(struct connectdata *conn) static CURLcode ftp_state_pwd(struct connectdata *conn)
{ {
CURLcode result; CURLcode result = Curl_pp_sendf(&conn->proto.ftpc.pp, "%s", "PWD");
if(!result)
state(conn, FTP_PWD);
/* send PWD to discover our entry point */ return result;
PPSENDF(&conn->proto.ftpc.pp, "%s", "PWD");
state(conn, FTP_PWD);
return CURLE_OK;
} }
/* For the FTP "protocol connect" and "doing" phases only */ /* For the FTP "protocol connect" and "doing" phases only */
@ -881,16 +868,19 @@ static CURLcode ftp_state_cwd(struct connectdata *conn)
where we ended up after login: */ where we ended up after login: */
ftpc->cwdcount = 0; /* we count this as the first path, then we add one ftpc->cwdcount = 0; /* we count this as the first path, then we add one
for all upcoming ones in the ftp->dirs[] array */ for all upcoming ones in the ftp->dirs[] array */
PPSENDF(&conn->proto.ftpc.pp, "CWD %s", ftpc->entrypath); result = Curl_pp_sendf(&ftpc->pp, "CWD %s", ftpc->entrypath);
state(conn, FTP_CWD); if(!result)
state(conn, FTP_CWD);
} }
else { else {
if(ftpc->dirdepth) { if(ftpc->dirdepth) {
ftpc->cwdcount = 1; ftpc->cwdcount = 1;
/* issue the first CWD, the rest is sent when the CWD responses are /* issue the first CWD, the rest is sent when the CWD responses are
received... */ received... */
PPSENDF(&conn->proto.ftpc.pp, "CWD %s", ftpc->dirs[ftpc->cwdcount -1]); result = Curl_pp_sendf(&ftpc->pp, "CWD %s",
state(conn, FTP_CWD); ftpc->dirs[ftpc->cwdcount -1]);
if(!result)
state(conn, FTP_CWD);
} }
else { else {
/* No CWD necessary */ /* No CWD necessary */
@ -1326,12 +1316,12 @@ static CURLcode ftp_state_use_pasv(struct connectdata *conn)
modeoff = conn->bits.ftp_use_epsv?0:1; modeoff = conn->bits.ftp_use_epsv?0:1;
PPSENDF(&ftpc->pp, "%s", mode[modeoff]); result = Curl_pp_sendf(&ftpc->pp, "%s", mode[modeoff]);
if(!result) {
ftpc->count1 = modeoff; ftpc->count1 = modeoff;
state(conn, FTP_PASV); state(conn, FTP_PASV);
infof(conn->data, "Connect data stream passively\n"); infof(conn->data, "Connect data stream passively\n");
}
return result; return result;
} }
@ -1364,23 +1354,23 @@ static CURLcode ftp_state_prepare_transfer(struct connectdata *conn)
if(data->set.ftp_use_pret) { if(data->set.ftp_use_pret) {
/* The user has requested that we send a PRET command /* The user has requested that we send a PRET command
to prepare the server for the upcoming PASV */ to prepare the server for the upcoming PASV */
if(!conn->proto.ftpc.file) { struct ftp_conn *ftpc = &conn->proto.ftpc;
PPSENDF(&conn->proto.ftpc.pp, "PRET %s", if(!conn->proto.ftpc.file)
data->set.str[STRING_CUSTOMREQUEST]? result = Curl_pp_sendf(&ftpc->pp, "PRET %s",
data->set.str[STRING_CUSTOMREQUEST]: data->set.str[STRING_CUSTOMREQUEST]?
(data->set.ftp_list_only?"NLST":"LIST")); data->set.str[STRING_CUSTOMREQUEST]:
} (data->set.ftp_list_only?"NLST":"LIST"));
else if(data->set.upload) { else if(data->set.upload)
PPSENDF(&conn->proto.ftpc.pp, "PRET STOR %s", conn->proto.ftpc.file); result = Curl_pp_sendf(&ftpc->pp, "PRET STOR %s",
} conn->proto.ftpc.file);
else { else
PPSENDF(&conn->proto.ftpc.pp, "PRET RETR %s", conn->proto.ftpc.file); result = Curl_pp_sendf(&ftpc->pp, "PRET RETR %s",
} conn->proto.ftpc.file);
state(conn, FTP_PRET); if(!result)
state(conn, FTP_PRET);
} }
else { else
result = ftp_state_use_pasv(conn); result = ftp_state_use_pasv(conn);
}
} }
return result; return result;
} }
@ -1396,9 +1386,9 @@ static CURLcode ftp_state_rest(struct connectdata *conn)
/* Determine if server can respond to REST command and therefore /* Determine if server can respond to REST command and therefore
whether it supports range */ whether it supports range */
PPSENDF(&conn->proto.ftpc.pp, "REST %d", 0); result = Curl_pp_sendf(&ftpc->pp, "REST %d", 0);
if(!result)
state(conn, FTP_REST); state(conn, FTP_REST);
} }
else else
result = ftp_state_prepare_transfer(conn); result = ftp_state_prepare_transfer(conn);
@ -1416,9 +1406,9 @@ static CURLcode ftp_state_size(struct connectdata *conn)
/* if a "head"-like request is being made (on a file) */ /* if a "head"-like request is being made (on a file) */
/* we know ftpc->file is a valid pointer to a file name */ /* we know ftpc->file is a valid pointer to a file name */
PPSENDF(&ftpc->pp, "SIZE %s", ftpc->file); result = Curl_pp_sendf(&ftpc->pp, "SIZE %s", ftpc->file);
if(!result)
state(conn, FTP_SIZE); state(conn, FTP_SIZE);
} }
else else
result = ftp_state_rest(conn); result = ftp_state_rest(conn);
@ -1485,10 +1475,8 @@ static CURLcode ftp_state_list(struct connectdata *conn)
result = Curl_pp_sendf(&conn->proto.ftpc.pp, "%s", cmd); result = Curl_pp_sendf(&conn->proto.ftpc.pp, "%s", cmd);
free(cmd); free(cmd);
if(result) if(!result)
return result; state(conn, FTP_LIST);
state(conn, FTP_LIST);
return result; return result;
} }
@ -1549,9 +1537,10 @@ static CURLcode ftp_state_mdtm(struct connectdata *conn)
/* we have requested to get the modified-time of the file, this is a white /* we have requested to get the modified-time of the file, this is a white
spot as the MDTM is not mentioned in RFC959 */ spot as the MDTM is not mentioned in RFC959 */
PPSENDF(&ftpc->pp, "MDTM %s", ftpc->file); result = Curl_pp_sendf(&ftpc->pp, "MDTM %s", ftpc->file);
state(conn, FTP_MDTM); if(!result)
state(conn, FTP_MDTM);
} }
else else
result = ftp_state_type(conn); result = ftp_state_type(conn);
@ -1587,8 +1576,9 @@ static CURLcode ftp_state_ul_setup(struct connectdata *conn,
if(data->state.resume_from < 0) { if(data->state.resume_from < 0) {
/* Got no given size to start from, figure it out */ /* Got no given size to start from, figure it out */
PPSENDF(&ftpc->pp, "SIZE %s", ftpc->file); result = Curl_pp_sendf(&ftpc->pp, "SIZE %s", ftpc->file);
state(conn, FTP_STOR_SIZE); if(!result)
state(conn, FTP_STOR_SIZE);
return result; return result;
} }
@ -1650,10 +1640,10 @@ static CURLcode ftp_state_ul_setup(struct connectdata *conn,
/* we've passed, proceed as normal */ /* we've passed, proceed as normal */
} /* resume_from */ } /* resume_from */
PPSENDF(&ftpc->pp, data->set.ftp_append?"APPE %s":"STOR %s", result = Curl_pp_sendf(&ftpc->pp, data->set.ftp_append?"APPE %s":"STOR %s",
ftpc->file); ftpc->file);
if(!result)
state(conn, FTP_STOR); state(conn, FTP_STOR);
return result; return result;
} }
@ -1711,7 +1701,9 @@ static CURLcode ftp_state_quote(struct connectdata *conn,
else else
ftpc->count2 = 0; /* failure means cancel operation */ ftpc->count2 = 0; /* failure means cancel operation */
PPSENDF(&ftpc->pp, "%s", cmd); result = Curl_pp_sendf(&ftpc->pp, "%s", cmd);
if(result)
return result;
state(conn, instate); state(conn, instate);
quote = TRUE; quote = TRUE;
} }
@ -1740,12 +1732,14 @@ static CURLcode ftp_state_quote(struct connectdata *conn,
the server terminates it, otherwise the client stops if the the server terminates it, otherwise the client stops if the
received byte count exceeds the reported file size. Set option received byte count exceeds the reported file size. Set option
CURLOPT_IGNORE_CONTENT_LENGTH to 1 to enable this behavior.*/ CURLOPT_IGNORE_CONTENT_LENGTH to 1 to enable this behavior.*/
PPSENDF(&ftpc->pp, "RETR %s", ftpc->file); result = Curl_pp_sendf(&ftpc->pp, "RETR %s", ftpc->file);
state(conn, FTP_RETR); if(!result)
state(conn, FTP_RETR);
} }
else { else {
PPSENDF(&ftpc->pp, "SIZE %s", ftpc->file); result = Curl_pp_sendf(&ftpc->pp, "SIZE %s", ftpc->file);
state(conn, FTP_RETR_SIZE); if(!result)
state(conn, FTP_RETR_SIZE);
} }
} }
} }
@ -1782,10 +1776,12 @@ static CURLcode ftp_epsv_disable(struct connectdata *conn)
conn->bits.ftp_use_epsv = FALSE; conn->bits.ftp_use_epsv = FALSE;
conn->data->state.errorbuf = FALSE; /* allow error message to get conn->data->state.errorbuf = FALSE; /* allow error message to get
rewritten */ rewritten */
PPSENDF(&conn->proto.ftpc.pp, "%s", "PASV"); result = Curl_pp_sendf(&conn->proto.ftpc.pp, "%s", "PASV");
conn->proto.ftpc.count1++; if(!result) {
/* remain in/go to the FTP_PASV state */ conn->proto.ftpc.count1++;
state(conn, FTP_PASV); /* remain in/go to the FTP_PASV state */
state(conn, FTP_PASV);
}
return result; return result;
} }
@ -2229,15 +2225,16 @@ static CURLcode ftp_state_retr(struct connectdata *conn,
infof(data, "Instructs server to resume from offset %" infof(data, "Instructs server to resume from offset %"
CURL_FORMAT_CURL_OFF_T "\n", data->state.resume_from); CURL_FORMAT_CURL_OFF_T "\n", data->state.resume_from);
PPSENDF(&ftpc->pp, "REST %" CURL_FORMAT_CURL_OFF_T, result = Curl_pp_sendf(&ftpc->pp, "REST %" CURL_FORMAT_CURL_OFF_T,
data->state.resume_from); data->state.resume_from);
if(!result)
state(conn, FTP_RETR_REST); state(conn, FTP_RETR_REST);
} }
else { else {
/* no resume */ /* no resume */
PPSENDF(&ftpc->pp, "RETR %s", ftpc->file); result = Curl_pp_sendf(&ftpc->pp, "RETR %s", ftpc->file);
state(conn, FTP_RETR); if(!result)
state(conn, FTP_RETR);
} }
return result; return result;
@ -2330,8 +2327,9 @@ static CURLcode ftp_state_rest_resp(struct connectdata *conn,
result = CURLE_FTP_COULDNT_USE_REST; result = CURLE_FTP_COULDNT_USE_REST;
} }
else { else {
PPSENDF(&ftpc->pp, "RETR %s", ftpc->file); result = Curl_pp_sendf(&ftpc->pp, "RETR %s", ftpc->file);
state(conn, FTP_RETR); if(!result)
state(conn, FTP_RETR);
} }
break; break;
} }
@ -2523,8 +2521,9 @@ static CURLcode ftp_state_loggedin(struct connectdata *conn)
parameter of '0' to indicate that no buffering is taking place parameter of '0' to indicate that no buffering is taking place
and the data connection should not be encapsulated. and the data connection should not be encapsulated.
*/ */
PPSENDF(&conn->proto.ftpc.pp, "PBSZ %d", 0); result = Curl_pp_sendf(&conn->proto.ftpc.pp, "PBSZ %d", 0);
state(conn, FTP_PBSZ); if(!result)
state(conn, FTP_PBSZ);
} }
else { else {
result = ftp_state_pwd(conn); result = ftp_state_pwd(conn);
@ -2546,8 +2545,9 @@ static CURLcode ftp_state_user_resp(struct connectdata *conn,
if((ftpcode == 331) && (ftpc->state == FTP_USER)) { if((ftpcode == 331) && (ftpc->state == FTP_USER)) {
/* 331 Password required for ... /* 331 Password required for ...
(the server requires to send the user's password too) */ (the server requires to send the user's password too) */
PPSENDF(&ftpc->pp, "PASS %s", conn->passwd?conn->passwd:""); result = Curl_pp_sendf(&ftpc->pp, "PASS %s", conn->passwd?conn->passwd:"");
state(conn, FTP_PASS); if(!result)
state(conn, FTP_PASS);
} }
else if(ftpcode/100 == 2) { else if(ftpcode/100 == 2) {
/* 230 User ... logged in. /* 230 User ... logged in.
@ -2556,8 +2556,10 @@ static CURLcode ftp_state_user_resp(struct connectdata *conn,
} }
else if(ftpcode == 332) { else if(ftpcode == 332) {
if(data->set.str[STRING_FTP_ACCOUNT]) { if(data->set.str[STRING_FTP_ACCOUNT]) {
PPSENDF(&ftpc->pp, "ACCT %s", data->set.str[STRING_FTP_ACCOUNT]); result = Curl_pp_sendf(&ftpc->pp, "ACCT %s",
state(conn, FTP_ACCT); data->set.str[STRING_FTP_ACCOUNT]);
if(!result)
state(conn, FTP_ACCT);
} }
else { else {
failf(data, "ACCT requested but none available"); failf(data, "ACCT requested but none available");
@ -2573,11 +2575,13 @@ static CURLcode ftp_state_user_resp(struct connectdata *conn,
if(conn->data->set.str[STRING_FTP_ALTERNATIVE_TO_USER] && if(conn->data->set.str[STRING_FTP_ALTERNATIVE_TO_USER] &&
!conn->data->state.ftp_trying_alternative) { !conn->data->state.ftp_trying_alternative) {
/* Ok, USER failed. Let's try the supplied command. */ /* Ok, USER failed. Let's try the supplied command. */
PPSENDF(&conn->proto.ftpc.pp, "%s", result =
conn->data->set.str[STRING_FTP_ALTERNATIVE_TO_USER]); Curl_pp_sendf(&ftpc->pp, "%s",
conn->data->state.ftp_trying_alternative = TRUE; conn->data->set.str[STRING_FTP_ALTERNATIVE_TO_USER]);
state(conn, FTP_USER); if(!result) {
result = CURLE_OK; conn->data->state.ftp_trying_alternative = TRUE;
state(conn, FTP_USER);
}
} }
else { else {
failf(data, "Access denied: %03d", ftpcode); failf(data, "Access denied: %03d", ftpcode);
@ -2679,15 +2683,12 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
(int)data->set.ftpsslauth); (int)data->set.ftpsslauth);
return CURLE_UNKNOWN_OPTION; /* we don't know what to do */ return CURLE_UNKNOWN_OPTION; /* we don't know what to do */
} }
PPSENDF(&ftpc->pp, "AUTH %s", ftpauth[ftpc->count1]); result = Curl_pp_sendf(&ftpc->pp, "AUTH %s", ftpauth[ftpc->count1]);
state(conn, FTP_AUTH); if(!result)
state(conn, FTP_AUTH);
} }
else { else
result = ftp_state_user(conn); result = ftp_state_user(conn);
if(result)
return result;
}
break; break;
case FTP_AUTH: case FTP_AUTH:
@ -2722,9 +2723,6 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
/* ignore the failure and continue */ /* ignore the failure and continue */
result = ftp_state_user(conn); result = ftp_state_user(conn);
} }
if(result)
return result;
break; break;
case FTP_USER: case FTP_USER:
@ -2737,10 +2735,11 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
break; break;
case FTP_PBSZ: case FTP_PBSZ:
PPSENDF(&ftpc->pp, "PROT %c", result =
data->set.use_ssl == CURLUSESSL_CONTROL ? 'C' : 'P'); Curl_pp_sendf(&ftpc->pp, "PROT %c",
state(conn, FTP_PROT); data->set.use_ssl == CURLUSESSL_CONTROL ? 'C' : 'P');
if(!result)
state(conn, FTP_PROT);
break; break;
case FTP_PROT: case FTP_PROT:
@ -2757,14 +2756,12 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
if(data->set.ftp_ccc) { if(data->set.ftp_ccc) {
/* CCC - Clear Command Channel /* CCC - Clear Command Channel
*/ */
PPSENDF(&ftpc->pp, "%s", "CCC"); result = Curl_pp_sendf(&ftpc->pp, "%s", "CCC");
state(conn, FTP_CCC); if(!result)
state(conn, FTP_CCC);
} }
else { else
result = ftp_state_pwd(conn); result = ftp_state_pwd(conn);
if(result)
return result;
}
break; break;
case FTP_CCC: case FTP_CCC:
@ -2772,16 +2769,12 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
/* First shut down the SSL layer (note: this call will block) */ /* First shut down the SSL layer (note: this call will block) */
result = Curl_ssl_shutdown(conn, FIRSTSOCKET); result = Curl_ssl_shutdown(conn, FIRSTSOCKET);
if(result) { if(result)
failf(conn->data, "Failed to clear the command channel (CCC)"); failf(conn->data, "Failed to clear the command channel (CCC)");
return result;
}
} }
if(!result)
/* Then continue as normal */ /* Then continue as normal */
result = ftp_state_pwd(conn); result = ftp_state_pwd(conn);
if(result)
return result;
break; break;
case FTP_PWD: case FTP_PWD:
@ -2847,7 +2840,6 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
systems. */ systems. */
if(!ftpc->server_os && dir[0] != '/') { if(!ftpc->server_os && dir[0] != '/') {
result = Curl_pp_sendf(&ftpc->pp, "%s", "SYST"); result = Curl_pp_sendf(&ftpc->pp, "%s", "SYST");
if(result) { if(result) {
free(dir); free(dir);
@ -2943,12 +2935,10 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
if((ftpcode >= 400) && !ftpc->count2) { if((ftpcode >= 400) && !ftpc->count2) {
/* failure response code, and not allowed to fail */ /* failure response code, and not allowed to fail */
failf(conn->data, "QUOT command failed with %03d", ftpcode); failf(conn->data, "QUOT command failed with %03d", ftpcode);
return CURLE_QUOTE_ERROR; result = CURLE_QUOTE_ERROR;
} }
result = ftp_state_quote(conn, FALSE, ftpc->state); else
if(result) result = ftp_state_quote(conn, FALSE, ftpc->state);
return result;
break; break;
case FTP_CWD: case FTP_CWD:
@ -2958,29 +2948,28 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
ftpc->cwdcount && !ftpc->count2) { ftpc->cwdcount && !ftpc->count2) {
/* try making it */ /* try making it */
ftpc->count2++; /* counter to prevent CWD-MKD loops */ ftpc->count2++; /* counter to prevent CWD-MKD loops */
PPSENDF(&ftpc->pp, "MKD %s", ftpc->dirs[ftpc->cwdcount - 1]); result = Curl_pp_sendf(&ftpc->pp, "MKD %s",
state(conn, FTP_MKD); ftpc->dirs[ftpc->cwdcount - 1]);
if(!result)
state(conn, FTP_MKD);
} }
else { else {
/* return failure */ /* return failure */
failf(data, "Server denied you to change to the given directory"); failf(data, "Server denied you to change to the given directory");
ftpc->cwdfail = TRUE; /* don't remember this path as we failed ftpc->cwdfail = TRUE; /* don't remember this path as we failed
to enter it */ to enter it */
return CURLE_REMOTE_ACCESS_DENIED; result = CURLE_REMOTE_ACCESS_DENIED;
} }
} }
else { else {
/* success */ /* success */
ftpc->count2 = 0; ftpc->count2 = 0;
if(++ftpc->cwdcount <= ftpc->dirdepth) { if(++ftpc->cwdcount <= ftpc->dirdepth)
/* send next CWD */ /* send next CWD */
PPSENDF(&ftpc->pp, "CWD %s", ftpc->dirs[ftpc->cwdcount - 1]); result = Curl_pp_sendf(&ftpc->pp, "CWD %s",
} ftpc->dirs[ftpc->cwdcount - 1]);
else { else
result = ftp_state_mdtm(conn); result = ftp_state_mdtm(conn);
if(result)
return result;
}
} }
break; break;
@ -2988,11 +2977,14 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
if((ftpcode/100 != 2) && !ftpc->count3--) { if((ftpcode/100 != 2) && !ftpc->count3--) {
/* failure to MKD the dir */ /* failure to MKD the dir */
failf(data, "Failed to MKD dir: %03d", ftpcode); failf(data, "Failed to MKD dir: %03d", ftpcode);
return CURLE_REMOTE_ACCESS_DENIED; result = CURLE_REMOTE_ACCESS_DENIED;
}
else {
state(conn, FTP_CWD);
/* send CWD */
result = Curl_pp_sendf(&ftpc->pp, "CWD %s",
ftpc->dirs[ftpc->cwdcount - 1]);
} }
state(conn, FTP_CWD);
/* send CWD */
PPSENDF(&ftpc->pp, "CWD %s", ftpc->dirs[ftpc->cwdcount - 1]);
break; break;
case FTP_MDTM: case FTP_MDTM:
@ -3372,17 +3364,17 @@ static
CURLcode ftp_sendquote(struct connectdata *conn, struct curl_slist *quote) CURLcode ftp_sendquote(struct connectdata *conn, struct curl_slist *quote)
{ {
struct curl_slist *item; struct curl_slist *item;
ssize_t nread;
int ftpcode;
CURLcode result;
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
struct pingpong *pp = &ftpc->pp; struct pingpong *pp = &ftpc->pp;
item = quote; item = quote;
while(item) { while(item) {
if(item->data) { if(item->data) {
ssize_t nread;
char *cmd = item->data; char *cmd = item->data;
bool acceptfail = FALSE; bool acceptfail = FALSE;
CURLcode result;
int ftpcode = 0;
/* if a command starts with an asterisk, which a legal FTP command never /* if a command starts with an asterisk, which a legal FTP command never
can, the command will be allowed to fail without it causing any can, the command will be allowed to fail without it causing any
@ -3394,11 +3386,11 @@ CURLcode ftp_sendquote(struct connectdata *conn, struct curl_slist *quote)
acceptfail = TRUE; acceptfail = TRUE;
} }
PPSENDF(&conn->proto.ftpc.pp, "%s", cmd); result = Curl_pp_sendf(&ftpc->pp, "%s", cmd);
if(!result) {
pp->response = Curl_now(); /* timeout relative now */ pp->response = Curl_now(); /* timeout relative now */
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
result = Curl_GetFTPResponse(&nread, conn, &ftpcode); }
if(result) if(result)
return result; return result;
@ -3446,12 +3438,14 @@ static CURLcode ftp_nb_type(struct connectdata *conn,
return ftp_state_type_resp(conn, 200, newstate); return ftp_state_type_resp(conn, 200, newstate);
} }
PPSENDF(&ftpc->pp, "TYPE %c", want); result = Curl_pp_sendf(&ftpc->pp, "TYPE %c", want);
state(conn, newstate); if(!result) {
state(conn, newstate);
/* keep track of our current transfer type */ /* keep track of our current transfer type */
ftpc->transfertype = want; ftpc->transfertype = want;
return CURLE_OK; }
return result;
} }
/*************************************************************************** /***************************************************************************