removed the socket argument from some functions that always passed in the
same socket and it was available from the passed-in struct anyway!
This commit is contained in:
Родитель
cc610f0d1f
Коммит
ae2ecfc5cb
74
lib/ftp.c
74
lib/ftp.c
|
@ -157,8 +157,7 @@ static CURLcode AllowServerConnect(struct SessionHandle *data,
|
|||
* response and extract the relevant return code for the invoking function.
|
||||
*/
|
||||
|
||||
int Curl_GetFTPResponse(int sockfd,
|
||||
char *buf,
|
||||
int Curl_GetFTPResponse(char *buf,
|
||||
struct connectdata *conn,
|
||||
int *ftpcode)
|
||||
{
|
||||
|
@ -169,6 +168,7 @@ int Curl_GetFTPResponse(int sockfd,
|
|||
* Alas, read as much as possible, split up into lines, use the ending
|
||||
* line in a response or continue reading. */
|
||||
|
||||
int sockfd = conn->firstsocket;
|
||||
int nread; /* total size read */
|
||||
int perline; /* count bytes per line */
|
||||
bool keepon=TRUE;
|
||||
|
@ -390,7 +390,7 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
|
|||
|
||||
|
||||
/* The first thing we do is wait for the "220*" line: */
|
||||
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
|
||||
if(nread < 0)
|
||||
return CURLE_OPERATION_TIMEOUTED;
|
||||
|
||||
|
@ -418,10 +418,10 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
|
|||
#endif
|
||||
|
||||
/* send USER */
|
||||
ftpsendf(conn->firstsocket, conn, "USER %s", ftp->user);
|
||||
ftpsendf(conn, "USER %s", ftp->user);
|
||||
|
||||
/* wait for feedback */
|
||||
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
|
||||
if(nread < 0)
|
||||
return CURLE_OPERATION_TIMEOUTED;
|
||||
|
||||
|
@ -434,8 +434,8 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
|
|||
else if(ftpcode == 331) {
|
||||
/* 331 Password required for ...
|
||||
(the server requires to send the user's password too) */
|
||||
ftpsendf(conn->firstsocket, conn, "PASS %s", ftp->passwd);
|
||||
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||
ftpsendf(conn, "PASS %s", ftp->passwd);
|
||||
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
|
||||
if(nread < 0)
|
||||
return CURLE_OPERATION_TIMEOUTED;
|
||||
|
||||
|
@ -480,10 +480,10 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
|
|||
}
|
||||
|
||||
/* send PWD to discover our entry point */
|
||||
ftpsendf(conn->firstsocket, conn, "PWD");
|
||||
ftpsendf(conn, "PWD");
|
||||
|
||||
/* wait for feedback */
|
||||
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
|
||||
if(nread < 0)
|
||||
return CURLE_OPERATION_TIMEOUTED;
|
||||
|
||||
|
@ -575,7 +575,7 @@ CURLcode Curl_ftp_done(struct connectdata *conn)
|
|||
if(!data->set.no_body && !conn->bits.resume_done) {
|
||||
/* now let's see what the server says about the transfer we
|
||||
just performed: */
|
||||
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
|
||||
if(nread < 0)
|
||||
return CURLE_OPERATION_TIMEOUTED;
|
||||
|
||||
|
@ -608,9 +608,9 @@ CURLcode ftp_sendquote(struct connectdata *conn, struct curl_slist *quote)
|
|||
item = quote;
|
||||
while (item) {
|
||||
if (item->data) {
|
||||
ftpsendf(conn->firstsocket, conn, "%s", item->data);
|
||||
ftpsendf(conn, "%s", item->data);
|
||||
|
||||
nread = Curl_GetFTPResponse(conn->firstsocket,
|
||||
nread = Curl_GetFTPResponse(
|
||||
conn->data->state.buffer, conn, &ftpcode);
|
||||
if (nread < 0)
|
||||
return CURLE_OPERATION_TIMEOUTED;
|
||||
|
@ -633,8 +633,8 @@ CURLcode ftp_cwd(struct connectdata *conn, char *path)
|
|||
ssize_t nread;
|
||||
int ftpcode;
|
||||
|
||||
ftpsendf(conn->firstsocket, conn, "CWD %s", path);
|
||||
nread = Curl_GetFTPResponse(conn->firstsocket,
|
||||
ftpsendf(conn, "CWD %s", path);
|
||||
nread = Curl_GetFTPResponse(
|
||||
conn->data->state.buffer, conn, &ftpcode);
|
||||
if (nread < 0)
|
||||
return CURLE_OPERATION_TIMEOUTED;
|
||||
|
@ -657,9 +657,9 @@ CURLcode ftp_getfiletime(struct connectdata *conn, char *file)
|
|||
|
||||
/* we have requested to get the modified-time of the file, this is yet
|
||||
again a grey area as the MDTM is not kosher RFC959 */
|
||||
ftpsendf(conn->firstsocket, conn, "MDTM %s", file);
|
||||
ftpsendf(conn, "MDTM %s", file);
|
||||
|
||||
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
|
||||
if(nread < 0)
|
||||
return CURLE_OPERATION_TIMEOUTED;
|
||||
|
||||
|
@ -691,9 +691,9 @@ static CURLcode ftp_transfertype(struct connectdata *conn,
|
|||
ssize_t nread;
|
||||
char *buf=data->state.buffer;
|
||||
|
||||
ftpsendf(conn->firstsocket, conn, "TYPE %s", ascii?"A":"I");
|
||||
ftpsendf(conn, "TYPE %s", ascii?"A":"I");
|
||||
|
||||
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
|
||||
if(nread < 0)
|
||||
return CURLE_OPERATION_TIMEOUTED;
|
||||
|
||||
|
@ -715,8 +715,8 @@ CURLcode ftp_getsize(struct connectdata *conn, char *file,
|
|||
ssize_t nread;
|
||||
char *buf=data->state.buffer;
|
||||
|
||||
ftpsendf(conn->firstsocket, conn, "SIZE %s", file);
|
||||
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||
ftpsendf(conn, "SIZE %s", file);
|
||||
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
|
||||
if(nread < 0)
|
||||
return CURLE_OPERATION_TIMEOUTED;
|
||||
|
||||
|
@ -983,7 +983,7 @@ CURLcode ftp_use_port(struct connectdata *conn)
|
|||
*q = '\0';
|
||||
}
|
||||
|
||||
ftpsendf(conn->firstsocket, conn, "%s |%d|%s|%s|", *modep, eprtaf,
|
||||
ftpsendf(conn, "%s |%d|%s|%s|", *modep, eprtaf,
|
||||
portmsgbuf, tmp);
|
||||
} else if (strcmp(*modep, "LPRT") == 0 ||
|
||||
strcmp(*modep, "PORT") == 0) {
|
||||
|
@ -1031,10 +1031,10 @@ CURLcode ftp_use_port(struct connectdata *conn)
|
|||
}
|
||||
}
|
||||
|
||||
ftpsendf(conn->firstsocket, conn, "%s %s", *modep, portmsgbuf);
|
||||
ftpsendf(conn, "%s %s", *modep, portmsgbuf);
|
||||
}
|
||||
|
||||
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
|
||||
if(nread < 0)
|
||||
return CURLE_OPERATION_TIMEOUTED;
|
||||
|
||||
|
@ -1158,13 +1158,13 @@ CURLcode ftp_use_port(struct connectdata *conn)
|
|||
sscanf( inet_ntoa(in), "%hu.%hu.%hu.%hu",
|
||||
&ip[0], &ip[1], &ip[2], &ip[3]);
|
||||
#endif
|
||||
ftpsendf(conn->firstsocket, conn, "PORT %d,%d,%d,%d,%d,%d",
|
||||
ftpsendf(conn, "PORT %d,%d,%d,%d,%d,%d",
|
||||
ip[0], ip[1], ip[2], ip[3],
|
||||
porttouse >> 8,
|
||||
porttouse & 255);
|
||||
}
|
||||
|
||||
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
|
||||
if(nread < 0)
|
||||
return CURLE_OPERATION_TIMEOUTED;
|
||||
|
||||
|
@ -1203,8 +1203,8 @@ CURLcode ftp_use_pasv(struct connectdata *conn)
|
|||
int modeoff;
|
||||
|
||||
for (modeoff = 0; mode[modeoff]; modeoff++) {
|
||||
ftpsendf(conn->firstsocket, conn, mode[modeoff]);
|
||||
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||
ftpsendf(conn, mode[modeoff]);
|
||||
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
|
||||
if(nread < 0)
|
||||
return CURLE_OPERATION_TIMEOUTED;
|
||||
|
||||
|
@ -1549,11 +1549,11 @@ CURLcode ftp_perform(struct connectdata *conn)
|
|||
/* Send everything on data->set.in to the socket */
|
||||
if(data->set.ftp_append)
|
||||
/* we append onto the file instead of rewriting it */
|
||||
ftpsendf(conn->firstsocket, conn, "APPE %s", ftp->file);
|
||||
ftpsendf(conn, "APPE %s", ftp->file);
|
||||
else
|
||||
ftpsendf(conn->firstsocket, conn, "STOR %s", ftp->file);
|
||||
ftpsendf(conn, "STOR %s", ftp->file);
|
||||
|
||||
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
|
||||
if(nread < 0)
|
||||
return CURLE_OPERATION_TIMEOUTED;
|
||||
|
||||
|
@ -1641,7 +1641,7 @@ CURLcode ftp_perform(struct connectdata *conn)
|
|||
better used since the LIST command output is not specified or
|
||||
standard in any way */
|
||||
|
||||
ftpsendf(conn->firstsocket, conn, "%s",
|
||||
ftpsendf(conn, "%s",
|
||||
data->set.customrequest?data->set.customrequest:
|
||||
(data->set.ftp_list_only?"NLST":"LIST"));
|
||||
}
|
||||
|
@ -1712,9 +1712,9 @@ CURLcode ftp_perform(struct connectdata *conn)
|
|||
infof(data, "Instructs server to resume from offset %d\n",
|
||||
conn->resume_from);
|
||||
|
||||
ftpsendf(conn->firstsocket, conn, "REST %d", conn->resume_from);
|
||||
ftpsendf(conn, "REST %d", conn->resume_from);
|
||||
|
||||
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
|
||||
if(nread < 0)
|
||||
return CURLE_OPERATION_TIMEOUTED;
|
||||
|
||||
|
@ -1724,10 +1724,10 @@ CURLcode ftp_perform(struct connectdata *conn)
|
|||
}
|
||||
}
|
||||
|
||||
ftpsendf(conn->firstsocket, conn, "RETR %s", ftp->file);
|
||||
ftpsendf(conn, "RETR %s", ftp->file);
|
||||
}
|
||||
|
||||
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
|
||||
if(nread < 0)
|
||||
return CURLE_OPERATION_TIMEOUTED;
|
||||
|
||||
|
@ -1888,7 +1888,7 @@ CURLcode Curl_ftp(struct connectdata *conn)
|
|||
* restrictions on the command!
|
||||
*
|
||||
*/
|
||||
size_t Curl_ftpsendf(int fd, struct connectdata *conn,
|
||||
size_t Curl_ftpsendf(struct connectdata *conn,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
size_t bytes_written;
|
||||
|
@ -1905,7 +1905,7 @@ size_t Curl_ftpsendf(int fd, struct connectdata *conn,
|
|||
strcat(s, "\r\n"); /* append a trailing CRLF */
|
||||
|
||||
bytes_written=0;
|
||||
Curl_write(conn, fd, s, strlen(s), &bytes_written);
|
||||
Curl_write(conn, conn->firstsocket, s, strlen(s), &bytes_written);
|
||||
|
||||
return(bytes_written);
|
||||
}
|
||||
|
|
|
@ -28,11 +28,10 @@ CURLcode Curl_ftp_done(struct connectdata *conn);
|
|||
CURLcode Curl_ftp_connect(struct connectdata *conn);
|
||||
CURLcode Curl_ftp_disconnect(struct connectdata *conn);
|
||||
|
||||
size_t Curl_ftpsendf(int fd, struct connectdata *, const char *fmt, ...);
|
||||
size_t Curl_ftpsendf(struct connectdata *, const char *fmt, ...);
|
||||
|
||||
/* The kerberos stuff needs this: */
|
||||
int Curl_GetFTPResponse(int sockfd, char *buf,
|
||||
struct connectdata *conn,
|
||||
int Curl_GetFTPResponse(char *buf, struct connectdata *conn,
|
||||
int *ftpcode);
|
||||
|
||||
#endif
|
||||
|
|
10
lib/krb4.c
10
lib/krb4.c
|
@ -245,7 +245,7 @@ krb4_auth(void *app_data, struct connectdata *conn)
|
|||
return AUTH_CONTINUE;
|
||||
}
|
||||
|
||||
Curl_ftpsendf(conn->firstsocket, conn, "ADAT %s", p);
|
||||
Curl_ftpsendf(conn, "ADAT %s", p);
|
||||
|
||||
nread = Curl_GetFTPResponse(conn->firstsocket,
|
||||
conn->data->state.buffer, conn, NULL);
|
||||
|
@ -313,10 +313,10 @@ void Curl_krb_kauth(struct connectdata *conn)
|
|||
|
||||
save = Curl_set_command_prot(conn, prot_private);
|
||||
|
||||
Curl_ftpsendf(conn->firstsocket, conn,
|
||||
Curl_ftpsendf(conn,
|
||||
"SITE KAUTH %s", conn->data->state.user);
|
||||
|
||||
nread = Curl_GetFTPResponse(conn->firstsocket, conn->data->state.buffer,
|
||||
nread = Curl_GetFTPResponse(conn->data->state.buffer,
|
||||
conn, NULL);
|
||||
if(nread < 0)
|
||||
return /*CURLE_OPERATION_TIMEOUTED*/;
|
||||
|
@ -380,10 +380,10 @@ void Curl_krb_kauth(struct connectdata *conn)
|
|||
}
|
||||
memset (tktcopy.dat, 0, tktcopy.length);
|
||||
|
||||
Curl_ftpsendf(conn->firstsocket, conn,
|
||||
Curl_ftpsendf(conn,
|
||||
"SITE KAUTH %s %s", name, p);
|
||||
|
||||
nread = Curl_GetFTPResponse(conn->firstsocket, conn->data->state.buffer,
|
||||
nread = Curl_GetFTPResponse(conn->data->state.buffer,
|
||||
conn, NULL);
|
||||
if(nread < 0)
|
||||
return /*CURLE_OPERATION_TIMEOUTED*/;
|
||||
|
|
|
@ -413,11 +413,10 @@ sec_prot_internal(struct connectdata *conn, int level)
|
|||
}
|
||||
|
||||
if(level){
|
||||
Curl_ftpsendf(conn->firstsocket, conn,
|
||||
Curl_ftpsendf(conn,
|
||||
"PBSZ %u", s);
|
||||
/* wait for feedback */
|
||||
nread = Curl_GetFTPResponse(conn->firstsocket,
|
||||
conn->data->state.buffer, conn, NULL);
|
||||
nread = Curl_GetFTPResponse(conn->data->state.buffer, conn, NULL);
|
||||
if(nread < 0)
|
||||
return /*CURLE_OPERATION_TIMEOUTED*/-1;
|
||||
if(/*ret != COMPLETE*/conn->data->state.buffer[0] != '2'){
|
||||
|
@ -432,12 +431,11 @@ sec_prot_internal(struct connectdata *conn, int level)
|
|||
conn->buffer_size = s;
|
||||
}
|
||||
|
||||
Curl_ftpsendf(conn->firstsocket, conn,
|
||||
"PROT %c", level["CSEP"]);
|
||||
Curl_ftpsendf(conn, "PROT %c", level["CSEP"]);
|
||||
/* wait for feedback */
|
||||
nread = Curl_GetFTPResponse(conn->firstsocket,
|
||||
conn->data->state.buffer, conn, NULL);
|
||||
nread = Curl_GetFTPResponse(conn->data->state.buffer, conn, NULL);
|
||||
if(nread < 0)
|
||||
|
||||
return /*CURLE_OPERATION_TIMEOUTED*/-1;
|
||||
if(/*ret != COMPLETE*/conn->data->state.buffer[0] != '2'){
|
||||
failf(conn->data, "Failed to set protection level.\n");
|
||||
|
@ -490,7 +488,7 @@ Curl_sec_login(struct connectdata *conn)
|
|||
}
|
||||
infof(data, "Trying %s...\n", (*m)->name);
|
||||
/*ret = command("AUTH %s", (*m)->name);***/
|
||||
Curl_ftpsendf(conn->firstsocket, conn,
|
||||
Curl_ftpsendf(conn,
|
||||
"AUTH %s", (*m)->name);
|
||||
/* wait for feedback */
|
||||
nread = Curl_GetFTPResponse(conn->firstsocket,
|
||||
|
|
Загрузка…
Ссылка в новой задаче