mirror of
https://github.com/curl/curl.git
synced 2026-08-26 07:13:32 +03:00
curl: make global truly global
The GlobalConfig only exists in a single instance and it has worked like this since the dawn of time. It is about time we stop passing around pointers to what was already essentially a global object and instead just use a... global. It simplifies things. Closes #18213
This commit is contained in:
parent
2d9f24bf24
commit
3b40128b0f
42 changed files with 473 additions and 626 deletions
|
|
@ -523,8 +523,7 @@ GetFileAndPassword(const char *nextarg, char **file, char **password)
|
|||
/* Get a size parameter for '--limit-rate' or '--max-filesize'.
|
||||
* We support a 'G', 'M' or 'K' suffix too.
|
||||
*/
|
||||
static ParameterError GetSizeParameter(struct GlobalConfig *global,
|
||||
const char *arg,
|
||||
static ParameterError GetSizeParameter(const char *arg,
|
||||
const char *which,
|
||||
curl_off_t *value_out)
|
||||
{
|
||||
|
|
@ -532,7 +531,7 @@ static ParameterError GetSizeParameter(struct GlobalConfig *global,
|
|||
curl_off_t value;
|
||||
|
||||
if(curlx_str_number(&unit, &value, CURL_OFF_T_MAX)) {
|
||||
warnf(global, "invalid number specified for %s", which);
|
||||
warnf("invalid number specified for %s", which);
|
||||
return PARAM_BAD_USE;
|
||||
}
|
||||
|
||||
|
|
@ -565,7 +564,7 @@ static ParameterError GetSizeParameter(struct GlobalConfig *global,
|
|||
/* for plain bytes, leave as-is */
|
||||
break;
|
||||
default:
|
||||
warnf(global, "unsupported %s unit. Use G, M, K or B", which);
|
||||
warnf("unsupported %s unit. Use G, M, K or B", which);
|
||||
return PARAM_BAD_USE;
|
||||
}
|
||||
*value_out = value;
|
||||
|
|
@ -591,8 +590,7 @@ static void cleanarg(char *str)
|
|||
#define MAX_DATAURLENCODE (500*1024*1024)
|
||||
|
||||
/* --data-urlencode */
|
||||
static ParameterError data_urlencode(struct GlobalConfig *global,
|
||||
const char *nextarg,
|
||||
static ParameterError data_urlencode(const char *nextarg,
|
||||
char **postp,
|
||||
size_t *lenp)
|
||||
{
|
||||
|
|
@ -631,7 +629,7 @@ static ParameterError data_urlencode(struct GlobalConfig *global,
|
|||
else {
|
||||
file = fopen(p, "rb");
|
||||
if(!file) {
|
||||
errorf(global, "Failed to open %s", p);
|
||||
errorf("Failed to open %s", p);
|
||||
return PARAM_READ_ERROR;
|
||||
}
|
||||
}
|
||||
|
|
@ -698,13 +696,12 @@ static void sethttpver(struct OperationConfig *config,
|
|||
{
|
||||
if(config->httpversion &&
|
||||
(config->httpversion != httpversion))
|
||||
warnf(config->global, "Overrides previous HTTP version option");
|
||||
warnf("Overrides previous HTTP version option");
|
||||
|
||||
config->httpversion = httpversion;
|
||||
}
|
||||
|
||||
static CURLcode set_trace_config(struct GlobalConfig *global,
|
||||
const char *token)
|
||||
static CURLcode set_trace_config(const char *token)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
const char *next, *name;
|
||||
|
|
@ -858,7 +855,7 @@ static ParameterError url_query(const char *nextarg,
|
|||
err = PARAM_NO_MEM;
|
||||
}
|
||||
else
|
||||
err = data_urlencode(config->global, nextarg, &query, &size);
|
||||
err = data_urlencode(nextarg, &query, &size);
|
||||
|
||||
if(!err) {
|
||||
if(config->query) {
|
||||
|
|
@ -885,10 +882,9 @@ static ParameterError set_data(cmdline_t cmd,
|
|||
FILE *file;
|
||||
size_t size = 0;
|
||||
ParameterError err = PARAM_OK;
|
||||
struct GlobalConfig *global = config->global;
|
||||
|
||||
if(cmd == C_DATA_URLENCODE) { /* --data-urlencode */
|
||||
err = data_urlencode(global, nextarg, &postdata, &size);
|
||||
err = data_urlencode(nextarg, &postdata, &size);
|
||||
if(err)
|
||||
return err;
|
||||
}
|
||||
|
|
@ -905,7 +901,7 @@ static ParameterError set_data(cmdline_t cmd,
|
|||
else {
|
||||
file = fopen(nextarg, "rb");
|
||||
if(!file) {
|
||||
errorf(global, "Failed to open %s", nextarg);
|
||||
errorf("Failed to open %s", nextarg);
|
||||
return PARAM_READ_ERROR;
|
||||
}
|
||||
}
|
||||
|
|
@ -958,8 +954,7 @@ static ParameterError set_data(cmdline_t cmd,
|
|||
return err;
|
||||
}
|
||||
|
||||
static ParameterError set_rate(struct GlobalConfig *global,
|
||||
const char *nextarg)
|
||||
static ParameterError set_rate(const char *nextarg)
|
||||
{
|
||||
/* --rate */
|
||||
/* support a few different suffixes, extract the suffix first, then
|
||||
|
|
@ -1007,14 +1002,14 @@ static ParameterError set_rate(struct GlobalConfig *global,
|
|||
numerator = 24*60*60*1000;
|
||||
break;
|
||||
default:
|
||||
errorf(global, "unsupported --rate unit");
|
||||
errorf("unsupported --rate unit");
|
||||
err = PARAM_BAD_USE;
|
||||
break;
|
||||
}
|
||||
|
||||
if((LONG_MAX / numerator) < numunits) {
|
||||
/* overflow, too large number */
|
||||
errorf(global, "too large --rate unit");
|
||||
errorf("too large --rate unit");
|
||||
err = PARAM_NUMBER_TOO_LARGE;
|
||||
}
|
||||
/* this typecast is okay based on the check above */
|
||||
|
|
@ -1076,7 +1071,7 @@ static ParameterError add_url(struct OperationConfig *config,
|
|||
url->useremote = url->noglob = TRUE;
|
||||
if(!err && (++config->num_urls > 1) &&
|
||||
(config->etag_save_file || config->etag_compare_file)) {
|
||||
errorf(config->global, "The etag options only work on a single URL");
|
||||
errorf("The etag options only work on a single URL");
|
||||
return PARAM_BAD_USE;
|
||||
}
|
||||
}
|
||||
|
|
@ -1159,20 +1154,17 @@ static ParameterError parse_localport(struct OperationConfig *config,
|
|||
static ParameterError parse_continue_at(struct OperationConfig *config,
|
||||
const char *nextarg)
|
||||
{
|
||||
struct GlobalConfig *global = config->global;
|
||||
ParameterError err = PARAM_OK;
|
||||
if(config->range) {
|
||||
errorf(global, "--continue-at is mutually exclusive with --range");
|
||||
errorf("--continue-at is mutually exclusive with --range");
|
||||
return PARAM_BAD_USE;
|
||||
}
|
||||
if(config->rm_partial) {
|
||||
errorf(config->global,
|
||||
"--continue-at is mutually exclusive with --remove-on-error");
|
||||
errorf("--continue-at is mutually exclusive with --remove-on-error");
|
||||
return PARAM_BAD_USE;
|
||||
}
|
||||
if(config->file_clobber_mode == CLOBBER_NEVER) {
|
||||
errorf(config->global,
|
||||
"--continue-at is mutually exclusive with --no-clobber");
|
||||
errorf("--continue-at is mutually exclusive with --no-clobber");
|
||||
return PARAM_BAD_USE;
|
||||
}
|
||||
/* This makes us continue an ftp transfer at given position */
|
||||
|
|
@ -1216,8 +1208,7 @@ static ParameterError parse_ech(struct OperationConfig *config,
|
|||
file = fopen(nextarg, FOPEN_READTEXT);
|
||||
}
|
||||
if(!file) {
|
||||
warnf(config->global,
|
||||
"Couldn't read file \"%s\" "
|
||||
warnf("Couldn't read file \"%s\" "
|
||||
"specified for \"--ech ecl:\" option",
|
||||
nextarg);
|
||||
return PARAM_BAD_USE; /* */
|
||||
|
|
@ -1252,7 +1243,7 @@ static ParameterError parse_header(struct OperationConfig *config,
|
|||
bool use_stdin = !strcmp(&nextarg[1], "-");
|
||||
FILE *file = use_stdin ? stdin : fopen(&nextarg[1], FOPEN_READTEXT);
|
||||
if(!file) {
|
||||
errorf(config->global, "Failed to open %s", &nextarg[1]);
|
||||
errorf("Failed to open %s", &nextarg[1]);
|
||||
err = PARAM_READ_ERROR;
|
||||
}
|
||||
else {
|
||||
|
|
@ -1392,10 +1383,9 @@ static ParameterError parse_range(struct OperationConfig *config,
|
|||
ParameterError err = PARAM_OK;
|
||||
curl_off_t value;
|
||||
const char *orig = nextarg;
|
||||
struct GlobalConfig *global = config->global;
|
||||
|
||||
if(config->use_resume) {
|
||||
errorf(global, "--continue-at is mutually exclusive with --range");
|
||||
errorf("--continue-at is mutually exclusive with --range");
|
||||
return PARAM_BAD_USE;
|
||||
}
|
||||
if(!curlx_str_number(&nextarg, &value, CURL_OFF_T_MAX) &&
|
||||
|
|
@ -1405,7 +1395,7 @@ static ParameterError parse_range(struct OperationConfig *config,
|
|||
claimed that to be a good way, why this code is added to work-around
|
||||
it. */
|
||||
char buffer[32];
|
||||
warnf(global, "A specified range MUST include at least one dash (-). "
|
||||
warnf("A specified range MUST include at least one dash (-). "
|
||||
"Appending one for you");
|
||||
msnprintf(buffer, sizeof(buffer), "%" CURL_FORMAT_CURL_OFF_T "-",
|
||||
value);
|
||||
|
|
@ -1418,7 +1408,7 @@ static ParameterError parse_range(struct OperationConfig *config,
|
|||
/* byte range requested */
|
||||
while(*nextarg) {
|
||||
if(!ISDIGIT(*nextarg) && *nextarg != '-' && *nextarg != ',') {
|
||||
warnf(global, "Invalid character is found in given range. "
|
||||
warnf("Invalid character is found in given range. "
|
||||
"A specified range MUST have only digits in "
|
||||
"\'start\'-\'stop\'. The server's response to this "
|
||||
"request is uncertain.");
|
||||
|
|
@ -1471,8 +1461,7 @@ static ParameterError parse_upload_file(struct OperationConfig *config,
|
|||
|
||||
static size_t verbose_nopts;
|
||||
|
||||
static ParameterError parse_verbose(struct GlobalConfig *global,
|
||||
bool toggle)
|
||||
static ParameterError parse_verbose(bool toggle)
|
||||
{
|
||||
ParameterError err = PARAM_OK;
|
||||
|
||||
|
|
@ -1480,7 +1469,7 @@ static ParameterError parse_verbose(struct GlobalConfig *global,
|
|||
* more than once in the same argument flag, like `-vvv`. */
|
||||
if(!toggle) {
|
||||
global->verbosity = 0;
|
||||
if(set_trace_config(global, "-all"))
|
||||
if(set_trace_config("-all"))
|
||||
err = PARAM_NO_MEM;
|
||||
global->tracetype = TRACE_NONE;
|
||||
return err;
|
||||
|
|
@ -1488,7 +1477,7 @@ static ParameterError parse_verbose(struct GlobalConfig *global,
|
|||
else if(!verbose_nopts) {
|
||||
/* fist `-v` in an argument resets to base verbosity */
|
||||
global->verbosity = 0;
|
||||
if(set_trace_config(global, "-all"))
|
||||
if(set_trace_config("-all"))
|
||||
return PARAM_NO_MEM;
|
||||
}
|
||||
/* the '%' thing here will cause the trace get sent to stderr */
|
||||
|
|
@ -1501,25 +1490,24 @@ static ParameterError parse_verbose(struct GlobalConfig *global,
|
|||
err = PARAM_NO_MEM;
|
||||
else {
|
||||
if(global->tracetype && (global->tracetype != TRACE_PLAIN))
|
||||
warnf(global,
|
||||
"-v, --verbose overrides an earlier trace option");
|
||||
warnf("-v, --verbose overrides an earlier trace option");
|
||||
global->tracetype = TRACE_PLAIN;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
global->verbosity = 2;
|
||||
if(set_trace_config(global, "ids,time,protocol"))
|
||||
if(set_trace_config("ids,time,protocol"))
|
||||
err = PARAM_NO_MEM;
|
||||
break;
|
||||
case 2:
|
||||
global->verbosity = 3;
|
||||
global->tracetype = TRACE_ASCII;
|
||||
if(set_trace_config(global, "ssl,read,write"))
|
||||
if(set_trace_config("ssl,read,write"))
|
||||
err = PARAM_NO_MEM;
|
||||
break;
|
||||
case 3:
|
||||
global->verbosity = 4;
|
||||
if(set_trace_config(global, "network"))
|
||||
if(set_trace_config("network"))
|
||||
err = PARAM_NO_MEM;
|
||||
break;
|
||||
default:
|
||||
|
|
@ -1549,7 +1537,7 @@ static ParameterError parse_writeout(struct OperationConfig *config,
|
|||
fname = nextarg;
|
||||
file = fopen(fname, FOPEN_READTEXT);
|
||||
if(!file) {
|
||||
errorf(config->global, "Failed to open %s", fname);
|
||||
errorf("Failed to open %s", fname);
|
||||
return PARAM_READ_ERROR;
|
||||
}
|
||||
}
|
||||
|
|
@ -1560,7 +1548,7 @@ static ParameterError parse_writeout(struct OperationConfig *config,
|
|||
if(err)
|
||||
return err;
|
||||
if(!config->writeout)
|
||||
warnf(config->global, "Failed to read %s", fname);
|
||||
warnf("Failed to read %s", fname);
|
||||
}
|
||||
else
|
||||
err = getstr(&config->writeout, nextarg, ALLOW_BLANK);
|
||||
|
|
@ -1596,15 +1584,14 @@ static ParameterError parse_time_cond(struct OperationConfig *config,
|
|||
if(config->condtime == -1) {
|
||||
curl_off_t value;
|
||||
/* now let's see if it is a filename to get the time from instead! */
|
||||
int rc = getfiletime(nextarg, config->global, &value);
|
||||
int rc = getfiletime(nextarg, &value);
|
||||
if(!rc)
|
||||
/* pull the time out from the file */
|
||||
config->condtime = value;
|
||||
else {
|
||||
/* failed, remove time condition */
|
||||
config->timecond = CURL_TIMECOND_NONE;
|
||||
warnf(config->global,
|
||||
"Illegal date format for -z, --time-cond (and not "
|
||||
warnf("Illegal date format for -z, --time-cond (and not "
|
||||
"a filename). Disabling time condition. "
|
||||
"See curl_getdate(3) for valid date syntax.");
|
||||
}
|
||||
|
|
@ -1684,10 +1671,9 @@ static void togglebit(bool toggle, unsigned long *modify, unsigned long bits)
|
|||
}
|
||||
|
||||
/* opt_depr is the function that handles ARG_DEPR options */
|
||||
static void opt_depr(struct GlobalConfig *global,
|
||||
const struct LongShort *a)
|
||||
static void opt_depr(const struct LongShort *a)
|
||||
{
|
||||
warnf(global, "--%s is deprecated and has no function anymore", a->lname);
|
||||
warnf("--%s is deprecated and has no function anymore", a->lname);
|
||||
}
|
||||
|
||||
static ParameterError opt_sslver(struct OperationConfig *config,
|
||||
|
|
@ -1695,7 +1681,7 @@ static ParameterError opt_sslver(struct OperationConfig *config,
|
|||
{
|
||||
if(config->ssl_version_max &&
|
||||
(config->ssl_version_max < ver)) {
|
||||
errorf(config->global, "Minimum TLS version set higher than max");
|
||||
errorf("Minimum TLS version set higher than max");
|
||||
return PARAM_BAD_USE;
|
||||
}
|
||||
config->ssl_version = ver;
|
||||
|
|
@ -1787,7 +1773,6 @@ static ParameterError opt_bool(struct OperationConfig *config,
|
|||
const struct LongShort *a,
|
||||
bool toggle)
|
||||
{
|
||||
struct GlobalConfig *global = config->global;
|
||||
switch(a->cmd) {
|
||||
case C_ALPN: /* --alpn */
|
||||
config->noalpn = !toggle;
|
||||
|
|
@ -1864,7 +1849,7 @@ static ParameterError opt_bool(struct OperationConfig *config,
|
|||
case C_SSL: /* --ssl */
|
||||
config->ftp_ssl = toggle;
|
||||
if(config->ftp_ssl)
|
||||
warnf(global, "--%s is an insecure option, consider --ssl-reqd instead",
|
||||
warnf("--%s is an insecure option, consider --ssl-reqd instead",
|
||||
a->lname);
|
||||
break;
|
||||
case C_FTP_SSL_CCC: /* --ftp-ssl-ccc */
|
||||
|
|
@ -2011,7 +1996,7 @@ static ParameterError opt_bool(struct OperationConfig *config,
|
|||
config->doh_verifystatus = toggle;
|
||||
break;
|
||||
case C_FALSE_START: /* --false-start */
|
||||
opt_depr(global, a);
|
||||
opt_depr(a);
|
||||
break;
|
||||
case C_SSL_NO_REVOKE: /* --ssl-no-revoke */
|
||||
config->ssl_no_revoke = toggle;
|
||||
|
|
@ -2046,15 +2031,14 @@ static ParameterError opt_bool(struct OperationConfig *config,
|
|||
case C_FAIL_WITH_BODY: /* --fail-with-body */
|
||||
config->failwithbody = toggle;
|
||||
if(config->failonerror && config->failwithbody) {
|
||||
errorf(config->global, "You must select either --fail or "
|
||||
errorf("You must select either --fail or "
|
||||
"--fail-with-body, not both.");
|
||||
return PARAM_BAD_USE;
|
||||
}
|
||||
break;
|
||||
case C_REMOVE_ON_ERROR: /* --remove-on-error */
|
||||
if(config->use_resume && toggle) {
|
||||
errorf(config->global,
|
||||
"--continue-at is mutually exclusive with --remove-on-error");
|
||||
errorf("--continue-at is mutually exclusive with --remove-on-error");
|
||||
return PARAM_BAD_USE;
|
||||
}
|
||||
config->rm_partial = toggle;
|
||||
|
|
@ -2062,7 +2046,7 @@ static ParameterError opt_bool(struct OperationConfig *config,
|
|||
case C_FAIL: /* --fail */
|
||||
config->failonerror = toggle;
|
||||
if(config->failonerror && config->failwithbody) {
|
||||
errorf(config->global, "You must select either --fail or "
|
||||
errorf("You must select either --fail or "
|
||||
"--fail-with-body, not both.");
|
||||
return PARAM_BAD_USE;
|
||||
}
|
||||
|
|
@ -2083,7 +2067,7 @@ static ParameterError opt_bool(struct OperationConfig *config,
|
|||
case C_HEAD: /* --head */
|
||||
config->no_body = toggle;
|
||||
config->show_headers = toggle;
|
||||
if(SetHTTPrequest(config, (config->no_body) ? TOOL_HTTPREQ_HEAD :
|
||||
if(SetHTTPrequest((config->no_body) ? TOOL_HTTPREQ_HEAD :
|
||||
TOOL_HTTPREQ_GET, &config->httpreq))
|
||||
return PARAM_BAD_USE;
|
||||
break;
|
||||
|
|
@ -2117,8 +2101,7 @@ static ParameterError opt_bool(struct OperationConfig *config,
|
|||
break;
|
||||
case C_CLOBBER: /* --clobber */
|
||||
if(config->use_resume && !toggle) {
|
||||
errorf(config->global,
|
||||
"--continue-at is mutually exclusive with --no-clobber");
|
||||
errorf("--continue-at is mutually exclusive with --no-clobber");
|
||||
return PARAM_BAD_USE;
|
||||
}
|
||||
config->file_clobber_mode = toggle ? CLOBBER_ALWAYS : CLOBBER_NEVER;
|
||||
|
|
@ -2146,7 +2129,7 @@ static ParameterError opt_bool(struct OperationConfig *config,
|
|||
global->showerror = toggle;
|
||||
break;
|
||||
case C_VERBOSE: /* --verbose */
|
||||
return parse_verbose(global, toggle);
|
||||
return parse_verbose(toggle);
|
||||
break;
|
||||
case C_VERSION: /* --version */
|
||||
if(toggle) /* --no-version yields no output! */
|
||||
|
|
@ -2166,12 +2149,12 @@ static ParameterError opt_bool(struct OperationConfig *config,
|
|||
FALLTHROUGH();
|
||||
case C_LOCATION: /* --location */
|
||||
if(config->followlocation == CURLFOLLOW_OBEYCODE)
|
||||
warnf(global, "--location overrides --follow");
|
||||
warnf("--location overrides --follow");
|
||||
config->followlocation = toggle ? CURLFOLLOW_ALL : 0;
|
||||
break;
|
||||
case C_FOLLOW: /* --follow */
|
||||
if(config->followlocation == CURLFOLLOW_ALL)
|
||||
warnf(global, "--follow overrides --location");
|
||||
warnf("--follow overrides --location");
|
||||
config->followlocation = toggle ? CURLFOLLOW_OBEYCODE : 0;
|
||||
break;
|
||||
default:
|
||||
|
|
@ -2189,7 +2172,6 @@ static ParameterError opt_filestring(struct OperationConfig *config,
|
|||
ParameterError err = PARAM_OK;
|
||||
curl_off_t value;
|
||||
long val;
|
||||
struct GlobalConfig *global = config->global;
|
||||
static const char *redir_protos[] = {
|
||||
"http",
|
||||
"https",
|
||||
|
|
@ -2249,7 +2231,7 @@ static ParameterError opt_filestring(struct OperationConfig *config,
|
|||
err = getstr(&global->trace_dump, nextarg, DENY_BLANK);
|
||||
if(!err) {
|
||||
if(global->tracetype && (global->tracetype != TRACE_BIN))
|
||||
warnf(global, "--trace overrides an earlier trace/verbose option");
|
||||
warnf("--trace overrides an earlier trace/verbose option");
|
||||
global->tracetype = TRACE_BIN;
|
||||
}
|
||||
break;
|
||||
|
|
@ -2257,20 +2239,19 @@ static ParameterError opt_filestring(struct OperationConfig *config,
|
|||
err = getstr(&global->trace_dump, nextarg, DENY_BLANK);
|
||||
if(!err) {
|
||||
if(global->tracetype && (global->tracetype != TRACE_ASCII))
|
||||
warnf(global,
|
||||
"--trace-ascii overrides an earlier trace/verbose option");
|
||||
warnf("--trace-ascii overrides an earlier trace/verbose option");
|
||||
global->tracetype = TRACE_ASCII;
|
||||
}
|
||||
break;
|
||||
case C_LIMIT_RATE: /* --limit-rate */
|
||||
err = GetSizeParameter(global, nextarg, "rate", &value);
|
||||
err = GetSizeParameter(nextarg, "rate", &value);
|
||||
if(!err) {
|
||||
config->recvpersecond = value;
|
||||
config->sendpersecond = value;
|
||||
}
|
||||
break;
|
||||
case C_RATE:
|
||||
err = set_rate(global, nextarg);
|
||||
err = set_rate(nextarg);
|
||||
break;
|
||||
case C_CREATE_FILE_MODE: /* --create-file-mode */
|
||||
err = oct2nummax(&config->create_file_mode, nextarg, 0777);
|
||||
|
|
@ -2292,7 +2273,7 @@ static ParameterError opt_filestring(struct OperationConfig *config,
|
|||
err = getstr(&config->aws_sigv4, nextarg, ALLOW_BLANK);
|
||||
break;
|
||||
case C_STDERR: /* --stderr */
|
||||
tool_set_stderr_file(global, nextarg);
|
||||
tool_set_stderr_file(nextarg);
|
||||
break;
|
||||
case C_INTERFACE: /* --interface */
|
||||
/* interface */
|
||||
|
|
@ -2309,7 +2290,7 @@ static ParameterError opt_filestring(struct OperationConfig *config,
|
|||
err = getstr(&config->haproxy_clientip, nextarg, DENY_BLANK);
|
||||
break;
|
||||
case C_MAX_FILESIZE: /* --max-filesize */
|
||||
err = GetSizeParameter(global, nextarg, "max-filesize", &value);
|
||||
err = GetSizeParameter(nextarg, "max-filesize", &value);
|
||||
if(!err)
|
||||
config->max_filesize = value;
|
||||
break;
|
||||
|
|
@ -2363,7 +2344,7 @@ static ParameterError opt_filestring(struct OperationConfig *config,
|
|||
err = getstr(&config->ftp_account, nextarg, DENY_BLANK);
|
||||
break;
|
||||
case C_FTP_METHOD: /* --ftp-method */
|
||||
config->ftp_filemethod = ftpfilemethod(config, nextarg);
|
||||
config->ftp_filemethod = ftpfilemethod(nextarg);
|
||||
break;
|
||||
case C_LOCAL_PORT: /* --local-port */
|
||||
err = parse_localport(config, nextarg);
|
||||
|
|
@ -2373,8 +2354,7 @@ static ParameterError opt_filestring(struct OperationConfig *config,
|
|||
break;
|
||||
case C_LIBCURL: /* --libcurl */
|
||||
#ifdef CURL_DISABLE_LIBCURL_OPTION
|
||||
warnf(global,
|
||||
"--libcurl option was disabled at build-time");
|
||||
warnf("--libcurl option was disabled at build-time");
|
||||
err = PARAM_OPTION_UNKNOWN;
|
||||
#else
|
||||
err = getstr(&global->libcurl, nextarg, DENY_BLANK);
|
||||
|
|
@ -2407,19 +2387,18 @@ static ParameterError opt_filestring(struct OperationConfig *config,
|
|||
break;
|
||||
case C_PROTO: /* --proto */
|
||||
config->proto_present = TRUE;
|
||||
err = proto2num(config, built_in_protos, &config->proto_str, nextarg);
|
||||
err = proto2num(built_in_protos, &config->proto_str, nextarg);
|
||||
break;
|
||||
case C_PROTO_REDIR: /* --proto-redir */
|
||||
config->proto_redir_present = TRUE;
|
||||
if(proto2num(config, redir_protos, &config->proto_redir_str,
|
||||
nextarg))
|
||||
if(proto2num(redir_protos, &config->proto_redir_str, nextarg))
|
||||
err = PARAM_BAD_USE;
|
||||
break;
|
||||
case C_RESOLVE: /* --resolve */
|
||||
err = add2list(&config->resolve, nextarg);
|
||||
break;
|
||||
case C_DELEGATION: /* --delegation */
|
||||
config->gssapi_delegation = delegation(config, nextarg);
|
||||
config->gssapi_delegation = delegation(nextarg);
|
||||
break;
|
||||
case C_MAIL_AUTH: /* --mail-auth */
|
||||
err = getstr(&config->mail_auth, nextarg, DENY_BLANK);
|
||||
|
|
@ -2455,7 +2434,7 @@ static ParameterError opt_filestring(struct OperationConfig *config,
|
|||
case C_TLS_MAX: /* --tls-max */
|
||||
err = str2tls_max(&config->ssl_version_max, nextarg);
|
||||
if(!err && (config->ssl_version_max < config->ssl_version)) {
|
||||
errorf(global, "--tls-max set lower than minimum accepted version");
|
||||
errorf("--tls-max set lower than minimum accepted version");
|
||||
err = PARAM_BAD_USE;
|
||||
}
|
||||
break;
|
||||
|
|
@ -2464,11 +2443,11 @@ static ParameterError opt_filestring(struct OperationConfig *config,
|
|||
/* 0 is a valid value for this timeout */
|
||||
break;
|
||||
case C_TRACE_CONFIG: /* --trace-config */
|
||||
if(set_trace_config(global, nextarg))
|
||||
if(set_trace_config(nextarg))
|
||||
err = PARAM_NO_MEM;
|
||||
break;
|
||||
case C_VARIABLE: /* --variable */
|
||||
err = setvariable(global, nextarg);
|
||||
err = setvariable(nextarg);
|
||||
break;
|
||||
case C_TLS13_CIPHERS: /* --tls13-ciphers */
|
||||
err = getstr(&config->cipher13_list, nextarg, DENY_BLANK);
|
||||
|
|
@ -2678,7 +2657,7 @@ static ParameterError opt_filestring(struct OperationConfig *config,
|
|||
break;
|
||||
case C_ETAG_SAVE: /* --etag-save */
|
||||
if(config->num_urls > 1) {
|
||||
errorf(global, "The etag options only work on a single URL");
|
||||
errorf("The etag options only work on a single URL");
|
||||
err = PARAM_BAD_USE;
|
||||
}
|
||||
else
|
||||
|
|
@ -2686,7 +2665,7 @@ static ParameterError opt_filestring(struct OperationConfig *config,
|
|||
break;
|
||||
case C_ETAG_COMPARE: /* --etag-compare */
|
||||
if(config->num_urls > 1) {
|
||||
errorf(global, "The etag options only work on a single URL");
|
||||
errorf("The etag options only work on a single URL");
|
||||
err = PARAM_BAD_USE;
|
||||
}
|
||||
else
|
||||
|
|
@ -2702,13 +2681,10 @@ static ParameterError opt_filestring(struct OperationConfig *config,
|
|||
case C_FORM_STRING: /* --form-string */
|
||||
/* "form data" simulation, this is a little advanced so lets do our best
|
||||
to sort this out slowly and carefully */
|
||||
if(formparse(config,
|
||||
nextarg,
|
||||
&config->mimeroot,
|
||||
&config->mimecurrent,
|
||||
if(formparse(nextarg, &config->mimeroot, &config->mimecurrent,
|
||||
(a->cmd == C_FORM_STRING))) /* literal string */
|
||||
err = PARAM_BAD_USE;
|
||||
else if(SetHTTPrequest(config, TOOL_HTTPREQ_MIMEPOST, &config->httpreq))
|
||||
else if(SetHTTPrequest(TOOL_HTTPREQ_MIMEPOST, &config->httpreq))
|
||||
err = PARAM_BAD_USE;
|
||||
break;
|
||||
case C_REQUEST_TARGET: /* --request-target */
|
||||
|
|
@ -2719,8 +2695,8 @@ static ParameterError opt_filestring(struct OperationConfig *config,
|
|||
err = parse_header(config, (cmdline_t)a->cmd, nextarg);
|
||||
break;
|
||||
case C_CONFIG: /* --config */
|
||||
if(parseconfig(nextarg, global)) {
|
||||
errorf(global, "cannot read config from '%s'", nextarg);
|
||||
if(parseconfig(nextarg)) {
|
||||
errorf("cannot read config from '%s'", nextarg);
|
||||
err = PARAM_READ_ERROR;
|
||||
}
|
||||
break;
|
||||
|
|
@ -2747,7 +2723,7 @@ static ParameterError opt_filestring(struct OperationConfig *config,
|
|||
break;
|
||||
case C_FTP_SSL_CCC_MODE: /* --ftp-ssl-ccc-mode */
|
||||
config->ftp_ssl_ccc = TRUE;
|
||||
config->ftp_ssl_ccc_mode = ftpcccmethod(config, nextarg);
|
||||
config->ftp_ssl_ccc_mode = ftpcccmethod(nextarg);
|
||||
break;
|
||||
case C_QUOTE: /* --quote */
|
||||
err = parse_quote(config, nextarg);
|
||||
|
|
@ -2849,7 +2825,6 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
|
|||
bool nextalloc = FALSE; /* if nextarg is allocated */
|
||||
bool consumearg = TRUE; /* the argument comes separate */
|
||||
const struct LongShort *a = NULL;
|
||||
struct GlobalConfig *global = config->global;
|
||||
verbose_nopts = 0; /* options processed in `flag`*/
|
||||
|
||||
*usedarg = FALSE; /* default is that we do not use the arg */
|
||||
|
|
@ -2911,7 +2886,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
|
|||
err = PARAM_EXPAND_ERROR;
|
||||
goto error;
|
||||
}
|
||||
err = varexpand(global, nextarg, &nbuf, &replaced);
|
||||
err = varexpand(nextarg, &nbuf, &replaced);
|
||||
if(err) {
|
||||
curlx_dyn_free(&nbuf);
|
||||
goto error;
|
||||
|
|
@ -2961,18 +2936,18 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
|
|||
*usedarg = consumearg; /* mark it as used */
|
||||
}
|
||||
if(a->desc & ARG_DEPR) {
|
||||
opt_depr(global, a);
|
||||
opt_depr(a);
|
||||
break;
|
||||
}
|
||||
|
||||
if((ARGTYPE(a->desc) == ARG_FILE) &&
|
||||
(nextarg[0] == '-') && nextarg[1]) {
|
||||
/* if the filename looks like a command line option */
|
||||
warnf(global, "The filename argument '%s' looks like a flag.",
|
||||
warnf("The filename argument '%s' looks like a flag.",
|
||||
nextarg);
|
||||
}
|
||||
else if(!strncmp("\xe2\x80\x9c", nextarg, 3)) {
|
||||
warnf(global, "The argument '%s' starts with a Unicode quote where "
|
||||
warnf("The argument '%s' starts with a Unicode quote where "
|
||||
"maybe an ASCII \" was intended?",
|
||||
nextarg);
|
||||
}
|
||||
|
|
@ -2983,7 +2958,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
|
|||
}
|
||||
else {
|
||||
if(a->desc & ARG_DEPR) {
|
||||
opt_depr(global, a);
|
||||
opt_depr(a);
|
||||
break;
|
||||
}
|
||||
/* ARG_NONE | ARG_BOOL */
|
||||
|
|
@ -3003,8 +2978,7 @@ error:
|
|||
return err;
|
||||
}
|
||||
|
||||
ParameterError parse_args(struct GlobalConfig *global, int argc,
|
||||
argv_item_t argv[])
|
||||
ParameterError parse_args(int argc, argv_item_t argv[])
|
||||
{
|
||||
int i;
|
||||
bool stillflags;
|
||||
|
|
@ -3045,7 +3019,7 @@ ParameterError parse_args(struct GlobalConfig *global, int argc,
|
|||
|
||||
if(config->url_list && config->url_list->url) {
|
||||
/* Allocate the next config */
|
||||
config->next = config_alloc(global);
|
||||
config->next = config_alloc();
|
||||
if(config->next) {
|
||||
/* Update the last config pointer */
|
||||
global->last = config->next;
|
||||
|
|
@ -3058,7 +3032,7 @@ ParameterError parse_args(struct GlobalConfig *global, int argc,
|
|||
result = PARAM_NO_MEM;
|
||||
}
|
||||
else {
|
||||
errorf(global, "missing URL before --next");
|
||||
errorf("missing URL before --next");
|
||||
result = PARAM_BAD_USE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue