SessionHandle: the protocol specific pointer is now a void *
All protocol handler structs are now opaque (void *) in the SessionHandle struct and moved in the request-specific sub-struct 'SingleRequest'. The intension is to keep the protocol specific knowledge in their own dedicated source files [protocol].c etc. There's some "leakage" where this policy is violated, to be addressed at a later point in time.
This commit is contained in:
42
lib/ftp.c
42
lib/ftp.c
@@ -493,7 +493,7 @@ static CURLcode ReceivedServerConnect(struct connectdata *conn, bool *received)
|
||||
static CURLcode InitiateTransfer(struct connectdata *conn)
|
||||
{
|
||||
struct SessionHandle *data = conn->data;
|
||||
struct FTP *ftp = data->state.proto.ftp;
|
||||
struct FTP *ftp = data->req.protop;
|
||||
CURLcode result = CURLE_OK;
|
||||
|
||||
if(conn->ssl[SECONDARYSOCKET].use) {
|
||||
@@ -835,7 +835,7 @@ static void _state(struct connectdata *conn,
|
||||
static CURLcode ftp_state_user(struct connectdata *conn)
|
||||
{
|
||||
CURLcode result;
|
||||
struct FTP *ftp = conn->data->state.proto.ftp;
|
||||
struct FTP *ftp = conn->data->req.protop;
|
||||
/* send USER */
|
||||
PPSENDF(&conn->proto.ftpc.pp, "USER %s", ftp->user?ftp->user:"");
|
||||
|
||||
@@ -1382,7 +1382,7 @@ static CURLcode ftp_state_use_pasv(struct connectdata *conn)
|
||||
static CURLcode ftp_state_prepare_transfer(struct connectdata *conn)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct FTP *ftp = conn->data->state.proto.ftp;
|
||||
struct FTP *ftp = conn->data->req.protop;
|
||||
struct SessionHandle *data = conn->data;
|
||||
|
||||
if(ftp->transfer != FTPTRANSFER_BODY) {
|
||||
@@ -1425,7 +1425,7 @@ static CURLcode ftp_state_prepare_transfer(struct connectdata *conn)
|
||||
static CURLcode ftp_state_rest(struct connectdata *conn)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct FTP *ftp = conn->data->state.proto.ftp;
|
||||
struct FTP *ftp = conn->data->req.protop;
|
||||
struct ftp_conn *ftpc = &conn->proto.ftpc;
|
||||
|
||||
if((ftp->transfer != FTPTRANSFER_BODY) && ftpc->file) {
|
||||
@@ -1446,7 +1446,7 @@ static CURLcode ftp_state_rest(struct connectdata *conn)
|
||||
static CURLcode ftp_state_size(struct connectdata *conn)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct FTP *ftp = conn->data->state.proto.ftp;
|
||||
struct FTP *ftp = conn->data->req.protop;
|
||||
struct ftp_conn *ftpc = &conn->proto.ftpc;
|
||||
|
||||
if((ftp->transfer == FTPTRANSFER_INFO) && ftpc->file) {
|
||||
@@ -1557,7 +1557,7 @@ static CURLcode ftp_state_stor_prequote(struct connectdata *conn)
|
||||
static CURLcode ftp_state_type(struct connectdata *conn)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct FTP *ftp = conn->data->state.proto.ftp;
|
||||
struct FTP *ftp = conn->data->req.protop;
|
||||
struct SessionHandle *data = conn->data;
|
||||
struct ftp_conn *ftpc = &conn->proto.ftpc;
|
||||
|
||||
@@ -1614,7 +1614,7 @@ static CURLcode ftp_state_ul_setup(struct connectdata *conn,
|
||||
bool sizechecked)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct FTP *ftp = conn->data->state.proto.ftp;
|
||||
struct FTP *ftp = conn->data->req.protop;
|
||||
struct SessionHandle *data = conn->data;
|
||||
struct ftp_conn *ftpc = &conn->proto.ftpc;
|
||||
int seekerr = CURL_SEEKFUNC_OK;
|
||||
@@ -1712,7 +1712,7 @@ static CURLcode ftp_state_quote(struct connectdata *conn,
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct SessionHandle *data = conn->data;
|
||||
struct FTP *ftp = data->state.proto.ftp;
|
||||
struct FTP *ftp = data->req.protop;
|
||||
struct ftp_conn *ftpc = &conn->proto.ftpc;
|
||||
bool quote=FALSE;
|
||||
struct curl_slist *item;
|
||||
@@ -2058,13 +2058,13 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
|
||||
* FTP pointer
|
||||
*/
|
||||
struct HTTP http_proxy;
|
||||
struct FTP *ftp_save = data->state.proto.ftp;
|
||||
struct FTP *ftp_save = data->req.protop;
|
||||
memset(&http_proxy, 0, sizeof(http_proxy));
|
||||
data->state.proto.http = &http_proxy;
|
||||
data->req.protop = &http_proxy;
|
||||
|
||||
result = Curl_proxyCONNECT(conn, SECONDARYSOCKET, newhost, newport);
|
||||
|
||||
data->state.proto.ftp = ftp_save;
|
||||
data->req.protop = ftp_save;
|
||||
|
||||
if(result)
|
||||
return result;
|
||||
@@ -2124,7 +2124,7 @@ static CURLcode ftp_state_mdtm_resp(struct connectdata *conn,
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct SessionHandle *data=conn->data;
|
||||
struct FTP *ftp = data->state.proto.ftp;
|
||||
struct FTP *ftp = data->req.protop;
|
||||
struct ftp_conn *ftpc = &conn->proto.ftpc;
|
||||
|
||||
switch(ftpcode) {
|
||||
@@ -2258,7 +2258,7 @@ static CURLcode ftp_state_retr(struct connectdata *conn,
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct SessionHandle *data=conn->data;
|
||||
struct FTP *ftp = data->state.proto.ftp;
|
||||
struct FTP *ftp = data->req.protop;
|
||||
struct ftp_conn *ftpc = &conn->proto.ftpc;
|
||||
|
||||
if(data->set.max_filesize && (filesize > data->set.max_filesize)) {
|
||||
@@ -2450,7 +2450,7 @@ static CURLcode ftp_state_get_resp(struct connectdata *conn,
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct SessionHandle *data = conn->data;
|
||||
struct FTP *ftp = data->state.proto.ftp;
|
||||
struct FTP *ftp = data->req.protop;
|
||||
char *buf = data->state.buffer;
|
||||
|
||||
if((ftpcode == 150) || (ftpcode == 125)) {
|
||||
@@ -2618,7 +2618,7 @@ static CURLcode ftp_state_user_resp(struct connectdata *conn,
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct SessionHandle *data = conn->data;
|
||||
struct FTP *ftp = data->state.proto.ftp;
|
||||
struct FTP *ftp = data->req.protop;
|
||||
struct ftp_conn *ftpc = &conn->proto.ftpc;
|
||||
(void)instate; /* no use for this yet */
|
||||
|
||||
@@ -3214,7 +3214,7 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
|
||||
bool premature)
|
||||
{
|
||||
struct SessionHandle *data = conn->data;
|
||||
struct FTP *ftp = data->state.proto.ftp;
|
||||
struct FTP *ftp = data->req.protop;
|
||||
struct ftp_conn *ftpc = &conn->proto.ftpc;
|
||||
struct pingpong *pp = &ftpc->pp;
|
||||
ssize_t nread;
|
||||
@@ -3631,7 +3631,7 @@ static CURLcode ftp_do_more(struct connectdata *conn, int *completep)
|
||||
bool complete = FALSE;
|
||||
|
||||
/* the ftp struct is inited in ftp_connect() */
|
||||
struct FTP *ftp = data->state.proto.ftp;
|
||||
struct FTP *ftp = data->req.protop;
|
||||
|
||||
/* if the second connection isn't done yet, wait for it */
|
||||
if(!conn->bits.tcpconnect[SECONDARYSOCKET]) {
|
||||
@@ -3779,7 +3779,7 @@ CURLcode ftp_perform(struct connectdata *conn,
|
||||
|
||||
if(conn->data->set.opt_no_body) {
|
||||
/* requested no body means no transfer... */
|
||||
struct FTP *ftp = conn->data->state.proto.ftp;
|
||||
struct FTP *ftp = conn->data->req.protop;
|
||||
ftp->transfer = FTPTRANSFER_INFO;
|
||||
}
|
||||
|
||||
@@ -4218,7 +4218,7 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
|
||||
{
|
||||
struct SessionHandle *data = conn->data;
|
||||
/* the ftp struct is already inited in ftp_connect() */
|
||||
struct FTP *ftp = data->state.proto.ftp;
|
||||
struct FTP *ftp = data->req.protop;
|
||||
struct ftp_conn *ftpc = &conn->proto.ftpc;
|
||||
const char *slash_pos; /* position of the first '/' char in curpos */
|
||||
const char *path_to_use = data->state.path;
|
||||
@@ -4408,7 +4408,7 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
|
||||
static CURLcode ftp_dophase_done(struct connectdata *conn,
|
||||
bool connected)
|
||||
{
|
||||
struct FTP *ftp = conn->data->state.proto.ftp;
|
||||
struct FTP *ftp = conn->data->req.protop;
|
||||
struct ftp_conn *ftpc = &conn->proto.ftpc;
|
||||
|
||||
if(connected) {
|
||||
@@ -4532,7 +4532,7 @@ static CURLcode ftp_setup_connection(struct connectdata *conn)
|
||||
#endif
|
||||
}
|
||||
|
||||
conn->data->state.proto.ftp = ftp = malloc(sizeof(struct FTP));
|
||||
conn->data->req.protop = ftp = malloc(sizeof(struct FTP));
|
||||
if(NULL == ftp)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user