1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
6 This file is part of systemd.
8 Copyright 2014 Zbigniew Jędrzejewski-Szmek
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 <refentry id="sd_bus_message_append_basic" conditional="ENABLE_KDBUS">
27 <title>sd_bus_message_append_basic</title>
28 <productname>systemd</productname>
32 <contrib>A monkey with a typewriter</contrib>
33 <firstname>Zbigniew</firstname>
34 <surname>Jędrzejewski-Szmek</surname>
35 <email>zbyszek@in.waw.pl</email>
41 <refentrytitle>sd_bus_message_append_basic</refentrytitle>
42 <manvolnum>3</manvolnum>
46 <refname>sd_bus_message_append_basic</refname>
48 <refpurpose>Attach a single part to a message</refpurpose>
53 <funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo>
56 <funcdef>int sd_bus_message_append_basic</funcdef>
57 <paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
58 <paramdef>char <parameter>type</parameter></paramdef>
59 <paramdef>char void *<parameter>p</parameter></paramdef>
65 <title>Description</title>
67 <para><function>sd_bus_message_append_basic</function> appends a
68 single item to the message <parameter>m</parameter>. Parameter
69 <parameter>type</parameter> determines how pointer
70 <parameter>p</parameter> is interpreted.
71 <parameter>type</parameter> must be one of the basic types
74 <ulink url="http://dbus.freedesktop.org/doc/dbus-specification.html#basic-types">Basic Types</ulink>
75 section of the D-Bus specification, and listed in the table below.
78 <table id='format-specifiers'>
79 <title>Item format specifiers</title>
82 <colspec colname='specifier' />
83 <colspec colname='constant' />
84 <colspec colname='description' />
85 <colspec colname='size' />
88 <entry>Specifier</entry>
89 <entry>Constant</entry>
90 <entry>Description</entry>
96 <entry><literal>y</literal></entry>
97 <entry><constant>SD_BUS_TYPE_BYTE</constant></entry>
98 <entry>unsigned interger</entry>
103 <entry><literal>b</literal></entry>
104 <entry><constant>SD_BUS_TYPE_BOOLEAN</constant></entry>
105 <entry>boolean</entry>
106 <entry>4 bytes</entry>
110 <entry><literal>n</literal></entry>
111 <entry><constant>SD_BUS_TYPE_INT16</constant></entry>
112 <entry>signed integer</entry>
113 <entry>2 bytes</entry>
117 <entry><literal>q</literal></entry>
118 <entry><constant>SD_BUS_TYPE_UINT16</constant></entry>
119 <entry>unsigned integer</entry>
120 <entry>2 bytes</entry>
124 <entry><literal>i</literal></entry>
125 <entry><constant>SD_BUS_TYPE_INT32</constant></entry>
126 <entry>signed integer</entry>
127 <entry>4 bytes</entry>
131 <entry><literal>u</literal></entry>
132 <entry><constant>SD_BUS_TYPE_UINT32</constant></entry>
133 <entry>unsigned integer</entry>
134 <entry>4 bytes</entry>
138 <entry><literal>x</literal></entry>
139 <entry><constant>SD_BUS_TYPE_INT64</constant></entry>
140 <entry>signed integer</entry>
141 <entry>8 bytes</entry>
145 <entry><literal>t</literal></entry>
146 <entry><constant>SD_BUS_TYPE_UINT64</constant></entry>
147 <entry>unsigned integer</entry>
148 <entry>8 bytes</entry>
152 <entry><literal>d</literal></entry>
153 <entry><constant>SD_BUS_TYPE_DOUBLE</constant></entry>
154 <entry>floating-point</entry>
155 <entry>8 bytes</entry>
159 <entry><literal>s</literal></entry>
160 <entry><constant>SD_BUS_TYPE_STRING</constant></entry>
161 <entry>Unicode string</entry>
162 <entry>variable</entry>
166 <entry><literal>o</literal></entry>
167 <entry><constant>SD_BUS_TYPE_OBJECT_PATH</constant></entry>
168 <entry>object path</entry>
169 <entry>variable</entry>
173 <entry><literal>g</literal></entry>
174 <entry><constant>SD_BUS_TYPE_SIGNATURE</constant></entry>
175 <entry>signature</entry>
176 <entry>variable</entry>
180 <entry><literal>h</literal></entry>
181 <entry><constant>SD_BUS_TYPE_UNIX_FD</constant></entry>
182 <entry>UNIX file descriptor</entry>
183 <entry>4 bytes</entry>
189 <para>The value of the parameter is copied into the memory area
190 containing the message and may be changed after this call. If
191 <parameter>type</parameter> is <literal>h</literal> (UNIX file
192 descriptor), it is always "consumed" by this call, and either
193 successfully appended to the message or closed.</para>
195 <para>For types <literal>s</literal>, <literal>o</literal>, and
196 <literal>g</literal>, the parameter <parameter>p</parameter> is
197 interpreted as a pointer to a <constant>NUL</constant>-terminated
198 character sequence. As a special case, a <constant>NULL</constant>
199 pointer is interpreted as an empty string. The string should be
200 valid Unicode string encoded as UTF-8. In case of the two latter
201 types, the additional requirements for a D-Bus object path or
202 type signature should be satisfied. Those requirements should be
203 verified by the recepient of the message.
208 <title>Return Value</title>
210 <para>On success, this call returns 0 or a positive integer. On
211 failure, it returns a negative errno-style error code.</para>
214 <refsect1 id='errors'>
215 <title>Errors</title>
217 <para>Returned errors may indicate the following problems:</para>
222 <term><varname>-EINVAL</varname></term>
224 <listitem><para>Specified parameter is invalid.
229 <term><varname>-EPERM</varname></term>
231 <listitem><para>Message has been sealed.
236 <term><varname>-ESTALE</varname></term>
238 <listitem><para>Message is in invalid state.
243 <term><varname>-ENXIO</varname></term>
245 <listitem><para>Message cannot be appended to.
250 <term><varname>-ENOMEM</varname></term>
252 <listitem><para>Memory allocation failed.</para></listitem>
260 <para>The <function>sd_bus_append_basic()</function> function
261 described here is available as a shared library, which can be
262 compiled and linked to with the
263 <constant>libsystemd</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
268 <title>See Also</title>
271 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
272 <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
273 <citerefentry><refentrytitle>sd_bus_message_append</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
274 <ulink url="http://dbus.freedesktop.org/doc/dbus-specification.html">The D-Bus specification</ulink>