2 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1+ -->
6 <refentry id=
"sd_bus_slot_set_userdata" xmlns:
xi=
"http://www.w3.org/2001/XInclude">
9 <title>sd_bus_slot_set_userdata
</title>
10 <productname>systemd
</productname>
14 <refentrytitle>sd_bus_slot_set_userdata
</refentrytitle>
15 <manvolnum>3</manvolnum>
19 <refname>sd_bus_slot_set_userdata
</refname>
20 <refname>sd_bus_slot_get_userdata
</refname>
22 <refpurpose>Set and query the value in the
"userdata" field
</refpurpose>
27 <funcsynopsisinfo>#include
<systemd/sd-bus.h
></funcsynopsisinfo>
30 <funcdef>void*
<function>sd_bus_slot_set_userdata
</function></funcdef>
31 <paramdef>sd_bus_slot*
<parameter>slot
</parameter></paramdef>
32 <paramdef>void*
<parameter>userdata
</parameter></paramdef>
36 <funcdef>void*
<function>sd_bus_slot_get_userdata
</function></funcdef>
37 <paramdef>sd_bus_slot*
<parameter>slot
</parameter></paramdef>
44 <title>Description
</title>
46 <para>The userdata pointer allows data to be passed between the point where a callback is
47 registered, for example when a filter is added using
48 <citerefentry><refentrytitle>sd_bus_add_filter
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
49 or an asynchronous function call is made using
50 <citerefentry><refentrytitle>sd_bus_call_async
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
51 and the point where the callback is called, without having any global state. The pointer has
52 type
<type>void*
</type> and is not used by the sd-bus functions in any way, except to pass to
53 the callback function.
</para>
55 <para>Usually, the userdata field is set when the slot object is initially
56 registered.
<function>sd_bus_slot_set_userdata()
</function> may be used to change it later for
57 the bus slot object
<parameter>slot
</parameter>. Previous value of the field is returned. The
58 argument and returned value may be
<constant>NULL
</constant>. It will be passed as the
59 <parameter>userdata
</parameter> argument to the callback function attached to the slot.
</para>
61 <para><function>sd_bus_slot_set_userdata()
</function> gets the value of the userdata field in
62 the bus slot object
<parameter>slot
</parameter>.
</para>
66 <title>Return Value
</title>
68 <para>On success, these functions return the value of the userdata field before the function
69 call. If the
<parameter>slot
</parameter> object is
<constant>NULL
</constant>,
70 <constant>NULL
</constant> will be returned to signify an error, but this is not distinguishable
71 from the userdata field value being
<constant>NULL
</constant>.
</para>
74 <xi:include href=
"libsystemd-pkgconfig.xml" />
77 <title>See Also
</title>
80 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
81 <citerefentry><refentrytitle>sd-bus
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
82 <citerefentry><refentrytitle>sd_bus_slot_set_destroy_callback
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
83 <citerefentry><refentrytitle>sd_bus_add_match
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
84 <citerefentry><refentrytitle>sd_bus_slot_get_current_userdata
</refentrytitle><manvolnum>3</manvolnum></citerefentry>