summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus/sd-bus.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-11-28 16:51:45 +0100
committerLennart Poettering <lennart@poettering.net>2014-11-28 20:29:43 +0100
commit5b820358cf2a5cb6d67cc0b1faaaca3b0171f1ac (patch)
tree91e4d6c1bbe2586c725b4de8d4308c5d6e0256a9 /src/libsystemd/sd-bus/sd-bus.c
parent5c3026927de9dfa60ad6ae8326fef5d7824e723e (diff)
sd-bus: add new sd_bus_get_address() for querying the current bus address
Also, update "busctl" to show this in its output.
Diffstat (limited to 'src/libsystemd/sd-bus/sd-bus.c')
-rw-r--r--src/libsystemd/sd-bus/sd-bus.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index 5947cd72c9..6b35036c06 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -3396,24 +3396,38 @@ _public_ int sd_bus_get_scope(sd_bus *bus, const char **scope) {
if (streq(n, "0-system")) {
*scope = "system";
- return 1;
+ return 0;
}
dash = strchr(n, '-');
if (streq(dash, "-user")) {
*scope = "user";
- return 1;
+ return 0;
}
}
if (bus->is_user) {
*scope = "user";
- return 1;
+ return 0;
}
if (bus->is_system) {
*scope = "system";
- return 1;
+ return 0;
+ }
+
+ return -ENODATA;
+}
+
+_public_ int sd_bus_get_address(sd_bus *bus, const char **address) {
+
+ assert_return(bus, -EINVAL);
+ assert_return(address, -EINVAL);
+ assert_return(!bus_pid_changed(bus), -ECHILD);
+
+ if (bus->address) {
+ *address = bus->address;
+ return 0;
}
return -ENODATA;