]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/bus-util: move string set append/get funcs to bus-message-util and bus-get...
authorMike Yuan <me@yhndnzj.com>
Sat, 11 Jan 2025 17:04:37 +0000 (18:04 +0100)
committerMike Yuan <me@yhndnzj.com>
Mon, 13 Jan 2025 15:55:42 +0000 (16:55 +0100)
src/core/dbus-cgroup.c
src/shared/bus-get-properties.c
src/shared/bus-get-properties.h
src/shared/bus-message-util.c
src/shared/bus-message-util.h
src/shared/bus-util.c
src/shared/bus-util.h

index fd48f3b07c9ca669419ba0544e5a2369acf73db4..c99f1e29ac1a4ad6c1d4c68d5b4869cf35c5c953 100644 (file)
@@ -7,6 +7,7 @@
 #include "bpf-firewall.h"
 #include "bpf-foreign.h"
 #include "bus-get-properties.h"
+#include "bus-message-util.h"
 #include "bus-util.h"
 #include "cgroup-util.h"
 #include "cgroup.h"
index 53e5d6b99f18715ad61f99e53260997bbad76937..bf267a23a550f281841c05f6e2d2e6b41e48213d 100644 (file)
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include "bus-get-properties.h"
+#include "bus-message-util.h"
 #include "rlimit-util.h"
 #include "stdio-util.h"
 #include "string-util.h"
@@ -164,3 +165,21 @@ int bus_property_get_rlimit(
 
         return sd_bus_message_append(reply, "t", u);
 }
+
+int bus_property_get_string_set(
+                sd_bus *bus,
+                const char *path,
+                const char *interface,
+                const char *property,
+                sd_bus_message *reply,
+                void *userdata,
+                sd_bus_error *error) {
+
+        Set **s = ASSERT_PTR(userdata);
+
+        assert(bus);
+        assert(property);
+        assert(reply);
+
+        return bus_message_append_string_set(reply, *s);
+}
index 4c351265028716708c3771523856bcfe931ca146..9ddf5454de6b7bc1f9aad6b33a66404706f328e0 100644 (file)
@@ -52,6 +52,8 @@ assert_cc(sizeof(mode_t) == sizeof(uint32_t));
 
 int bus_property_get_rlimit(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
 
+int bus_property_get_string_set(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
+
 #define BUS_DEFINE_PROPERTY_GET_GLOBAL(function, bus_type, val)         \
         int function(sd_bus *bus,                                       \
                      const char *path,                                  \
index a6523ff00e025e581bf8afac688e959b3c14d7dc..8da112caccb594fefbc96f1bf8dc59c5820db555 100644 (file)
@@ -216,6 +216,25 @@ clear:
         return r;
 }
 
+int bus_message_append_string_set(sd_bus_message *m, const Set *set) {
+        int r;
+
+        assert(m);
+
+        r = sd_bus_message_open_container(m, 'a', "s");
+        if (r < 0)
+                return r;
+
+        const char *s;
+        SET_FOREACH(s, set) {
+                r = sd_bus_message_append(m, "s", s);
+                if (r < 0)
+                        return r;
+        }
+
+        return sd_bus_message_close_container(m);
+}
+
 int bus_message_dump_string(sd_bus_message *message) {
         const char *s;
         int r;
index baec1cb92b784a1854d06650386bb225a6cbf50a..d4a05f5b9c28ae72e7a96b9a22a86e561351f403 100644 (file)
@@ -19,6 +19,8 @@ int bus_message_read_dns_servers(
                         struct in_addr_full ***ret_dns,
                         size_t *ret_n_dns);
 
+int bus_message_append_string_set(sd_bus_message *m, const Set *s);
+
 int bus_message_dump_string(sd_bus_message *message);
 int bus_message_dump_fd(sd_bus_message *message);
 
index 9e875751e719aaae9b67b995e3ac885f2b8f31bb..5c76346fc3198f75d0e32409847b23cc0950f75c 100644 (file)
@@ -862,43 +862,6 @@ int bus_register_malloc_status(sd_bus *bus, const char *destination) {
         return 0;
 }
 
-int bus_message_append_string_set(sd_bus_message *m, Set *set) {
-        const char *s;
-        int r;
-
-        assert(m);
-
-        r = sd_bus_message_open_container(m, 'a', "s");
-        if (r < 0)
-                return r;
-
-        SET_FOREACH(s, set) {
-                r = sd_bus_message_append(m, "s", s);
-                if (r < 0)
-                        return r;
-        }
-
-        return sd_bus_message_close_container(m);
-}
-
-int bus_property_get_string_set(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        Set **s = ASSERT_PTR(userdata);
-
-        assert(bus);
-        assert(property);
-        assert(reply);
-
-        return bus_message_append_string_set(reply, *s);
-}
-
 int bus_creds_get_pidref(
                 sd_bus_creds *c,
                 PidRef *ret) {
index 755421c11f51966002d00a6ebd4d085e3228a56f..47c0711868b50a07f5956d4a820d93b4de516bb8 100644 (file)
@@ -78,10 +78,6 @@ int bus_reply_pair_array(sd_bus_message *m, char **l);
 /* Listen to GetMallocInfo() calls to 'destination' and return malloc_info() via FD */
 int bus_register_malloc_status(sd_bus *bus, const char *destination);
 
-int bus_message_append_string_set(sd_bus_message *m, Set *s);
-
-int bus_property_get_string_set(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
-
 int bus_creds_get_pidref(sd_bus_creds *c, PidRef *ret);
 int bus_query_sender_pidref(sd_bus_message *m, PidRef *ret);