#include <systemd/sd-bus.h>
sd_bus_request_name()
SD_BUS_NAME_ALLOW_REPLACEMENT
SD_BUS_NAME_REPLACE_EXISTING
SD_BUS_NAME_QUEUE
sd_bus_request_name() operates in a synchronous fashion: a message requesting the name is sent to the bus broker, and the call waits until the broker responds.
sd_bus_request_name_async() is an asynchronous version of sd_bus_request_name(). Instead of waiting for the request to complete, the request message is enqueued. The specified callback will be called when the broker's response is received. If the parameter is specified as NULL a default implementation is used instead which will terminate the connection when the name cannot be acquired. The function returns a slot object in its slot parameter --- if it is passed as non-NULL --- which may be used as a reference to the name request operation. Use sd_bus_slot_unref(3) to destroy this reference. Note that destroying the reference will not unregister the name, but simply ensure the specified callback is no longer called.
sd_bus_release_name() releases an acquired well-known name. It takes a bus connection and a valid bus name as parameters. This function operates synchronously, sending a release request message to the bus broker and waiting for it to reply.
sd_bus_release_name_async() is an asynchronous version of sd_bus_release_name(). The specified callback function is called when the name has been released successfully. If specified as NULL a generic implementation is used that ignores the result of the operation. As above, the slot (if non-NULL) is set to an object that may be used to reference the operation.
These functions are supported only on bus connections, i.e. connections to a bus broker and not on direct connections.
On success, these calls return 0 or a positive integer. On failure, these calls return a negative errno-style error code.
If SD_BUS_NAME_QUEUE is specified, sd_bus_request_name() will return 0 when the name is already taken by another peer and the client has been added to the queue for the name. In that case, the caller can subscribe to "NameOwnerChanged" signals to be notified when the name is successfully acquired. sd_bus_request_name() returns > 0 when the name has immediately been acquired successfully.
Returned errors may indicate the following problems:
-EALREADY
-EEXIST
-ESRCH
-EADDRINUSE
-EINVAL
-ENOTCONN
-ECHILD
These APIs are implemented as a shared library, which can be compiled and linked to with the libsystemd pkg-config(1) file.
systemd(1), sd-bus(3), sd_bus_new(3), sd_bus_slot_unref(3)