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">
6 SPDX-License-Identifier: LGPL-2.1+
8 Copyright 2014 Zbigniew Jędrzejewski-Szmek
11 <refentry id="sd_bus_message_append_basic" xmlns:xi="http://www.w3.org/2001/XInclude">
14 <title>sd_bus_message_append_basic</title>
15 <productname>systemd</productname>
19 <contrib>A monkey with a typewriter</contrib>
20 <firstname>Zbigniew</firstname>
21 <surname>Jędrzejewski-Szmek</surname>
22 <email>zbyszek@in.waw.pl</email>
28 <refentrytitle>sd_bus_message_append_basic</refentrytitle>
29 <manvolnum>3</manvolnum>
33 <refname>sd_bus_message_append_basic</refname>
35 <refpurpose>Attach a single field to a message</refpurpose>
40 <funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo>
43 <funcdef>int sd_bus_message_append_basic</funcdef>
44 <paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
45 <paramdef>char <parameter>type</parameter></paramdef>
46 <paramdef>const void *<parameter>p</parameter></paramdef>
52 <title>Description</title>
54 <para><function>sd_bus_message_append_basic()</function> appends a
55 single field to the message <parameter>m</parameter>. The
56 parameter <parameter>type</parameter> determines how the pointer
57 <parameter>p</parameter> is interpreted.
58 <parameter>type</parameter> must be one of the basic types as
60 url="http://dbus.freedesktop.org/doc/dbus-specification.html#basic-types">Basic
61 Types</ulink> section of the D-Bus specification, and listed in
65 <table id='format-specifiers'>
66 <title>Item type specifiers</title>
69 <colspec colname='specifier' />
70 <colspec colname='constant' />
71 <colspec colname='description' />
72 <colspec colname='size' />
73 <colspec colname='ctype' />
76 <entry>Specifier</entry>
77 <entry>Constant</entry>
78 <entry>Description</entry>
80 <entry>Expected C Type</entry>
85 <entry><literal>y</literal></entry>
86 <entry><constant>SD_BUS_TYPE_BYTE</constant></entry>
87 <entry>unsigned integer</entry>
89 <entry>uint8_t</entry>
93 <entry><literal>b</literal></entry>
94 <entry><constant>SD_BUS_TYPE_BOOLEAN</constant></entry>
95 <entry>boolean</entry>
96 <entry>4 bytes</entry>
101 <entry><literal>n</literal></entry>
102 <entry><constant>SD_BUS_TYPE_INT16</constant></entry>
103 <entry>signed integer</entry>
104 <entry>2 bytes</entry>
105 <entry>int16_t</entry>
109 <entry><literal>q</literal></entry>
110 <entry><constant>SD_BUS_TYPE_UINT16</constant></entry>
111 <entry>unsigned integer</entry>
112 <entry>2 bytes</entry>
113 <entry>uint16_t</entry>
117 <entry><literal>i</literal></entry>
118 <entry><constant>SD_BUS_TYPE_INT32</constant></entry>
119 <entry>signed integer</entry>
120 <entry>4 bytes</entry>
121 <entry>int32_t</entry>
125 <entry><literal>u</literal></entry>
126 <entry><constant>SD_BUS_TYPE_UINT32</constant></entry>
127 <entry>unsigned integer</entry>
128 <entry>4 bytes</entry>
129 <entry>uint32_t</entry>
133 <entry><literal>x</literal></entry>
134 <entry><constant>SD_BUS_TYPE_INT64</constant></entry>
135 <entry>signed integer</entry>
136 <entry>8 bytes</entry>
137 <entry>int64_t</entry>
141 <entry><literal>t</literal></entry>
142 <entry><constant>SD_BUS_TYPE_UINT64</constant></entry>
143 <entry>unsigned integer</entry>
144 <entry>8 bytes</entry>
145 <entry>uint64_t</entry>
149 <entry><literal>d</literal></entry>
150 <entry><constant>SD_BUS_TYPE_DOUBLE</constant></entry>
151 <entry>floating-point</entry>
152 <entry>8 bytes</entry>
153 <entry>double</entry>
157 <entry><literal>s</literal></entry>
158 <entry><constant>SD_BUS_TYPE_STRING</constant></entry>
159 <entry>Unicode string</entry>
160 <entry>variable</entry>
161 <entry>char[]</entry>
165 <entry><literal>o</literal></entry>
166 <entry><constant>SD_BUS_TYPE_OBJECT_PATH</constant></entry>
167 <entry>object path</entry>
168 <entry>variable</entry>
169 <entry>char[]</entry>
173 <entry><literal>g</literal></entry>
174 <entry><constant>SD_BUS_TYPE_SIGNATURE</constant></entry>
175 <entry>signature</entry>
176 <entry>variable</entry>
177 <entry>char[]</entry>
181 <entry><literal>h</literal></entry>
182 <entry><constant>SD_BUS_TYPE_UNIX_FD</constant></entry>
183 <entry>UNIX file descriptor</entry>
184 <entry>4 bytes</entry>
191 <para>The value of the parameter is copied into a memory area held
192 by the message object, stays in the possession of the caller and
193 may hence be freely changed after this call without affecting the
194 bus message it has been added to. If <parameter>type</parameter>
195 is <literal>h</literal> (UNIX file descriptor), the descriptor is
196 duplicated by this call and the passed descriptor stays in
197 possession of the caller.</para>
199 <para>For types <literal>s</literal>, <literal>o</literal>, and
200 <literal>g</literal>, the parameter <parameter>p</parameter> is
201 interpreted as a pointer to a <constant>NUL</constant>-terminated
202 character sequence. As a special case, a <constant>NULL</constant>
203 pointer is interpreted as an empty string. The string should be
204 valid Unicode string encoded as UTF-8. In case of the two latter
205 types, the additional requirements for a D-Bus object path or
206 type signature should be satisfied. Those requirements should be
207 verified by the recipient of the message.
212 <title>Return Value</title>
214 <para>On success, this call returns 0 or a positive integer. On
215 failure, it returns a negative errno-style error code.</para>
218 <refsect1 id='errors'>
219 <title>Errors</title>
221 <para>Returned errors may indicate the following problems:</para>
226 <term><constant>-EINVAL</constant></term>
228 <listitem><para>Specified parameter is invalid.
233 <term><constant>-EPERM</constant></term>
235 <listitem><para>Message has been sealed.
240 <term><constant>-ESTALE</constant></term>
242 <listitem><para>Message is in invalid state.
247 <term><constant>-ENXIO</constant></term>
249 <listitem><para>Message cannot be appended to.
254 <term><constant>-ENOMEM</constant></term>
256 <listitem><para>Memory allocation failed.</para></listitem>
261 <xi:include href="libelogind-pkgconfig.xml" />
264 <title>See Also</title>
267 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
268 <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
269 <citerefentry><refentrytitle>sd_bus_message_append</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
270 <ulink url="http://dbus.freedesktop.org/doc/dbus-specification.html">The D-Bus specification</ulink>