]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
conf-parser: move config_parse_timezone() to conf-parser.[ch] 32290/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 16 Apr 2024 01:28:06 +0000 (10:28 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 19 Apr 2024 01:23:01 +0000 (10:23 +0900)
Even though it is currently only used by networkd, the parser itself
is quite generic. Let's move it to the shared library.

src/network/networkd-network.c
src/network/networkd-network.h
src/shared/conf-parser.c
src/shared/conf-parser.h

index 8c52438092b9f477c493ce7d76e1f07a11b7bc66..15d5721866a373f26f47fefbedd66d1dfc540969 100644 (file)
@@ -923,40 +923,6 @@ int config_parse_stacked_netdev(
         return 0;
 }
 
-int config_parse_timezone(
-                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) {
-
-        char **tz = ASSERT_PTR(data);
-        int r;
-
-        assert(filename);
-        assert(lvalue);
-        assert(rvalue);
-
-        if (isempty(rvalue)) {
-                *tz = mfree(*tz);
-                return 0;
-        }
-
-        r = verify_timezone(rvalue, LOG_WARNING);
-        if (r < 0) {
-                log_syntax(unit, LOG_WARNING, filename, line, r,
-                           "Timezone is not valid, ignoring assignment: %s", rvalue);
-                return 0;
-        }
-
-        return free_and_strdup_warn(tz, rvalue);
-}
-
 int config_parse_required_for_online(
                 const char *unit,
                 const char *filename,
index 9d82df00059bbfb33772c4a94b42c65c73fe63f3..dd938e525aa830663f4659816efe7b779538f0eb 100644 (file)
@@ -424,7 +424,6 @@ bool network_has_static_ipv6_configurations(Network *network);
 
 CONFIG_PARSER_PROTOTYPE(config_parse_stacked_netdev);
 CONFIG_PARSER_PROTOTYPE(config_parse_tunnel);
-CONFIG_PARSER_PROTOTYPE(config_parse_timezone);
 CONFIG_PARSER_PROTOTYPE(config_parse_required_for_online);
 CONFIG_PARSER_PROTOTYPE(config_parse_required_family_for_online);
 CONFIG_PARSER_PROTOTYPE(config_parse_keep_configuration);
index e2d3b65f88d22155562d3d52b9593b402f12f484..277f4ee42fd82b4e1e0cb5be1e64b8c029eef916 100644 (file)
@@ -1979,3 +1979,37 @@ int config_parse_unsigned_bounded(
 DEFINE_CONFIG_PARSE(config_parse_percent, parse_percent, "Failed to parse percent value");
 DEFINE_CONFIG_PARSE(config_parse_permyriad, parse_permyriad, "Failed to parse permyriad value");
 DEFINE_CONFIG_PARSE_PTR(config_parse_sec_fix_0, parse_sec_fix_0, usec_t, "Failed to parse time value");
+
+int config_parse_timezone(
+                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) {
+
+        char **tz = ASSERT_PTR(data);
+        int r;
+
+        assert(filename);
+        assert(lvalue);
+        assert(rvalue);
+
+        if (isempty(rvalue)) {
+                *tz = mfree(*tz);
+                return 0;
+        }
+
+        r = verify_timezone(rvalue, LOG_WARNING);
+        if (r < 0) {
+                log_syntax(unit, LOG_WARNING, filename, line, r,
+                           "Timezone is not valid, ignoring assignment: %s", rvalue);
+                return 0;
+        }
+
+        return free_and_strdup_warn(tz, rvalue);
+}
index 254d6cb70bc133e97c6a63a9760637eed003d5b6..35e203cb1271a2e20838fb6f57f565fe4709434d 100644 (file)
@@ -250,6 +250,7 @@ CONFIG_PARSER_PROTOTYPE(config_parse_percent);
 CONFIG_PARSER_PROTOTYPE(config_parse_permyriad);
 CONFIG_PARSER_PROTOTYPE(config_parse_pid);
 CONFIG_PARSER_PROTOTYPE(config_parse_sec_fix_0);
+CONFIG_PARSER_PROTOTYPE(config_parse_timezone);
 
 typedef enum Disabled {
         DISABLED_CONFIGURATION,