In preparation for parsing global options added the GlobalConfig
structure to the getparameter() function.
char *nextarg, /* NULL if unset */
bool *usedarg, /* set to TRUE if the arg
has been used */
char *nextarg, /* NULL if unset */
bool *usedarg, /* set to TRUE if the arg
has been used */
+ struct GlobalConfig *global,
struct OperationConfig *config)
{
char letter;
struct OperationConfig *config)
{
char letter;
config->insecure_ok = toggle;
break;
case 'K': /* parse config file */
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;
warnf(config, "error trying read config from the '%s' file\n",
nextarg);
break;
else {
nextarg = (i < (argc - 1)) ? argv[i + 1] : NULL;
else {
nextarg = (i < (argc - 1)) ? argv[i + 1] : NULL;
- result = getparameter(flag, nextarg, &passarg, operation);
+ result = getparameter(flag, nextarg, &passarg, config, operation);
if(!result && passarg)
i++; /* we're supposed to skip this */
}
if(!result && passarg)
i++; /* we're supposed to skip this */
}
bool used;
/* Just add the URL please */
bool used;
/* Just add the URL please */
- result = getparameter((char *)"--url", argv[i], &used, operation);
+ result = getparameter((char *)"--url", argv[i], &used, config, operation);
struct GlobalConfig;
struct OperationConfig;
struct GlobalConfig;
struct OperationConfig;
-ParameterError getparameter(char *flag,
- char *nextarg,
- bool *usedarg,
- struct OperationConfig *config);
+ParameterError getparameter(char *flag, char *nextarg, bool *usedarg,
+ struct GlobalConfig *global,
+ struct OperationConfig *operation);
#ifdef UNITTESTS
void parse_cert_parameter(const char *cert_parameter,
#ifdef UNITTESTS
void parse_cert_parameter(const char *cert_parameter,
/* Parse .curlrc if necessary */
if((argc == 1) || (!curlx_strequal(argv[1], "-q"))) {
/* Parse .curlrc if necessary */
if((argc == 1) || (!curlx_strequal(argv[1], "-q"))) {
- parseconfig(NULL, config->first); /* ignore possible failure */
+ parseconfig(NULL, config); /* ignore possible failure */
/* If we had no arguments then make sure a url was specified in .curlrc */
if((argc < 2) && (!config->first->url_list)) {
/* If we had no arguments then make sure a url was specified in .curlrc */
if((argc < 2) && (!config->first->url_list)) {
static char *my_get_line(FILE *fp);
/* return 0 on everything-is-fine, and non-zero otherwise */
static char *my_get_line(FILE *fp);
/* return 0 on everything-is-fine, and non-zero otherwise */
-int parseconfig(const char *filename, struct OperationConfig *config)
+int parseconfig(const char *filename, struct GlobalConfig *global)
bool usedarg;
char *home;
int rc = 0;
bool usedarg;
char *home;
int rc = 0;
+ struct OperationConfig *operation = global->first;
if(!filename || !*filename) {
/* NULL or no file name attempts to load .curlrc from the homedir! */
if(!filename || !*filename) {
/* NULL or no file name attempts to load .curlrc from the homedir! */
case '#': /* comment */
break;
default:
case '#': /* comment */
break;
default:
- warnf(config, "%s:%d: warning: '%s' uses unquoted white space in the"
- " line that may cause side-effects!\n",
+ warnf(operation, "%s:%d: warning: '%s' uses unquoted white space in"
+ " the line that may cause side-effects!\n",
filename, lineno, option);
}
}
filename, lineno, option);
}
}
#ifdef DEBUG_CONFIG
fprintf(stderr, "PARAM: \"%s\"\n",(param ? param : "(null)"));
#endif
#ifdef DEBUG_CONFIG
fprintf(stderr, "PARAM: \"%s\"\n",(param ? param : "(null)"));
#endif
- res = getparameter(option, param, &usedarg, config);
+ res = getparameter(option, param, &usedarg, global, operation);
if(param && *param && !usedarg)
/* we passed in a parameter that wasn't used! */
if(param && *param && !usedarg)
/* we passed in a parameter that wasn't used! */
res != PARAM_VERSION_INFO_REQUESTED &&
res != PARAM_ENGINES_REQUESTED) {
const char *reason = param2text(res);
res != PARAM_VERSION_INFO_REQUESTED &&
res != PARAM_ENGINES_REQUESTED) {
const char *reason = param2text(res);
- warnf(config, "%s:%d: warning: '%s' %s\n",
+ warnf(operation, "%s:%d: warning: '%s' %s\n",
filename, lineno, option, reason);
}
}
filename, lineno, option, reason);
}
}
***************************************************************************/
#include "tool_setup.h"
***************************************************************************/
#include "tool_setup.h"
-int parseconfig(const char *filename, struct OperationConfig *config);
+int parseconfig(const char *filename, struct GlobalConfig *config);
#endif /* HEADER_CURL_TOOL_PARSECFG_H */
#endif /* HEADER_CURL_TOOL_PARSECFG_H */