diff parser-cfg.c @ 34172:5761a9a31bcb

Sanitize include option behaviour. If the file could not be opened/read/processed, print a message and quit instead of completely silently ignoring it.
author reimar
date Tue, 25 Oct 2011 20:45:09 +0000
parents 55abe5125482
children 2d529504ec2d
line wrap: on
line diff
--- a/parser-cfg.c	Tue Oct 25 20:42:50 2011 +0000
+++ b/parser-cfg.c	Tue Oct 25 20:45:09 2011 +0000
@@ -50,9 +50,10 @@
 /// Setup the \ref Config from a config file.
 /** \param config The config object.
  *  \param conffile Path to the config file.
+ *  \param silent print message when failing to open file only at verbose level
  *  \return 1 on sucess, -1 on error.
  */
-int m_config_parse_config_file(m_config_t* config, const char *conffile)
+int m_config_parse_config_file(m_config_t* config, const char *conffile, int silent)
 {
 #define PRINT_LINENUM	mp_msg(MSGT_CFGPARSER,MSGL_V,"%s(%d): ", conffile, line_num)
 #define MAX_LINE_LEN	10000
@@ -96,9 +97,9 @@
 	mp_msg(MSGT_CFGPARSER,MSGL_V,"\n");
 
 	if ((fp = fopen(conffile, "r")) == NULL) {
-	  mp_msg(MSGT_CFGPARSER,MSGL_V,": %s\n", strerror(errno));
+	  mp_msg(MSGT_CFGPARSER,silent?MSGL_V:MSGL_ERR,"Failed to read %s: %s\n", conffile, strerror(errno));
 		free(line);
-		ret = 0;
+		ret = silent ? 0 : -1;
 		goto out;
 	}