1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2013 Lennart Poettering
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
28 #include "bus-internal.h"
29 #include "bus-message.h"
30 #include "bus-control.h"
32 int sd_bus_get_unique_name(sd_bus *bus, const char **unique) {
40 r = bus_ensure_running(bus);
44 *unique = bus->unique_name;
48 int sd_bus_request_name(sd_bus *bus, const char *name, int flags) {
49 _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
58 r = sd_bus_call_method(
60 "org.freedesktop.DBus",
62 "org.freedesktop.DBus",
72 r = sd_bus_message_read(reply, "u", &ret);
79 int sd_bus_release_name(sd_bus *bus, const char *name) {
80 _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
89 r = sd_bus_call_method(
91 "org.freedesktop.DBus",
93 "org.freedesktop.DBus",
102 r = sd_bus_message_read(reply, "u", &ret);
109 int sd_bus_list_names(sd_bus *bus, char ***l) {
110 _cleanup_bus_message_unref_ sd_bus_message *reply1 = NULL, *reply2 = NULL;
119 r = sd_bus_call_method(
121 "org.freedesktop.DBus",
123 "org.freedesktop.DBus",
131 r = sd_bus_call_method(
133 "org.freedesktop.DBus",
135 "org.freedesktop.DBus",
136 "ListActivatableNames",
143 r = bus_message_read_strv_extend(reply1, &x);
149 r = bus_message_read_strv_extend(reply2, &x);
159 int sd_bus_get_owner(sd_bus *bus, const char *name, char **owner) {
160 _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
169 r = sd_bus_call_method(
171 "org.freedesktop.DBus",
173 "org.freedesktop.DBus",
182 r = sd_bus_message_read(reply, "s", &found);
199 int sd_bus_get_owner_uid(sd_bus *bus, const char *name, uid_t *uid) {
200 _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
211 r = sd_bus_call_method(
213 "org.freedesktop.DBus",
215 "org.freedesktop.DBus",
216 "GetConnectionUnixUser",
224 r = sd_bus_message_read(reply, "u", &u);
232 int sd_bus_get_owner_pid(sd_bus *bus, const char *name, pid_t *pid) {
233 _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
244 r = sd_bus_call_method(
246 "org.freedesktop.DBus",
248 "org.freedesktop.DBus",
249 "GetConnectionUnixProcessID",
257 r = sd_bus_message_read(reply, "u", &u);
268 int bus_add_match_internal(sd_bus *bus, const char *match) {
272 return sd_bus_call_method(
274 "org.freedesktop.DBus",
276 "org.freedesktop.DBus",
284 int bus_remove_match_internal(sd_bus *bus, const char *match) {
288 return sd_bus_call_method(
290 "org.freedesktop.DBus",
292 "org.freedesktop.DBus",