]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/sd_bus_message_append_basic.xml
verify: use manager_load_startable_unit_or_warn() to load units for verification
[thirdparty/systemd.git] / man / sd_bus_message_append_basic.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
b975b0d5 8 This file is part of systemd.
effbc8e4 9
b975b0d5 10 Copyright 2014 Zbigniew Jędrzejewski-Szmek
effbc8e4 11
b975b0d5
ZJS
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.
effbc8e4 16
b975b0d5
ZJS
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.
effbc8e4 21
b975b0d5
ZJS
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/>.
effbc8e4
ZJS
24-->
25
48f69d8f 26<refentry id="sd_bus_message_append_basic">
effbc8e4
ZJS
27
28 <refentryinfo>
29 <title>sd_bus_message_append_basic</title>
30 <productname>systemd</productname>
31
32 <authorgroup>
33 <author>
34 <contrib>A monkey with a typewriter</contrib>
35 <firstname>Zbigniew</firstname>
36 <surname>Jędrzejewski-Szmek</surname>
37 <email>zbyszek@in.waw.pl</email>
38 </author>
39 </authorgroup>
40 </refentryinfo>
41
42 <refmeta>
43 <refentrytitle>sd_bus_message_append_basic</refentrytitle>
44 <manvolnum>3</manvolnum>
45 </refmeta>
46
47 <refnamediv>
48 <refname>sd_bus_message_append_basic</refname>
49
e8216945 50 <refpurpose>Attach a single field to a message</refpurpose>
effbc8e4
ZJS
51 </refnamediv>
52
53 <refsynopsisdiv>
54 <funcsynopsis>
55 <funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
56
57 <funcprototype>
58 <funcdef>int sd_bus_message_append_basic</funcdef>
59 <paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
60 <paramdef>char <parameter>type</parameter></paramdef>
e8216945 61 <paramdef>const void *<parameter>p</parameter></paramdef>
effbc8e4
ZJS
62 </funcprototype>
63 </funcsynopsis>
64 </refsynopsisdiv>
65
66 <refsect1>
67 <title>Description</title>
68
e8216945
LP
69 <para><function>sd_bus_message_append_basic()</function> appends a
70 single field to the message <parameter>m</parameter>. The
71 parameter <parameter>type</parameter> determines how the pointer
effbc8e4 72 <parameter>p</parameter> is interpreted.
e8216945
LP
73 <parameter>type</parameter> must be one of the basic types as
74 defined by the <ulink
75 url="http://dbus.freedesktop.org/doc/dbus-specification.html#basic-types">Basic
76 Types</ulink> section of the D-Bus specification, and listed in
77 the table below.
effbc8e4
ZJS
78 </para>
79
80 <table id='format-specifiers'>
e8216945 81 <title>Item type specifiers</title>
effbc8e4 82
e8216945 83 <tgroup cols='5'>
effbc8e4
ZJS
84 <colspec colname='specifier' />
85 <colspec colname='constant' />
86 <colspec colname='description' />
87 <colspec colname='size' />
e8216945 88 <colspec colname='ctype' />
effbc8e4
ZJS
89 <thead>
90 <row>
91 <entry>Specifier</entry>
92 <entry>Constant</entry>
93 <entry>Description</entry>
94 <entry>Size</entry>
e8216945 95 <entry>Expected C Type</entry>
effbc8e4
ZJS
96 </row>
97 </thead>
98 <tbody>
99 <row>
100 <entry><literal>y</literal></entry>
101 <entry><constant>SD_BUS_TYPE_BYTE</constant></entry>
06b643e7 102 <entry>unsigned integer</entry>
effbc8e4 103 <entry>1 byte</entry>
e8216945 104 <entry>uint8_t</entry>
effbc8e4
ZJS
105 </row>
106
107 <row>
108 <entry><literal>b</literal></entry>
109 <entry><constant>SD_BUS_TYPE_BOOLEAN</constant></entry>
110 <entry>boolean</entry>
111 <entry>4 bytes</entry>
e8216945 112 <entry>int</entry>
effbc8e4
ZJS
113 </row>
114
115 <row>
116 <entry><literal>n</literal></entry>
117 <entry><constant>SD_BUS_TYPE_INT16</constant></entry>
118 <entry>signed integer</entry>
119 <entry>2 bytes</entry>
e8216945 120 <entry>int16_t</entry>
effbc8e4
ZJS
121 </row>
122
123 <row>
124 <entry><literal>q</literal></entry>
125 <entry><constant>SD_BUS_TYPE_UINT16</constant></entry>
126 <entry>unsigned integer</entry>
127 <entry>2 bytes</entry>
e8216945 128 <entry>uint16_t</entry>
effbc8e4
ZJS
129 </row>
130
131 <row>
132 <entry><literal>i</literal></entry>
133 <entry><constant>SD_BUS_TYPE_INT32</constant></entry>
134 <entry>signed integer</entry>
135 <entry>4 bytes</entry>
e8216945 136 <entry>int32_t</entry>
effbc8e4
ZJS
137 </row>
138
139 <row>
140 <entry><literal>u</literal></entry>
141 <entry><constant>SD_BUS_TYPE_UINT32</constant></entry>
142 <entry>unsigned integer</entry>
143 <entry>4 bytes</entry>
e8216945 144 <entry>uint32_t</entry>
effbc8e4
ZJS
145 </row>
146
147 <row>
148 <entry><literal>x</literal></entry>
149 <entry><constant>SD_BUS_TYPE_INT64</constant></entry>
150 <entry>signed integer</entry>
151 <entry>8 bytes</entry>
e8216945 152 <entry>int64_t</entry>
effbc8e4
ZJS
153 </row>
154
155 <row>
156 <entry><literal>t</literal></entry>
157 <entry><constant>SD_BUS_TYPE_UINT64</constant></entry>
158 <entry>unsigned integer</entry>
159 <entry>8 bytes</entry>
e8216945 160 <entry>uint64_t</entry>
effbc8e4
ZJS
161 </row>
162
163 <row>
164 <entry><literal>d</literal></entry>
165 <entry><constant>SD_BUS_TYPE_DOUBLE</constant></entry>
166 <entry>floating-point</entry>
167 <entry>8 bytes</entry>
e8216945 168 <entry>double</entry>
effbc8e4
ZJS
169 </row>
170
171 <row>
172 <entry><literal>s</literal></entry>
173 <entry><constant>SD_BUS_TYPE_STRING</constant></entry>
174 <entry>Unicode string</entry>
175 <entry>variable</entry>
e8216945 176 <entry>char[]</entry>
effbc8e4
ZJS
177 </row>
178
179 <row>
180 <entry><literal>o</literal></entry>
181 <entry><constant>SD_BUS_TYPE_OBJECT_PATH</constant></entry>
182 <entry>object path</entry>
183 <entry>variable</entry>
e8216945 184 <entry>char[]</entry>
effbc8e4
ZJS
185 </row>
186
187 <row>
188 <entry><literal>g</literal></entry>
189 <entry><constant>SD_BUS_TYPE_SIGNATURE</constant></entry>
190 <entry>signature</entry>
191 <entry>variable</entry>
e8216945 192 <entry>char[]</entry>
effbc8e4
ZJS
193 </row>
194
195 <row>
196 <entry><literal>h</literal></entry>
197 <entry><constant>SD_BUS_TYPE_UNIX_FD</constant></entry>
198 <entry>UNIX file descriptor</entry>
199 <entry>4 bytes</entry>
e8216945 200 <entry>int</entry>
effbc8e4
ZJS
201 </row>
202 </tbody>
203 </tgroup>
204 </table>
205
e8216945
LP
206 <para>The value of the parameter is copied into a memory area held
207 by the message object, stays in the possession of the caller and
208 may hence be freely changed after this call without affecting the
209 bus message it has been added to. If <parameter>type</parameter>
210 is <literal>h</literal> (UNIX file descriptor), the descriptor is
211 duplicated by this call and the passed descriptor stays in
212 possession of the caller.</para>
effbc8e4
ZJS
213
214 <para>For types <literal>s</literal>, <literal>o</literal>, and
215 <literal>g</literal>, the parameter <parameter>p</parameter> is
216 interpreted as a pointer to a <constant>NUL</constant>-terminated
217 character sequence. As a special case, a <constant>NULL</constant>
218 pointer is interpreted as an empty string. The string should be
219 valid Unicode string encoded as UTF-8. In case of the two latter
b8bde116 220 types, the additional requirements for a D-Bus object path or
effbc8e4 221 type signature should be satisfied. Those requirements should be
06b643e7 222 verified by the recipient of the message.
effbc8e4
ZJS
223 </para>
224 </refsect1>
225
226 <refsect1>
227 <title>Return Value</title>
228
229 <para>On success, this call returns 0 or a positive integer. On
230 failure, it returns a negative errno-style error code.</para>
231 </refsect1>
232
233 <refsect1 id='errors'>
234 <title>Errors</title>
235
236 <para>Returned errors may indicate the following problems:</para>
237
238 <variablelist>
239
240 <varlistentry>
8474b70c 241 <term><constant>-EINVAL</constant></term>
effbc8e4
ZJS
242
243 <listitem><para>Specified parameter is invalid.
244 </para></listitem>
245 </varlistentry>
246
247 <varlistentry>
8474b70c 248 <term><constant>-EPERM</constant></term>
effbc8e4
ZJS
249
250 <listitem><para>Message has been sealed.
251 </para></listitem>
252 </varlistentry>
253
254 <varlistentry>
8474b70c 255 <term><constant>-ESTALE</constant></term>
effbc8e4
ZJS
256
257 <listitem><para>Message is in invalid state.
258 </para></listitem>
259 </varlistentry>
260
261 <varlistentry>
8474b70c 262 <term><constant>-ENXIO</constant></term>
effbc8e4
ZJS
263
264 <listitem><para>Message cannot be appended to.
265 </para></listitem>
266 </varlistentry>
267
268 <varlistentry>
8474b70c 269 <term><constant>-ENOMEM</constant></term>
effbc8e4
ZJS
270
271 <listitem><para>Memory allocation failed.</para></listitem>
272 </varlistentry>
273 </variablelist>
274 </refsect1>
275
276 <refsect1>
277 <title>Notes</title>
278
b8bde116 279 <para>The <function>sd_bus_append_basic()</function> function
effbc8e4
ZJS
280 described here is available as a shared library, which can be
281 compiled and linked to with the
5aded369 282 <constant>libsystemd</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
effbc8e4
ZJS
283 file.</para>
284 </refsect1>
285
286 <refsect1>
287 <title>See Also</title>
288
289 <para>
290 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
291 <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
292 <citerefentry><refentrytitle>sd_bus_message_append</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
293 <ulink url="http://dbus.freedesktop.org/doc/dbus-specification.html">The D-Bus specification</ulink>
294 </para>
295 </refsect1>
296
297</refentry>