]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/sd_bus_message_open_container.xml
man: fix incorrectly placed full stop
[thirdparty/systemd.git] / man / sd_bus_message_open_container.xml
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+ -->
5
6 <refentry id="sd_bus_message_open_container"
7 xmlns:xi="http://www.w3.org/2001/XInclude">
8
9 <refentryinfo>
10 <title>sd_bus_message_open_container</title>
11 <productname>systemd</productname>
12 </refentryinfo>
13
14 <refmeta>
15 <refentrytitle>sd_bus_message_open_container</refentrytitle>
16 <manvolnum>3</manvolnum>
17 </refmeta>
18
19 <refnamediv>
20 <refname>sd_bus_message_open_container</refname>
21 <refname>sd_bus_message_close_container</refname>
22 <refname>sd_bus_message_enter_container</refname>
23 <refname>sd_bus_message_exit_container</refname>
24
25 <refpurpose>Create and move between containers in D-Bus messages</refpurpose>
26 </refnamediv>
27
28 <refsynopsisdiv>
29 <funcsynopsis>
30 <funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
31
32 <funcprototype>
33 <funcdef>int sd_bus_message_open_container</funcdef>
34 <paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
35 <paramdef>char <parameter>type</parameter></paramdef>
36 <paramdef>const char *<parameter>contents</parameter></paramdef>
37 </funcprototype>
38
39 <funcprototype>
40 <funcdef>int sd_bus_message_close_container</funcdef>
41 <paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
42 </funcprototype>
43
44 <funcprototype>
45 <funcdef>int sd_bus_message_enter_container</funcdef>
46 <paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
47 <paramdef>char <parameter>type</parameter></paramdef>
48 <paramdef>const char *<parameter>contents</parameter></paramdef>
49 </funcprototype>
50
51 <funcprototype>
52 <funcdef>int sd_bus_message_exit_container</funcdef>
53 <paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
54 </funcprototype>
55 </funcsynopsis>
56 </refsynopsisdiv>
57
58 <refsect1>
59 <title>Description</title>
60
61 <para><function>sd_bus_message_open_container()</function> appends a new container to the message
62 <parameter>m</parameter>. After opening a new container, it can be filled with content using
63 <citerefentry><refentrytitle>sd_bus_message_append</refentrytitle><manvolnum>3</manvolnum></citerefentry>
64 and similar functions. Containers behave like a stack. To nest containers inside each other, call
65 <function>sd_bus_message_open_container()</function> multiple times without calling
66 <function>sd_bus_message_close_container()</function> in between. Each container will be nested inside the
67 previous container. <parameter>type</parameter> represents the container type and should be one of
68 <literal>r</literal>, <literal>a</literal>, <literal>v</literal> or <literal>e</literal> as described in
69 <citerefentry><refentrytitle>sd_bus_message_append</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
70 Instead of literals, the corresponding constants <constant>SD_BUS_TYPE_STRUCT</constant>,
71 <constant>SD_BUS_TYPE_ARRAY</constant>, <constant>SD_BUS_TYPE_VARIANT</constant> or
72 <constant>SD_BUS_TYPE_DICT_ENTRY</constant> can also be used. <parameter>contents</parameter> describes
73 the type of the container's elements and should be a D-Bus type string following the rules described in
74 <citerefentry><refentrytitle>sd_bus_message_append</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
75 </para>
76
77 <para><function>sd_bus_message_close_container()</function> closes the last container opened with
78 <function>sd_bus_message_open_container()</function>. On success, the write pointer of the message
79 <parameter>m</parameter> is positioned after the closed container in its parent container or in
80 <parameter>m</parameter> itself if there is no parent container.</para>
81
82 <para><function>sd_bus_message_enter_container()</function> enters the next container of the message
83 <parameter>m</parameter>. It behaves mostly the same as
84 <function>sd_bus_message_open_container()</function>. Entering a container allows reading its contents
85 with
86 <citerefentry><refentrytitle>sd_bus_message_read</refentrytitle><manvolnum>3</manvolnum></citerefentry>
87 and similar functions. <parameter>type</parameter> and <parameter>contents</parameter> are the same as in
88 <function>sd_bus_message_open_container()</function>.</para>
89
90 <para><function>sd_bus_message_exit_container()</function> exits the scope of the last container entered
91 with <function>sd_bus_message_enter_container()</function>. It behaves mostly the same as
92 <function>sd_bus_message_close_container()</function>.</para>
93 </refsect1>
94
95 <refsect1>
96 <title>Return Value</title>
97
98 <para>On success, these functions return a non-negative integer. On failure, they return a negative
99 errno-style error code.</para>
100
101 <refsect2>
102 <title>Errors</title>
103
104 <para>Returned errors may indicate the following problems:</para>
105
106 <variablelist>
107 <varlistentry>
108 <term><constant>-EINVAL</constant></term>
109
110 <listitem><para><parameter>m</parameter> or <parameter>contents</parameter> are
111 <constant>NULL</constant> or <parameter>type</parameter> is invalid.</para></listitem>
112 </varlistentry>
113
114 <varlistentry>
115 <term><constant>-EPERM</constant></term>
116
117 <listitem><para>The message <parameter>m</parameter> is already sealed.</para></listitem>
118 </varlistentry>
119
120 <varlistentry>
121 <term><constant>-ESTALE</constant></term>
122
123 <listitem><para>The message <parameter>m</parameter> is in an invalid state.</para></listitem>
124 </varlistentry>
125
126 <varlistentry>
127 <term><constant>-ENOMEM</constant></term>
128
129 <listitem><para>Memory allocation failed.</para></listitem>
130 </varlistentry>
131 </variablelist>
132 </refsect2>
133 </refsect1>
134
135 <xi:include href="libsystemd-pkgconfig.xml" />
136
137 <refsect1>
138 <title>Examples</title>
139
140 <example>
141 <title>Append an array of strings to a message</title>
142
143 <programlisting><xi:include href="sd-bus-container-append.c" parse="text" /></programlisting>
144 </example>
145
146 <example>
147 <title>Read an array of strings from a message</title>
148
149 <programlisting><xi:include href="sd-bus-container-read.c" parse="text" /></programlisting>
150 </example>
151 </refsect1>
152
153 <refsect1>
154 <title>See Also</title>
155
156 <para>
157 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
158 <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
159 <citerefentry><refentrytitle>sd_bus_message_append</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
160 <citerefentry><refentrytitle>sd_bus_message_read</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
161 <ulink url="https://dbus.freedesktop.org/doc/dbus-specification.html">The D-Bus specification</ulink>
162 </para>
163 </refsect1>
164
165 </refentry>