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 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">
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 field 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>const void *<parameter>p</parameter></paramdef>
65 <title>Description</title>
67 <para><function>sd_bus_message_append_basic()</function> appends a
68 single field to the message <parameter>m</parameter>. The
69 parameter <parameter>type</parameter> determines how the pointer
70 <parameter>p</parameter> is interpreted.
71 <parameter>type</parameter> must be one of the basic types as
73 url="http://dbus.freedesktop.org/doc/dbus-specification.html#basic-types">Basic
74 Types</ulink> section of the D-Bus specification, and listed in
78 <table id='format-specifiers'>
79 <title>Item type specifiers</title>
82 <colspec colname='specifier' />
83 <colspec colname='constant' />
84 <colspec colname='description' />
85 <colspec colname='size' />
86 <colspec colname='ctype' />
89 <entry>Specifier</entry>
90 <entry>Constant</entry>
91 <entry>Description</entry>
93 <entry>Expected C Type</entry>
98 <entry><literal>y</literal></entry>
99 <entry><constant>SD_BUS_TYPE_BYTE</constant></entry>
100 <entry>unsigned integer</entry>
101 <entry>1 byte</entry>
102 <entry>uint8_t</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>
114 <entry><literal>n</literal></entry>
115 <entry><constant>SD_BUS_TYPE_INT16</constant></entry>
116 <entry>signed integer</entry>
117 <entry>2 bytes</entry>
118 <entry>int16_t</entry>
122 <entry><literal>q</literal></entry>
123 <entry><constant>SD_BUS_TYPE_UINT16</constant></entry>
124 <entry>unsigned integer</entry>
125 <entry>2 bytes</entry>
126 <entry>uint16_t</entry>
130 <entry><literal>i</literal></entry>
131 <entry><constant>SD_BUS_TYPE_INT32</constant></entry>
132 <entry>signed integer</entry>
133 <entry>4 bytes</entry>
134 <entry>int32_t</entry>
138 <entry><literal>u</literal></entry>
139 <entry><constant>SD_BUS_TYPE_UINT32</constant></entry>
140 <entry>unsigned integer</entry>
141 <entry>4 bytes</entry>
142 <entry>uint32_t</entry>
146 <entry><literal>x</literal></entry>
147 <entry><constant>SD_BUS_TYPE_INT64</constant></entry>
148 <entry>signed integer</entry>
149 <entry>8 bytes</entry>
150 <entry>int64_t</entry>
154 <entry><literal>t</literal></entry>
155 <entry><constant>SD_BUS_TYPE_UINT64</constant></entry>
156 <entry>unsigned integer</entry>
157 <entry>8 bytes</entry>
158 <entry>uint64_t</entry>
162 <entry><literal>d</literal></entry>
163 <entry><constant>SD_BUS_TYPE_DOUBLE</constant></entry>
164 <entry>floating-point</entry>
165 <entry>8 bytes</entry>
166 <entry>double</entry>
170 <entry><literal>s</literal></entry>
171 <entry><constant>SD_BUS_TYPE_STRING</constant></entry>
172 <entry>Unicode string</entry>
173 <entry>variable</entry>
174 <entry>char[]</entry>
178 <entry><literal>o</literal></entry>
179 <entry><constant>SD_BUS_TYPE_OBJECT_PATH</constant></entry>
180 <entry>object path</entry>
181 <entry>variable</entry>
182 <entry>char[]</entry>
186 <entry><literal>g</literal></entry>
187 <entry><constant>SD_BUS_TYPE_SIGNATURE</constant></entry>
188 <entry>signature</entry>
189 <entry>variable</entry>
190 <entry>char[]</entry>
194 <entry><literal>h</literal></entry>
195 <entry><constant>SD_BUS_TYPE_UNIX_FD</constant></entry>
196 <entry>UNIX file descriptor</entry>
197 <entry>4 bytes</entry>
204 <para>The value of the parameter is copied into a memory area held
205 by the message object, stays in the possession of the caller and
206 may hence be freely changed after this call without affecting the
207 bus message it has been added to. If <parameter>type</parameter>
208 is <literal>h</literal> (UNIX file descriptor), the descriptor is
209 duplicated by this call and the passed descriptor stays in
210 possession of the caller.</para>
212 <para>For types <literal>s</literal>, <literal>o</literal>, and
213 <literal>g</literal>, the parameter <parameter>p</parameter> is
214 interpreted as a pointer to a <constant>NUL</constant>-terminated
215 character sequence. As a special case, a <constant>NULL</constant>
216 pointer is interpreted as an empty string. The string should be
217 valid Unicode string encoded as UTF-8. In case of the two latter
218 types, the additional requirements for a D-Bus object path or
219 type signature should be satisfied. Those requirements should be
220 verified by the recipient of the message.
225 <title>Return Value</title>
227 <para>On success, this call returns 0 or a positive integer. On
228 failure, it returns a negative errno-style error code.</para>
231 <refsect1 id='errors'>
232 <title>Errors</title>
234 <para>Returned errors may indicate the following problems:</para>
239 <term><constant>-EINVAL</constant></term>
241 <listitem><para>Specified parameter is invalid.
246 <term><constant>-EPERM</constant></term>
248 <listitem><para>Message has been sealed.
253 <term><constant>-ESTALE</constant></term>
255 <listitem><para>Message is in invalid state.
260 <term><constant>-ENXIO</constant></term>
262 <listitem><para>Message cannot be appended to.
267 <term><constant>-ENOMEM</constant></term>
269 <listitem><para>Memory allocation failed.</para></listitem>
277 <para>The <function>sd_bus_append_basic()</function> function
278 described here is available as a shared library, which can be
279 compiled and linked to with the
280 <constant>libelogind</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
285 <title>See Also</title>
288 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
289 <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
290 <citerefentry><refentrytitle>sd_bus_message_append</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
291 <ulink url="http://dbus.freedesktop.org/doc/dbus-specification.html">The D-Bus specification</ulink>