aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2014-02-23 16:04:39 +0000
committerSteve Holme <steve_holme@hotmail.com>2014-02-25 19:38:17 +0000
commit0704dd770d545271ff11210e983a434a043738a7 (patch)
treebf9534d4e28993994a46964db6b75efa3d078de3 /src
parentad388a7d37c7cd610155af84d4f88d1cf36e3f5b (diff)
tool_getparam: Added global config to getparameter()
In preparation for parsing global options added the GlobalConfig structure to the getparameter() function.
Diffstat (limited to 'src')
-rw-r--r--src/tool_getparam.c7
-rw-r--r--src/tool_getparam.h7
-rw-r--r--src/tool_operate.c2
-rw-r--r--src/tool_parsecfg.c11
-rw-r--r--src/tool_parsecfg.h2
5 files changed, 15 insertions, 14 deletions
diff --git a/src/tool_getparam.c b/src/tool_getparam.c
index c64169c76..701f43d99 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;
@@ -1847,7 +1848,7 @@ ParameterError parse_args(struct GlobalConfig *config, int argc,
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 */
}
@@ -1856,7 +1857,7 @@ ParameterError parse_args(struct GlobalConfig *config, int argc,
bool used;
/* Just add the URL please */
- result = getparameter((char *)"--url", argv[i], &used, operation);
+ result = getparameter((char *)"--url", argv[i], &used, config, operation);
}
}
diff --git a/src/tool_getparam.h b/src/tool_getparam.h
index a13ce6d90..9ecd35401 100644
--- a/src/tool_getparam.h
+++ b/src/tool_getparam.h
@@ -44,10 +44,9 @@ typedef enum {
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,
diff --git a/src/tool_operate.c b/src/tool_operate.c
index 6458c11a9..2fb945310 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -1789,7 +1789,7 @@ CURLcode operate(struct GlobalConfig *config, int argc, argv_item_t argv[])
/* 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)) {
diff --git a/src/tool_parsecfg.c b/src/tool_parsecfg.c
index 69bacbf18..da10c878f 100644
--- a/src/tool_parsecfg.c
+++ b/src/tool_parsecfg.c
@@ -44,7 +44,7 @@ static const char *unslashquote(const char *line, char *param);
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)
{
int res;
FILE *file;
@@ -52,6 +52,7 @@ int parseconfig(const char *filename, struct OperationConfig *config)
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! */
@@ -201,8 +202,8 @@ int parseconfig(const char *filename, struct OperationConfig *config)
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);
}
}
@@ -218,7 +219,7 @@ int parseconfig(const char *filename, struct OperationConfig *config)
#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! */
@@ -234,7 +235,7 @@ int parseconfig(const char *filename, struct OperationConfig *config)
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);
}
}
diff --git a/src/tool_parsecfg.h b/src/tool_parsecfg.h
index af9f50bf1..c3b19d544 100644
--- a/src/tool_parsecfg.h
+++ b/src/tool_parsecfg.h
@@ -23,7 +23,7 @@
***************************************************************************/
#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 */