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+
9 <refentry id=
"sd_bus_message_append_basic" xmlns:
xi=
"http://www.w3.org/2001/XInclude">
12 <title>sd_bus_message_append_basic
</title>
13 <productname>systemd
</productname>
17 <refentrytitle>sd_bus_message_append_basic
</refentrytitle>
18 <manvolnum>3</manvolnum>
22 <refname>sd_bus_message_append_basic
</refname>
24 <refpurpose>Attach a single field to a message
</refpurpose>
29 <funcsynopsisinfo>#include
<systemd/sd-bus.h
></funcsynopsisinfo>
32 <funcdef>int sd_bus_message_append_basic
</funcdef>
33 <paramdef>sd_bus_message *
<parameter>m
</parameter></paramdef>
34 <paramdef>char
<parameter>type
</parameter></paramdef>
35 <paramdef>const void *
<parameter>p
</parameter></paramdef>
41 <title>Description
</title>
43 <para><function>sd_bus_message_append_basic()
</function> appends a
44 single field to the message
<parameter>m
</parameter>. The
45 parameter
<parameter>type
</parameter> determines how the pointer
46 <parameter>p
</parameter> is interpreted.
47 <parameter>type
</parameter> must be one of the basic types as
49 url=
"http://dbus.freedesktop.org/doc/dbus-specification.html#basic-types">Basic
50 Types
</ulink> section of the D-Bus specification, and listed in
54 <table id='format-specifiers'
>
55 <title>Item type specifiers
</title>
58 <colspec colname='specifier'
/>
59 <colspec colname='constant'
/>
60 <colspec colname='description'
/>
61 <colspec colname='size'
/>
62 <colspec colname='ctype'
/>
65 <entry>Specifier
</entry>
66 <entry>Constant
</entry>
67 <entry>Description
</entry>
69 <entry>Expected C Type
</entry>
74 <entry><literal>y
</literal></entry>
75 <entry><constant>SD_BUS_TYPE_BYTE
</constant></entry>
76 <entry>unsigned integer
</entry>
78 <entry>uint8_t
</entry>
82 <entry><literal>b
</literal></entry>
83 <entry><constant>SD_BUS_TYPE_BOOLEAN
</constant></entry>
84 <entry>boolean
</entry>
85 <entry>4 bytes
</entry>
90 <entry><literal>n
</literal></entry>
91 <entry><constant>SD_BUS_TYPE_INT16
</constant></entry>
92 <entry>signed integer
</entry>
93 <entry>2 bytes
</entry>
94 <entry>int16_t
</entry>
98 <entry><literal>q
</literal></entry>
99 <entry><constant>SD_BUS_TYPE_UINT16
</constant></entry>
100 <entry>unsigned integer
</entry>
101 <entry>2 bytes
</entry>
102 <entry>uint16_t
</entry>
106 <entry><literal>i
</literal></entry>
107 <entry><constant>SD_BUS_TYPE_INT32
</constant></entry>
108 <entry>signed integer
</entry>
109 <entry>4 bytes
</entry>
110 <entry>int32_t
</entry>
114 <entry><literal>u
</literal></entry>
115 <entry><constant>SD_BUS_TYPE_UINT32
</constant></entry>
116 <entry>unsigned integer
</entry>
117 <entry>4 bytes
</entry>
118 <entry>uint32_t
</entry>
122 <entry><literal>x
</literal></entry>
123 <entry><constant>SD_BUS_TYPE_INT64
</constant></entry>
124 <entry>signed integer
</entry>
125 <entry>8 bytes
</entry>
126 <entry>int64_t
</entry>
130 <entry><literal>t
</literal></entry>
131 <entry><constant>SD_BUS_TYPE_UINT64
</constant></entry>
132 <entry>unsigned integer
</entry>
133 <entry>8 bytes
</entry>
134 <entry>uint64_t
</entry>
138 <entry><literal>d
</literal></entry>
139 <entry><constant>SD_BUS_TYPE_DOUBLE
</constant></entry>
140 <entry>floating-point
</entry>
141 <entry>8 bytes
</entry>
142 <entry>double
</entry>
146 <entry><literal>s
</literal></entry>
147 <entry><constant>SD_BUS_TYPE_STRING
</constant></entry>
148 <entry>Unicode string
</entry>
149 <entry>variable
</entry>
150 <entry>char[]
</entry>
154 <entry><literal>o
</literal></entry>
155 <entry><constant>SD_BUS_TYPE_OBJECT_PATH
</constant></entry>
156 <entry>object path
</entry>
157 <entry>variable
</entry>
158 <entry>char[]
</entry>
162 <entry><literal>g
</literal></entry>
163 <entry><constant>SD_BUS_TYPE_SIGNATURE
</constant></entry>
164 <entry>signature
</entry>
165 <entry>variable
</entry>
166 <entry>char[]
</entry>
170 <entry><literal>h
</literal></entry>
171 <entry><constant>SD_BUS_TYPE_UNIX_FD
</constant></entry>
172 <entry>UNIX file descriptor
</entry>
173 <entry>4 bytes
</entry>
180 <para>The value of the parameter is copied into a memory area held
181 by the message object, stays in the possession of the caller and
182 may hence be freely changed after this call without affecting the
183 bus message it has been added to. If
<parameter>type
</parameter>
184 is
<literal>h
</literal> (UNIX file descriptor), the descriptor is
185 duplicated by this call and the passed descriptor stays in
186 possession of the caller.
</para>
188 <para>For types
<literal>s
</literal>,
<literal>o
</literal>, and
189 <literal>g
</literal>, the parameter
<parameter>p
</parameter> is
190 interpreted as a pointer to a
<constant>NUL
</constant>-terminated
191 character sequence. As a special case, a
<constant>NULL
</constant>
192 pointer is interpreted as an empty string. The string should be
193 valid Unicode string encoded as UTF-
8. In case of the two latter
194 types, the additional requirements for a D-Bus object path or
195 type signature should be satisfied. Those requirements should be
196 verified by the recipient of the message.
201 <title>Return Value
</title>
203 <para>On success, this call returns
0 or a positive integer. On
204 failure, it returns a negative errno-style error code.
</para>
207 <refsect1 id='errors'
>
208 <title>Errors
</title>
210 <para>Returned errors may indicate the following problems:
</para>
215 <term><constant>-EINVAL
</constant></term>
217 <listitem><para>Specified parameter is invalid.
222 <term><constant>-EPERM
</constant></term>
224 <listitem><para>Message has been sealed.
229 <term><constant>-ESTALE
</constant></term>
231 <listitem><para>Message is in invalid state.
236 <term><constant>-ENXIO
</constant></term>
238 <listitem><para>Message cannot be appended to.
243 <term><constant>-ENOMEM
</constant></term>
245 <listitem><para>Memory allocation failed.
</para></listitem>
250 <xi:include href=
"libsystemd-pkgconfig.xml" />
253 <title>See Also
</title>
256 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
257 <citerefentry><refentrytitle>sd-bus
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
258 <citerefentry><refentrytitle>sd_bus_message_append
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
259 <ulink url=
"http://dbus.freedesktop.org/doc/dbus-specification.html">The D-Bus specification
</ulink>