1 <?xml version='1.0'?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
5 <!-- SPDX-License-Identifier: LGPL-2.1+ -->
7 <refentry id="sd_bus_slot_set_destroy_callback"
8 xmlns:xi="http://www.w3.org/2001/XInclude">
11 <title>sd_bus_slot_set_destroy_callback</title>
12 <productname>elogind</productname>
16 <refentrytitle>sd_bus_slot_set_destroy_callback</refentrytitle>
17 <manvolnum>3</manvolnum>
21 <refname>sd_bus_slot_set_destroy_callback</refname>
22 <refname>sd_bus_slot_get_destroy_callback</refname>
24 <refpurpose>Define the callback function for resource cleanup.</refpurpose>
29 <funcsynopsisinfo>#include <elogind/sd-bus.h></funcsynopsisinfo>
32 <funcdef>typedef int (*<function>sd_bus_destroy_t</function>)</funcdef>
33 <paramdef>void *<parameter>userdata</parameter></paramdef>
37 <funcdef>int <function>sd_bus_slot_set_destroy_callback</function></funcdef>
38 <paramdef>sd_bus_slot *<parameter>slot</parameter></paramdef>
39 <paramdef>sd_bus_destroy_t <parameter>callback</parameter></paramdef>
43 <funcdef>int <function>sd_bus_slot_get_destroy_callback</function></funcdef>
44 <paramdef>sd_bus_slot *<parameter>slot</parameter></paramdef>
45 <paramdef>sd_bus_destroy_t *<parameter>callback</parameter></paramdef>
51 <title>Description</title>
53 <para><function>sd_bus_slot_set_destroy_callback()</function> sets
54 <parameter>callback</parameter> as the callback function to be called right before the bus slot
55 object <parameter>slot</parameter> is deallocated. The <parameter>userdata</parameter> pointer
56 from the slot object will be passed as the <parameter>userdata</parameter> parameter. This
57 pointer can be set specified as an argument to the constuctor functions, see
58 <citerefentry><refentrytitle>sd_bus_add_match</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
60 <citerefentry><refentrytitle>sd_bus_set_userdata</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
61 This callback function is called even if <parameter>userdata</parameter> is
62 <constant>NULL</constant>.</para>
64 <para><function>sd_bus_slot_get_destroy_callback()</function> returns the current callback
65 for <parameter>slot</parameter> in the <parameter>callback</parameter> parameter.</para>
69 <title>Return Value</title>
71 <para>On success, <function>sd_bus_slot_set_destroy_callback()</function> returns 0 or a
72 positive integer. On failure, it returns a negative errno-style error code.</para>
74 <para><function>sd_bus_slot_get_destroy_callback()</function> returns 1 if the destroy callback
75 function is set, 0 if not. On failure, it returns a negative errno-style error code.</para>
81 <para>Returned errors may indicate the following problems:</para>
85 <term><constant>-EINVAL</constant></term>
87 <listitem><para>The <parameter>slot</parameter> parameter is <constant>NULL</constant>.
93 <xi:include href="libelogind-pkgconfig.xml" />
96 <title>See Also</title>
99 <citerefentry><refentrytitle>elogind</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
100 <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
101 <citerefentry><refentrytitle>sd_bus_slot_set_floating</refentrytitle><manvolnum>3</manvolnum></citerefentry>