Macros | Enumerations | Functions | Variables
ftp.c File Reference
#include "curl_setup.h"
#include <curl/curl.h>
#include "urldata.h"
#include "sendf.h"
#include "if2ip.h"
#include "hostip.h"
#include "progress.h"
#include "transfer.h"
#include "escape.h"
#include "http.h"
#include "socks.h"
#include "ftp.h"
#include "fileinfo.h"
#include "ftplistparser.h"
#include "curl_sec.h"
#include "strtoofft.h"
#include "strcase.h"
#include "vtls/vtls.h"
#include "connect.h"
#include "strerror.h"
#include "inet_ntop.h"
#include "inet_pton.h"
#include "select.h"
#include "parsedate.h"
#include "sockaddr.h"
#include "multiif.h"
#include "url.h"
#include "speedcheck.h"
#include "warnless.h"
#include "http_proxy.h"
#include "non-ascii.h"
#include "curl_printf.h"
#include "curl_memory.h"
#include "memdebug.h"
Include dependency graph for ftp.c:

Go to the source code of this file.

Macros

#define CURL_FTP_HTTPSTYLE_HEAD   1
 
#define INET_ADDRSTRLEN   16
 
#define LASTLINE(line)   (STATUSCODE(line) && (' ' == line[3]))
 
#define NI_MAXHOST   1025
 
#define PPSENDF(x, y, z)
 
#define SBUF_SIZE   1024
 
#define state(x, y)   _state(x,y)
 
#define STATUSCODE(line)
 

Enumerations

enum  ftpport { EPRT, PORT, DONE }
 

Functions

static void _state (struct connectdata *conn, ftpstate newstate)
 
static CURLcode AcceptServerConnect (struct connectdata *conn)
 
static CURLcode AllowServerConnect (struct connectdata *conn, bool *connected)
 
static void close_secondarysocket (struct connectdata *conn)
 
static char * control_address (struct connectdata *conn)
 
CURLcode Curl_ftpsend (struct connectdata *conn, const char *cmd)
 
CURLcode Curl_GetFTPResponse (ssize_t *nreadp, struct connectdata *conn, int *ftpcode)
 
static void freedirs (struct ftp_conn *ftpc)
 
static CURLcode ftp_block_statemach (struct connectdata *conn)
 
static CURLcode ftp_connect (struct connectdata *conn, bool *done)
 
static CURLcode ftp_disconnect (struct connectdata *conn, bool dead_connection)
 
static CURLcode ftp_do (struct connectdata *conn, bool *done)
 
static CURLcode ftp_do_more (struct connectdata *conn, int *completed)
 
static CURLcode ftp_doing (struct connectdata *conn, bool *dophase_done)
 
static int ftp_domore_getsock (struct connectdata *conn, curl_socket_t *socks, int numsocks)
 
static CURLcode ftp_done (struct connectdata *conn, CURLcode, bool premature)
 
static CURLcode ftp_dophase_done (struct connectdata *conn, bool connected)
 
static bool ftp_endofresp (struct connectdata *conn, char *line, size_t len, int *code)
 
static CURLcode ftp_epsv_disable (struct connectdata *conn)
 
static int ftp_getsock (struct connectdata *conn, curl_socket_t *socks, int numsocks)
 
static CURLcode ftp_multi_statemach (struct connectdata *conn, bool *done)
 
static CURLcode ftp_nb_type (struct connectdata *conn, bool ascii, ftpstate newstate)
 
static int ftp_need_type (struct connectdata *conn, bool ascii)
 
static CURLcode ftp_parse_url_path (struct connectdata *conn)
 
static void ftp_pasv_verbose (struct connectdata *conn, Curl_addrinfo *ai, char *newhost, int port)
 
static CURLcode ftp_perform (struct connectdata *conn, bool *connected, bool *dophase_done)
 
static CURLcode ftp_quit (struct connectdata *conn)
 
static CURLcode ftp_range (struct connectdata *conn)
 
static CURLcode ftp_readresp (curl_socket_t sockfd, struct pingpong *pp, int *ftpcode, size_t *size)
 
static CURLcode ftp_regular_transfer (struct connectdata *conn, bool *done)
 
static CURLcode ftp_sendquote (struct connectdata *conn, struct curl_slist *quote)
 
static CURLcode ftp_setup_connection (struct connectdata *conn)
 
static CURLcode ftp_state_acct_resp (struct connectdata *conn, int ftpcode)
 
static CURLcode ftp_state_cwd (struct connectdata *conn)
 
static CURLcode ftp_state_get_resp (struct connectdata *conn, int ftpcode, ftpstate instate)
 
static CURLcode ftp_state_list (struct connectdata *conn)
 
static CURLcode ftp_state_loggedin (struct connectdata *conn)
 
static CURLcode ftp_state_mdtm (struct connectdata *conn)
 
static CURLcode ftp_state_mdtm_resp (struct connectdata *conn, int ftpcode)
 
static CURLcode ftp_state_pasv_resp (struct connectdata *conn, int ftpcode)
 
static CURLcode ftp_state_port_resp (struct connectdata *conn, int ftpcode)
 
static CURLcode ftp_state_prepare_transfer (struct connectdata *conn)
 
static CURLcode ftp_state_pwd (struct connectdata *conn)
 
static CURLcode ftp_state_quote (struct connectdata *conn, bool init, ftpstate instate)
 
static CURLcode ftp_state_rest (struct connectdata *conn)
 
static CURLcode ftp_state_rest_resp (struct connectdata *conn, int ftpcode, ftpstate instate)
 
static CURLcode ftp_state_retr (struct connectdata *conn, curl_off_t filesize)
 
static CURLcode ftp_state_retr_prequote (struct connectdata *conn)
 
static CURLcode ftp_state_size (struct connectdata *conn)
 
static CURLcode ftp_state_size_resp (struct connectdata *conn, int ftpcode, ftpstate instate)
 
static CURLcode ftp_state_stor_prequote (struct connectdata *conn)
 
static CURLcode ftp_state_stor_resp (struct connectdata *conn, int ftpcode, ftpstate instate)
 
static CURLcode ftp_state_type (struct connectdata *conn)
 
static CURLcode ftp_state_type_resp (struct connectdata *conn, int ftpcode, ftpstate instate)
 
static CURLcode ftp_state_ul_setup (struct connectdata *conn, bool sizechecked)
 
static CURLcode ftp_state_use_pasv (struct connectdata *conn)
 
static CURLcode ftp_state_use_port (struct connectdata *conn, ftpport fcmd)
 
static CURLcode ftp_state_user (struct connectdata *conn)
 
static CURLcode ftp_state_user_resp (struct connectdata *conn, int ftpcode, ftpstate instate)
 
static CURLcode ftp_statemach_act (struct connectdata *conn)
 
static time_t ftp_timeleft_accept (struct Curl_easy *data)
 
static CURLcode init_wc_data (struct connectdata *conn)
 
static CURLcode InitiateTransfer (struct connectdata *conn)
 
static bool isBadFtpString (const char *string)
 
static CURLcode ReceivedServerConnect (struct connectdata *conn, bool *received)
 
static void wc_data_dtor (void *ptr)
 
static CURLcode wc_statemach (struct connectdata *conn)
 

Variables

const struct Curl_handler Curl_handler_ftp
 

Macro Definition Documentation

◆ CURL_FTP_HTTPSTYLE_HEAD

#define CURL_FTP_HTTPSTYLE_HEAD   1

Definition at line 236 of file ftp.c.

◆ INET_ADDRSTRLEN

#define INET_ADDRSTRLEN   16

Definition at line 89 of file ftp.c.

◆ LASTLINE

#define LASTLINE (   line)    (STATUSCODE(line) && (' ' == line[3]))

Definition at line 545 of file ftp.c.

◆ NI_MAXHOST

#define NI_MAXHOST   1025

Definition at line 86 of file ftp.c.

◆ PPSENDF

#define PPSENDF (   x,
  y,
 
)
Value:
result = Curl_pp_sendf(x,y,z); \
if(result) \
return result

Definition at line 157 of file ftp.c.

◆ SBUF_SIZE

#define SBUF_SIZE   1024

◆ state

#define state (   x,
 
)    _state(x,y)

Definition at line 100 of file ftp.c.

◆ STATUSCODE

#define STATUSCODE (   line)
Value:
(ISDIGIT(line[0]) && ISDIGIT(line[1]) && \
ISDIGIT(line[2]))

Definition at line 541 of file ftp.c.

Enumeration Type Documentation

◆ ftpport

enum ftpport
Enumerator
EPRT 
PORT 
DONE 

Definition at line 919 of file ftp.c.

Function Documentation

◆ _state()

static void _state ( struct connectdata conn,
ftpstate  newstate 
)
static

Definition at line 769 of file ftp.c.

◆ AcceptServerConnect()

static CURLcode AcceptServerConnect ( struct connectdata conn)
static

Definition at line 276 of file ftp.c.

◆ AllowServerConnect()

static CURLcode AllowServerConnect ( struct connectdata conn,
bool connected 
)
static

Definition at line 495 of file ftp.c.

◆ close_secondarysocket()

static void close_secondarysocket ( struct connectdata conn)
static

Definition at line 217 of file ftp.c.

◆ control_address()

static char* control_address ( struct connectdata conn)
static

Definition at line 1807 of file ftp.c.

◆ Curl_ftpsend()

CURLcode Curl_ftpsend ( struct connectdata conn,
const char *  cmd 
)

Definition at line 3989 of file ftp.c.

◆ Curl_GetFTPResponse()

CURLcode Curl_GetFTPResponse ( ssize_t nreadp,
struct connectdata conn,
int *  ftpcode 
)

Definition at line 624 of file ftp.c.

◆ freedirs()

static void freedirs ( struct ftp_conn ftpc)
static

Definition at line 238 of file ftp.c.

◆ ftp_block_statemach()

static CURLcode ftp_block_statemach ( struct connectdata conn)
static

Definition at line 3063 of file ftp.c.

◆ ftp_connect()

static CURLcode ftp_connect ( struct connectdata conn,
bool done 
)
static

Definition at line 3086 of file ftp.c.

◆ ftp_disconnect()

static CURLcode ftp_disconnect ( struct connectdata conn,
bool  dead_connection 
)
static

Definition at line 4083 of file ftp.c.

◆ ftp_do()

static CURLcode ftp_do ( struct connectdata conn,
bool done 
)
static

Definition at line 3959 of file ftp.c.

◆ ftp_do_more()

static CURLcode ftp_do_more ( struct connectdata conn,
int *  completed 
)
static

Definition at line 3533 of file ftp.c.

◆ ftp_doing()

static CURLcode ftp_doing ( struct connectdata conn,
bool dophase_done 
)
static

Definition at line 4352 of file ftp.c.

◆ ftp_domore_getsock()

static int ftp_domore_getsock ( struct connectdata conn,
curl_socket_t socks,
int  numsocks 
)
static

Definition at line 826 of file ftp.c.

◆ ftp_done()

static CURLcode ftp_done ( struct connectdata conn,
CURLcode  status,
bool  premature 
)
static

Definition at line 3130 of file ftp.c.

◆ ftp_dophase_done()

static CURLcode ftp_dophase_done ( struct connectdata conn,
bool  connected 
)
static

Definition at line 4323 of file ftp.c.

◆ ftp_endofresp()

static bool ftp_endofresp ( struct connectdata conn,
char *  line,
size_t  len,
int *  code 
)
static

Definition at line 547 of file ftp.c.

◆ ftp_epsv_disable()

static CURLcode ftp_epsv_disable ( struct connectdata conn)
static

Definition at line 1784 of file ftp.c.

◆ ftp_getsock()

static int ftp_getsock ( struct connectdata conn,
curl_socket_t socks,
int  numsocks 
)
static

Definition at line 818 of file ftp.c.

◆ ftp_multi_statemach()

static CURLcode ftp_multi_statemach ( struct connectdata conn,
bool done 
)
static

Definition at line 3049 of file ftp.c.

◆ ftp_nb_type()

static CURLcode ftp_nb_type ( struct connectdata conn,
bool  ascii,
ftpstate  newstate 
)
static

Definition at line 3424 of file ftp.c.

◆ ftp_need_type()

static int ftp_need_type ( struct connectdata conn,
bool  ascii 
)
static

Definition at line 3410 of file ftp.c.

◆ ftp_parse_url_path()

static CURLcode ftp_parse_url_path ( struct connectdata conn)
static

Definition at line 4133 of file ftp.c.

◆ ftp_pasv_verbose()

static void ftp_pasv_verbose ( struct connectdata conn,
Curl_addrinfo ai,
char *  newhost,
int  port 
)
static

Definition at line 3455 of file ftp.c.

◆ ftp_perform()

static CURLcode ftp_perform ( struct connectdata conn,
bool connected,
bool dophase_done 
)
static

Definition at line 3697 of file ftp.c.

◆ ftp_quit()

static CURLcode ftp_quit ( struct connectdata conn)
static

Definition at line 4053 of file ftp.c.

◆ ftp_range()

static CURLcode ftp_range ( struct connectdata conn)
static

Definition at line 3471 of file ftp.c.

◆ ftp_readresp()

static CURLcode ftp_readresp ( curl_socket_t  sockfd,
struct pingpong pp,
int *  ftpcode,
size_t size 
)
static

Definition at line 560 of file ftp.c.

◆ ftp_regular_transfer()

static CURLcode ftp_regular_transfer ( struct connectdata conn,
bool done 
)
static

Definition at line 4380 of file ftp.c.

◆ ftp_sendquote()

static CURLcode ftp_sendquote ( struct connectdata conn,
struct curl_slist quote 
)
static

Definition at line 3359 of file ftp.c.

◆ ftp_setup_connection()

static CURLcode ftp_setup_connection ( struct connectdata conn)
static

Definition at line 4417 of file ftp.c.

◆ ftp_state_acct_resp()

static CURLcode ftp_state_acct_resp ( struct connectdata conn,
int  ftpcode 
)
static

Definition at line 2583 of file ftp.c.

◆ ftp_state_cwd()

static CURLcode ftp_state_cwd ( struct connectdata conn)
static

Definition at line 874 of file ftp.c.

◆ ftp_state_get_resp()

static CURLcode ftp_state_get_resp ( struct connectdata conn,
int  ftpcode,
ftpstate  instate 
)
static

Definition at line 2370 of file ftp.c.

◆ ftp_state_list()

static CURLcode ftp_state_list ( struct connectdata conn)
static

Definition at line 1440 of file ftp.c.

◆ ftp_state_loggedin()

static CURLcode ftp_state_loggedin ( struct connectdata conn)
static

Definition at line 2498 of file ftp.c.

◆ ftp_state_mdtm()

static CURLcode ftp_state_mdtm ( struct connectdata conn)
static

Definition at line 1561 of file ftp.c.

◆ ftp_state_mdtm_resp()

static CURLcode ftp_state_mdtm_resp ( struct connectdata conn,
int  ftpcode 
)
static

Definition at line 2040 of file ftp.c.

◆ ftp_state_pasv_resp()

static CURLcode ftp_state_pasv_resp ( struct connectdata conn,
int  ftpcode 
)
static

Definition at line 1819 of file ftp.c.

◆ ftp_state_port_resp()

static CURLcode ftp_state_port_resp ( struct connectdata conn,
int  ftpcode 
)
static

Definition at line 2004 of file ftp.c.

◆ ftp_state_prepare_transfer()

static CURLcode ftp_state_prepare_transfer ( struct connectdata conn)
static

Definition at line 1356 of file ftp.c.

◆ ftp_state_pwd()

static CURLcode ftp_state_pwd ( struct connectdata conn)
static

Definition at line 806 of file ftp.c.

◆ ftp_state_quote()

static CURLcode ftp_state_quote ( struct connectdata conn,
bool  init,
ftpstate  instate 
)
static

Definition at line 1679 of file ftp.c.

◆ ftp_state_rest()

static CURLcode ftp_state_rest ( struct connectdata conn)
static

Definition at line 1399 of file ftp.c.

◆ ftp_state_rest_resp()

static CURLcode ftp_state_rest_resp ( struct connectdata conn,
int  ftpcode,
ftpstate  instate 
)
static

Definition at line 2297 of file ftp.c.

◆ ftp_state_retr()

static CURLcode ftp_state_retr ( struct connectdata conn,
curl_off_t  filesize 
)
static

Definition at line 2175 of file ftp.c.

◆ ftp_state_retr_prequote()

static CURLcode ftp_state_retr_prequote ( struct connectdata conn)
static

Definition at line 1506 of file ftp.c.

◆ ftp_state_size()

static CURLcode ftp_state_size ( struct connectdata conn)
static

Definition at line 1420 of file ftp.c.

◆ ftp_state_size_resp()

static CURLcode ftp_state_size_resp ( struct connectdata conn,
int  ftpcode,
ftpstate  instate 
)
static

Definition at line 2257 of file ftp.c.

◆ ftp_state_stor_prequote()

static CURLcode ftp_state_stor_prequote ( struct connectdata conn)
static

Definition at line 1517 of file ftp.c.

◆ ftp_state_stor_resp()

static CURLcode ftp_state_stor_resp ( struct connectdata conn,
int  ftpcode,
ftpstate  instate 
)
static

Definition at line 2333 of file ftp.c.

◆ ftp_state_type()

static CURLcode ftp_state_type ( struct connectdata conn)
static

Definition at line 1528 of file ftp.c.

◆ ftp_state_type_resp()

static CURLcode ftp_state_type_resp ( struct connectdata conn,
int  ftpcode,
ftpstate  instate 
)
static

Definition at line 2145 of file ftp.c.

◆ ftp_state_ul_setup()

static CURLcode ftp_state_ul_setup ( struct connectdata conn,
bool  sizechecked 
)
static

Definition at line 1584 of file ftp.c.

◆ ftp_state_use_pasv()

static CURLcode ftp_state_use_pasv ( struct connectdata conn)
static

Definition at line 1310 of file ftp.c.

◆ ftp_state_use_port()

static CURLcode ftp_state_use_port ( struct connectdata conn,
ftpport  fcmd 
)
static

Definition at line 925 of file ftp.c.

◆ ftp_state_user()

static CURLcode ftp_state_user ( struct connectdata conn)
static

Definition at line 793 of file ftp.c.

◆ ftp_state_user_resp()

static CURLcode ftp_state_user_resp ( struct connectdata conn,
int  ftpcode,
ftpstate  instate 
)
static

Definition at line 2527 of file ftp.c.

◆ ftp_statemach_act()

static CURLcode ftp_statemach_act ( struct connectdata conn)
static

Definition at line 2599 of file ftp.c.

◆ ftp_timeleft_accept()

static time_t ftp_timeleft_accept ( struct Curl_easy data)
static

Definition at line 335 of file ftp.c.

◆ init_wc_data()

static CURLcode init_wc_data ( struct connectdata conn)
static

Definition at line 3740 of file ftp.c.

◆ InitiateTransfer()

static CURLcode InitiateTransfer ( struct connectdata conn)
static

Definition at line 444 of file ftp.c.

◆ isBadFtpString()

static bool isBadFtpString ( const char *  string)
static

Definition at line 262 of file ftp.c.

◆ ReceivedServerConnect()

static CURLcode ReceivedServerConnect ( struct connectdata conn,
bool received 
)
static

Definition at line 373 of file ftp.c.

◆ wc_data_dtor()

static void wc_data_dtor ( void *  ptr)
static

Definition at line 3732 of file ftp.c.

◆ wc_statemach()

static CURLcode wc_statemach ( struct connectdata conn)
static

Definition at line 3833 of file ftp.c.

Variable Documentation

◆ Curl_handler_ftp

const struct Curl_handler Curl_handler_ftp
ftp_domore_getsock
static int ftp_domore_getsock(struct connectdata *conn, curl_socket_t *socks, int numsocks)
Definition: ftp.c:826
ftp_doing
static CURLcode ftp_doing(struct connectdata *conn, bool *dophase_done)
Definition: ftp.c:4352
ISDIGIT
#define ISDIGIT(x)
Definition: curl_setup_once.h:283
Curl_pp_sendf
CURLcode Curl_pp_sendf(struct pingpong *pp, const char *fmt,...)
Definition: pingpong.c:248
ZERO_NULL
#define ZERO_NULL
Definition: curlx.c:131
ftp_do
static CURLcode ftp_do(struct connectdata *conn, bool *done)
Definition: ftp.c:3959
ftp_done
static CURLcode ftp_done(struct connectdata *conn, CURLcode, bool premature)
Definition: ftp.c:3130
ftp_disconnect
static CURLcode ftp_disconnect(struct connectdata *conn, bool dead_connection)
Definition: ftp.c:4083
ftp_connect
static CURLcode ftp_connect(struct connectdata *conn, bool *done)
Definition: ftp.c:3086
ftp_multi_statemach
static CURLcode ftp_multi_statemach(struct connectdata *conn, bool *done)
Definition: ftp.c:3049
ftp_setup_connection
static CURLcode ftp_setup_connection(struct connectdata *conn)
Definition: ftp.c:4417
ftp_getsock
static int ftp_getsock(struct connectdata *conn, curl_socket_t *socks, int numsocks)
Definition: ftp.c:818
PROTOPT_PROXY_AS_HTTP
#define PROTOPT_PROXY_AS_HTTP
Definition: urldata.h:713
ftp_do_more
static CURLcode ftp_do_more(struct connectdata *conn, int *completed)
Definition: ftp.c:3533
PROTOPT_DUAL
#define PROTOPT_DUAL
Definition: urldata.h:699
PROTOPT_NEEDSPWD
#define PROTOPT_NEEDSPWD
Definition: urldata.h:707
result
UNITTEST_START int result
Definition: unit1304.c:49
PROTOPT_CLOSEACTION
#define PROTOPT_CLOSEACTION
Definition: urldata.h:700
PORT_FTP
#define PORT_FTP
Definition: urldata.h:29
PROTOPT_NOURLQUERY
#define PROTOPT_NOURLQUERY
Definition: urldata.h:708
CURLPROTO_FTP
#define CURLPROTO_FTP
Definition: curl.h:844


rc_tagdetect_client
Author(s): Monika Florek-Jasinska , Raphael Schaller
autogenerated on Sun May 15 2022 02:25:01