err = PARAM_BAD_USE;
}
else {
- err = parseconfig(nextarg, max_recursive);
+ err = parseconfig(nextarg, max_recursive, NULL);
}
break;
case C_CRLFILE: /* --crlfile */
{
CURLcode result = CURLE_OK;
const char *first_arg;
+ char *curlrc_path = NULL;
+ bool found_curlrc = FALSE;
first_arg = argc > 1 ? convert_tchar_to_UTF8(argv[1]) : NULL;
if((argc == 1) ||
(first_arg && strncmp(first_arg, "-q", 2) &&
strcmp(first_arg, "--disable"))) {
- parseconfig(NULL, CONFIG_MAX_LEVELS); /* ignore possible failure */
+ if(!parseconfig(NULL, CONFIG_MAX_LEVELS, &curlrc_path))
+ found_curlrc = TRUE;
/* If we had no arguments then make sure a URL was specified in .curlrc */
if((argc < 2) && (!global->first->url_list)) {
if(!result) {
/* Parse the command line arguments */
ParameterError res = parse_args(argc, argv);
+ if(found_curlrc) {
+ /* After parse_args so notef knows the verbosity */
+ notef("Read config file from '%s'", curlrc_path);
+ free(curlrc_path);
+ }
if(res) {
result = CURLE_OK;
#define MAX_CONFIG_LINE_LENGTH (10*1024*1024)
/* return 0 on everything-is-fine, and non-zero otherwise */
-ParameterError parseconfig(const char *filename, int max_recursive)
+ParameterError parseconfig(const char *filename, int max_recursive,
+ char **resolved)
{
FILE *file = NULL;
bool usedarg = FALSE;
if((err == PARAM_READ_ERROR) && filename)
errorf("cannot read config from '%s'", filename);
+ if(!err && resolved) {
+ *resolved = strdup(filename);
+ if(!*resolved)
+ err = PARAM_NO_MEM;
+ }
free(pathalloc);
return err;
}
/* only allow this many levels of recursive --config use */
#define CONFIG_MAX_LEVELS 5
-ParameterError parseconfig(const char *filename, int max_recursive);
+ParameterError parseconfig(const char *filename, int max_recursive,
+ char **resolved);
bool my_get_line(FILE *fp, struct dynbuf *db, bool *error);
#endif /* HEADER_CURL_TOOL_PARSECFG_H */