chiark / gitweb /
improve dump output for sockets
[elogind.git] / conf-parser.c
index 26188583310e1d62e87f8e72e66fe965b34cc3b8..2f013e3f24c26f19a76aa7d1ec7b1d220cfbdf07 100644 (file)
@@ -12,7 +12,6 @@
 #include "strv.h"
 #include "log.h"
 
-#define WHITESPACE " \t\n"
 #define COMMENTS "#;\n"
 #define LINE_MAX 4096
 
@@ -45,8 +44,8 @@ static int next_assignment(
                 return t->parse(filename, line, section, lvalue, rvalue, t->data, userdata);
         }
 
-        log_error("[%s:%u] Unknown lvalue '%s' in section '%s'.", filename, line, lvalue, strna(section));
-        return -EBADMSG;
+        log_info("[%s:%u] Unknown lvalue '%s' in section '%s'. Ignoring.", filename, line, lvalue, strna(section));
+        return 0;
 }
 
 /* Returns non-zero when c is contained in s */
@@ -110,7 +109,7 @@ static int parse_line(const char *filename, unsigned line, char **section, const
                         }
                 }
 
-                r = config_parse(fn, sections, t, userdata);
+                r = config_parse(fn, NULL, sections, t, userdata);
                 free(path);
                 return r;
         }
@@ -163,19 +162,20 @@ static int parse_line(const char *filename, unsigned line, char **section, const
 }
 
 /* Go through the file and parse each line */
-int config_parse(const char *filename, const char* const * sections, const ConfigItem *t, void *userdata) {
+int config_parse(const char *filename, FILE *f, const char* const * sections, const ConfigItem *t, void *userdata) {
         unsigned line = 0;
         char *section = NULL;
-        FILE *f;
         int r;
 
         assert(filename);
         assert(t);
 
-        if (!(f = fopen(filename, "re"))) {
-                r = -errno;
-                log_error("Failed to open configuration file '%s': %s", filename, strerror(-r));
-                goto finish;
+        if (!f) {
+                if (!(f = fopen(filename, "re"))) {
+                        r = -errno;
+                        log_error("Failed to open configuration file '%s': %s", filename, strerror(-r));
+                        goto finish;
+                }
         }
 
         while (!feof(f)) {