X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=conf-parser.c;h=2cf90f2defa1ff8dec0ae4d5c7aad47d433baecd;hb=6dde1f33e1249a8a6b354372dd95065f26b8c712;hp=58c00541b6f3313d3feaae5eac82e2f0140edff3;hpb=b2aa81efdef98f113c391a3081b8be5d05ef9566;p=elogind.git
diff --git a/conf-parser.c b/conf-parser.c
index 58c00541b..2cf90f2de 100644
--- a/conf-parser.c
+++ b/conf-parser.c
@@ -1,5 +1,24 @@
/*-*- Mode: C; c-basic-offset: 8 -*-*/
+/***
+ This file is part of systemd.
+
+ Copyright 2010 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with systemd; If not, see .
+***/
+
#include
#include
#include
@@ -13,7 +32,6 @@
#include "log.h"
#define COMMENTS "#;\n"
-#define NEWLINES "\n\r"
#define LINE_MAX 4096
/* Run the user supplied parser for an assignment */
@@ -45,7 +63,10 @@ static int next_assignment(
return t->parse(filename, line, section, lvalue, rvalue, t->data, userdata);
}
- log_info("[%s:%u] Unknown lvalue '%s' in section '%s'. Ignoring.", filename, line, lvalue, strna(section));
+ /* Warn about unknown non-extension fields. */
+ if (!startswith(lvalue, "X-"))
+ log_info("[%s:%u] Unknown lvalue '%s' in section '%s'. Ignoring.", filename, line, lvalue, strna(section));
+
return 0;
}
@@ -90,6 +111,7 @@ static int parse_line(const char *filename, unsigned line, char **section, const
return -ENOMEM;
if (sections && !strv_contains((char**) sections, n)) {
+ log_error("[%s:%u] Unknown section '%s'.", filename, line, n);
free(n);
return -EBADMSG;
}
@@ -116,6 +138,7 @@ int config_parse(const char *filename, FILE *f, const char* const * sections, co
unsigned line = 0;
char *section = NULL;
int r;
+ bool ours = false;
assert(filename);
assert(t);
@@ -126,6 +149,8 @@ int config_parse(const char *filename, FILE *f, const char* const * sections, co
log_error("Failed to open configuration file '%s': %s", filename, strerror(-r));
goto finish;
}
+
+ ours = true;
}
while (!feof(f)) {
@@ -149,7 +174,7 @@ int config_parse(const char *filename, FILE *f, const char* const * sections, co
finish:
free(section);
- if (f)
+ if (f && ours)
fclose(f);
return r;
@@ -346,8 +371,12 @@ int config_parse_strv(
if (!(n = new(char*, k+1)))
return -ENOMEM;
- for (k = 0; (*sv)[k]; k++)
- n[k] = (*sv)[k];
+ if (*sv)
+ for (k = 0; (*sv)[k]; k++)
+ n[k] = (*sv)[k];
+ else
+ k = 0;
+
FOREACH_WORD_QUOTED(w, l, rvalue, state)
if (!(n[k++] = strndup(w, l)))
goto fail;