]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
conf-parser: add config_parse_permille()
authorMarc Kleine-Budde <mkl@pengutronix.de>
Tue, 5 Jun 2018 14:08:29 +0000 (16:08 +0200)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Sat, 9 Jun 2018 13:12:31 +0000 (15:12 +0200)
src/shared/conf-parser.c
src/shared/conf-parser.h

index b5ee07c9bd773336da9deec6e981469ac32b27b0..29dd1ddc887194d8468c918013c7667e985d53c6 100644 (file)
@@ -1203,3 +1203,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;
+}
index 70d313d4ebd5d8123d19d118d63cac2daecab96a..8546d5ce6695c846ca9115349c5693e02d7c8306 100644 (file)
@@ -140,6 +140,7 @@ CONFIG_PARSER_PROTOTYPE(config_parse_log_facility);
 CONFIG_PARSER_PROTOTYPE(config_parse_log_level);
 CONFIG_PARSER_PROTOTYPE(config_parse_signal);
 CONFIG_PARSER_PROTOTYPE(config_parse_personality);
+CONFIG_PARSER_PROTOTYPE(config_parse_permille);
 CONFIG_PARSER_PROTOTYPE(config_parse_ifname);
 CONFIG_PARSER_PROTOTYPE(config_parse_ip_port);
 CONFIG_PARSER_PROTOTYPE(config_parse_join_controllers);