diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-11-19 01:23:08 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-11-20 19:37:02 +0100 |
commit | 911121a7c837040454c5d0422e2a225a8d799eef (patch) | |
tree | 7347fbd3ecd0abf1eb6fcbd7319910f98bb73210 /src/libsystemd-bus/sd-bus.c | |
parent | aea93debfa1281a7d5f1523225b043955c1c2472 (diff) |
bus: add sd_bus_send_to() API call
Diffstat (limited to 'src/libsystemd-bus/sd-bus.c')
-rw-r--r-- | src/libsystemd-bus/sd-bus.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/libsystemd-bus/sd-bus.c b/src/libsystemd-bus/sd-bus.c index 0be5a29f36..c8248e19aa 100644 --- a/src/libsystemd-bus/sd-bus.c +++ b/src/libsystemd-bus/sd-bus.c @@ -1435,6 +1435,27 @@ _public_ int sd_bus_send(sd_bus *bus, sd_bus_message *m, uint64_t *serial) { return 1; } +_public_ int sd_bus_send_to(sd_bus *bus, sd_bus_message *m, const char *destination, uint64_t *serial) { + int r; + + assert_return(bus, -EINVAL); + assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); + assert_return(m, -EINVAL); + assert_return(!bus_pid_changed(bus), -ECHILD); + + if (!streq_ptr(m->destination, destination)) { + + if (!destination) + return -EEXIST; + + r = sd_bus_message_set_destination(m, destination); + if (r < 0) + return r; + } + + return sd_bus_send(bus, m, serial); +} + static usec_t calc_elapse(uint64_t usec) { if (usec == (uint64_t) -1) return 0; |