1
0
mirror of https://github.com/moparisthebest/curl synced 2024-11-12 04:25:08 -05:00

ftplistparser: renamed some members and variables

... to make them better spell out what they're for.
This commit is contained in:
Daniel Stenberg 2018-04-20 10:29:44 +02:00
parent 5e5725a476
commit 98a768f0a6
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
5 changed files with 47 additions and 47 deletions

View File

@ -3687,10 +3687,10 @@ CURLcode ftp_perform(struct connectdata *conn,
static void wc_data_dtor(void *ptr) static void wc_data_dtor(void *ptr)
{ {
struct ftp_wc_tmpdata *tmp = ptr; struct ftp_wc *ftpwc = ptr;
if(tmp) if(ftpwc)
Curl_ftp_parselist_data_free(&tmp->parser); Curl_ftp_parselist_data_free(&ftpwc->parser);
free(tmp); free(ftpwc);
} }
static CURLcode init_wc_data(struct connectdata *conn) static CURLcode init_wc_data(struct connectdata *conn)
@ -3699,7 +3699,7 @@ static CURLcode init_wc_data(struct connectdata *conn)
char *path = conn->data->state.path; char *path = conn->data->state.path;
struct WildcardData *wildcard = &(conn->data->wildcard); struct WildcardData *wildcard = &(conn->data->wildcard);
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
struct ftp_wc_tmpdata *ftp_tmp; struct ftp_wc *ftpwc;
last_slash = strrchr(conn->data->state.path, '/'); last_slash = strrchr(conn->data->state.path, '/');
if(last_slash) { if(last_slash) {
@ -3731,23 +3731,23 @@ static CURLcode init_wc_data(struct connectdata *conn)
/* program continues only if URL is not ending with slash, allocate needed /* program continues only if URL is not ending with slash, allocate needed
resources for wildcard transfer */ resources for wildcard transfer */
/* allocate ftp protocol specific temporary wildcard data */ /* allocate ftp protocol specific wildcard data */
ftp_tmp = calloc(1, sizeof(struct ftp_wc_tmpdata)); ftpwc = calloc(1, sizeof(struct ftp_wc));
if(!ftp_tmp) { if(!ftpwc) {
Curl_safefree(wildcard->pattern); Curl_safefree(wildcard->pattern);
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
} }
/* INITIALIZE parselist structure */ /* INITIALIZE parselist structure */
ftp_tmp->parser = Curl_ftp_parselist_data_alloc(); ftpwc->parser = Curl_ftp_parselist_data_alloc();
if(!ftp_tmp->parser) { if(!ftpwc->parser) {
Curl_safefree(wildcard->pattern); Curl_safefree(wildcard->pattern);
free(ftp_tmp); free(ftpwc);
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
} }
wildcard->tmp = ftp_tmp; /* put it to the WildcardData tmp pointer */ wildcard->protdata = ftpwc; /* put it to the WildcardData tmp pointer */
wildcard->tmp_dtor = wc_data_dtor; wildcard->dtor = wc_data_dtor;
/* wildcard does not support NOCWD option (assert it?) */ /* wildcard does not support NOCWD option (assert it?) */
if(conn->data->set.ftp_filemethod == FTPFILE_NOCWD) if(conn->data->set.ftp_filemethod == FTPFILE_NOCWD)
@ -3757,27 +3757,27 @@ static CURLcode init_wc_data(struct connectdata *conn)
result = ftp_parse_url_path(conn); result = ftp_parse_url_path(conn);
if(result) { if(result) {
Curl_safefree(wildcard->pattern); Curl_safefree(wildcard->pattern);
wildcard->tmp_dtor(wildcard->tmp); wildcard->dtor(wildcard->protdata);
wildcard->tmp_dtor = ZERO_NULL; wildcard->dtor = ZERO_NULL;
wildcard->tmp = NULL; wildcard->protdata = NULL;
return result; return result;
} }
wildcard->path = strdup(conn->data->state.path); wildcard->path = strdup(conn->data->state.path);
if(!wildcard->path) { if(!wildcard->path) {
Curl_safefree(wildcard->pattern); Curl_safefree(wildcard->pattern);
wildcard->tmp_dtor(wildcard->tmp); wildcard->dtor(wildcard->protdata);
wildcard->tmp_dtor = ZERO_NULL; wildcard->dtor = ZERO_NULL;
wildcard->tmp = NULL; wildcard->protdata = NULL;
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
} }
/* backup old write_function */ /* backup old write_function */
ftp_tmp->backup.write_function = conn->data->set.fwrite_func; ftpwc->backup.write_function = conn->data->set.fwrite_func;
/* parsing write function */ /* parsing write function */
conn->data->set.fwrite_func = Curl_ftp_parselist; conn->data->set.fwrite_func = Curl_ftp_parselist;
/* backup old file descriptor */ /* backup old file descriptor */
ftp_tmp->backup.file_descriptor = conn->data->set.out; ftpwc->backup.file_descriptor = conn->data->set.out;
/* let the writefunc callback know what curl pointer is working with */ /* let the writefunc callback know what curl pointer is working with */
conn->data->set.out = conn; conn->data->set.out = conn;
@ -3803,14 +3803,14 @@ static CURLcode wc_statemach(struct connectdata *conn)
case CURLWC_MATCHING: { case CURLWC_MATCHING: {
/* In this state is LIST response successfully parsed, so lets restore /* In this state is LIST response successfully parsed, so lets restore
previous WRITEFUNCTION callback and WRITEDATA pointer */ previous WRITEFUNCTION callback and WRITEDATA pointer */
struct ftp_wc_tmpdata *ftp_tmp = wildcard->tmp; struct ftp_wc *ftpwc = wildcard->protdata;
conn->data->set.fwrite_func = ftp_tmp->backup.write_function; conn->data->set.fwrite_func = ftpwc->backup.write_function;
conn->data->set.out = ftp_tmp->backup.file_descriptor; conn->data->set.out = ftpwc->backup.file_descriptor;
ftp_tmp->backup.write_function = ZERO_NULL; ftpwc->backup.write_function = ZERO_NULL;
ftp_tmp->backup.file_descriptor = NULL; ftpwc->backup.file_descriptor = NULL;
wildcard->state = CURLWC_DOWNLOADING; wildcard->state = CURLWC_DOWNLOADING;
if(Curl_ftp_parselist_geterror(ftp_tmp->parser)) { if(Curl_ftp_parselist_geterror(ftpwc->parser)) {
/* error found in LIST parsing */ /* error found in LIST parsing */
wildcard->state = CURLWC_CLEAN; wildcard->state = CURLWC_CLEAN;
return wc_statemach(conn); return wc_statemach(conn);
@ -3892,10 +3892,10 @@ static CURLcode wc_statemach(struct connectdata *conn)
} }
case CURLWC_CLEAN: { case CURLWC_CLEAN: {
struct ftp_wc_tmpdata *ftp_tmp = wildcard->tmp; struct ftp_wc *ftpwc = wildcard->protdata;
result = CURLE_OK; result = CURLE_OK;
if(ftp_tmp) if(ftpwc)
result = Curl_ftp_parselist_geterror(ftp_tmp->parser); result = Curl_ftp_parselist_geterror(ftpwc->parser);
wildcard->state = result ? CURLWC_ERROR : CURLWC_DONE; wildcard->state = result ? CURLWC_ERROR : CURLWC_DONE;
} break; } break;

View File

@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -81,7 +81,7 @@ typedef enum {
struct ftp_parselist_data; /* defined later in ftplistparser.c */ struct ftp_parselist_data; /* defined later in ftplistparser.c */
struct ftp_wc_tmpdata { struct ftp_wc {
struct ftp_parselist_data *parser; struct ftp_parselist_data *parser;
struct { struct {

View File

@ -270,9 +270,9 @@ static CURLcode ftp_pl_insert_finfo(struct connectdata *conn,
{ {
curl_fnmatch_callback compare; curl_fnmatch_callback compare;
struct WildcardData *wc = &conn->data->wildcard; struct WildcardData *wc = &conn->data->wildcard;
struct ftp_wc_tmpdata *tmpdata = wc->tmp; struct ftp_wc *ftpwc = wc->protdata;
struct curl_llist *llist = &wc->filelist; struct curl_llist *llist = &wc->filelist;
struct ftp_parselist_data *parser = tmpdata->parser; struct ftp_parselist_data *parser = ftpwc->parser;
bool add = TRUE; bool add = TRUE;
struct curl_fileinfo *finfo = &infop->info; struct curl_fileinfo *finfo = &infop->info;
@ -316,7 +316,7 @@ static CURLcode ftp_pl_insert_finfo(struct connectdata *conn,
Curl_fileinfo_dtor(NULL, finfo); Curl_fileinfo_dtor(NULL, finfo);
} }
tmpdata->parser->file_data = NULL; ftpwc->parser->file_data = NULL;
return CURLE_OK; return CURLE_OK;
} }
@ -325,8 +325,8 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
{ {
size_t bufflen = size*nmemb; size_t bufflen = size*nmemb;
struct connectdata *conn = (struct connectdata *)connptr; struct connectdata *conn = (struct connectdata *)connptr;
struct ftp_wc_tmpdata *tmpdata = conn->data->wildcard.tmp; struct ftp_wc *ftpwc = conn->data->wildcard.protdata;
struct ftp_parselist_data *parser = tmpdata->parser; struct ftp_parselist_data *parser = ftpwc->parser;
struct fileinfo *infop; struct fileinfo *infop;
struct curl_fileinfo *finfo; struct curl_fileinfo *finfo;
unsigned long i = 0; unsigned long i = 0;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -43,12 +43,12 @@ void Curl_wildcard_dtor(struct WildcardData *wc)
if(!wc) if(!wc)
return; return;
if(wc->tmp_dtor) { if(wc->dtor) {
wc->tmp_dtor(wc->tmp); wc->dtor(wc->protdata);
wc->tmp_dtor = ZERO_NULL; wc->dtor = ZERO_NULL;
wc->tmp = NULL; wc->protdata = NULL;
} }
DEBUGASSERT(wc->tmp == NULL); DEBUGASSERT(wc->protdata == NULL);
Curl_llist_destroy(&wc->filelist, NULL); Curl_llist_destroy(&wc->filelist, NULL);

View File

@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 2010 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 2010 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -40,7 +40,7 @@ typedef enum {
will end */ will end */
} curl_wildcard_states; } curl_wildcard_states;
typedef void (*curl_wildcard_tmp_dtor)(void *ptr); typedef void (*curl_wildcard_dtor)(void *ptr);
/* struct keeping information about wildcard download process */ /* struct keeping information about wildcard download process */
struct WildcardData { struct WildcardData {
@ -48,8 +48,8 @@ struct WildcardData {
char *path; /* path to the directory, where we trying wildcard-match */ char *path; /* path to the directory, where we trying wildcard-match */
char *pattern; /* wildcard pattern */ char *pattern; /* wildcard pattern */
struct curl_llist filelist; /* llist with struct Curl_fileinfo */ struct curl_llist filelist; /* llist with struct Curl_fileinfo */
void *tmp; /* pointer to protocol specific temporary data */ void *protdata; /* pointer to protocol specific temporary data */
curl_wildcard_tmp_dtor tmp_dtor; curl_wildcard_dtor dtor;
void *customptr; /* for CURLOPT_CHUNK_DATA pointer */ void *customptr; /* for CURLOPT_CHUNK_DATA pointer */
}; };