chiark / gitweb /
tree-wide: drop 'This file is part of systemd' blurb
[elogind.git] / src / shared / conf-parser.c
index 949a77fd2615a39174c6f4dafad3d625ce0be9fd..9116cc8dd13298a48099ab7b8fb975457d8fbbd9 100644 (file)
@@ -1,7 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 /***
-  This file is part of systemd.
-
   Copyright 2010 Lennart Poettering
 ***/
 
 //#include "rlimit-util.h"
 //#include "rlimit-util.h"
 //#include "rlimit-util.h"
+//#include "rlimit-util.h"
+//#include "rlimit-util.h"
+//#include "rlimit-util.h"
+//#include "rlimit-util.h"
 
 int config_item_table_lookup(
                 const void *table,
@@ -654,7 +656,7 @@ int config_parse_bool(const char* unit,
                 return fatal ? -ENOEXEC : 0;
         }
 
-        *b = !!k;
+        *b = k;
         return 0;
 }
 
@@ -740,10 +742,8 @@ int config_parse_path(
         assert(rvalue);
         assert(data);
 
-        if (isempty(rvalue)) {
-                n = NULL;
+        if (isempty(rvalue))
                 goto finalize;
-        }
 
         n = strdup(rvalue);
         if (!n)
@@ -754,9 +754,7 @@ int config_parse_path(
                 return fatal ? -ENOEXEC : 0;
 
 finalize:
-        free_and_replace(*s, n);
-
-        return 0;
+        return free_and_replace(*s, n);
 }
 
 int config_parse_strv(
@@ -1231,3 +1229,34 @@ int config_parse_rlimit(
 
         return 0;
 }
+
+int config_parse_permille(const char* unit,
+                          const char *filename,
+                          unsigned line,
+                          const char *section,
+                          unsigned section_line,
+                          const char *lvalue,
+                          int ltype,
+                          const char *rvalue,
+                          void *data,
+                          void *userdata) {
+
+        unsigned *permille = data;
+        int r;
+
+        assert(filename);
+        assert(lvalue);
+        assert(rvalue);
+        assert(permille);
+
+        r = parse_permille(rvalue);
+        if (r < 0) {
+                log_syntax(unit, LOG_ERR, filename, line, r,
+                           "Failed to parse permille value, ignoring: %s", rvalue);
+                return 0;
+        }
+
+        *permille = (unsigned) r;
+
+        return 0;
+}