diff options
Diffstat (limited to 'src/tool_getparam.c')
-rw-r--r-- | src/tool_getparam.c | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/src/tool_getparam.c b/src/tool_getparam.c index f6b889804..5e907416b 100644 --- a/src/tool_getparam.c +++ b/src/tool_getparam.c @@ -373,6 +373,7 @@ ParameterError getparameter(char *flag, /* f or -long-flag */ char *nextarg, /* NULL if unset */ bool *usedarg, /* set to TRUE if the arg has been used */ + struct GlobalConfig *global, struct OperationConfig *config) { char letter; @@ -1433,7 +1434,7 @@ ParameterError getparameter(char *flag, /* f or -long-flag */ config->insecure_ok = toggle; break; case 'K': /* parse config file */ - if(parseconfig(nextarg, config)) + if(parseconfig(nextarg, global)) warnf(config, "error trying read config from the '%s' file\n", nextarg); break; @@ -1618,15 +1619,15 @@ ParameterError getparameter(char *flag, /* f or -long-flag */ config->mute = config->noprogress = TRUE; else config->mute = config->noprogress = FALSE; - if(config->showerror < 0) + if(global->showerror < 0) /* if still on the default value, set showerror to the reverse of toggle. This is to allow -S and -s to be used in an independent order but still have the same effect. */ - config->showerror = (!toggle)?TRUE:FALSE; /* toggle off */ + global->showerror = (!toggle)?TRUE:FALSE; /* toggle off */ break; case 'S': /* show errors */ - config->showerror = toggle?1:0; /* toggle on if used with -s */ + global->showerror = toggle?1:0; /* toggle on if used with -s */ break; case 't': /* Telnet options */ @@ -1798,32 +1799,36 @@ ParameterError getparameter(char *flag, /* f or -long-flag */ return PARAM_OK; } -ParameterError parse_args(struct OperationConfig *config, int argc, +ParameterError parse_args(struct GlobalConfig *config, int argc, argv_item_t argv[]) { int i; bool stillflags; char *orig_opt; ParameterError result = PARAM_OK; + struct OperationConfig *operation = config->first; for(i = 1, stillflags = TRUE; i < argc && !result; i++) { orig_opt = argv[i]; if(curlx_strequal(":", argv[i]) && - (config->url_list && config->url_list->url)) { + (operation->url_list && operation->url_list->url)) { /* Allocate the next config */ - config->next = malloc(sizeof(struct OperationConfig)); - if(config->next) { + operation->next = malloc(sizeof(struct OperationConfig)); + if(operation->next) { /* Initialise the newly created config */ - config_init(config->next); + config_init(operation->next); /* Copy the easy handle */ - config->next->easy = config->easy; + operation->next->easy = config->easy; + + /* Update the last operation pointer */ + config->last = operation->next; /* Move onto the new config */ - config->next->prev = config; - config = config->next; + operation->next->prev = operation; + operation = operation->next; /* Reset the flag indicator */ stillflags = TRUE; @@ -1843,7 +1848,7 @@ ParameterError parse_args(struct OperationConfig *config, int argc, else { nextarg = (i < (argc - 1)) ? argv[i + 1] : NULL; - result = getparameter(flag, nextarg, &passarg, config); + result = getparameter(flag, nextarg, &passarg, config, operation); if(!result && passarg) i++; /* we're supposed to skip this */ } @@ -1852,7 +1857,8 @@ ParameterError parse_args(struct OperationConfig *config, int argc, bool used; /* Just add the URL please */ - result = getparameter((char *)"--url", argv[i], &used, config); + result = getparameter((char *)"--url", argv[i], &used, config, + operation); } } @@ -1863,9 +1869,9 @@ ParameterError parse_args(struct OperationConfig *config, int argc, const char *reason = param2text(result); if(!curlx_strequal(":", orig_opt)) - helpf(config->errors, "option %s: %s\n", orig_opt, reason); + helpf(operation->errors, "option %s: %s\n", orig_opt, reason); else - helpf(config->errors, "%s\n", reason); + helpf(operation->errors, "%s\n", reason); } return result; |