#include "warnless.h"
#include "http_proxy.h"
#include "non-ascii.h"
+/* The last 3 #include files should be in this order */
#include "curl_printf.h"
-
#include "curl_memory.h"
-/* The last #include file should be: */
#include "memdebug.h"
#ifndef NI_MAXHOST
*/
static CURLcode AcceptServerConnect(struct connectdata *conn)
{
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
curl_socket_t sock = conn->sock[SECONDARYSOCKET];
curl_socket_t s = CURL_SOCKET_BAD;
#ifdef ENABLE_IPV6
* Curl_pgrsTime(..., TIMER_STARTACCEPT);
*
*/
-static long ftp_timeleft_accept(struct SessionHandle *data)
+static long ftp_timeleft_accept(struct Curl_easy *data)
{
long timeout_ms = DEFAULT_ACCEPT_TIMEOUT;
long other;
*/
static CURLcode ReceivedServerConnect(struct connectdata *conn, bool *received)
{
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
curl_socket_t ctrl_sock = conn->sock[FIRSTSOCKET];
curl_socket_t data_sock = conn->sock[SECONDARYSOCKET];
struct ftp_conn *ftpc = &conn->proto.ftpc;
*/
static CURLcode InitiateTransfer(struct connectdata *conn)
{
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
struct FTP *ftp = data->req.protop;
CURLcode result = CURLE_OK;
*/
static CURLcode AllowServerConnect(struct connectdata *conn, bool *connected)
{
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
long timeout_ms;
CURLcode result = CURLE_OK;
size_t *size) /* size of the response */
{
struct connectdata *conn = pp->conn;
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
#ifdef HAVE_GSSAPI
char * const buf = data->state.buffer;
#endif
curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
long timeout; /* timeout in milliseconds */
long interval_ms;
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
CURLcode result = CURLE_OK;
struct ftp_conn *ftpc = &conn->proto.ftpc;
struct pingpong *pp = &ftpc->pp;
/* check and reset timeout value every lap */
timeout = Curl_pp_state_timeout(pp);
- if(timeout <=0 ) {
+ if(timeout <=0) {
failf(data, "FTP response timeout");
return CURLE_OPERATION_TIMEDOUT; /* already too little time */
}
}
else {
socks[1] = conn->sock[SECONDARYSOCKET];
- bits |= GETSOCK_WRITESOCK(1);
+ bits |= GETSOCK_WRITESOCK(1) | GETSOCK_READSOCK(1);
}
return bits;
{
CURLcode result = CURLE_OK;
struct ftp_conn *ftpc = &conn->proto.ftpc;
- struct SessionHandle *data=conn->data;
+ struct Curl_easy *data=conn->data;
curl_socket_t portsock= CURL_SOCKET_BAD;
char myhost[256] = "";
if(*string_ftpport == '[') {
/* [ipv6]:port(-range) */
ip_start = string_ftpport + 1;
- if((ip_end = strchr(string_ftpport, ']')) != NULL )
+ if((ip_end = strchr(string_ftpport, ']')) != NULL)
strncpy(addr, ip_start, ip_end - ip_start);
}
else
else
#endif
/* (ipv4|domain|interface):port(-range) */
- strncpy(addr, string_ftpport, ip_end - ip_start );
+ strncpy(addr, string_ftpport, ip_end - ip_start);
}
else
/* ipv4|interface */
/* correct errors like:
* :1234-1230
- * :-4711 , in this case port_min is (unsigned)-1,
+ * :-4711, in this case port_min is (unsigned)-1,
* therefore port_min > port_max for all cases
* but port_max = (unsigned)-1
*/
- if(port_min > port_max )
+ if(port_min > port_max)
port_min = port_max = 0;
{
CURLcode result = CURLE_OK;
struct FTP *ftp = conn->data->req.protop;
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
if(ftp->transfer != FTPTRANSFER_BODY) {
/* doesn't transfer any data */
static CURLcode ftp_state_list(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
/* If this output is to be machine-parsed, the NLST command might be better
to use, since the LIST command output is not specified or standard in any
}
}
- cmd = aprintf( "%s%s%s",
- data->set.str[STRING_CUSTOMREQUEST]?
- data->set.str[STRING_CUSTOMREQUEST]:
- (data->set.ftp_list_only?"NLST":"LIST"),
- lstArg? " ": "",
- lstArg? lstArg: "" );
+ cmd = aprintf("%s%s%s",
+ data->set.str[STRING_CUSTOMREQUEST]?
+ data->set.str[STRING_CUSTOMREQUEST]:
+ (data->set.ftp_list_only?"NLST":"LIST"),
+ lstArg? " ": "",
+ lstArg? lstArg: "");
if(!cmd) {
free(lstArg);
{
CURLcode result = CURLE_OK;
struct FTP *ftp = conn->data->req.protop;
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
struct ftp_conn *ftpc = &conn->proto.ftpc;
/* If we have selected NOBODY and HEADER, it means that we only want file
static CURLcode ftp_state_mdtm(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
struct ftp_conn *ftpc = &conn->proto.ftpc;
/* Requested time of file or time-depended transfer? */
{
CURLcode result = CURLE_OK;
struct FTP *ftp = conn->data->req.protop;
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
struct ftp_conn *ftpc = &conn->proto.ftpc;
int seekerr = CURL_SEEKFUNC_OK;
/* 4. lower the infilesize counter */
/* => transfer as usual */
- if(data->state.resume_from < 0 ) {
+ if(data->state.resume_from < 0) {
/* Got no given size to start from, figure it out */
PPSENDF(&ftpc->pp, "SIZE %s", ftpc->file);
state(conn, FTP_STOR_SIZE);
ftpstate instate)
{
CURLcode result = CURLE_OK;
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
struct FTP *ftp = data->req.protop;
struct ftp_conn *ftpc = &conn->proto.ftpc;
bool quote=FALSE;
bool *magicdone)
{
CURLcode result = CURLE_OK;
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
#if defined(CURL_DISABLE_PROXY)
(void) newhost;
{
struct ftp_conn *ftpc = &conn->proto.ftpc;
CURLcode result;
- struct SessionHandle *data=conn->data;
+ struct Curl_easy *data=conn->data;
struct Curl_dns_entry *addr=NULL;
int rc;
unsigned short connectport; /* the local port connect() should use! */
static CURLcode ftp_state_port_resp(struct connectdata *conn,
int ftpcode)
{
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
struct ftp_conn *ftpc = &conn->proto.ftpc;
ftpport fcmd = (ftpport)ftpc->count1;
CURLcode result = CURLE_OK;
int ftpcode)
{
CURLcode result = CURLE_OK;
- struct SessionHandle *data=conn->data;
+ struct Curl_easy *data=conn->data;
struct FTP *ftp = data->req.protop;
struct ftp_conn *ftpc = &conn->proto.ftpc;
ftpstate instate)
{
CURLcode result = CURLE_OK;
- struct SessionHandle *data=conn->data;
+ struct Curl_easy *data=conn->data;
if(ftpcode/100 != 2) {
/* "sasserftpd" and "(u)r(x)bot ftpd" both responds with 226 after a
curl_off_t filesize)
{
CURLcode result = CURLE_OK;
- struct SessionHandle *data=conn->data;
+ struct Curl_easy *data=conn->data;
struct FTP *ftp = data->req.protop;
struct ftp_conn *ftpc = &conn->proto.ftpc;
ftpstate instate)
{
CURLcode result = CURLE_OK;
- struct SessionHandle *data=conn->data;
+ struct Curl_easy *data=conn->data;
curl_off_t filesize;
char *buf = data->state.buffer;
int ftpcode, ftpstate instate)
{
CURLcode result = CURLE_OK;
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
if(ftpcode>=400) {
failf(data, "Failed FTP upload: %0d", ftpcode);
ftpstate instate)
{
CURLcode result = CURLE_OK;
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
struct FTP *ftp = data->req.protop;
char *buf = data->state.buffer;
ftpstate instate)
{
CURLcode result = CURLE_OK;
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
struct FTP *ftp = data->req.protop;
struct ftp_conn *ftpc = &conn->proto.ftpc;
(void)instate; /* no use for this yet */
int ftpcode)
{
CURLcode result = CURLE_OK;
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
if(ftpcode != 230) {
failf(data, "ACCT rejected by server: %03d", ftpcode);
result = CURLE_FTP_WEIRD_PASS_REPLY; /* FIX */
{
CURLcode result;
curl_socket_t sock = conn->sock[FIRSTSOCKET];
- struct SessionHandle *data=conn->data;
+ struct Curl_easy *data=conn->data;
int ftpcode;
struct ftp_conn *ftpc = &conn->proto.ftpc;
struct pingpong *pp = &ftpc->pp;
* Input argument is already checked for validity.
*/
static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
- bool premature)
+ bool premature)
{
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
struct FTP *ftp = data->req.protop;
struct ftp_conn *ftpc = &conn->proto.ftpc;
struct pingpong *pp = &ftpc->pp;
ssize_t nread;
int ftpcode;
CURLcode result = CURLE_OK;
- bool was_ctl_valid = ftpc->ctl_valid;
char *path;
const char *path_to_use = data->state.path;
if(!ftp)
- /* When the easy handle is removed from the multi while libcurl is still
- * trying to resolve the host name, it seems that the ftp struct is not
- * yet initialized, but the removal action calls Curl_done() which calls
- * this function. So we simply return success if no ftp pointer is set.
- */
return CURLE_OK;
switch(status) {
/* the connection stays alive fine even though this happened */
/* fall-through */
case CURLE_OK: /* doesn't affect the control connection's status */
- if(!premature) {
- ftpc->ctl_valid = was_ctl_valid;
+ if(!premature)
break;
- }
+
/* until we cope better with prematurely ended requests, let them
* fallback as if in complete failure */
default: /* by default, an error means the control connection is
curl_off_t from, to;
char *ptr;
char *ptr2;
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
struct ftp_conn *ftpc = &conn->proto.ftpc;
if(data->state.use_range && data->state.range) {
static CURLcode ftp_do_more(struct connectdata *conn, int *completep)
{
- struct SessionHandle *data=conn->data;
+ struct Curl_easy *data=conn->data;
struct ftp_conn *ftpc = &conn->proto.ftpc;
CURLcode result = CURLE_OK;
bool connected = FALSE;
(void)ftp_quit(conn); /* ignore errors on the QUIT */
if(ftpc->entrypath) {
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
if(data->state.most_recent_ftp_entrypath == ftpc->entrypath) {
data->state.most_recent_ftp_entrypath = NULL;
}
static
CURLcode ftp_parse_url_path(struct connectdata *conn)
{
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
/* the ftp struct is already inited in ftp_connect() */
struct FTP *ftp = data->req.protop;
struct ftp_conn *ftpc = &conn->proto.ftpc;
{
CURLcode result=CURLE_OK;
bool connected=FALSE;
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
struct ftp_conn *ftpc = &conn->proto.ftpc;
data->req.size = -1; /* make sure this is unknown at this point */
static CURLcode ftp_setup_connection(struct connectdata *conn)
{
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
char *type;
char command;
struct FTP *ftp;