]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/sd_bus_message_append_basic.xml
bec126836e8d6ebe30e91acc37d29b1594b789a6
[thirdparty/systemd.git] / man / sd_bus_message_append_basic.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_basic">
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
50 <refpurpose>Attach a single field to a message</refpurpose>
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>
61 <paramdef>const void *<parameter>p</parameter></paramdef>
62 </funcprototype>
63 </funcsynopsis>
64 </refsynopsisdiv>
65
66 <refsect1>
67 <title>Description</title>
68
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
72 <parameter>p</parameter> is interpreted.
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.
78 </para>
79
80 <table id='format-specifiers'>
81 <title>Item type specifiers</title>
82
83 <tgroup cols='5'>
84 <colspec colname='specifier' />
85 <colspec colname='constant' />
86 <colspec colname='description' />
87 <colspec colname='size' />
88 <colspec colname='ctype' />
89 <thead>
90 <row>
91 <entry>Specifier</entry>
92 <entry>Constant</entry>
93 <entry>Description</entry>
94 <entry>Size</entry>
95 <entry>Expected C Type</entry>
96 </row>
97 </thead>
98 <tbody>
99 <row>
100 <entry><literal>y</literal></entry>
101 <entry><constant>SD_BUS_TYPE_BYTE</constant></entry>
102 <entry>unsigned integer</entry>
103 <entry>1 byte</entry>
104 <entry>uint8_t</entry>
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>
112 <entry>int</entry>
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>
120 <entry>int16_t</entry>
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>
128 <entry>uint16_t</entry>
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>
136 <entry>int32_t</entry>
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>
144 <entry>uint32_t</entry>
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>
152 <entry>int64_t</entry>
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>
160 <entry>uint64_t</entry>
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>
168 <entry>double</entry>
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>
176 <entry>char[]</entry>
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>
184 <entry>char[]</entry>
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>
192 <entry>char[]</entry>
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>
200 <entry>int</entry>
201 </row>
202 </tbody>
203 </tgroup>
204 </table>
205
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>
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
220 types, the additional requirements for a D-Bus object path or
221 type signature should be satisfied. Those requirements should be
222 verified by the recipient of the message.
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>
241 <term><constant>-EINVAL</constant></term>
242
243 <listitem><para>Specified parameter is invalid.
244 </para></listitem>
245 </varlistentry>
246
247 <varlistentry>
248 <term><constant>-EPERM</constant></term>
249
250 <listitem><para>Message has been sealed.
251 </para></listitem>
252 </varlistentry>
253
254 <varlistentry>
255 <term><constant>-ESTALE</constant></term>
256
257 <listitem><para>Message is in invalid state.
258 </para></listitem>
259 </varlistentry>
260
261 <varlistentry>
262 <term><constant>-ENXIO</constant></term>
263
264 <listitem><para>Message cannot be appended to.
265 </para></listitem>
266 </varlistentry>
267
268 <varlistentry>
269 <term><constant>-ENOMEM</constant></term>
270
271 <listitem><para>Memory allocation failed.</para></listitem>
272 </varlistentry>
273 </variablelist>
274 </refsect1>
275
276 <refsect1>
277 <title>Notes</title>
278
279 <para>The <function>sd_bus_append_basic()</function> function
280 described here is available as a shared library, which can be
281 compiled and linked to with the
282 <constant>libsystemd</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
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>