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