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