2013-12-03 21:01:26 +04:00
<?xml version='1.0'?> <!-- * - nxml - * -->
< !DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!--
This file is part of systemd.
Copyright 2013 Lennart Poettering
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http: / / w w w . g n u . o r g / l i c e n s e s /> .
-->
2014-02-20 01:04:30 +04:00
<refentry id= "sd_bus_request_name" conditional= "ENABLE_KDBUS" >
2013-12-03 21:01:26 +04:00
<refentryinfo >
<title > sd_bus_request_name</title>
<productname > systemd</productname>
<authorgroup >
<author >
<contrib > Developer</contrib>
<firstname > Lennart</firstname>
<surname > Poettering</surname>
<email > lennart@poettering.net</email>
</author>
</authorgroup>
</refentryinfo>
<refmeta >
<refentrytitle > sd_bus_request_name</refentrytitle>
<manvolnum > 3</manvolnum>
</refmeta>
<refnamediv >
<refname > sd_bus_request_name</refname>
<refname > sd_bus_release_name</refname>
<refpurpose > Request or release a well-known name on a bus</refpurpose>
</refnamediv>
<refsynopsisdiv >
<funcsynopsis >
<funcsynopsisinfo > #include < systemd/sd-bus.h> </funcsynopsisinfo>
<funcprototype >
<funcdef > int <function > sd_bus_request_name</function> </funcdef>
2014-05-08 03:28:46 +04:00
<paramdef > sd_bus *<parameter > bus</parameter> </paramdef>
2013-12-03 21:01:26 +04:00
<paramdef > const char *<parameter > name</parameter> </paramdef>
2013-12-13 19:01:54 +04:00
<paramdef > uint64_t <parameter > flags</parameter> </paramdef>
2013-12-03 21:01:26 +04:00
</funcprototype>
<funcprototype >
<funcdef > int <function > sd_bus_release_name</function> </funcdef>
2014-05-08 03:28:46 +04:00
<paramdef > sd_bus *<parameter > bus</parameter> </paramdef>
2013-12-03 21:01:26 +04:00
<paramdef > const char *<parameter > name</parameter> </paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1 >
<title > Description</title>
<para > <function > sd_bus_request_name()</function> requests
a well-known name on a bus. It takes a bus connection,
a valid bus name and a flags parameter. The flags
parameter is a combination of the following
flags:</para>
<variablelist >
<varlistentry >
<term > <varname > SD_BUS_NAME_ALLOW_REPLACEMENT</varname> </term>
<listitem > <para > After acquiring the
2013-12-26 05:47:45 +04:00
name successfully, permit other peers
2013-12-03 21:01:26 +04:00
to take over the name when they try to
acquire it with the
<varname > SD_BUS_NAME_REPLACE_EXISTING</varname>
flag set. If
<varname > SD_BUS_NAME_ALLOW_REPLACEMENT</varname>
2013-12-26 05:47:44 +04:00
is not set on the original request,
2013-12-03 21:01:26 +04:00
such a request by other peers will be
denied.</para> </listitem>
</varlistentry>
<varlistentry >
<term > <varname > SD_BUS_NAME_REPLACE_EXISTING</varname> </term>
2013-12-26 05:47:45 +04:00
<listitem > <para > Take over the name
if it is already acquired by another
peer, and that other peer has permitted
takeover by setting
2013-12-03 21:01:26 +04:00
<varname > SD_BUS_NAME_ALLOW_REPLACEMENT</varname>
while acquiring it.</para> </listitem>
</varlistentry>
<varlistentry >
2013-12-13 01:01:40 +04:00
<term > <varname > SD_BUS_NAME_QUEUE</varname> </term>
2013-12-03 21:01:26 +04:00
2013-12-26 05:47:45 +04:00
<listitem > <para > Queue the acquisition
of the name when the name is already
2013-12-03 21:01:26 +04:00
taken.</para> </listitem>
</varlistentry>
</variablelist>
<para > <function > sd_bus_release_name()</function> releases
an acquired well-known name. It takes a bus connection
and a valid bus name as parameters.</para>
</refsect1>
<refsect1 >
<title > Return Value</title>
<para > On success, these calls return 0 or a positive
integer. On failure, these calls return a negative
errno-style error code.</para>
2013-12-13 01:01:40 +04:00
<para > If <varname > SD_BUS_NAME_QUEUE</varname> is
2013-12-26 05:47:44 +04:00
specified, <function > sd_bus_request_name()</function>
2013-12-13 01:01:40 +04:00
will return 0 when the name is already taken by
another peer and the client has been added to the
2013-12-26 05:47:44 +04:00
queue for the name. In that case, the caller can
2013-12-13 01:01:40 +04:00
subscribe to <literal > NameOwnerChanged</literal>
signals to be notified when the name is successfully
acquired. <function > sd_bus_request_name()</function>
returns > 0 when the name has immediately been
2013-12-03 21:01:26 +04:00
acquired successfully.</para>
</refsect1>
<refsect1 >
<title > Errors</title>
<para > Returned errors may indicate the following problems:</para>
<variablelist >
<varlistentry >
<term > <varname > -EALREADY</varname> </term>
<listitem > <para > The caller already is
the owner of the specified
name.</para> </listitem>
</varlistentry>
<varlistentry >
<term > <varname > -EEXIST</varname> </term>
<listitem > <para > The name has already
been acquired by a different peer, and
SD_BUS_NAME_REPLACE_EXISTING was not
specified or the other peer did not
specify SD_BUS_NAME_ALLOW_REPLACEMENT
while acquiring the
name.</para> </listitem>
2013-12-13 19:01:54 +04:00
</varlistentry>
<varlistentry >
<term > <varname > -ESRCH</varname> </term>
2013-12-26 05:47:45 +04:00
<listitem > <para > It was attempted to
2013-12-13 19:01:54 +04:00
release a name that is currently not
registered on the
bus.</para> </listitem>
</varlistentry>
<varlistentry >
<term > <varname > -EADDRINUSE</varname> </term>
2013-12-26 05:47:45 +04:00
<listitem > <para > It was attempted to
2013-12-13 19:01:54 +04:00
release a name that is owned by a
different peer on the
bus.</para> </listitem>
2013-12-03 21:01:26 +04:00
</varlistentry>
<varlistentry >
<term > <varname > -EINVAL</varname> </term>
<listitem > <para > A specified parameter
is invalid.</para> </listitem>
</varlistentry>
<varlistentry >
<term > <varname > -ENOTCONN</varname> </term>
<listitem > <para > The bus connection has
been disconnected.</para> </listitem>
</varlistentry>
<varlistentry >
<term > <varname > -ECHILD</varname> </term>
<listitem > <para > The bus connection has
been created in a different process
2013-12-26 05:47:45 +04:00
than the current one.</para> </listitem>
2013-12-03 21:01:26 +04:00
</varlistentry>
</variablelist>
</refsect1>
<refsect1 >
<title > Notes</title>
<para > The <function > sd_bus_acquire_name()</function>
2013-12-25 21:03:05 +04:00
and <function > sd_bus_release_name()</function>
2013-12-26 05:47:43 +04:00
interfaces are available as a shared library, which can
2013-12-03 21:01:26 +04:00
be compiled and linked to with the
2014-01-13 20:30:51 +04:00
<constant > libsystemd</constant> <citerefentry > <refentrytitle > pkg-config</refentrytitle> <manvolnum > 1</manvolnum> </citerefentry>
2013-12-03 21:01:26 +04:00
file.</para>
</refsect1>
<refsect1 >
<title > See Also</title>
<para >
<citerefentry > <refentrytitle > systemd</refentrytitle> <manvolnum > 1</manvolnum> </citerefentry> ,
<citerefentry > <refentrytitle > sd-bus</refentrytitle> <manvolnum > 3</manvolnum> </citerefentry> ,
<citerefentry > <refentrytitle > sd_bus_new</refentrytitle> <manvolnum > 3</manvolnum> </citerefentry>
</para>
</refsect1>
</refentry>