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 This file is part of systemd.
10 Copyright 2014 Zbigniew Jędrzejewski-Szmek
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.
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.
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/>.
26 <refentry id=
"sd_bus_message_append_basic">
29 <title>sd_bus_message_append_basic
</title>
30 <productname>systemd
</productname>
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>
43 <refentrytitle>sd_bus_message_append_basic
</refentrytitle>
44 <manvolnum>3</manvolnum>
48 <refname>sd_bus_message_append_basic
</refname>
50 <refpurpose>Attach a single field to a message
</refpurpose>
55 <funcsynopsisinfo>#include
<systemd/sd-bus.h
></funcsynopsisinfo>
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>
67 <title>Description
</title>
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
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
80 <table id='format-specifiers'
>
81 <title>Item type specifiers
</title>
84 <colspec colname='specifier'
/>
85 <colspec colname='constant'
/>
86 <colspec colname='description'
/>
87 <colspec colname='size'
/>
88 <colspec colname='ctype'
/>
91 <entry>Specifier
</entry>
92 <entry>Constant
</entry>
93 <entry>Description
</entry>
95 <entry>Expected C Type
</entry>
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>
108 <entry><literal>b
</literal></entry>
109 <entry><constant>SD_BUS_TYPE_BOOLEAN
</constant></entry>
110 <entry>boolean
</entry>
111 <entry>4 bytes
</entry>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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.
227 <title>Return Value
</title>
229 <para>On success, this call returns
0 or a positive integer. On
230 failure, it returns a negative errno-style error code.
</para>
233 <refsect1 id='errors'
>
234 <title>Errors
</title>
236 <para>Returned errors may indicate the following problems:
</para>
241 <term><constant>-EINVAL
</constant></term>
243 <listitem><para>Specified parameter is invalid.
248 <term><constant>-EPERM
</constant></term>
250 <listitem><para>Message has been sealed.
255 <term><constant>-ESTALE
</constant></term>
257 <listitem><para>Message is in invalid state.
262 <term><constant>-ENXIO
</constant></term>
264 <listitem><para>Message cannot be appended to.
269 <term><constant>-ENOMEM
</constant></term>
271 <listitem><para>Memory allocation failed.
</para></listitem>
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>
287 <title>See Also
</title>
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>