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 <!ENTITY % entities SYSTEM
"custom-entities.ent" >
9 This file is part of systemd.
11 Copyright 2014 Zbigniew Jędrzejewski-Szmek
13 systemd is free software; you can redistribute it and/or modify it
14 under the terms of the GNU Lesser General Public License as published by
15 the Free Software Foundation; either version 2.1 of the License, or
16 (at your option) any later version.
18 systemd is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 Lesser General Public License for more details.
23 You should have received a copy of the GNU Lesser General Public License
24 along with systemd; If not, see <http://www.gnu.org/licenses/>.
27 <refentry id=
"sd_bus_message_append_basic">
30 <title>sd_bus_message_append_basic
</title>
31 <productname>systemd
</productname>
35 <contrib>A monkey with a typewriter
</contrib>
36 <firstname>Zbigniew
</firstname>
37 <surname>Jędrzejewski-Szmek
</surname>
38 <email>zbyszek@in.waw.pl
</email>
44 <refentrytitle>sd_bus_message_append_basic
</refentrytitle>
45 <manvolnum>3</manvolnum>
49 <refname>sd_bus_message_append_basic
</refname>
51 <refpurpose>Attach a single part to a message
</refpurpose>
56 <funcsynopsisinfo>#include
<systemd/sd-bus.h
></funcsynopsisinfo>
59 <funcdef>int sd_bus_message_append_basic
</funcdef>
60 <paramdef>sd_bus_message *
<parameter>m
</parameter></paramdef>
61 <paramdef>char
<parameter>type
</parameter></paramdef>
62 <paramdef>char void *
<parameter>p
</parameter></paramdef>
68 <title>Description
</title>
70 <para><function>sd_bus_message_append_basic
</function> appends a
71 single item to the message
<parameter>m
</parameter>. Parameter
72 <parameter>type
</parameter> determines how pointer
73 <parameter>p
</parameter> is interpreted.
74 <parameter>type
</parameter> must be one of the basic types
77 <ulink url=
"http://dbus.freedesktop.org/doc/dbus-specification.html#basic-types">Basic Types
</ulink>
78 section of the D-Bus specification, and listed in the table below.
81 <table id='format-specifiers'
>
82 <title>Item format specifiers
</title>
85 <colspec colname='specifier'
/>
86 <colspec colname='constant'
/>
87 <colspec colname='description'
/>
88 <colspec colname='size'
/>
91 <entry>Specifier
</entry>
92 <entry>Constant
</entry>
93 <entry>Description
</entry>
99 <entry><literal>y
</literal></entry>
100 <entry><constant>SD_BUS_TYPE_BYTE
</constant></entry>
101 <entry>unsigned integer
</entry>
102 <entry>1 byte
</entry>
106 <entry><literal>b
</literal></entry>
107 <entry><constant>SD_BUS_TYPE_BOOLEAN
</constant></entry>
108 <entry>boolean
</entry>
109 <entry>4 bytes
</entry>
113 <entry><literal>n
</literal></entry>
114 <entry><constant>SD_BUS_TYPE_INT16
</constant></entry>
115 <entry>signed integer
</entry>
116 <entry>2 bytes
</entry>
120 <entry><literal>q
</literal></entry>
121 <entry><constant>SD_BUS_TYPE_UINT16
</constant></entry>
122 <entry>unsigned integer
</entry>
123 <entry>2 bytes
</entry>
127 <entry><literal>i
</literal></entry>
128 <entry><constant>SD_BUS_TYPE_INT32
</constant></entry>
129 <entry>signed integer
</entry>
130 <entry>4 bytes
</entry>
134 <entry><literal>u
</literal></entry>
135 <entry><constant>SD_BUS_TYPE_UINT32
</constant></entry>
136 <entry>unsigned integer
</entry>
137 <entry>4 bytes
</entry>
141 <entry><literal>x
</literal></entry>
142 <entry><constant>SD_BUS_TYPE_INT64
</constant></entry>
143 <entry>signed integer
</entry>
144 <entry>8 bytes
</entry>
148 <entry><literal>t
</literal></entry>
149 <entry><constant>SD_BUS_TYPE_UINT64
</constant></entry>
150 <entry>unsigned integer
</entry>
151 <entry>8 bytes
</entry>
155 <entry><literal>d
</literal></entry>
156 <entry><constant>SD_BUS_TYPE_DOUBLE
</constant></entry>
157 <entry>floating-point
</entry>
158 <entry>8 bytes
</entry>
162 <entry><literal>s
</literal></entry>
163 <entry><constant>SD_BUS_TYPE_STRING
</constant></entry>
164 <entry>Unicode string
</entry>
165 <entry>variable
</entry>
169 <entry><literal>o
</literal></entry>
170 <entry><constant>SD_BUS_TYPE_OBJECT_PATH
</constant></entry>
171 <entry>object path
</entry>
172 <entry>variable
</entry>
176 <entry><literal>g
</literal></entry>
177 <entry><constant>SD_BUS_TYPE_SIGNATURE
</constant></entry>
178 <entry>signature
</entry>
179 <entry>variable
</entry>
183 <entry><literal>h
</literal></entry>
184 <entry><constant>SD_BUS_TYPE_UNIX_FD
</constant></entry>
185 <entry>UNIX file descriptor
</entry>
186 <entry>4 bytes
</entry>
192 <para>The value of the parameter is copied into the memory area
193 containing the message and may be changed after this call. If
194 <parameter>type
</parameter> is
<literal>h
</literal> (UNIX file
195 descriptor), it is always
"consumed" by this call, and either
196 successfully appended to the message or closed.
</para>
198 <para>For types
<literal>s
</literal>,
<literal>o
</literal>, and
199 <literal>g
</literal>, the parameter
<parameter>p
</parameter> is
200 interpreted as a pointer to a
<constant>NUL
</constant>-terminated
201 character sequence. As a special case, a
<constant>NULL
</constant>
202 pointer is interpreted as an empty string. The string should be
203 valid Unicode string encoded as UTF-
8. In case of the two latter
204 types, the additional requirements for a D-Bus object path or
205 type signature should be satisfied. Those requirements should be
206 verified by the recipient of the message.
211 <title>Return Value
</title>
213 <para>On success, this call returns
0 or a positive integer. On
214 failure, it returns a negative errno-style error code.
</para>
217 <refsect1 id='errors'
>
218 <title>Errors
</title>
220 <para>Returned errors may indicate the following problems:
</para>
225 <term><constant>-EINVAL
</constant></term>
227 <listitem><para>Specified parameter is invalid.
232 <term><constant>-EPERM
</constant></term>
234 <listitem><para>Message has been sealed.
239 <term><constant>-ESTALE
</constant></term>
241 <listitem><para>Message is in invalid state.
246 <term><constant>-ENXIO
</constant></term>
248 <listitem><para>Message cannot be appended to.
253 <term><constant>-ENOMEM
</constant></term>
255 <listitem><para>Memory allocation failed.
</para></listitem>
263 <para>The
<function>sd_bus_append_basic()
</function> function
264 described here is available as a shared library, which can be
265 compiled and linked to with the
266 <constant>libsystemd
</constant> <citerefentry project='die-net'
><refentrytitle>pkg-config
</refentrytitle><manvolnum>1</manvolnum></citerefentry>
271 <title>See Also
</title>
274 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
275 <citerefentry><refentrytitle>sd-bus
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
276 <citerefentry><refentrytitle>sd_bus_message_append
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
277 <ulink url=
"http://dbus.freedesktop.org/doc/dbus-specification.html">The D-Bus specification
</ulink>