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 -->
5
6<refentry id="sd_bus_slot_set_floating" xmlns:xi="http://www.w3.org/2001/XInclude">
7
8  <refentryinfo>
9    <title>sd_bus_slot_set_floating</title>
10    <productname>systemd</productname>
11  </refentryinfo>
12
13  <refmeta>
14    <refentrytitle>sd_bus_slot_set_floating</refentrytitle>
15    <manvolnum>3</manvolnum>
16  </refmeta>
17
18  <refnamediv>
19    <refname>sd_bus_slot_set_floating</refname>
20    <refname>sd_bus_slot_get_floating</refname>
21
22    <refpurpose>Control whether a bus slot object is "floating"</refpurpose>
23  </refnamediv>
24
25  <refsynopsisdiv>
26    <funcsynopsis>
27      <funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
28
29      <funcprototype>
30        <funcdef>int <function>sd_bus_slot_set_floating</function></funcdef>
31        <paramdef>sd_bus_slot *<parameter>slot</parameter></paramdef>
32        <paramdef>int <parameter>b</parameter></paramdef>
33      </funcprototype>
34
35      <funcprototype>
36        <funcdef>int <function>sd_bus_slot_get_floating</function></funcdef>
37        <paramdef>sd_bus_slot *<parameter>slot</parameter></paramdef>
38      </funcprototype>
39
40    </funcsynopsis>
41  </refsynopsisdiv>
42
43  <refsect1>
44    <title>Description</title>
45
46    <para><function>sd_bus_slot_set_floating()</function> controls whether the specified bus slot object
47    <parameter>slot</parameter> shall be "floating" or not. A floating bus slot object's lifetime is bound to the
48    lifetime of the bus object it is associated with, meaning that it remains allocated as long as the bus object
49    itself and is freed automatically when the bus object is freed. Regular (i.e. non-floating) bus slot objects keep
50    the bus referenced, hence the bus object remains allocated at least as long as there remains at least one
51    referenced bus slot object around. The floating state hence controls the direction of referencing between the bus
52    object and the bus slot objects: if floating the bus pins the bus slot, and otherwise the bus slot pins the bus
53    objects. Use <function>sd_bus_slot_set_floating()</function> to switch between both modes: if the
54    <parameter>b</parameter> parameter is zero, the slot object is considered floating, otherwise it is made a regular
55    (non-floating) slot object.</para>
56
57    <para>Bus slot objects may be allocated with calls such as
58    <citerefentry><refentrytitle>sd_bus_add_match</refentrytitle><manvolnum>3</manvolnum></citerefentry>. If the
59    <parameter>slot</parameter> of these functions is non-<constant>NULL</constant> the slot object will be of the
60    regular kind (i.e. non-floating), otherwise it will be created floating. With
61    <function>sd_bus_slot_set_floating()</function> a bus slot object allocated as regular can be converted into a
62    floating object and back. This is particularly useful for creating a bus slot object, then changing parameters of
63    it, and then turning it into a floating object, whose lifecycle is managed by the bus object.</para>
64
65    <para><function>sd_bus_slot_get_floating()</function> returns the current floating state of the specified bus slot
66    object. It returns negative on error, zero if the bus slot object is a regular (non-floating) object and positive
67    otherwise.</para>
68  </refsect1>
69
70  <refsect1>
71    <title>Return Value</title>
72
73    <para>On success, these functions return 0 or a positive integer. On failure, they return a negative
74    errno-style error code.</para>
75
76    <refsect2>
77      <title>Errors</title>
78
79      <para>Returned errors may indicate the following problems:</para>
80
81      <variablelist>
82        <varlistentry>
83          <term><constant>-EINVAL</constant></term>
84
85          <listitem><para>The <parameter>slot</parameter> parameter is <constant>NULL</constant>.</para></listitem>
86        </varlistentry>
87
88        <varlistentry>
89          <term><constant>-ECHILD</constant></term>
90
91          <listitem><para>The bus connection has been created in a different process.</para></listitem>
92        </varlistentry>
93
94        <varlistentry>
95          <term><constant>-ESTALE</constant></term>
96
97          <listitem><para>The bus object the specified bus slot object is associated with has already been
98          freed, and hence no change in the floating state can be made anymore.</para></listitem>
99        </varlistentry>
100      </variablelist>
101    </refsect2>
102  </refsect1>
103
104  <xi:include href="libsystemd-pkgconfig.xml" />
105
106  <refsect1>
107    <title>See Also</title>
108
109    <para>
110      <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
111      <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
112      <citerefentry><refentrytitle>sd_bus_slot_set_destroy_callback</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
113      <citerefentry><refentrytitle>sd_bus_add_match</refentrytitle><manvolnum>3</manvolnum></citerefentry>
114    </para>
115  </refsect1>
116
117</refentry>
118