summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-10-11 23:02:47 +0200
committerLennart Poettering <lennart@poettering.net>2013-10-11 23:02:47 +0200
commit55736ed0c7ead8c93f2156f751399326a4656055 (patch)
tree4ce923ee6af7db4d9366078ae43f0b3620cbb050 /src/libsystemd-bus
parentf11ca85a897c770c10bf5aef79b31e955bcb3c13 (diff)
bus: add sd_bus_message_append_strv() to easily add a NULL terminated string array to a message
Diffstat (limited to 'src/libsystemd-bus')
-rw-r--r--src/libsystemd-bus/bus-message.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/src/libsystemd-bus/bus-message.c b/src/libsystemd-bus/bus-message.c
index 264a2f63f1..18c2d1c19d 100644
--- a/src/libsystemd-bus/bus-message.c
+++ b/src/libsystemd-bus/bus-message.c
@@ -2304,14 +2304,10 @@ int sd_bus_message_append_string_memfd(sd_bus_message *m, sd_memfd *memfd) {
void *a;
int r;
- if (!m)
- return -EINVAL;
- if (!memfd)
- return -EINVAL;
- if (m->sealed)
- return -EPERM;
- if (m->poisoned)
- return -ESTALE;
+ assert_return(m, -EINVAL);
+ assert_return(memfd, -EINVAL);
+ assert_return(!m->sealed, -EPERM);
+ assert_return(!m->poisoned, -ESTALE);
r = sd_memfd_set_sealed(memfd, true);
if (r < 0)
@@ -2376,6 +2372,27 @@ int sd_bus_message_append_string_memfd(sd_bus_message *m, sd_memfd *memfd) {
return 0;
}
+int sd_bus_message_append_strv(sd_bus_message *m, char **l) {
+ char **i;
+ int r;
+
+ assert_return(m, -EINVAL);
+ assert_return(!m->sealed, -EPERM);
+ assert_return(!m->poisoned, -ESTALE);
+
+ r = sd_bus_message_open_container(m, 'a', "s");
+ if (r < 0)
+ return r;
+
+ STRV_FOREACH(i, l) {
+ r = sd_bus_message_append_basic(m, 's', *i);
+ if (r < 0)
+ return r;
+ }
+
+ return sd_bus_message_close_container(m);
+}
+
int bus_body_part_map(struct bus_body_part *part) {
void *p;
size_t psz;