basic/linux: update kernel headers from v6.14-rc1
[systemd.io.git] / man / sd_bus_track_add_name.xml
blob5b3306da6509617ac6015ddebff050ccb7b8950a
1 <?xml version='1.0'?>
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3   "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
6 <refentry id="sd_bus_track_add_name" xmlns:xi="http://www.w3.org/2001/XInclude">
8   <refentryinfo>
9     <title>sd_bus_track_add_name</title>
10     <productname>systemd</productname>
11   </refentryinfo>
13   <refmeta>
14     <refentrytitle>sd_bus_track_add_name</refentrytitle>
15     <manvolnum>3</manvolnum>
16   </refmeta>
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>
30     <refpurpose>Add, remove and retrieve bus peers tracked in a bus peer tracking object</refpurpose>
31   </refnamediv>
33   <refsynopsisdiv>
34     <funcsynopsis>
35       <funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
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>
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>
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>
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>
61       <funcprototype>
62         <funcdef>unsigned <function>sd_bus_track_count</function></funcdef>
63         <paramdef>sd_bus_track* <parameter>t</parameter></paramdef>
64       </funcprototype>
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>
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>
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>
84       <funcprototype>
85         <funcdef>const char* <function>sd_bus_track_first</function></funcdef>
86         <paramdef>sd_bus_track* <parameter>t</parameter></paramdef>
87       </funcprototype>
89       <funcprototype>
90         <funcdef>const char* <function>sd_bus_track_next</function></funcdef>
91         <paramdef>sd_bus_track* <parameter>t</parameter></paramdef>
92       </funcprototype>
94     </funcsynopsis>
95   </refsynopsisdiv>
97   <refsect1>
98     <title>Description</title>
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>
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>
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>
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 of whether recursive mode is used or not.</para>
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>
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>
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>
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>
157   <refsect1>
158     <title>Return Value</title>
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     has not. On failure, they return a negative errno-style error code.</para>
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>
170     <para><function>sd_bus_track_count()</function> returns the number of names currently being tracked, or 0 on
171     failure.</para>
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>
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>
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>
185     <refsect2>
186       <title>Errors</title>
188       <para>Returned errors may indicate the following problems:</para>
190       <variablelist>
192         <varlistentry>
193           <term><constant>-EUNATCH</constant></term>
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>
200         <varlistentry>
201           <term><constant>-EINVAL</constant></term>
203           <listitem><para>Specified parameter is invalid.</para></listitem>
204         </varlistentry>
206         <varlistentry>
207           <term><constant>-ENOMEM</constant></term>
209           <listitem><para>Memory allocation failed.</para></listitem>
210         </varlistentry>
212       </variablelist>
213     </refsect2>
214   </refsect1>
216   <xi:include href="libsystemd-pkgconfig.xml" />
218   <refsect1>
219     <title>History</title>
220     <para><function>sd_bus_track_add_name()</function>,
221     <function>sd_bus_track_add_sender()</function>,
222     <function>sd_bus_track_remove_name()</function>,
223     <function>sd_bus_track_remove_sender()</function>,
224     <function>sd_bus_track_count()</function>,
225     <function>sd_bus_track_count_name()</function>,
226     <function>sd_bus_track_count_sender()</function>,
227     <function>sd_bus_track_contains()</function>,
228     <function>sd_bus_track_first()</function>, and
229     <function>sd_bus_track_next()</function> were added in version 232.</para>
230   </refsect1>
232   <refsect1>
233     <title>See Also</title>
235     <para><simplelist type="inline">
236       <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
237       <member><citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
238       <member><citerefentry><refentrytitle>sd_bus_track_new</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
239     </simplelist></para>
240   </refsect1>
242 </refentry>