systemd/man/sd_bus_request_name.html
2014-07-11 02:23:25 +02:00

83 lines
9.4 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>sd_bus_request_name</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><style>
a.headerlink {
color: #c60f0f;
font-size: 0.8em;
padding: 0 4px 0 4px;
text-decoration: none;
visibility: hidden;
}
a.headerlink:hover {
background-color: #c60f0f;
color: white;
}
h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, dt:hover > a.headerlink {
visibility: visible;
}
</style><a href="index.html">Index </a>·
<a href="systemd.directives.html">Directives </a>·
<a href="../python-systemd/index.html">Python </a>·
<a href="../libudev/index.html">libudev </a>·
<a href="../libudev/index.html">gudev </a><span style="float:right">systemd 214</span><hr><div class="refentry"><a name="sd_bus_request_name"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>sd_bus_request_name, sd_bus_release_name — Request or release a well-known name on a bus</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;systemd/sd-bus.h&gt;</pre><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_bus_request_name</b>(</code></td><td>sd_bus *<var class="pdparam">bus</var>, </td></tr><tr><td> </td><td>const char *<var class="pdparam">name</var>, </td></tr><tr><td> </td><td>uint64_t <var class="pdparam">flags</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_bus_release_name</b>(</code></td><td>sd_bus *<var class="pdparam">bus</var>, </td></tr><tr><td> </td><td>const char *<var class="pdparam">name</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idm214183571808"></a><h2 id="Description">Description<a class="headerlink" title="Permalink to this headline" href="#Description"></a></h2><p><code class="function">sd_bus_request_name()</code> 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:</p><div class="variablelist"><dl class="variablelist"><dt id="SD_BUS_NAME_ALLOW_REPLACEMENT"><span class="term"><code class="varname">SD_BUS_NAME_ALLOW_REPLACEMENT</code></span><a class="headerlink" title="Permalink to this term" href="#SD_BUS_NAME_ALLOW_REPLACEMENT"></a></dt><dd><p>After acquiring the
name successfully, permit other peers
to take over the name when they try to
acquire it with the
<code class="varname">SD_BUS_NAME_REPLACE_EXISTING</code>
flag set. If
<code class="varname">SD_BUS_NAME_ALLOW_REPLACEMENT</code>
is not set on the original request,
such a request by other peers will be
denied.</p></dd><dt id="SD_BUS_NAME_REPLACE_EXISTING"><span class="term"><code class="varname">SD_BUS_NAME_REPLACE_EXISTING</code></span><a class="headerlink" title="Permalink to this term" href="#SD_BUS_NAME_REPLACE_EXISTING"></a></dt><dd><p>Take over the name
if it is already acquired by another
peer, and that other peer has permitted
takeover by setting
<code class="varname">SD_BUS_NAME_ALLOW_REPLACEMENT</code>
while acquiring it.</p></dd><dt id="SD_BUS_NAME_QUEUE"><span class="term"><code class="varname">SD_BUS_NAME_QUEUE</code></span><a class="headerlink" title="Permalink to this term" href="#SD_BUS_NAME_QUEUE"></a></dt><dd><p>Queue the acquisition
of the name when the name is already
taken.</p></dd></dl></div><p><code class="function">sd_bus_release_name()</code> releases
an acquired well-known name. It takes a bus connection
and a valid bus name as parameters.</p></div><div class="refsect1"><a name="idm214183800816"></a><h2 id="Return Value">Return Value<a class="headerlink" title="Permalink to this headline" href="#Return%20Value"></a></h2><p>On success, these calls return 0 or a positive
integer. On failure, these calls return a negative
errno-style error code.</p><p>If <code class="varname">SD_BUS_NAME_QUEUE</code> is
specified, <code class="function">sd_bus_request_name()</code>
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 "<code class="literal">NameOwnerChanged</code>"
signals to be notified when the name is successfully
acquired. <code class="function">sd_bus_request_name()</code>
returns &gt; 0 when the name has immediately been
acquired successfully.</p></div><div class="refsect1"><a name="idm214183114928"></a><h2 id="Errors">Errors<a class="headerlink" title="Permalink to this headline" href="#Errors"></a></h2><p>Returned errors may indicate the following problems:</p><div class="variablelist"><dl class="variablelist"><dt id="-EALREADY"><span class="term"><code class="varname">-EALREADY</code></span><a class="headerlink" title="Permalink to this term" href="#-EALREADY"></a></dt><dd><p>The caller already is
the owner of the specified
name.</p></dd><dt id="-EEXIST"><span class="term"><code class="varname">-EEXIST</code></span><a class="headerlink" title="Permalink to this term" href="#-EEXIST"></a></dt><dd><p>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.</p></dd><dt id="-ESRCH"><span class="term"><code class="varname">-ESRCH</code></span><a class="headerlink" title="Permalink to this term" href="#-ESRCH"></a></dt><dd><p>It was attempted to
release a name that is currently not
registered on the
bus.</p></dd><dt id="-EADDRINUSE"><span class="term"><code class="varname">-EADDRINUSE</code></span><a class="headerlink" title="Permalink to this term" href="#-EADDRINUSE"></a></dt><dd><p>It was attempted to
release a name that is owned by a
different peer on the
bus.</p></dd><dt id="-EINVAL"><span class="term"><code class="varname">-EINVAL</code></span><a class="headerlink" title="Permalink to this term" href="#-EINVAL"></a></dt><dd><p>A specified parameter
is invalid.</p></dd><dt id="-ENOTCONN"><span class="term"><code class="varname">-ENOTCONN</code></span><a class="headerlink" title="Permalink to this term" href="#-ENOTCONN"></a></dt><dd><p>The bus connection has
been disconnected.</p></dd><dt id="-ECHILD"><span class="term"><code class="varname">-ECHILD</code></span><a class="headerlink" title="Permalink to this term" href="#-ECHILD"></a></dt><dd><p>The bus connection has
been created in a different process
than the current one.</p></dd></dl></div></div><div class="refsect1"><a name="idm214182875920"></a><h2 id="Notes">Notes<a class="headerlink" title="Permalink to this headline" href="#Notes"></a></h2><p>The <code class="function">sd_bus_acquire_name()</code>
and <code class="function">sd_bus_release_name()</code>
interfaces are available as a shared library, which can
be compiled and linked to with the
<code class="constant">libsystemd</code> <a href="pkg-config.html"><span class="citerefentry"><span class="refentrytitle">pkg-config</span>(1)</span></a>
file.</p></div><div class="refsect1"><a name="idm214185727168"></a><h2 id="See Also">See Also<a class="headerlink" title="Permalink to this headline" href="#See%20Also"></a></h2><p>
<a href="systemd.html"><span class="citerefentry"><span class="refentrytitle">systemd</span>(1)</span></a>,
<a href="sd-bus.html"><span class="citerefentry"><span class="refentrytitle">sd-bus</span>(3)</span></a>,
<a href="sd_bus_new.html"><span class="citerefentry"><span class="refentrytitle">sd_bus_new</span>(3)</span></a>
</p></div></div></body></html>