| 1 |
<?xml version='1.0'?> |
| 2 |
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" |
| 3 |
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"> |
| 4 |
<!-- SPDX-License-Identifier: LGPL-2.1-or-later --> |
| 5 |
|
| 6 |
<refentry id="sd_bus_message_read_strv" xmlns:xi="http://www.w3.org/2001/XInclude"> |
| 7 |
|
| 8 |
<refentryinfo> |
| 9 |
<title>sd_bus_message_read_strv</title> |
| 10 |
<productname>systemd</productname> |
| 11 |
</refentryinfo> |
| 12 |
|
| 13 |
<refmeta> |
| 14 |
<refentrytitle>sd_bus_message_read_strv</refentrytitle> |
| 15 |
<manvolnum>3</manvolnum> |
| 16 |
</refmeta> |
| 17 |
|
| 18 |
<refnamediv> |
| 19 |
<refname>sd_bus_message_read_strv</refname> |
| 20 |
<refname>sd_bus_message_read_strv_extend</refname> |
| 21 |
|
| 22 |
<refpurpose>Access an array of strings in a message</refpurpose> |
| 23 |
</refnamediv> |
| 24 |
|
| 25 |
<refsynopsisdiv> |
| 26 |
<funcsynopsis> |
| 27 |
<funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo> |
| 28 |
|
| 29 |
<funcprototype> |
| 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> |
| 33 |
</funcprototype> |
| 34 |
|
| 35 |
<funcprototype> |
| 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> |
| 39 |
</funcprototype> |
| 40 |
</funcsynopsis> |
| 41 |
</refsynopsisdiv> |
| 42 |
|
| 43 |
<refsect1> |
| 44 |
<title>Description</title> |
| 45 |
|
| 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. Also note that as a matter of |
| 53 |
optimization, if an empty array is encountered a <constant>NULL</constant> pointer might be returned |
| 54 |
here, and should be considered equivalent to an array with zero entries.</para> |
| 55 |
|
| 56 |
<para><function>sd_bus_message_read_strv_extend()</function> is similar, but the second parameter is an |
| 57 |
input-output parameter. If <parameter>*l</parameter> is <constant>NULL</constant>, if behaves identically |
| 58 |
to <function>sd_bus_message_read_strv()</function>. Otherwise, <parameter>*l</parameter> must point to a |
| 59 |
strv, which will be reallocated and extended with additional strings. This function is particularly |
| 60 |
useful when combining multiple lists of strings in a message or messages into a single array of strings. |
| 61 |
</para> |
| 62 |
</refsect1> |
| 63 |
|
| 64 |
<refsect1> |
| 65 |
<title>Return Value</title> |
| 66 |
|
| 67 |
<para>On success, these functions return a non-negative integer. On failure, they return a negative |
| 68 |
errno-style error code.</para> |
| 69 |
|
| 70 |
<refsect2> |
| 71 |
<title>Errors</title> |
| 72 |
|
| 73 |
<para>Returned errors may indicate the following problems:</para> |
| 74 |
|
| 75 |
<variablelist> |
| 76 |
<varlistentry> |
| 77 |
<term><constant>-EINVAL</constant></term> |
| 78 |
|
| 79 |
<listitem><para><parameter>m</parameter> or <parameter>l</parameter> are <constant>NULL</constant>. |
| 80 |
</para> |
| 81 |
|
| 82 |
<xi:include href="version-info.xml" xpointer="v246"/></listitem> |
| 83 |
</varlistentry> |
| 84 |
|
| 85 |
<varlistentry> |
| 86 |
<term><constant>-EPERM</constant></term> |
| 87 |
|
| 88 |
<listitem><para>The message is not sealed.</para> |
| 89 |
|
| 90 |
<xi:include href="version-info.xml" xpointer="v246"/></listitem> |
| 91 |
</varlistentry> |
| 92 |
|
| 93 |
<varlistentry> |
| 94 |
<term><constant>-EBADMSG</constant></term> |
| 95 |
|
| 96 |
<listitem><para>The message cannot be parsed.</para> |
| 97 |
|
| 98 |
<xi:include href="version-info.xml" xpointer="v246"/></listitem> |
| 99 |
</varlistentry> |
| 100 |
|
| 101 |
<varlistentry> |
| 102 |
<term><constant>-ENXIO</constant></term> |
| 103 |
|
| 104 |
<listitem><para>The message "read pointer" is not right before an array of the appropriate type. |
| 105 |
</para> |
| 106 |
|
| 107 |
<xi:include href="version-info.xml" xpointer="v248"/></listitem> |
| 108 |
</varlistentry> |
| 109 |
</variablelist> |
| 110 |
</refsect2> |
| 111 |
</refsect1> |
| 112 |
|
| 113 |
<refsect1> |
| 114 |
<title>History</title> |
| 115 |
<para><function>sd_bus_message_read_strv()</function> was added in version 246.</para> |
| 116 |
<para><function>sd_bus_message_read_strv_extend()</function> was added in version 252.</para> |
| 117 |
</refsect1> |
| 118 |
|
| 119 |
<refsect1> |
| 120 |
<title>See Also</title> |
| 121 |
|
| 122 |
<para><simplelist type="inline"> |
| 123 |
<member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 124 |
<member><citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 125 |
<member><citerefentry><refentrytitle>sd_bus_message_read</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 126 |
</simplelist></para> |
| 127 |
</refsect1> |
| 128 |
|
| 129 |
</refentry> |