]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/sd_bus_message_append_array.xml
verify: use manager_load_startable_unit_or_warn() to load units for verification
[thirdparty/systemd.git] / man / sd_bus_message_append_array.xml
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">
4
5 <!--
6 SPDX-License-Identifier: LGPL-2.1+
7
8 This file is part of systemd.
9
10 Copyright 2014 Zbigniew Jędrzejewski-Szmek
11
12 systemd is free software; you can redistribute it and/or modify it
13 under the terms of the GNU Lesser General Public License as published by
14 the Free Software Foundation; either version 2.1 of the License, or
15 (at your option) any later version.
16
17 systemd is distributed in the hope that it will be useful, but
18 WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Lesser General Public License for more details.
21
22 You should have received a copy of the GNU Lesser General Public License
23 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 -->
25
26 <refentry id="sd_bus_message_append_array"
27 xmlns:xi="http://www.w3.org/2001/XInclude">
28
29 <refentryinfo>
30 <title>sd_bus_message_append_array</title>
31 <productname>systemd</productname>
32
33 <authorgroup>
34 <author>
35 <contrib>A monkey with a typewriter</contrib>
36 <firstname>Zbigniew</firstname>
37 <surname>Jędrzejewski-Szmek</surname>
38 <email>zbyszek@in.waw.pl</email>
39 </author>
40 </authorgroup>
41 </refentryinfo>
42
43 <refmeta>
44 <refentrytitle>sd_bus_message_append_array</refentrytitle>
45 <manvolnum>3</manvolnum>
46 </refmeta>
47
48 <refnamediv>
49 <refname>sd_bus_message_append_array</refname>
50 <refname>sd_bus_message_append_array_memfd</refname>
51 <refname>sd_bus_message_append_array_iovec</refname>
52 <refname>sd_bus_message_append_array_space</refname>
53
54 <refpurpose>Append an array of fields to a D-Bus
55 message</refpurpose>
56 </refnamediv>
57
58 <refsynopsisdiv>
59 <funcsynopsis>
60 <funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
61
62 <funcprototype>
63 <funcdef>int sd_bus_message_append_array</funcdef>
64 <paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
65 <paramdef>char <parameter>type</parameter></paramdef>
66 <paramdef>char void *<parameter>ptr</parameter></paramdef>
67 <paramdef>size_t <parameter>size</parameter></paramdef>
68 </funcprototype>
69
70 <funcprototype>
71 <funcdef>int sd_bus_message_append_array_memfd</funcdef>
72 <paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
73 <paramdef>char <parameter>type</parameter></paramdef>
74 <paramdef>int <parameter>memfd</parameter></paramdef>
75 <paramdef>uint64_t <parameter>offset</parameter></paramdef>
76 <paramdef>uint64_t <parameter>size</parameter></paramdef>
77 </funcprototype>
78
79 <funcprototype>
80 <funcdef>int sd_bus_message_append_array_iovec</funcdef>
81 <paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
82 <paramdef>char <parameter>type</parameter></paramdef>
83 <paramdef>const struct iovec *<parameter>iov</parameter></paramdef>
84 <paramdef>unsigned <parameter>n</parameter></paramdef>
85 </funcprototype>
86
87 <funcprototype>
88 <funcdef>int sd_bus_message_append_array_space</funcdef>
89 <paramdef>char <parameter>type</parameter></paramdef>
90 <paramdef>size_t <parameter>size</parameter></paramdef>
91 <paramdef>void **<parameter>ptr</parameter></paramdef>
92 </funcprototype>
93 </funcsynopsis>
94 </refsynopsisdiv>
95
96 <refsect1>
97 <title>Description</title>
98
99 <para>The <function>sd_bus_message_append_array()</function>
100 function appends an array to a D-Bus message
101 <parameter>m</parameter>. A container will be opened, the array
102 contents appended, and the container closed. The parameter
103 <parameter>type</parameter> determines how the pointer
104 <parameter>p</parameter> is interpreted.
105 <parameter>type</parameter> must be one of the "trivial" types
106 <literal>y</literal>, <literal>n</literal>, <literal>q</literal>,
107 <literal>i</literal>, <literal>u</literal>, <literal>x</literal>,
108 <literal>t</literal>, <literal>d</literal> (but not
109 <literal>b</literal>), as defined by the <ulink
110 url="http://dbus.freedesktop.org/doc/dbus-specification.html#basic-types">Basic
111 Types</ulink> section of the D-Bus specification, and listed in
112 <citerefentry><refentrytitle>sd_bus_message_append_basic</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
113 Pointer <parameter>p</parameter> must point to an array of size
114 <parameter>size</parameter> bytes containing items of the
115 respective type. Size <parameter>size</parameter> must be a
116 multiple of the size of the type <parameter>type</parameter>. As a
117 special case, <parameter>p</parameter> may be
118 <constant>NULL</constant>, if <parameter>size</parameter> is 0.
119 The memory pointed to by <parameter>p</parameter> is copied into
120 the memory area containing the message and stays in possession of
121 the caller. The caller may hence freely change the data after this
122 call without affecting the message the array was appended
123 to.</para>
124
125 <para>The <function>sd_bus_message_append_array_memfd()</function>
126 function appends an array of a trivial type to message
127 <parameter>m</parameter>, similar to
128 <function>sd_bus_message_append_array()</function>. The contents
129 of the memory file descriptor <parameter>memfd</parameter>
130 starting at the specified offset and of the specified size is
131 used as the contents of the array. The offset and size must be a
132 multiple of the size of the type
133 <parameter>type</parameter>. However, as a special exception, if
134 the offset is specified as zero and the size specified as
135 UINT64_MAX the full memory file descriptor contents is used. The
136 memory file descriptor is sealed by this call if it has not been
137 sealed yet, and cannot be modified after this call. See
138 <citerefentry
139 project='man-pages'><refentrytitle>memfd_create</refentrytitle><manvolnum>2</manvolnum></citerefentry>
140 for details about memory file descriptors. Appending arrays with
141 memory file descriptors enables efficient zero-copy data transfer,
142 as the memory file descriptor may be passed as-is to the
143 destination, without copying the memory in it to the destination
144 process. Not all protocol transports support passing memory file
145 descriptors between participants, in which case this call will
146 automatically fall back to copying. Also, as memory file
147 descriptor passing is inefficient for smaller amounts of data,
148 copying might still be enforced even where memory file descriptor
149 passing is supported.</para>
150
151 <para>The <function>sd_bus_message_append_array_iovec()</function>
152 function appends an array of a trivial type to the message
153 <parameter>m</parameter>, similar to
154 <function>sd_bus_message_append_array()</function>. Contents of
155 the I/O vector array <parameter>iov</parameter> are used as the
156 contents of the array. The total size of
157 <parameter>iov</parameter> payload (the sum of
158 <structfield>iov_len</structfield> fields) must be a multiple of
159 the size of the type <parameter>type</parameter>. The
160 <parameter>iov</parameter> argument must point to
161 <parameter>n</parameter> I/O vector structures. Each structure may
162 have the <structname>iov_base</structname> field set, in which
163 case the memory pointed to will be copied into the message, or
164 unset (set to zero), in which case a block of zeros of length
165 <structname>iov_len</structname> bytes will be inserted. The
166 memory pointed at by <parameter>iov</parameter> may be changed
167 after this call.</para>
168
169 <para>The <function>sd_bus_message_append_array_space()</function>
170 function appends space for an array of a trivial type to message
171 <parameter>m</parameter>. It behaves the same as
172 <function>sd_bus_message_append_array()</function>, but instead of
173 copying items to the message, it returns a pointer to the
174 destination area to the caller in pointer
175 <parameter>p</parameter>. The caller should subsequently write the
176 array contents to this memory. Modifications to the memory
177 pointed to should only occur until the next operation on the bus
178 message is invoked. Most importantly, the memory should not be
179 altered anymore when another field has been added to the message
180 or the message has been sealed.</para>
181 </refsect1>
182
183 <refsect1>
184 <title>Return Value</title>
185
186 <para>On success, these calls return 0 or a positive integer. On
187 failure, they return a negative errno-style error code.</para>
188 </refsect1>
189
190 <xi:include href="sd_bus_message_append_basic.xml" xpointer="errors" />
191
192 <refsect1>
193 <title>Notes</title>
194
195 <para><function>sd_bus_append_array()</function> and other
196 functions described here are available as a shared library, which
197 can be compiled and linked to with the
198 <constant>libsystemd</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
199 file.</para>
200 </refsect1>
201
202 <refsect1>
203 <title>See Also</title>
204
205 <para>
206 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
207 <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
208 <citerefentry><refentrytitle>sd_bus_message_append</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
209 <citerefentry><refentrytitle>sd_bus_message_append_basic</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
210 <citerefentry project='man-pages'><refentrytitle>memfd_create</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
211 <ulink url="http://dbus.freedesktop.org/doc/dbus-specification.html">The D-Bus specification</ulink>
212 </para>
213 </refsect1>
214
215 </refentry>