chiark / gitweb /
Fedora: further unit tweaks
[elogind.git] / src / conf-parser.c
index 1cabc0d789b2d9ef17f9689490e81fb498f2e006..aac64b29a3811c734ecc121f5b4ecaa7f6178ee7 100644 (file)
@@ -1,4 +1,4 @@
-/*-*- Mode: C; c-basic-offset: 8 -*-*/
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
 
 /***
   This file is part of systemd.
@@ -31,8 +31,6 @@
 #include "strv.h"
 #include "log.h"
 
-#define COMMENTS "#;\n"
-
 /* Run the user supplied parser for an assignment */
 static int next_assignment(
                 const char *filename,
@@ -122,7 +120,7 @@ static int parse_line(const char *filename, unsigned line, char **section, const
                 return 0;
         }
 
-        if (sections && !strv_contains((char**) sections, *section))
+        if (sections && (!*section || !strv_contains((char**) sections, *section)))
                 return 0;
 
         if (!(e = strchr(l, '='))) {
@@ -248,6 +246,31 @@ int config_parse_int(
         return 0;
 }
 
+int config_parse_uint64(
+                const char *filename,
+                unsigned line,
+                const char *section,
+                const char *lvalue,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
+
+        uint64_t *u = data;
+        int r;
+
+        assert(filename);
+        assert(lvalue);
+        assert(rvalue);
+        assert(data);
+
+        if ((r = safe_atou64(rvalue, u)) < 0) {
+                log_error("[%s:%u] Failed to parse numeric value: %s", filename, line, rvalue);
+                return r;
+        }
+
+        return 0;
+}
+
 int config_parse_unsigned(
                 const char *filename,
                 unsigned line,