| 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_destroy_callback" |
| 7 |
xmlns:xi="http://www.w3.org/2001/XInclude"> |
| 8 |
|
| 9 |
<refentryinfo> |
| 10 |
<title>sd_bus_slot_set_destroy_callback</title> |
| 11 |
<productname>systemd</productname> |
| 12 |
</refentryinfo> |
| 13 |
|
| 14 |
<refmeta> |
| 15 |
<refentrytitle>sd_bus_slot_set_destroy_callback</refentrytitle> |
| 16 |
<manvolnum>3</manvolnum> |
| 17 |
</refmeta> |
| 18 |
|
| 19 |
<refnamediv> |
| 20 |
<refname>sd_bus_slot_set_destroy_callback</refname> |
| 21 |
<refname>sd_bus_slot_get_destroy_callback</refname> |
| 22 |
<refname>sd_bus_track_set_destroy_callback</refname> |
| 23 |
<refname>sd_bus_track_get_destroy_callback</refname> |
| 24 |
<refname>sd_bus_destroy_t</refname> |
| 25 |
|
| 26 |
<refpurpose>Define the callback function for resource cleanup</refpurpose> |
| 27 |
</refnamediv> |
| 28 |
|
| 29 |
<refsynopsisdiv> |
| 30 |
<funcsynopsis> |
| 31 |
<funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo> |
| 32 |
|
| 33 |
<funcprototype> |
| 34 |
<funcdef>typedef int (*<function>sd_bus_destroy_t</function>)</funcdef> |
| 35 |
<paramdef>void *<parameter>userdata</parameter></paramdef> |
| 36 |
</funcprototype> |
| 37 |
|
| 38 |
<funcprototype> |
| 39 |
<funcdef>int <function>sd_bus_slot_set_destroy_callback</function></funcdef> |
| 40 |
<paramdef>sd_bus_slot *<parameter>slot</parameter></paramdef> |
| 41 |
<paramdef>sd_bus_destroy_t <parameter>callback</parameter></paramdef> |
| 42 |
</funcprototype> |
| 43 |
|
| 44 |
<funcprototype> |
| 45 |
<funcdef>int <function>sd_bus_slot_get_destroy_callback</function></funcdef> |
| 46 |
<paramdef>sd_bus_slot *<parameter>slot</parameter></paramdef> |
| 47 |
<paramdef>sd_bus_destroy_t *<parameter>callback</parameter></paramdef> |
| 48 |
</funcprototype> |
| 49 |
|
| 50 |
<funcprototype> |
| 51 |
<funcdef>int <function>sd_bus_track_set_destroy_callback</function></funcdef> |
| 52 |
<paramdef>sd_bus_track *<parameter>track</parameter></paramdef> |
| 53 |
<paramdef>sd_bus_destroy_t <parameter>callback</parameter></paramdef> |
| 54 |
</funcprototype> |
| 55 |
|
| 56 |
<funcprototype> |
| 57 |
<funcdef>int <function>sd_bus_track_get_destroy_callback</function></funcdef> |
| 58 |
<paramdef>sd_bus_track *<parameter>track</parameter></paramdef> |
| 59 |
<paramdef>sd_bus_destroy_t *<parameter>callback</parameter></paramdef> |
| 60 |
</funcprototype> |
| 61 |
</funcsynopsis> |
| 62 |
</refsynopsisdiv> |
| 63 |
|
| 64 |
<refsect1> |
| 65 |
<title>Description</title> |
| 66 |
|
| 67 |
<para><function>sd_bus_slot_set_destroy_callback()</function> sets <parameter>callback</parameter> as the callback |
| 68 |
function to be called right before the bus slot object <parameter>slot</parameter> is deallocated. The |
| 69 |
<parameter>userdata</parameter> pointer from the slot object will be passed as the <parameter>userdata</parameter> |
| 70 |
parameter. This pointer can be set by an argument to the constructor functions, see |
| 71 |
<citerefentry><refentrytitle>sd_bus_add_match</refentrytitle><manvolnum>3</manvolnum></citerefentry>, or directly, |
| 72 |
see <citerefentry><refentrytitle>sd_bus_slot_set_userdata</refentrytitle><manvolnum>3</manvolnum></citerefentry>. |
| 73 |
This callback function is called even if <parameter>userdata</parameter> is <constant>NULL</constant>. Note that |
| 74 |
this callback is invoked at a time where the bus slot object itself is already invalidated, and executing |
| 75 |
operations or taking new references to the bus slot object is not permissible.</para> |
| 76 |
|
| 77 |
<para><function>sd_bus_slot_get_destroy_callback()</function> returns the current callback |
| 78 |
for <parameter>slot</parameter> in the <parameter>callback</parameter> parameter.</para> |
| 79 |
|
| 80 |
<para><function>sd_bus_track_set_destroy_callback()</function> and |
| 81 |
<function>sd_bus_track_get_destroy_callback()</function> provide equivalent functionality for the |
| 82 |
<parameter>userdata</parameter> pointer associated with bus peer tracking objects. For details about bus peer |
| 83 |
tracking objects, see |
| 84 |
<citerefentry><refentrytitle>sd_bus_track_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para> |
| 85 |
</refsect1> |
| 86 |
|
| 87 |
<refsect1> |
| 88 |
<title>Return Value</title> |
| 89 |
|
| 90 |
<para>On success, <function>sd_bus_slot_set_destroy_callback()</function> and |
| 91 |
<function>sd_bus_track_set_destroy_callback()</function> return 0 or a positive integer. On failure, they |
| 92 |
return a negative errno-style error code.</para> |
| 93 |
|
| 94 |
<para><function>sd_bus_slot_get_destroy_callback()</function> and |
| 95 |
<function>sd_bus_track_get_destroy_callback()</function> return positive if the destroy callback function |
| 96 |
is set, 0 if not. On failure, they return a negative errno-style error code.</para> |
| 97 |
|
| 98 |
<refsect2> |
| 99 |
<title>Errors</title> |
| 100 |
|
| 101 |
<para>Returned errors may indicate the following problems:</para> |
| 102 |
|
| 103 |
<variablelist> |
| 104 |
<varlistentry> |
| 105 |
<term><constant>-EINVAL</constant></term> |
| 106 |
|
| 107 |
<listitem><para>The <parameter>slot</parameter> or <parameter>track</parameter> parameter is |
| 108 |
<constant>NULL</constant>.</para></listitem> |
| 109 |
</varlistentry> |
| 110 |
</variablelist> |
| 111 |
</refsect2> |
| 112 |
</refsect1> |
| 113 |
|
| 114 |
<xi:include href="libsystemd-pkgconfig.xml" /> |
| 115 |
|
| 116 |
<refsect1> |
| 117 |
<title>History</title> |
| 118 |
<para><function>sd_bus_destroy_t()</function>, |
| 119 |
<function>sd_bus_slot_set_destroy_callback()</function>, |
| 120 |
<function>sd_bus_slot_get_destroy_callback()</function>, |
| 121 |
<function>sd_bus_track_set_destroy_callback()</function>, and |
| 122 |
<function>sd_bus_track_get_destroy_callback()</function> were added in version 239.</para> |
| 123 |
</refsect1> |
| 124 |
|
| 125 |
<refsect1> |
| 126 |
<title>See Also</title> |
| 127 |
|
| 128 |
<para><simplelist type="inline"> |
| 129 |
<member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 130 |
<member><citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 131 |
<member><citerefentry><refentrytitle>sd_bus_slot_set_floating</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 132 |
<member><citerefentry><refentrytitle>sd_bus_add_match</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 133 |
<member><citerefentry><refentrytitle>sd_bus_track_new</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 134 |
<member><citerefentry><refentrytitle>sd_bus_slot_set_userdata</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 135 |
<member><citerefentry><refentrytitle>sd_bus_track_set_userdata</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 136 |
</simplelist></para> |
| 137 |
</refsect1> |
| 138 |
|
| 139 |
</refentry> |