ftp.h
Go to the documentation of this file.
1 #ifndef HEADER_CURL_FTP_H
2 #define HEADER_CURL_FTP_H
3 /***************************************************************************
4  * _ _ ____ _
5  * Project ___| | | | _ \| |
6  * / __| | | | |_) | |
7  * | (__| |_| | _ <| |___
8  * \___|\___/|_| \_\_____|
9  *
10  * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
11  *
12  * This software is licensed as described in the file COPYING, which
13  * you should have received as part of this distribution. The terms
14  * are also available at https://curl.haxx.se/docs/copyright.html.
15  *
16  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17  * copies of the Software, and permit persons to whom the Software is
18  * furnished to do so, under the terms of the COPYING file.
19  *
20  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21  * KIND, either express or implied.
22  *
23  ***************************************************************************/
24 
25 #include "pingpong.h"
26 
27 #ifndef CURL_DISABLE_FTP
28 extern const struct Curl_handler Curl_handler_ftp;
29 
30 #ifdef USE_SSL
31 extern const struct Curl_handler Curl_handler_ftps;
32 #endif
33 
34 CURLcode Curl_ftpsend(struct connectdata *, const char *cmd);
35 CURLcode Curl_GetFTPResponse(ssize_t *nread, struct connectdata *conn,
36  int *ftpcode);
37 #endif /* CURL_DISABLE_FTP */
38 
39 /****************************************************************************
40  * FTP unique setup
41  ***************************************************************************/
42 typedef enum {
43  FTP_STOP, /* do nothing state, stops the state machine */
44  FTP_WAIT220, /* waiting for the initial 220 response immediately after
45  a connect */
56  FTP_QUOTE, /* waiting for a response to a command sent in a quote list */
60  FTP_CWD, /* change dir */
61  FTP_MKD, /* if the dir didn't exist */
62  FTP_MDTM, /* to figure out the datestamp */
63  FTP_TYPE, /* to set type when doing a head-like request */
64  FTP_LIST_TYPE, /* set type when about to do a dir list */
65  FTP_RETR_TYPE, /* set type when about to RETR a file */
66  FTP_STOR_TYPE, /* set type when about to STOR a file */
67  FTP_SIZE, /* get the remote file's size for head-like request */
68  FTP_RETR_SIZE, /* get the remote file's size for RETR */
69  FTP_STOR_SIZE, /* get the size for STOR */
70  FTP_REST, /* when used to check if the server supports it in head-like */
71  FTP_RETR_REST, /* when asking for "resume" in for RETR */
72  FTP_PORT, /* generic state for PORT, LPRT and EPRT, check count1 */
73  FTP_PRET, /* generic state for PRET RETR, PRET STOR and PRET LIST/NLST */
74  FTP_PASV, /* generic state for PASV and EPSV, check count1 */
75  FTP_LIST, /* generic state for LIST, NLST or a custom list command */
77  FTP_STOR, /* generic state for STOR and APPE */
79  FTP_LAST /* never used */
80 } ftpstate;
81 
82 struct ftp_parselist_data; /* defined later in ftplistparser.c */
83 
86 
87  struct {
90  } backup;
91 };
92 
93 typedef enum {
94  FTPFILE_MULTICWD = 1, /* as defined by RFC1738 */
95  FTPFILE_NOCWD = 2, /* use SIZE / RETR / STOR on the full path */
96  FTPFILE_SINGLECWD = 3 /* make one CWD, then SIZE / RETR / STOR on the
97  file */
98 } curl_ftpfile;
99 
100 /* This FTP struct is used in the Curl_easy. All FTP data that is
101  connection-oriented must be in FTP_conn to properly deal with the fact that
102  perhaps the Curl_easy is changed between the times the connection is
103  used. */
104 struct FTP {
106  char *user; /* user name string */
107  char *passwd; /* password string */
108 
109  /* transfer a file/body or not, done as a typedefed enum just to make
110  debuggers display the full symbol and not just the numerical value */
113 };
114 
115 
116 /* ftp_conn is used for struct connection-oriented data in the connectdata
117  struct */
118 struct ftp_conn {
119  struct pingpong pp;
120  char *entrypath; /* the PWD reply when we logged on */
121  char **dirs; /* realloc()ed array for path components */
122  int dirdepth; /* number of entries used in the 'dirs' array */
123  int diralloc; /* number of entries allocated for the 'dirs' array */
124  char *file; /* decoded file */
125  bool dont_check; /* Set to TRUE to prevent the final (post-transfer)
126  file size and 226/250 status check. It should still
127  read the line, just ignore the result. */
128  bool ctl_valid; /* Tells Curl_ftp_quit() whether or not to do anything. If
129  the connection has timed out or been closed, this
130  should be FALSE when it gets to Curl_ftp_quit() */
131  bool cwddone; /* if it has been determined that the proper CWD combo
132  already has been done */
133  int cwdcount; /* number of CWD commands issued */
134  bool cwdfail; /* set TRUE if a CWD command fails, as then we must prevent
135  caching the current directory */
136  bool wait_data_conn; /* this is set TRUE if data connection is waited */
137  char *prevpath; /* conn->path from the previous transfer */
138  curl_ftpfile prevmethod; /* ftp method in previous transfer */
139  char transfertype; /* set by ftp_transfertype for use by Curl_client_write()a
140  and others (A/I or zero) */
141  int count1; /* general purpose counter for the state machine */
142  int count2; /* general purpose counter for the state machine */
143  int count3; /* general purpose counter for the state machine */
144  ftpstate state; /* always use ftp.c:state() to change state! */
145  ftpstate state_saved; /* transfer type saved to be reloaded after
146  data connection is established */
147  curl_off_t retr_size_saved; /* Size of retrieved file saved */
148  char *server_os; /* The target server operating system. */
149  curl_off_t known_filesize; /* file size is different from -1, if wildcard
150  LIST parsing was done and wc_statemach set
151  it */
152  /* newhost is the (allocated) IP addr or host name to connect the data
153  connection to */
154  char *newhost; /* this is the pair to connect the DATA... */
155  unsigned short newport; /* connection to */
156 
157 };
158 
159 #define DEFAULT_ACCEPT_TIMEOUT 60000 /* milliseconds == one minute */
160 
161 #endif /* HEADER_CURL_FTP_H */
curl_ftpfile
Definition: ftp.h:93
struct ftp_parselist_data * parser
Definition: ftp.h:85
char * passwd
Definition: ftp.h:107
ftpstate state_saved
Definition: ftp.h:145
Definition: ftp.h:77
bool cwdfail
Definition: ftp.h:134
Definition: ftp.h:75
curl_pp_transfer transfer
Definition: ftp.h:111
CURLcode Curl_GetFTPResponse(ssize_t *nread, struct connectdata *conn, int *ftpcode)
Definition: ftp.c:624
FILE * file_descriptor
Definition: ftp.h:89
CURLcode Curl_ftpsend(struct connectdata *, const char *cmd)
Definition: ftp.c:3989
Definition: ftp.h:104
curl_ftpfile prevmethod
Definition: ftp.h:138
int diralloc
Definition: ftp.h:123
Definition: ftp.h:60
unsigned short newport
Definition: ftp.h:155
CURLcode
Definition: curl.h:454
char transfertype
Definition: ftp.h:139
char ** dirs
Definition: ftp.h:121
char * prevpath
Definition: ftp.h:137
bool wait_data_conn
Definition: ftp.h:136
Definition: ftp.h:53
Definition: ftp.h:46
Definition: ftp.h:48
char * server_os
Definition: ftp.h:148
char * newhost
Definition: ftp.h:154
Definition: ftp.h:79
curl_off_t retr_size_saved
Definition: ftp.h:147
curl_off_t known_filesize
Definition: ftp.h:149
Definition: ftp.h:70
curl_off_t * bytecountp
Definition: ftp.h:105
int count3
Definition: ftp.h:143
bool cwddone
Definition: ftp.h:131
bool ctl_valid
Definition: ftp.h:128
Definition: ftp.h:72
Definition: ftp.h:63
int dirdepth
Definition: ftp.h:122
int count1
Definition: ftp.h:141
curl_write_callback write_function
Definition: ftp.h:88
Definition: ftp.h:62
CURL_TYPEOF_CURL_OFF_T curl_off_t
Definition: system.h:420
ftpstate
Definition: ftp.h:42
Definition: ftp.h:49
Definition: ftp.h:73
Definition: ftp.h:50
Definition: ftp.h:43
size_t(* curl_write_callback)(char *buffer, size_t size, size_t nitems, void *outstream)
Definition: curl.h:243
Definition: ftp.h:78
#define ssize_t
Definition: config-win32.h:382
Definition: ftp.h:74
Definition: ftp.h:76
curl_off_t downloadsize
Definition: ftp.h:112
Definition: ftp.h:54
char * user
Definition: ftp.h:106
struct ftp_wc_tmpdata::@10 backup
Definition: ftp.h:61
ftpstate state
Definition: ftp.h:144
bool dont_check
Definition: ftp.h:125
int cwdcount
Definition: ftp.h:133
int count2
Definition: ftp.h:142
Definition: ftp.h:56
Definition: ftp.h:118
char * entrypath
Definition: ftp.h:120
Definition: ftp.h:47
Definition: ftp.h:52
Definition: ftp.h:67
const struct Curl_handler Curl_handler_ftp
Definition: ftp.c:166
curl_pp_transfer
Definition: pingpong.h:35
char * file
Definition: ftp.h:124
Definition: ftp.h:51


rc_tagdetect_client
Author(s): Monika Florek-Jasinska , Raphael Schaller
autogenerated on Sat Feb 13 2021 03:42:09