mirror of
https://github.com/curl/curl.git
synced 2024-11-27 05:50:21 +08:00
tool_operate: split up the huge single_transfer into sub functions
- split up in a few smaller and easier to read functions - simplify several sections - avoid superfluous extra allocations - remove unused debug code Closes #15385
This commit is contained in:
parent
30da1f5974
commit
59831f8061
2862
src/tool_operate.c
2862
src/tool_operate.c
File diff suppressed because it is too large
Load Diff
@ -41,7 +41,7 @@ struct per_transfer {
|
||||
long num_retries; /* counts the performed retries */
|
||||
struct timeval start; /* start of this transfer */
|
||||
struct timeval retrystart;
|
||||
char *this_url;
|
||||
char *url;
|
||||
unsigned int urlnum; /* the index of the given URL */
|
||||
char *outfile;
|
||||
int infd;
|
||||
|
@ -493,7 +493,7 @@ CURLcode glob_url(struct URLGlob **glob, char *url, curl_off_t *urlnum,
|
||||
fprintf(error, "curl: (%d) %s\n", res, t);
|
||||
}
|
||||
/* it failed, we cleanup */
|
||||
glob_cleanup(glob_expand);
|
||||
glob_cleanup(&glob_expand);
|
||||
*urlnum = 1;
|
||||
return res;
|
||||
}
|
||||
@ -502,10 +502,11 @@ CURLcode glob_url(struct URLGlob **glob, char *url, curl_off_t *urlnum,
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
void glob_cleanup(struct URLGlob *glob)
|
||||
void glob_cleanup(struct URLGlob **globp)
|
||||
{
|
||||
size_t i;
|
||||
curl_off_t elem;
|
||||
struct URLGlob *glob = *globp;
|
||||
|
||||
if(!glob)
|
||||
return;
|
||||
@ -523,6 +524,7 @@ void glob_cleanup(struct URLGlob *glob)
|
||||
}
|
||||
Curl_safefree(glob->glob_buffer);
|
||||
Curl_safefree(glob);
|
||||
*globp = NULL;
|
||||
}
|
||||
|
||||
CURLcode glob_next_url(char **globbed, struct URLGlob *glob)
|
||||
|
@ -73,6 +73,6 @@ struct URLGlob {
|
||||
CURLcode glob_url(struct URLGlob**, char *, curl_off_t *, FILE *);
|
||||
CURLcode glob_next_url(char **, struct URLGlob *);
|
||||
CURLcode glob_match_url(char **, char *, struct URLGlob *);
|
||||
void glob_cleanup(struct URLGlob *glob);
|
||||
void glob_cleanup(struct URLGlob **glob);
|
||||
|
||||
#endif /* HEADER_CURL_TOOL_URLGLOB_H */
|
||||
|
@ -204,7 +204,7 @@ static int urlpart(struct per_transfer *per, writeoutid vid,
|
||||
rc = 5;
|
||||
}
|
||||
else
|
||||
url = per->this_url;
|
||||
url = per->url;
|
||||
|
||||
if(!rc) {
|
||||
switch(vid) {
|
||||
@ -373,8 +373,8 @@ static int writeString(FILE *stream, const struct writeoutvar *wovar,
|
||||
}
|
||||
break;
|
||||
case VAR_INPUT_URL:
|
||||
if(per->this_url) {
|
||||
strinfo = per->this_url;
|
||||
if(per->url) {
|
||||
strinfo = per->url;
|
||||
valid = true;
|
||||
}
|
||||
break;
|
||||
@ -398,7 +398,7 @@ static int writeString(FILE *stream, const struct writeoutvar *wovar,
|
||||
case VAR_INPUT_URLEQUERY:
|
||||
case VAR_INPUT_URLEFRAGMENT:
|
||||
case VAR_INPUT_URLEZONEID:
|
||||
if(per->this_url) {
|
||||
if(per->url) {
|
||||
if(!urlpart(per, wovar->id, &strinfo)) {
|
||||
freestr = strinfo;
|
||||
valid = true;
|
||||
|
Loading…
Reference in New Issue
Block a user