#include "strv.h"
#include "log.h"
-#define WHITESPACE " \t\n"
#define COMMENTS "#;\n"
#define LINE_MAX 4096
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 */
}
}
- r = config_parse(fn, sections, t, userdata);
+ r = config_parse(fn, NULL, sections, t, userdata);
free(path);
return r;
}
}
/* 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)) {