]>
Commit | Line | Data |
---|---|---|
e7176abb LP |
1 | <?xml version='1.0'?> <!--*-nxml-*--> |
2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" | |
681eb9cf FB |
3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [ |
4 | <!ENTITY % entities SYSTEM "custom-entities.ent" > | |
5 | %entities; | |
6 | ]> | |
e7176abb LP |
7 | |
8 | <!-- | |
9 | This file is part of systemd. | |
10 | ||
11 | Copyright 2013 Lennart Poettering | |
12 | ||
13 | systemd is free software; you can redistribute it and/or modify it | |
14 | under the terms of the GNU Lesser General Public License as published by | |
15 | the Free Software Foundation; either version 2.1 of the License, or | |
16 | (at your option) any later version. | |
17 | ||
18 | systemd is distributed in the hope that it will be useful, but | |
19 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
21 | Lesser General Public License for more details. | |
22 | ||
23 | You should have received a copy of the GNU Lesser General Public License | |
24 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
25 | --> | |
26 | ||
48f69d8f | 27 | <refentry id="sd_bus_request_name"> |
e7176abb | 28 | |
798d3a52 ZJS |
29 | <refentryinfo> |
30 | <title>sd_bus_request_name</title> | |
31 | <productname>systemd</productname> | |
32 | ||
33 | <authorgroup> | |
34 | <author> | |
35 | <contrib>Developer</contrib> | |
36 | <firstname>Lennart</firstname> | |
37 | <surname>Poettering</surname> | |
38 | <email>lennart@poettering.net</email> | |
39 | </author> | |
40 | </authorgroup> | |
41 | </refentryinfo> | |
42 | ||
43 | <refmeta> | |
44 | <refentrytitle>sd_bus_request_name</refentrytitle> | |
45 | <manvolnum>3</manvolnum> | |
46 | </refmeta> | |
47 | ||
48 | <refnamediv> | |
49 | <refname>sd_bus_request_name</refname> | |
50 | <refname>sd_bus_release_name</refname> | |
51 | <refpurpose>Request or release a well-known name on a bus</refpurpose> | |
52 | </refnamediv> | |
53 | ||
54 | <refsynopsisdiv> | |
55 | <funcsynopsis> | |
56 | <funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo> | |
57 | ||
58 | <funcprototype> | |
59 | <funcdef>int <function>sd_bus_request_name</function></funcdef> | |
60 | <paramdef>sd_bus *<parameter>bus</parameter></paramdef> | |
61 | <paramdef>const char *<parameter>name</parameter></paramdef> | |
62 | <paramdef>uint64_t <parameter>flags</parameter></paramdef> | |
63 | </funcprototype> | |
64 | ||
65 | <funcprototype> | |
66 | <funcdef>int <function>sd_bus_release_name</function></funcdef> | |
67 | <paramdef>sd_bus *<parameter>bus</parameter></paramdef> | |
68 | <paramdef>const char *<parameter>name</parameter></paramdef> | |
69 | </funcprototype> | |
70 | </funcsynopsis> | |
71 | </refsynopsisdiv> | |
72 | ||
73 | <refsect1> | |
74 | <title>Description</title> | |
75 | ||
76 | <para><function>sd_bus_request_name()</function> requests a | |
77 | well-known name on a bus. It takes a bus connection, a valid bus | |
78 | name and a flags parameter. The flags parameter is a combination | |
79 | of the following flags:</para> | |
80 | ||
81 | <variablelist> | |
82 | <varlistentry> | |
83 | <term><varname>SD_BUS_NAME_ALLOW_REPLACEMENT</varname></term> | |
84 | ||
85 | <listitem><para>After acquiring the name successfully, permit | |
86 | other peers to take over the name when they try to acquire it | |
87 | with the <varname>SD_BUS_NAME_REPLACE_EXISTING</varname> flag | |
88 | set. If <varname>SD_BUS_NAME_ALLOW_REPLACEMENT</varname> is | |
89 | not set on the original request, such a request by other peers | |
90 | will be denied.</para></listitem> | |
91 | </varlistentry> | |
92 | ||
93 | <varlistentry> | |
94 | <term><varname>SD_BUS_NAME_REPLACE_EXISTING</varname></term> | |
95 | ||
96 | <listitem><para>Take over the name if it is already acquired | |
97 | by another peer, and that other peer has permitted takeover by | |
98 | setting <varname>SD_BUS_NAME_ALLOW_REPLACEMENT</varname> while | |
99 | acquiring it.</para></listitem> | |
100 | </varlistentry> | |
101 | ||
102 | <varlistentry> | |
103 | <term><varname>SD_BUS_NAME_QUEUE</varname></term> | |
104 | ||
105 | <listitem><para>Queue the acquisition of the name when the | |
106 | name is already taken.</para></listitem> | |
107 | </varlistentry> | |
108 | </variablelist> | |
109 | ||
110 | <para><function>sd_bus_release_name()</function> releases an | |
111 | acquired well-known name. It takes a bus connection and a valid | |
112 | bus name as parameters.</para> | |
113 | </refsect1> | |
114 | ||
115 | <refsect1> | |
116 | <title>Return Value</title> | |
117 | ||
118 | <para>On success, these calls return 0 or a positive integer. On | |
119 | failure, these calls return a negative errno-style error | |
120 | code.</para> | |
121 | ||
122 | <para>If <varname>SD_BUS_NAME_QUEUE</varname> is specified, | |
123 | <function>sd_bus_request_name()</function> will return 0 when the | |
124 | name is already taken by another peer and the client has been | |
125 | added to the queue for the name. In that case, the caller can | |
126 | subscribe to <literal>NameOwnerChanged</literal> signals to be | |
127 | notified when the name is successfully acquired. | |
128 | <function>sd_bus_request_name()</function> returns > 0 when the | |
129 | name has immediately been acquired successfully.</para> | |
130 | </refsect1> | |
131 | ||
132 | <refsect1> | |
133 | <title>Errors</title> | |
134 | ||
135 | <para>Returned errors may indicate the following problems:</para> | |
136 | ||
137 | <variablelist> | |
138 | <varlistentry> | |
139 | <term><constant>-EALREADY</constant></term> | |
140 | ||
141 | <listitem><para>The caller already is the owner of the | |
142 | specified name.</para></listitem> | |
143 | </varlistentry> | |
144 | ||
145 | <varlistentry> | |
146 | <term><constant>-EEXIST</constant></term> | |
147 | ||
148 | <listitem><para>The name has already been acquired by a | |
149 | different peer, and SD_BUS_NAME_REPLACE_EXISTING was not | |
150 | specified or the other peer did not specify | |
151 | SD_BUS_NAME_ALLOW_REPLACEMENT while acquiring the | |
152 | name.</para></listitem> | |
153 | </varlistentry> | |
154 | ||
155 | <varlistentry> | |
156 | <term><constant>-ESRCH</constant></term> | |
157 | ||
158 | <listitem><para>It was attempted to release a name that is | |
159 | currently not registered on the bus.</para></listitem> | |
160 | </varlistentry> | |
161 | ||
162 | <varlistentry> | |
163 | <term><constant>-EADDRINUSE</constant></term> | |
164 | ||
165 | <listitem><para>It was attempted to release a name that is | |
166 | owned by a different peer on the bus.</para></listitem> | |
167 | </varlistentry> | |
168 | ||
169 | <varlistentry> | |
170 | <term><constant>-EINVAL</constant></term> | |
171 | ||
172 | <listitem><para>A specified parameter is | |
173 | invalid.</para></listitem> | |
174 | </varlistentry> | |
175 | ||
176 | <varlistentry> | |
177 | <term><constant>-ENOTCONN</constant></term> | |
178 | ||
179 | <listitem><para>The bus connection has been | |
180 | disconnected.</para></listitem> | |
181 | </varlistentry> | |
182 | ||
183 | <varlistentry> | |
184 | <term><constant>-ECHILD</constant></term> | |
185 | ||
186 | <listitem><para>The bus connection has been created in a | |
187 | different process than the current one.</para></listitem> | |
188 | </varlistentry> | |
189 | </variablelist> | |
190 | </refsect1> | |
191 | ||
192 | <refsect1> | |
193 | <title>Notes</title> | |
194 | ||
195 | <para>The <function>sd_bus_acquire_name()</function> and | |
196 | <function>sd_bus_release_name()</function> interfaces are | |
197 | available as a shared library, which can be compiled and linked to | |
198 | with the | |
199 | <constant>libsystemd</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry> | |
200 | file.</para> | |
201 | </refsect1> | |
202 | ||
203 | <refsect1> | |
204 | <title>See Also</title> | |
205 | ||
206 | <para> | |
207 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
208 | <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
209 | <citerefentry><refentrytitle>sd_bus_new</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
210 | </para> | |
211 | </refsect1> | |
e7176abb LP |
212 | |
213 | </refentry> |