chiark / gitweb /
Merge patches from Hleb Valoshka
[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   This file is part of elogind.
7
8   Copyright 2014 Zbigniew Jędrzejewski-Szmek
9
10   elogind 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.
14
15   elogind 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.
19
20   You should have received a copy of the GNU Lesser General Public License
21   along with elogind; If not, see <http://www.gnu.org/licenses/>.
22 -->
23
24 <refentry id="sd_bus_message_append_basic">
25
26   <refentryinfo>
27     <title>sd_bus_message_append_basic</title>
28     <productname>elogind</productname>
29
30     <authorgroup>
31       <author>
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>
36       </author>
37     </authorgroup>
38   </refentryinfo>
39
40   <refmeta>
41     <refentrytitle>sd_bus_message_append_basic</refentrytitle>
42     <manvolnum>3</manvolnum>
43   </refmeta>
44
45   <refnamediv>
46     <refname>sd_bus_message_append_basic</refname>
47
48     <refpurpose>Attach a single field to a message</refpurpose>
49   </refnamediv>
50
51   <refsynopsisdiv>
52     <funcsynopsis>
53       <funcsynopsisinfo>#include &lt;elogind/sd-bus.h&gt;</funcsynopsisinfo>
54
55       <funcprototype>
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>
60       </funcprototype>
61     </funcsynopsis>
62   </refsynopsisdiv>
63
64   <refsect1>
65     <title>Description</title>
66
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
72     defined by the <ulink
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
75     the table below.
76     </para>
77
78     <table id='format-specifiers'>
79       <title>Item type specifiers</title>
80
81       <tgroup cols='5'>
82         <colspec colname='specifier' />
83         <colspec colname='constant' />
84         <colspec colname='description' />
85         <colspec colname='size' />
86         <colspec colname='ctype' />
87         <thead>
88           <row>
89             <entry>Specifier</entry>
90             <entry>Constant</entry>
91             <entry>Description</entry>
92             <entry>Size</entry>
93             <entry>Expected C Type</entry>
94           </row>
95         </thead>
96         <tbody>
97           <row>
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>
103           </row>
104
105           <row>
106             <entry><literal>b</literal></entry>
107             <entry><constant>SD_BUS_TYPE_BOOLEAN</constant></entry>
108             <entry>boolean</entry>
109             <entry>4 bytes</entry>
110             <entry>int</entry>
111           </row>
112
113           <row>
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>
119           </row>
120
121           <row>
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>
127           </row>
128
129           <row>
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>
135           </row>
136
137           <row>
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>
143           </row>
144
145           <row>
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>
151           </row>
152
153           <row>
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>
159           </row>
160
161           <row>
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>
167           </row>
168
169           <row>
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>
175           </row>
176
177           <row>
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>
183           </row>
184
185           <row>
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>
191           </row>
192
193           <row>
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>
198             <entry>int</entry>
199           </row>
200        </tbody>
201       </tgroup>
202     </table>
203
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>
211
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.
221     </para>
222   </refsect1>
223
224   <refsect1>
225     <title>Return Value</title>
226
227     <para>On success, this call returns 0 or a positive integer. On
228     failure, it returns a negative errno-style error code.</para>
229   </refsect1>
230
231   <refsect1 id='errors'>
232     <title>Errors</title>
233
234     <para>Returned errors may indicate the following problems:</para>
235
236     <variablelist>
237
238       <varlistentry>
239         <term><constant>-EINVAL</constant></term>
240
241         <listitem><para>Specified parameter is invalid.
242         </para></listitem>
243       </varlistentry>
244
245       <varlistentry>
246         <term><constant>-EPERM</constant></term>
247
248         <listitem><para>Message has been sealed.
249         </para></listitem>
250       </varlistentry>
251
252       <varlistentry>
253         <term><constant>-ESTALE</constant></term>
254
255         <listitem><para>Message is in invalid state.
256         </para></listitem>
257       </varlistentry>
258
259       <varlistentry>
260         <term><constant>-ENXIO</constant></term>
261
262         <listitem><para>Message cannot be appended to.
263         </para></listitem>
264       </varlistentry>
265
266       <varlistentry>
267         <term><constant>-ENOMEM</constant></term>
268
269         <listitem><para>Memory allocation failed.</para></listitem>
270       </varlistentry>
271     </variablelist>
272   </refsect1>
273
274   <refsect1>
275     <title>Notes</title>
276
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>
281     file.</para>
282   </refsect1>
283
284   <refsect1>
285     <title>See Also</title>
286
287     <para>
288       <citerefentry><refentrytitle>elogind</refentrytitle><manvolnum>8</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>
292     </para>
293   </refsect1>
294
295 </refentry>