| 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 --> |
| 5 |
|
| 6 |
<refentry id="sd_bus_slot_set_userdata" xmlns:xi="http://www.w3.org/2001/XInclude"> |
| 7 |
|
| 8 |
<refentryinfo> |
| 9 |
<title>sd_bus_slot_set_userdata</title> |
| 10 |
<productname>systemd</productname> |
| 11 |
</refentryinfo> |
| 12 |
|
| 13 |
<refmeta> |
| 14 |
<refentrytitle>sd_bus_slot_set_userdata</refentrytitle> |
| 15 |
<manvolnum>3</manvolnum> |
| 16 |
</refmeta> |
| 17 |
|
| 18 |
<refnamediv> |
| 19 |
<refname>sd_bus_slot_set_userdata</refname> |
| 20 |
<refname>sd_bus_slot_get_userdata</refname> |
| 21 |
|
| 22 |
<refpurpose>Set and query the value in the "userdata" field</refpurpose> |
| 23 |
</refnamediv> |
| 24 |
|
| 25 |
<refsynopsisdiv> |
| 26 |
<funcsynopsis> |
| 27 |
<funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo> |
| 28 |
|
| 29 |
<funcprototype> |
| 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> |
| 33 |
</funcprototype> |
| 34 |
|
| 35 |
<funcprototype> |
| 36 |
<funcdef>void* <function>sd_bus_slot_get_userdata</function></funcdef> |
| 37 |
<paramdef>sd_bus_slot* <parameter>slot</parameter></paramdef> |
| 38 |
</funcprototype> |
| 39 |
|
| 40 |
</funcsynopsis> |
| 41 |
</refsynopsisdiv> |
| 42 |
|
| 43 |
<refsect1> |
| 44 |
<title>Description</title> |
| 45 |
|
| 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> |
| 54 |
|
| 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> |
| 60 |
|
| 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> |
| 63 |
</refsect1> |
| 64 |
|
| 65 |
<refsect1> |
| 66 |
<title>Return Value</title> |
| 67 |
|
| 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> |
| 72 |
</refsect1> |
| 73 |
|
| 74 |
<xi:include href="libsystemd-pkgconfig.xml" /> |
| 75 |
|
| 76 |
<refsect1> |
| 77 |
<title>History</title> |
| 78 |
<para><function>sd_bus_slot_set_userdata()</function> and |
| 79 |
<function>sd_bus_slot_get_userdata()</function> were added in version 240.</para> |
| 80 |
</refsect1> |
| 81 |
|
| 82 |
<refsect1> |
| 83 |
<title>See Also</title> |
| 84 |
|
| 85 |
<para><simplelist type="inline"> |
| 86 |
<member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 87 |
<member><citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 88 |
<member><citerefentry><refentrytitle>sd_bus_slot_set_destroy_callback</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 89 |
<member><citerefentry><refentrytitle>sd_bus_add_match</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 90 |
<member><citerefentry><refentrytitle>sd_bus_slot_get_current_userdata</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 91 |
</simplelist></para> |
| 92 |
</refsect1> |
| 93 |
|
| 94 |
</refentry> |