Added -g, fixed so that short options worked again. My last "merged"fix did
screw a few things up.
This commit is contained in:
29
src/main.c
29
src/main.c
@@ -255,7 +255,7 @@ static void help(void)
|
|||||||
" --cacert <file> CA certifciate to verify peer against (HTTPS)\n"
|
" --cacert <file> CA certifciate to verify peer against (HTTPS)\n"
|
||||||
" -f/--fail Fail silently (no output at all) on errors (H)\n"
|
" -f/--fail Fail silently (no output at all) on errors (H)\n"
|
||||||
" -F/--form <name=content> Specify HTTP POST data (H)\n"
|
" -F/--form <name=content> Specify HTTP POST data (H)\n"
|
||||||
|
" -g/--globoff Disable URL sequences and ranges using {} and []\n"
|
||||||
" -h/--help This help text\n"
|
" -h/--help This help text\n"
|
||||||
" -H/--header <line> Custom header to pass to server. (H)\n"
|
" -H/--header <line> Custom header to pass to server. (H)\n"
|
||||||
" -i/--include Include the HTTP-header in the output (H)\n"
|
" -i/--include Include the HTTP-header in the output (H)\n"
|
||||||
@@ -280,6 +280,7 @@ static void help(void)
|
|||||||
" -S/--show-error Show error. With -s, make curl show errors when they occur\n"
|
" -S/--show-error Show error. With -s, make curl show errors when they occur\n"
|
||||||
" -t/--upload Transfer/upload stdin to remote site\n"
|
" -t/--upload Transfer/upload stdin to remote site\n"
|
||||||
" -T/--upload-file <file> Transfer/upload <file> to remote site\n"
|
" -T/--upload-file <file> Transfer/upload <file> to remote site\n"
|
||||||
|
" --url <URL> Another way to specify URL to work with\n"
|
||||||
" -u/--user <user[:password]> Specify user and password to use\n"
|
" -u/--user <user[:password]> Specify user and password to use\n"
|
||||||
" -U/--proxy-user <user[:password]> Specify Proxy authentication\n"
|
" -U/--proxy-user <user[:password]> Specify Proxy authentication\n"
|
||||||
" -v/--verbose Makes the operation more talkative\n"
|
" -v/--verbose Makes the operation more talkative\n"
|
||||||
@@ -347,6 +348,7 @@ struct Configurable {
|
|||||||
char *krb4level;
|
char *krb4level;
|
||||||
bool progressmode;
|
bool progressmode;
|
||||||
bool nobuffer;
|
bool nobuffer;
|
||||||
|
bool globoff;
|
||||||
|
|
||||||
char *writeout; /* %-styled format string to output */
|
char *writeout; /* %-styled format string to output */
|
||||||
|
|
||||||
@@ -542,7 +544,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||||||
{"Ea", "cacert", TRUE},
|
{"Ea", "cacert", TRUE},
|
||||||
{"f", "fail", FALSE},
|
{"f", "fail", FALSE},
|
||||||
{"F", "form", TRUE},
|
{"F", "form", TRUE},
|
||||||
|
{"g", "globoff", FALSE},
|
||||||
{"h", "help", FALSE},
|
{"h", "help", FALSE},
|
||||||
{"H", "header", TRUE},
|
{"H", "header", TRUE},
|
||||||
{"i", "include", FALSE},
|
{"i", "include", FALSE},
|
||||||
@@ -642,8 +644,8 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||||||
if(hit < 0) {
|
if(hit < 0) {
|
||||||
return PARAM_OPTION_UNKNOWN;
|
return PARAM_OPTION_UNKNOWN;
|
||||||
}
|
}
|
||||||
if(!longopt && flag[1]) {
|
if(!longopt && aliases[hit].extraparam && parse[1]) {
|
||||||
nextarg=&flag[1]; /* this is the actual extra parameter */
|
nextarg=&parse[1]; /* this is the actual extra parameter */
|
||||||
singleopt=TRUE; /* don't loop anymore after this */
|
singleopt=TRUE; /* don't loop anymore after this */
|
||||||
}
|
}
|
||||||
else if((!nextarg || !*nextarg) && aliases[hit].extraparam) {
|
else if((!nextarg || !*nextarg) && aliases[hit].extraparam) {
|
||||||
@@ -835,6 +837,10 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||||||
return PARAM_BAD_USE;
|
return PARAM_BAD_USE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'g': /* g disables URLglobbing */
|
||||||
|
config->globoff ^= TRUE;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'h': /* h for help */
|
case 'h': /* h for help */
|
||||||
help();
|
help();
|
||||||
return PARAM_HELP_REQUESTED;
|
return PARAM_HELP_REQUESTED;
|
||||||
@@ -1415,7 +1421,7 @@ operate(struct Configurable *config, int argc, char *argv[])
|
|||||||
|
|
||||||
char *url = NULL;
|
char *url = NULL;
|
||||||
|
|
||||||
URLGlob *urls;
|
URLGlob *urls=NULL;
|
||||||
int urlnum;
|
int urlnum;
|
||||||
char *outfiles;
|
char *outfiles;
|
||||||
int separator = 0;
|
int separator = 0;
|
||||||
@@ -1557,11 +1563,14 @@ operate(struct Configurable *config, int argc, char *argv[])
|
|||||||
outs.stream = stdout;
|
outs.stream = stdout;
|
||||||
outs.config = config;
|
outs.config = config;
|
||||||
|
|
||||||
/* expand '{...}' and '[...]' expressions and return total number of URLs
|
if(!config->globoff) {
|
||||||
in pattern set */
|
/* Unless explicitly shut off, we expand '{...}' and '[...]' expressions
|
||||||
|
and return total number of URLs in pattern set */
|
||||||
res = glob_url(&urls, url, &urlnum);
|
res = glob_url(&urls, url, &urlnum);
|
||||||
if(res != CURLE_OK)
|
if(res != CURLE_OK)
|
||||||
return res;
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* save outfile pattern before expansion */
|
/* save outfile pattern before expansion */
|
||||||
outfiles = urlnode->outfile?strdup(urlnode->outfile):NULL;
|
outfiles = urlnode->outfile?strdup(urlnode->outfile):NULL;
|
||||||
@@ -1570,11 +1579,10 @@ operate(struct Configurable *config, int argc, char *argv[])
|
|||||||
/* multiple files extracted to stdout, insert separators! */
|
/* multiple files extracted to stdout, insert separators! */
|
||||||
separator = 1;
|
separator = 1;
|
||||||
}
|
}
|
||||||
for (i = 0; (url = next_url(urls)); ++i) {
|
for (i = 0; (url = urls?next_url(urls):(i?NULL:url)); ++i) {
|
||||||
char *outfile;
|
char *outfile;
|
||||||
outfile = outfiles?strdup(outfiles):NULL;
|
outfile = outfiles?strdup(outfiles):NULL;
|
||||||
|
|
||||||
|
|
||||||
if((urlnode->flags&GETOUT_USEREMOTE) ||
|
if((urlnode->flags&GETOUT_USEREMOTE) ||
|
||||||
(outfile && !strequal("-", outfile)) ) {
|
(outfile && !strequal("-", outfile)) ) {
|
||||||
|
|
||||||
@@ -1597,7 +1605,7 @@ operate(struct Configurable *config, int argc, char *argv[])
|
|||||||
return CURLE_WRITE_ERROR;
|
return CURLE_WRITE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else if(urls) {
|
||||||
/* fill '#1' ... '#9' terms from URL pattern */
|
/* fill '#1' ... '#9' terms from URL pattern */
|
||||||
char *storefile = outfile;
|
char *storefile = outfile;
|
||||||
outfile = match_url(storefile, urls);
|
outfile = match_url(storefile, urls);
|
||||||
@@ -1855,6 +1863,7 @@ operate(struct Configurable *config, int argc, char *argv[])
|
|||||||
if(outfiles)
|
if(outfiles)
|
||||||
free(outfiles);
|
free(outfiles);
|
||||||
|
|
||||||
|
if(urls)
|
||||||
/* cleanup memory used for URL globbing patterns */
|
/* cleanup memory used for URL globbing patterns */
|
||||||
glob_cleanup(urls);
|
glob_cleanup(urls);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user