]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/sd_bus_message_append_basic.xml
test-execute: Add tests for new PassEnvironment= directive
[thirdparty/systemd.git] / man / sd_bus_message_append_basic.xml
CommitLineData
3802a3d3 1<?xml version='1.0'?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
effbc8e4 2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
12b42c76 3"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
effbc8e4
ZJS
4
5<!--
b975b0d5 6 This file is part of systemd.
effbc8e4 7
b975b0d5 8 Copyright 2014 Zbigniew Jędrzejewski-Szmek
effbc8e4 9
b975b0d5
ZJS
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.
effbc8e4 14
b975b0d5
ZJS
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.
effbc8e4 19
b975b0d5
ZJS
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/>.
effbc8e4
ZJS
22-->
23
48f69d8f 24<refentry id="sd_bus_message_append_basic">
effbc8e4
ZJS
25
26 <refentryinfo>
27 <title>sd_bus_message_append_basic</title>
28 <productname>systemd</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
e8216945 48 <refpurpose>Attach a single field to a message</refpurpose>
effbc8e4
ZJS
49 </refnamediv>
50
51 <refsynopsisdiv>
52 <funcsynopsis>
53 <funcsynopsisinfo>#include &lt;systemd/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>
e8216945 59 <paramdef>const void *<parameter>p</parameter></paramdef>
effbc8e4
ZJS
60 </funcprototype>
61 </funcsynopsis>
62 </refsynopsisdiv>
63
64 <refsect1>
65 <title>Description</title>
66
e8216945
LP
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
effbc8e4 70 <parameter>p</parameter> is interpreted.
e8216945
LP
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.
effbc8e4
ZJS
76 </para>
77
78 <table id='format-specifiers'>
e8216945 79 <title>Item type specifiers</title>
effbc8e4 80
e8216945 81 <tgroup cols='5'>
effbc8e4
ZJS
82 <colspec colname='specifier' />
83 <colspec colname='constant' />
84 <colspec colname='description' />
85 <colspec colname='size' />
e8216945 86 <colspec colname='ctype' />
effbc8e4
ZJS
87 <thead>
88 <row>
89 <entry>Specifier</entry>
90 <entry>Constant</entry>
91 <entry>Description</entry>
92 <entry>Size</entry>
e8216945 93 <entry>Expected C Type</entry>
effbc8e4
ZJS
94 </row>
95 </thead>
96 <tbody>
97 <row>
98 <entry><literal>y</literal></entry>
99 <entry><constant>SD_BUS_TYPE_BYTE</constant></entry>
06b643e7 100 <entry>unsigned integer</entry>
effbc8e4 101 <entry>1 byte</entry>
e8216945 102 <entry>uint8_t</entry>
effbc8e4
ZJS
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>
e8216945 110 <entry>int</entry>
effbc8e4
ZJS
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>
e8216945 118 <entry>int16_t</entry>
effbc8e4
ZJS
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>
e8216945 126 <entry>uint16_t</entry>
effbc8e4
ZJS
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>
e8216945 134 <entry>int32_t</entry>
effbc8e4
ZJS
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>
e8216945 142 <entry>uint32_t</entry>
effbc8e4
ZJS
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>
e8216945 150 <entry>int64_t</entry>
effbc8e4
ZJS
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>
e8216945 158 <entry>uint64_t</entry>
effbc8e4
ZJS
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>
e8216945 166 <entry>double</entry>
effbc8e4
ZJS
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>
e8216945 174 <entry>char[]</entry>
effbc8e4
ZJS
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>
e8216945 182 <entry>char[]</entry>
effbc8e4
ZJS
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>
e8216945 190 <entry>char[]</entry>
effbc8e4
ZJS
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>
e8216945 198 <entry>int</entry>
effbc8e4
ZJS
199 </row>
200 </tbody>
201 </tgroup>
202 </table>
203
e8216945
LP
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>
effbc8e4
ZJS
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
b8bde116 218 types, the additional requirements for a D-Bus object path or
effbc8e4 219 type signature should be satisfied. Those requirements should be
06b643e7 220 verified by the recipient of the message.
effbc8e4
ZJS
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>
8474b70c 239 <term><constant>-EINVAL</constant></term>
effbc8e4
ZJS
240
241 <listitem><para>Specified parameter is invalid.
242 </para></listitem>
243 </varlistentry>
244
245 <varlistentry>
8474b70c 246 <term><constant>-EPERM</constant></term>
effbc8e4
ZJS
247
248 <listitem><para>Message has been sealed.
249 </para></listitem>
250 </varlistentry>
251
252 <varlistentry>
8474b70c 253 <term><constant>-ESTALE</constant></term>
effbc8e4
ZJS
254
255 <listitem><para>Message is in invalid state.
256 </para></listitem>
257 </varlistentry>
258
259 <varlistentry>
8474b70c 260 <term><constant>-ENXIO</constant></term>
effbc8e4
ZJS
261
262 <listitem><para>Message cannot be appended to.
263 </para></listitem>
264 </varlistentry>
265
266 <varlistentry>
8474b70c 267 <term><constant>-ENOMEM</constant></term>
effbc8e4
ZJS
268
269 <listitem><para>Memory allocation failed.</para></listitem>
270 </varlistentry>
271 </variablelist>
272 </refsect1>
273
274 <refsect1>
275 <title>Notes</title>
276
b8bde116 277 <para>The <function>sd_bus_append_basic()</function> function
effbc8e4
ZJS
278 described here is available as a shared library, which can be
279 compiled and linked to with the
5aded369 280 <constant>libsystemd</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
effbc8e4
ZJS
281 file.</para>
282 </refsect1>
283
284 <refsect1>
285 <title>See Also</title>
286
287 <para>
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>
292 </para>
293 </refsect1>
294
295</refentry>