2 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
6 <refentry id=
"sd_bus_message_append_basic" xmlns:
xi=
"http://www.w3.org/2001/XInclude">
9 <title>sd_bus_message_append_basic
</title>
10 <productname>systemd
</productname>
14 <refentrytitle>sd_bus_message_append_basic
</refentrytitle>
15 <manvolnum>3</manvolnum>
19 <refname>sd_bus_message_append_basic
</refname>
21 <refpurpose>Attach a single field to a message
</refpurpose>
26 <funcsynopsisinfo>#include
<systemd/sd-bus.h
></funcsynopsisinfo>
29 <funcdef>int sd_bus_message_append_basic
</funcdef>
30 <paramdef>sd_bus_message *
<parameter>m
</parameter></paramdef>
31 <paramdef>char
<parameter>type
</parameter></paramdef>
32 <paramdef>const void *
<parameter>p
</parameter></paramdef>
38 <title>Description
</title>
40 <para><function>sd_bus_message_append_basic()
</function> appends a
41 single field to the message
<parameter>m
</parameter>. The
42 parameter
<parameter>type
</parameter> determines how the pointer
43 <parameter>p
</parameter> is interpreted.
44 <parameter>type
</parameter> must be one of the basic types as
46 url=
"https://dbus.freedesktop.org/doc/dbus-specification.html#basic-types">Basic
47 Types
</ulink> section of the D-Bus specification, and listed in
51 <table id='format-specifiers'
>
52 <title>Item type specifiers
</title>
55 <colspec colname='specifier'
/>
56 <colspec colname='constant'
/>
57 <colspec colname='description'
/>
58 <colspec colname='size'
/>
59 <colspec colname='ctype'
/>
62 <entry>Specifier
</entry>
63 <entry>Constant
</entry>
64 <entry>Description
</entry>
66 <entry>Expected C Type
</entry>
71 <entry><literal>y
</literal></entry>
72 <entry><constant>SD_BUS_TYPE_BYTE
</constant></entry>
73 <entry>unsigned integer
</entry>
75 <entry>uint8_t
</entry>
79 <entry><literal>b
</literal></entry>
80 <entry><constant>SD_BUS_TYPE_BOOLEAN
</constant></entry>
81 <entry>boolean
</entry>
82 <entry>4 bytes
</entry>
87 <entry><literal>n
</literal></entry>
88 <entry><constant>SD_BUS_TYPE_INT16
</constant></entry>
89 <entry>signed integer
</entry>
90 <entry>2 bytes
</entry>
91 <entry>int16_t
</entry>
95 <entry><literal>q
</literal></entry>
96 <entry><constant>SD_BUS_TYPE_UINT16
</constant></entry>
97 <entry>unsigned integer
</entry>
98 <entry>2 bytes
</entry>
99 <entry>uint16_t
</entry>
103 <entry><literal>i
</literal></entry>
104 <entry><constant>SD_BUS_TYPE_INT32
</constant></entry>
105 <entry>signed integer
</entry>
106 <entry>4 bytes
</entry>
107 <entry>int32_t
</entry>
111 <entry><literal>u
</literal></entry>
112 <entry><constant>SD_BUS_TYPE_UINT32
</constant></entry>
113 <entry>unsigned integer
</entry>
114 <entry>4 bytes
</entry>
115 <entry>uint32_t
</entry>
119 <entry><literal>x
</literal></entry>
120 <entry><constant>SD_BUS_TYPE_INT64
</constant></entry>
121 <entry>signed integer
</entry>
122 <entry>8 bytes
</entry>
123 <entry>int64_t
</entry>
127 <entry><literal>t
</literal></entry>
128 <entry><constant>SD_BUS_TYPE_UINT64
</constant></entry>
129 <entry>unsigned integer
</entry>
130 <entry>8 bytes
</entry>
131 <entry>uint64_t
</entry>
135 <entry><literal>d
</literal></entry>
136 <entry><constant>SD_BUS_TYPE_DOUBLE
</constant></entry>
137 <entry>floating-point
</entry>
138 <entry>8 bytes
</entry>
139 <entry>double
</entry>
143 <entry><literal>s
</literal></entry>
144 <entry><constant>SD_BUS_TYPE_STRING
</constant></entry>
145 <entry>Unicode string
</entry>
146 <entry>variable
</entry>
147 <entry>char[]
</entry>
151 <entry><literal>o
</literal></entry>
152 <entry><constant>SD_BUS_TYPE_OBJECT_PATH
</constant></entry>
153 <entry>object path
</entry>
154 <entry>variable
</entry>
155 <entry>char[]
</entry>
159 <entry><literal>g
</literal></entry>
160 <entry><constant>SD_BUS_TYPE_SIGNATURE
</constant></entry>
161 <entry>signature
</entry>
162 <entry>variable
</entry>
163 <entry>char[]
</entry>
167 <entry><literal>h
</literal></entry>
168 <entry><constant>SD_BUS_TYPE_UNIX_FD
</constant></entry>
169 <entry>UNIX file descriptor
</entry>
170 <entry>4 bytes
</entry>
177 <para>The value of the parameter is copied into a memory area held
178 by the message object, stays in the possession of the caller and
179 may hence be freely changed after this call without affecting the
180 bus message it has been added to. If
<parameter>type
</parameter>
181 is
<literal>h
</literal> (UNIX file descriptor), the descriptor is
182 duplicated by this call and the passed descriptor stays in
183 possession of the caller.
</para>
185 <para>For types
<literal>s
</literal>,
<literal>o
</literal>, and
186 <literal>g
</literal>, the parameter
<parameter>p
</parameter> is
187 interpreted as a pointer to a
<constant>NUL
</constant>-terminated
188 character sequence. As a special case, a
<constant>NULL
</constant>
189 pointer is interpreted as an empty string. The string should be
190 valid Unicode string encoded as UTF-
8. In case of the two latter
191 types, the additional requirements for a D-Bus object path or
192 type signature should be satisfied. Those requirements should be
193 verified by the recipient of the message.
198 <title>Return Value
</title>
200 <para>On success, this call returns
0 or a positive integer. On
201 failure, it returns a negative errno-style error code.
</para>
203 <refsect2 id='errors'
>
204 <title>Errors
</title>
206 <para>Returned errors may indicate the following problems:
</para>
211 <term><constant>-EINVAL
</constant></term>
213 <listitem><para>Specified parameter is invalid.
218 <term><constant>-EPERM
</constant></term>
220 <listitem><para>Message has been sealed.
225 <term><constant>-ESTALE
</constant></term>
227 <listitem><para>Message is in invalid state.
232 <term><constant>-ENXIO
</constant></term>
234 <listitem><para>Message cannot be appended to.
239 <term><constant>-ENOMEM
</constant></term>
241 <listitem><para>Memory allocation failed.
</para></listitem>
247 <xi:include href=
"libsystemd-pkgconfig.xml" />
250 <title>See Also
</title>
252 <para><simplelist type=
"inline">
253 <member><citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
254 <member><citerefentry><refentrytitle>sd-bus
</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
255 <member><citerefentry><refentrytitle>sd_bus_message_read_basic
</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
256 <member><citerefentry><refentrytitle>sd_bus_message_append
</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
257 <member><ulink url=
"https://dbus.freedesktop.org/doc/dbus-specification.html">The D-Bus specification
</ulink></member>