chiark / gitweb /
shared: split out code for adding multiple names to sd_bus_track object
authorLennart Poettering <lennart@poettering.net>
Tue, 15 Nov 2016 18:18:36 +0000 (19:18 +0100)
committerSven Eden <yamakuzure@gmx.net>
Mon, 17 Jul 2017 15:58:35 +0000 (17:58 +0200)
Let's introduce a new call bus_track_add_name_many() that adds a string list to
a tracking object.

src/shared/bus-util.c
src/shared/bus-util.h

index 2d1b3b9654061bbc7fda308ffb0f880b987840de..0b77d3f85d411548b2fbe91ccd714721d000908b 100644 (file)
@@ -1600,3 +1600,22 @@ int bus_property_get_rlimit(
         return sd_bus_message_append(reply, "t", u);
 }
 #endif // 0
+
+int bus_track_add_name_many(sd_bus_track *t, char **l) {
+        int r = 0;
+        char **i;
+
+        assert(t);
+
+        /* Continues adding after failure, and returns the first failure. */
+
+        STRV_FOREACH(i, l) {
+                int k;
+
+                k = sd_bus_track_add_name(t, *i);
+                if (k < 0 && r >= 0)
+                        r = k;
+        }
+
+        return r;
+}
index 614f626e0ce27ab32ef67600701b18101c0390a2..38732b6312f0cf70a6b68a5417700e5778f4975e 100644 (file)
@@ -179,3 +179,5 @@ int bus_path_decode_unique(const char *path, const char *prefix, char **ret_send
 #if 0 /// UNNEEDED by elogind
 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);
 #endif // 0
+
+int bus_track_add_name_many(sd_bus_track *t, char **l);