chiark / gitweb /
2e57b92af4e399b949a9080e0dabda576e104cf3
[elogind.git] / man / sd_bus_message_append_basic.xml
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
5 <!--
6   SPDX-License-Identifier: LGPL-2.1+
7
8   This file is part of systemd.
9
10   Copyright 2014 Zbigniew JÄ™drzejewski-Szmek
11 -->
12
13 <refentry id="sd_bus_message_append_basic" xmlns:xi="http://www.w3.org/2001/XInclude">
14
15   <refentryinfo>
16     <title>sd_bus_message_append_basic</title>
17     <productname>systemd</productname>
18
19     <authorgroup>
20       <author>
21         <contrib>A monkey with a typewriter</contrib>
22         <firstname>Zbigniew</firstname>
23         <surname>JÄ™drzejewski-Szmek</surname>
24         <email>zbyszek@in.waw.pl</email>
25       </author>
26     </authorgroup>
27   </refentryinfo>
28
29   <refmeta>
30     <refentrytitle>sd_bus_message_append_basic</refentrytitle>
31     <manvolnum>3</manvolnum>
32   </refmeta>
33
34   <refnamediv>
35     <refname>sd_bus_message_append_basic</refname>
36
37     <refpurpose>Attach a single field to a message</refpurpose>
38   </refnamediv>
39
40   <refsynopsisdiv>
41     <funcsynopsis>
42       <funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
43
44       <funcprototype>
45         <funcdef>int sd_bus_message_append_basic</funcdef>
46         <paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
47         <paramdef>char <parameter>type</parameter></paramdef>
48         <paramdef>const void *<parameter>p</parameter></paramdef>
49       </funcprototype>
50     </funcsynopsis>
51   </refsynopsisdiv>
52
53   <refsect1>
54     <title>Description</title>
55
56     <para><function>sd_bus_message_append_basic()</function> appends a
57     single field to the message <parameter>m</parameter>. The
58     parameter <parameter>type</parameter> determines how the pointer
59     <parameter>p</parameter> is interpreted.
60     <parameter>type</parameter> must be one of the basic types as
61     defined by the <ulink
62     url="http://dbus.freedesktop.org/doc/dbus-specification.html#basic-types">Basic
63     Types</ulink> section of the D-Bus specification, and listed in
64     the table below.
65     </para>
66
67     <table id='format-specifiers'>
68       <title>Item type specifiers</title>
69
70       <tgroup cols='5'>
71         <colspec colname='specifier' />
72         <colspec colname='constant' />
73         <colspec colname='description' />
74         <colspec colname='size' />
75         <colspec colname='ctype' />
76         <thead>
77           <row>
78             <entry>Specifier</entry>
79             <entry>Constant</entry>
80             <entry>Description</entry>
81             <entry>Size</entry>
82             <entry>Expected C Type</entry>
83           </row>
84         </thead>
85         <tbody>
86           <row>
87             <entry><literal>y</literal></entry>
88             <entry><constant>SD_BUS_TYPE_BYTE</constant></entry>
89             <entry>unsigned integer</entry>
90             <entry>1 byte</entry>
91             <entry>uint8_t</entry>
92           </row>
93
94           <row>
95             <entry><literal>b</literal></entry>
96             <entry><constant>SD_BUS_TYPE_BOOLEAN</constant></entry>
97             <entry>boolean</entry>
98             <entry>4 bytes</entry>
99             <entry>int</entry>
100           </row>
101
102           <row>
103             <entry><literal>n</literal></entry>
104             <entry><constant>SD_BUS_TYPE_INT16</constant></entry>
105             <entry>signed integer</entry>
106             <entry>2 bytes</entry>
107             <entry>int16_t</entry>
108           </row>
109
110           <row>
111             <entry><literal>q</literal></entry>
112             <entry><constant>SD_BUS_TYPE_UINT16</constant></entry>
113             <entry>unsigned integer</entry>
114             <entry>2 bytes</entry>
115             <entry>uint16_t</entry>
116           </row>
117
118           <row>
119             <entry><literal>i</literal></entry>
120             <entry><constant>SD_BUS_TYPE_INT32</constant></entry>
121             <entry>signed integer</entry>
122             <entry>4 bytes</entry>
123             <entry>int32_t</entry>
124           </row>
125
126           <row>
127             <entry><literal>u</literal></entry>
128             <entry><constant>SD_BUS_TYPE_UINT32</constant></entry>
129             <entry>unsigned integer</entry>
130             <entry>4 bytes</entry>
131             <entry>uint32_t</entry>
132           </row>
133
134           <row>
135             <entry><literal>x</literal></entry>
136             <entry><constant>SD_BUS_TYPE_INT64</constant></entry>
137             <entry>signed integer</entry>
138             <entry>8 bytes</entry>
139             <entry>int64_t</entry>
140           </row>
141
142           <row>
143             <entry><literal>t</literal></entry>
144             <entry><constant>SD_BUS_TYPE_UINT64</constant></entry>
145             <entry>unsigned integer</entry>
146             <entry>8 bytes</entry>
147             <entry>uint64_t</entry>
148           </row>
149
150           <row>
151             <entry><literal>d</literal></entry>
152             <entry><constant>SD_BUS_TYPE_DOUBLE</constant></entry>
153             <entry>floating-point</entry>
154             <entry>8 bytes</entry>
155             <entry>double</entry>
156           </row>
157
158           <row>
159             <entry><literal>s</literal></entry>
160             <entry><constant>SD_BUS_TYPE_STRING</constant></entry>
161             <entry>Unicode string</entry>
162             <entry>variable</entry>
163             <entry>char[]</entry>
164           </row>
165
166           <row>
167             <entry><literal>o</literal></entry>
168             <entry><constant>SD_BUS_TYPE_OBJECT_PATH</constant></entry>
169             <entry>object path</entry>
170             <entry>variable</entry>
171             <entry>char[]</entry>
172           </row>
173
174           <row>
175             <entry><literal>g</literal></entry>
176             <entry><constant>SD_BUS_TYPE_SIGNATURE</constant></entry>
177             <entry>signature</entry>
178             <entry>variable</entry>
179             <entry>char[]</entry>
180           </row>
181
182           <row>
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>
187             <entry>int</entry>
188           </row>
189        </tbody>
190       </tgroup>
191     </table>
192
193     <para>The value of the parameter is copied into a memory area held
194     by the message object, stays in the possession of the caller and
195     may hence be freely changed after this call without affecting the
196     bus message it has been added to. If <parameter>type</parameter>
197     is <literal>h</literal> (UNIX file descriptor), the descriptor is
198     duplicated by this call and the passed descriptor stays in
199     possession of the caller.</para>
200
201     <para>For types <literal>s</literal>, <literal>o</literal>, and
202     <literal>g</literal>, the parameter <parameter>p</parameter> is
203     interpreted as a pointer to a <constant>NUL</constant>-terminated
204     character sequence. As a special case, a <constant>NULL</constant>
205     pointer is interpreted as an empty string. The string should be
206     valid Unicode string encoded as UTF-8. In case of the two latter
207     types, the additional requirements for a D-Bus object path or
208     type signature should be satisfied. Those requirements should be
209     verified by the recipient of the message.
210     </para>
211   </refsect1>
212
213   <refsect1>
214     <title>Return Value</title>
215
216     <para>On success, this call returns 0 or a positive integer. On
217     failure, it returns a negative errno-style error code.</para>
218   </refsect1>
219
220   <refsect1 id='errors'>
221     <title>Errors</title>
222
223     <para>Returned errors may indicate the following problems:</para>
224
225     <variablelist>
226
227       <varlistentry>
228         <term><constant>-EINVAL</constant></term>
229
230         <listitem><para>Specified parameter is invalid.
231         </para></listitem>
232       </varlistentry>
233
234       <varlistentry>
235         <term><constant>-EPERM</constant></term>
236
237         <listitem><para>Message has been sealed.
238         </para></listitem>
239       </varlistentry>
240
241       <varlistentry>
242         <term><constant>-ESTALE</constant></term>
243
244         <listitem><para>Message is in invalid state.
245         </para></listitem>
246       </varlistentry>
247
248       <varlistentry>
249         <term><constant>-ENXIO</constant></term>
250
251         <listitem><para>Message cannot be appended to.
252         </para></listitem>
253       </varlistentry>
254
255       <varlistentry>
256         <term><constant>-ENOMEM</constant></term>
257
258         <listitem><para>Memory allocation failed.</para></listitem>
259       </varlistentry>
260     </variablelist>
261   </refsect1>
262
263   <xi:include href="libelogind-pkgconfig.xml" />
264
265   <refsect1>
266     <title>See Also</title>
267
268     <para>
269       <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
270       <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
271       <citerefentry><refentrytitle>sd_bus_message_append</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
272       <ulink url="http://dbus.freedesktop.org/doc/dbus-specification.html">The D-Bus specification</ulink>
273     </para>
274   </refsect1>
275
276 </refentry>