]>
Commit | Line | Data |
---|---|---|
514094f9 | 1 | <?xml version='1.0'?> |
3a54a157 ZJS |
2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" |
3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> | |
fa17b4e8 ZJS |
4 | <!-- SPDX-License-Identifier: LGPL-2.1+ --> |
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> | |
66223497 LP |
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> | |
fa17b4e8 ZJS |
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> | |
66223497 LP |
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> | |
fa17b4e8 ZJS |
61 | </funcsynopsis> |
62 | </refsynopsisdiv> | |
63 | ||
64 | <refsect1> | |
65 | <title>Description</title> | |
66 | ||
66223497 LP |
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> | |
fa17b4e8 ZJS |
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> | |
66223497 LP |
79 | |
80 | <para><function>sd_bus_track_set_destroy_callback()</function> and | |
69ae75d7 | 81 | <function>sd_bus_track_get_destroy_callback()</function> provide equivalent functionality for the |
66223497 LP |
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> | |
fa17b4e8 ZJS |
85 | </refsect1> |
86 | ||
87 | <refsect1> | |
88 | <title>Return Value</title> | |
89 | ||
66223497 | 90 | <para>On success, <function>sd_bus_slot_set_destroy_callback()</function> and |
b1de39de ZJS |
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> | |
fa17b4e8 | 93 | |
66223497 | 94 | <para><function>sd_bus_slot_get_destroy_callback()</function> and |
b1de39de ZJS |
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> | |
fa17b4e8 | 97 | |
b1de39de ZJS |
98 | <refsect2> |
99 | <title>Errors</title> | |
fa17b4e8 | 100 | |
b1de39de | 101 | <para>Returned errors may indicate the following problems:</para> |
fa17b4e8 | 102 | |
b1de39de ZJS |
103 | <variablelist> |
104 | <varlistentry> | |
105 | <term><constant>-EINVAL</constant></term> | |
fa17b4e8 | 106 | |
b1de39de ZJS |
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> | |
fa17b4e8 ZJS |
112 | </refsect1> |
113 | ||
114 | <xi:include href="libsystemd-pkgconfig.xml" /> | |
115 | ||
116 | <refsect1> | |
117 | <title>See Also</title> | |
118 | ||
119 | <para> | |
120 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
121 | <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
66223497 LP |
122 | <citerefentry><refentrytitle>sd_bus_slot_set_floating</refentrytitle><manvolnum>3</manvolnum></citerefentry>, |
123 | <citerefentry><refentrytitle>sd_bus_add_match</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
124 | <citerefentry><refentrytitle>sd_bus_track_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
125 | <citerefentry><refentrytitle>sd_bus_slot_set_userdata</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
126 | <citerefentry><refentrytitle>sd_bus_track_set_userdata</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
fa17b4e8 ZJS |
127 | </para> |
128 | </refsect1> | |
129 | ||
130 | </refentry> |