2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
6 <refentry id="sd_bus_message_read_strv" xmlns:xi="http://www.w3.org/2001/XInclude">
9 <title>sd_bus_message_read_strv</title>
10 <productname>systemd</productname>
14 <refentrytitle>sd_bus_message_read_strv</refentrytitle>
15 <manvolnum>3</manvolnum>
19 <refname>sd_bus_message_read_strv</refname>
20 <refname>sd_bus_message_read_strv_extend</refname>
22 <refpurpose>Access an array of strings in a message</refpurpose>
27 <funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo>
30 <funcdef>int <function>sd_bus_message_read_strv</function></funcdef>
31 <paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
32 <paramdef>char ***<parameter>l</parameter></paramdef>
36 <funcdef>int <function>sd_bus_message_read_strv_extend</function></funcdef>
37 <paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
38 <paramdef>char ***<parameter>l</parameter></paramdef>
44 <title>Description</title>
46 <para><function>sd_bus_message_read_strv()</function> reads an array of string-like items from the
47 message <parameter>m</parameter>. The "read pointer" in the message must be right before an array of
48 strings (D-Bus type <literal>as</literal>), object paths (D-Bus type <literal>ao</literal>), or
49 signatures (D-Bus type <literal>ag</literal>). On success, a pointer to a
50 <constant>NULL</constant>-terminated array of strings (strv) is returned in the output parameter
51 <parameter>l</parameter>. Note that ownership of this array is transferred to the caller. Hence, the
52 caller is responsible for freeing this array and its contents.</para>
54 <para><function>sd_bus_message_read_strv_extend()</function> is similar, but the second parameter is an
55 input-output parameter. If <parameter>*l</parameter> is <constant>NULL</constant>, if behaves identically
56 to <function>sd_bus_message_read_strv()</function>. Otherwise, <parameter>*l</parameter> must point to a
57 strv, which will be reallocated and extended with additional strings. This function is particularly
58 useful when combining multiple lists of strings in a message or messages into a single array of strings.
63 <title>Return Value</title>
65 <para>On success, these functions return a non-negative integer. On failure, they return a negative
66 errno-style error code.</para>
71 <para>Returned errors may indicate the following problems:</para>
75 <term><constant>-EINVAL</constant></term>
77 <listitem><para><parameter>m</parameter> or <parameter>l</parameter> are <constant>NULL</constant>.
80 <xi:include href="version-info.xml" xpointer="v246"/></listitem>
84 <term><constant>-EPERM</constant></term>
86 <listitem><para>The message is not sealed.</para>
88 <xi:include href="version-info.xml" xpointer="v246"/></listitem>
92 <term><constant>-EBADMSG</constant></term>
94 <listitem><para>The message cannot be parsed.</para>
96 <xi:include href="version-info.xml" xpointer="v246"/></listitem>
100 <term><constant>-ENXIO</constant></term>
102 <listitem><para>The message "read pointer" is not right before an array of the appropriate type.
105 <xi:include href="version-info.xml" xpointer="v248"/></listitem>
112 <title>History</title>
113 <para><function>sd_bus_message_read_strv()</function> was added in version 246.</para>
114 <para><function>sd_bus_message_read_strv_extend()</function> was added in version 252.</para>
118 <title>See Also</title>
121 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
122 <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
123 <citerefentry><refentrytitle>sd_bus_message_read</refentrytitle><manvolnum>3</manvolnum></citerefentry>