1:255.13-alt1
[systemd_ALT.git] / man / sd_bus_slot_set_destroy_callback.xml
blob404db6edbf332dfe6a5c13fc69c7d591c02da5ae
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.2/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
6 <refentry id="sd_bus_slot_set_destroy_callback"
7           xmlns:xi="http://www.w3.org/2001/XInclude">
9   <refentryinfo>
10     <title>sd_bus_slot_set_destroy_callback</title>
11     <productname>systemd</productname>
12   </refentryinfo>
14   <refmeta>
15     <refentrytitle>sd_bus_slot_set_destroy_callback</refentrytitle>
16     <manvolnum>3</manvolnum>
17   </refmeta>
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>
26     <refpurpose>Define the callback function for resource cleanup</refpurpose>
27   </refnamediv>
29   <refsynopsisdiv>
30     <funcsynopsis>
31       <funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
33       <funcprototype>
34         <funcdef>typedef int (*<function>sd_bus_destroy_t</function>)</funcdef>
35         <paramdef>void *<parameter>userdata</parameter></paramdef>
36       </funcprototype>
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>
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>
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>
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>
64   <refsect1>
65     <title>Description</title>
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>
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>
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>
87   <refsect1>
88     <title>Return Value</title>
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>
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>
98     <refsect2>
99       <title>Errors</title>
101       <para>Returned errors may indicate the following problems:</para>
103       <variablelist>
104         <varlistentry>
105           <term><constant>-EINVAL</constant></term>
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>
114   <xi:include href="libsystemd-pkgconfig.xml" />
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>
125   <refsect1>
126     <title>See Also</title>
128     <para>
129       <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
130       <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
131       <citerefentry><refentrytitle>sd_bus_slot_set_floating</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
132       <citerefentry><refentrytitle>sd_bus_add_match</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
133       <citerefentry><refentrytitle>sd_bus_track_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
134       <citerefentry><refentrytitle>sd_bus_slot_set_userdata</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
135       <citerefentry><refentrytitle>sd_bus_track_set_userdata</refentrytitle><manvolnum>3</manvolnum></citerefentry>
136     </para>
137   </refsect1>
139 </refentry>