diff --git a/owlps-aggregator/owlps-aggregatord.c b/owlps-aggregator/owlps-aggregatord.c index 69d2292..a1c4819 100644 --- a/owlps-aggregator/owlps-aggregatord.c +++ b/owlps-aggregator/owlps-aggregatord.c @@ -282,7 +282,11 @@ int parse_config_file(int argc, char **argv) CFG_END() } ; - char *config_file = NULL ; // Configuration file name + // Configuration file name + char *config_file = NULL ; + // True if we are using the default configuration file, false if the + // user specified a different one with -f + bool default_config_file = false ; // Option -f specifies a config file, options -h and -V exit the // program, so we search for them first @@ -315,6 +319,7 @@ int parse_config_file(int argc, char **argv) // If -f isn't found, we use the default config file if (config_file == NULL) { + default_config_file = true ; config_file = malloc((strlen(DEFAULT_CONFIG_FILE) + 1) * sizeof(char)) ; if (! config_file) @@ -331,9 +336,15 @@ int parse_config_file(int argc, char **argv) switch (cfg_parse(cfg, config_file)) { case CFG_FILE_ERROR : - fprintf(stderr, - "Error! Cannot open configuration file \"%s\": %s.\n", - config_file, strerror(errno)) ; + /* If we can't open the file, we display a message only if + * the user used -f. In verbose mode, it would be nice to + * display the message even if the user didn't use -f, but + * the command-line options are not parsed yet so the verbose + * level is always zero. */ + if (! default_config_file) + fprintf(stderr, + "Error! Cannot open configuration file \"%s\": %s.\n", + config_file, strerror(errno)) ; break ; case CFG_PARSE_ERROR : fprintf(stderr,