]>
Commit | Line | Data |
---|---|---|
514094f9 | 1 | <?xml version='1.0'?> |
3a54a157 ZJS |
2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" |
3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> | |
0307f791 | 4 | <!-- SPDX-License-Identifier: LGPL-2.1+ --> |
ecddb2b5 | 5 | |
7d6b2723 | 6 | <refentry id="sd_bus_track_add_name" xmlns:xi="http://www.w3.org/2001/XInclude"> |
ecddb2b5 LP |
7 | |
8 | <refentryinfo> | |
9 | <title>sd_bus_track_add_name</title> | |
10 | <productname>systemd</productname> | |
ecddb2b5 LP |
11 | </refentryinfo> |
12 | ||
13 | <refmeta> | |
14 | <refentrytitle>sd_bus_track_add_name</refentrytitle> | |
15 | <manvolnum>3</manvolnum> | |
16 | </refmeta> | |
17 | ||
18 | <refnamediv> | |
19 | <refname>sd_bus_track_add_name</refname> | |
20 | <refname>sd_bus_track_add_sender</refname> | |
21 | <refname>sd_bus_track_remove_name</refname> | |
22 | <refname>sd_bus_track_remove_sender</refname> | |
23 | <refname>sd_bus_track_count</refname> | |
24 | <refname>sd_bus_track_count_sender</refname> | |
25 | <refname>sd_bus_track_count_name</refname> | |
26 | <refname>sd_bus_track_contains</refname> | |
27 | <refname>sd_bus_track_first</refname> | |
28 | <refname>sd_bus_track_next</refname> | |
29 | ||
30 | <refpurpose>Add, remove and retrieve bus peers tracked in a bus peer tracking object</refpurpose> | |
31 | </refnamediv> | |
32 | ||
33 | <refsynopsisdiv> | |
34 | <funcsynopsis> | |
35 | <funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo> | |
36 | ||
37 | <funcprototype> | |
38 | <funcdef>int <function>sd_bus_track_add_name</function></funcdef> | |
39 | <paramdef>sd_bus_track* <parameter>t</parameter></paramdef> | |
40 | <paramdef>const char* <parameter>name</parameter></paramdef> | |
41 | </funcprototype> | |
42 | ||
43 | <funcprototype> | |
44 | <funcdef>int <function>sd_bus_track_add_sender</function></funcdef> | |
45 | <paramdef>sd_bus_track* <parameter>t</parameter></paramdef> | |
46 | <paramdef>sd_bus_message* <parameter>message</parameter></paramdef> | |
47 | </funcprototype> | |
48 | ||
49 | <funcprototype> | |
50 | <funcdef>int <function>sd_bus_track_remove_name</function></funcdef> | |
51 | <paramdef>sd_bus_track* <parameter>t</parameter></paramdef> | |
52 | <paramdef>const char* <parameter>name</parameter></paramdef> | |
53 | </funcprototype> | |
54 | ||
55 | <funcprototype> | |
56 | <funcdef>int <function>sd_bus_track_remove_sender</function></funcdef> | |
57 | <paramdef>sd_bus_track* <parameter>t</parameter></paramdef> | |
58 | <paramdef>sd_bus_message* <parameter>message</parameter></paramdef> | |
59 | </funcprototype> | |
60 | ||
61 | <funcprototype> | |
62 | <funcdef>unsigned <function>sd_bus_track_count</function></funcdef> | |
63 | <paramdef>sd_bus_track* <parameter>t</parameter></paramdef> | |
64 | </funcprototype> | |
65 | ||
66 | <funcprototype> | |
67 | <funcdef>int <function>sd_bus_track_count_name</function></funcdef> | |
68 | <paramdef>sd_bus_track* <parameter>t</parameter></paramdef> | |
69 | <paramdef>const char* <parameter>name</parameter></paramdef> | |
70 | </funcprototype> | |
71 | ||
72 | <funcprototype> | |
73 | <funcdef>int <function>sd_bus_track_count_sender</function></funcdef> | |
74 | <paramdef>sd_bus_track* <parameter>t</parameter></paramdef> | |
75 | <paramdef>sd_bus_message* <parameter>message</parameter></paramdef> | |
76 | </funcprototype> | |
77 | ||
78 | <funcprototype> | |
79 | <funcdef>int <function>sd_bus_track_contains</function></funcdef> | |
80 | <paramdef>sd_bus_track* <parameter>t</parameter></paramdef> | |
81 | <paramdef>const char* <parameter>name</parameter></paramdef> | |
82 | </funcprototype> | |
83 | ||
84 | <funcprototype> | |
85 | <funcdef>const char* <function>sd_bus_track_first</function></funcdef> | |
86 | <paramdef>sd_bus_track* <parameter>t</parameter></paramdef> | |
87 | </funcprototype> | |
88 | ||
89 | <funcprototype> | |
90 | <funcdef>const char* <function>sd_bus_track_next</function></funcdef> | |
91 | <paramdef>sd_bus_track* <parameter>t</parameter></paramdef> | |
92 | </funcprototype> | |
93 | ||
94 | </funcsynopsis> | |
95 | </refsynopsisdiv> | |
96 | ||
97 | <refsect1> | |
98 | <title>Description</title> | |
99 | ||
100 | <para><function>sd_bus_track_add_name()</function> adds a peer to track to a bus peer tracking object. The first | |
101 | argument should refer to a bus peer tracking object created with | |
102 | <citerefentry><refentrytitle>sd_bus_track_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>, the second | |
103 | name should refer to a D-Bus peer name to track, either in unique or well-known service format. If the name is not | |
104 | tracked yet it will be added to the list of names to track. If it already is being tracked and non-recursive mode | |
105 | is enabled, no operation is executed by this call. If recursive mode is enabled a per-name counter is increased by | |
106 | one each time this call is invoked, and <function>sd_bus_track_remove_name()</function> has to be called as many | |
107 | times as <function>sd_bus_track_add_name()</function> was invoked before in order to stop tracking of the name. Use | |
108 | <citerefentry><refentrytitle>sd_bus_track_set_recursive</refentrytitle><manvolnum>3</manvolnum></citerefentry> to | |
109 | switch from the default non-recursive mode to recursive mode, or back. Note that the specified name is tracked as | |
110 | it is, well-known names are not resolved to unique names by this call. Note that multiple bus peer tracking objects | |
111 | may track the same name.</para> | |
112 | ||
113 | <para><function>sd_bus_track_remove_name()</function> undoes the effect of | |
114 | <function>sd_bus_track_add_name()</function> and removes a bus peer name from the list of peers to watch. Depending | |
115 | on whether non-recursive or recursive mode is enabled for the bus peer tracking object this call will either remove | |
116 | the name fully from the tracking object, or will simply decrement the per-name counter by one, removing the name | |
117 | only when the counter reaches zero (see above). Note that a bus peer disconnecting from the bus will implicitly | |
118 | remove its names fully from the bus peer tracking object, regardless of the current per-name counter.</para> | |
119 | ||
120 | <para><function>sd_bus_track_add_sender()</function> and <function>sd_bus_track_remove_sender()</function> are | |
121 | similar to <function>sd_bus_track_add_name()</function> and <function>sd_bus_track_remove_name()</function> but | |
122 | take a bus message as argument. The sender of this bus message is determined and added to/removed from the bus peer | |
123 | tracking object. As messages always originate from unique names, and never from well-known names this means that | |
124 | this call will effectively only add unique names to the bus peer tracking object.</para> | |
125 | ||
126 | <para><function>sd_bus_track_count()</function> returns the number of names currently being tracked by the | |
127 | specified bus peer tracking object. Note that this function always returns the actual number of names tracked, and | |
128 | hence if <function>sd_bus_track_add_name()</function> has been invoked multiple times for the same name it is only | |
129 | counted as one, regardless if recursive mode is used or not.</para> | |
130 | ||
131 | <para><function>sd_bus_track_count_name()</function> returns the current per-name counter for the specified | |
132 | name. If non-recursive mode is used this returns either 1 or 0, depending on whether the specified name has been | |
133 | added to the tracking object before, or not. If recursive mode has been enabled, values larger than 1 may be | |
134 | returned too, in case <function>sd_bus_track_add_name()</function> has been called multiple times for the same | |
135 | name.</para> | |
136 | ||
137 | <para><function>sd_bus_track_count_sender()</function> is similar to | |
138 | <function>sd_bus_track_count_name()</function>, but takes a bus message object and returns the per-name counter | |
139 | matching the sender of the message.</para> | |
140 | ||
141 | <para><function>sd_bus_track_contains()</function> may be used to determine whether the specified name has been | |
142 | added at least once to the specified bus peer tracking object.</para> | |
143 | ||
144 | <para><function>sd_bus_track_first()</function> and <function>sd_bus_track_next()</function> may be used to | |
145 | enumerate all names currently being tracked by the passed bus peer tracking | |
146 | object. <function>sd_bus_track_first()</function> returns the first entry in the object, and resets an internally | |
147 | maintained read index. Each subsequent invocation of <function>sd_bus_track_next()</function> returns the next name | |
148 | contained in the bus object. If the end is reached <constant>NULL</constant> is returned. If no names have been | |
149 | added to the object yet <function>sd_bus_track_first()</function> will return <constant>NULL</constant> | |
150 | immediately. The order in which names are returned is undefined; in particular which name is considered the first | |
151 | returned is not defined. If recursive mode is enabled and the same name has been added multiple times to the bus | |
152 | peer tracking object it is only returned once by this enumeration. If new names are added to or existing names | |
153 | removed from the bus peer tracking object while it is being enumerated the enumeration ends on the next invocation | |
154 | of <function>sd_bus_track_next()</function> as <constant>NULL</constant> is returned.</para> | |
155 | </refsect1> | |
156 | ||
157 | <refsect1> | |
158 | <title>Return Value</title> | |
159 | ||
160 | <para>On success, <function>sd_bus_track_add_name()</function> and <function>sd_bus_track_add_sender()</function> | |
161 | return 0 if the specified name has already been added to the bus peer tracking object before and positive if it | |
162 | hasn't. On failure, they return a negative errno-style error code.</para> | |
163 | ||
164 | <para><function>sd_bus_track_remove_name()</function> and <function>sd_bus_track_remove_sender()</function> return | |
165 | positive if the specified name was previously tracked by the bus peer tracking object and has now been removed. In | |
166 | non-recursive mode, 0 is returned if the specified name was not being tracked yet. In recursive mode | |
167 | <constant>-EUNATCH</constant> is returned in this case. On failure, they return a negative errno-style error | |
168 | code.</para> | |
169 | ||
170 | <para><function>sd_bus_track_count()</function> returns the number of names currently being tracked, or 0 on | |
171 | failure.</para> | |
172 | ||
173 | <para><function>sd_bus_track_count_name()</function> and <function>sd_bus_track_count_sender()</function> return | |
174 | the current per-name counter for the specified name or the sender of the specified message. Zero is returned for | |
175 | names that are not being tracked yet, a positive value for names added at least once. Larger values than 1 are only | |
176 | returned in recursive mode. On failure, a negative errno-style error code is returned.</para> | |
177 | ||
178 | <para><function>sd_bus_track_contains()</function> returns the passed name if it exists in the bus peer tracking | |
179 | object. On failure, and if the name has not been added yet <constant>NULL</constant> is returned.</para> | |
180 | ||
181 | <para><function>sd_bus_track_first()</function> and <function>sd_bus_track_next()</function> return the first/next | |
182 | name contained in the bus peer tracking object, and <constant>NULL</constant> if the end of the enumeration is | |
183 | reached and on error.</para> | |
ecddb2b5 | 184 | |
b1de39de ZJS |
185 | <refsect2> |
186 | <title>Errors</title> | |
ecddb2b5 | 187 | |
b1de39de | 188 | <para>Returned errors may indicate the following problems:</para> |
ecddb2b5 | 189 | |
b1de39de | 190 | <variablelist> |
ecddb2b5 | 191 | |
b1de39de ZJS |
192 | <varlistentry> |
193 | <term><constant>-EUNATCH</constant></term> | |
ecddb2b5 | 194 | |
b1de39de ZJS |
195 | <listitem><para><function>sd_bus_track_remove_name()</function> or |
196 | <function>sd_bus_track_remove_sender()</function> have been invoked for a name not previously added | |
197 | to the bus peer object.</para></listitem> | |
198 | </varlistentry> | |
ecddb2b5 | 199 | |
b1de39de ZJS |
200 | <varlistentry> |
201 | <term><constant>-EINVAL</constant></term> | |
ecddb2b5 | 202 | |
b1de39de ZJS |
203 | <listitem><para>Specified parameter is invalid.</para></listitem> |
204 | </varlistentry> | |
ecddb2b5 | 205 | |
b1de39de ZJS |
206 | <varlistentry> |
207 | <term><constant>-ENOMEM</constant></term> | |
ecddb2b5 | 208 | |
b1de39de ZJS |
209 | <listitem><para>Memory allocation failed.</para></listitem> |
210 | </varlistentry> | |
ecddb2b5 | 211 | |
b1de39de ZJS |
212 | </variablelist> |
213 | </refsect2> | |
ecddb2b5 LP |
214 | </refsect1> |
215 | ||
7d6b2723 | 216 | <xi:include href="libsystemd-pkgconfig.xml" /> |
ecddb2b5 LP |
217 | |
218 | <refsect1> | |
219 | <title>See Also</title> | |
220 | ||
221 | <para> | |
222 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
223 | <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
224 | <citerefentry><refentrytitle>sd_bus_track_new</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
225 | </para> | |
226 | </refsect1> | |
227 | ||
228 | </refentry> |