| 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_dump" |
| 7 |
xmlns:xi="http://www.w3.org/2001/XInclude"> |
| 8 |
|
| 9 |
<refentryinfo> |
| 10 |
<title>sd_bus_message_dump</title> |
| 11 |
<productname>systemd</productname> |
| 12 |
</refentryinfo> |
| 13 |
|
| 14 |
<refmeta> |
| 15 |
<refentrytitle>sd_bus_message_dump</refentrytitle> |
| 16 |
<manvolnum>3</manvolnum> |
| 17 |
</refmeta> |
| 18 |
|
| 19 |
<refnamediv> |
| 20 |
<refname>sd_bus_message_dump</refname> |
| 21 |
<refname>sd_bus_message_dump_json</refname> |
| 22 |
|
| 23 |
<refpurpose>Produce a string representation of a message for debugging purposes</refpurpose> |
| 24 |
</refnamediv> |
| 25 |
|
| 26 |
<refsynopsisdiv> |
| 27 |
<funcsynopsis> |
| 28 |
<funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo> |
| 29 |
|
| 30 |
<funcprototype> |
| 31 |
<funcdef>int sd_bus_message_dump</funcdef> |
| 32 |
<paramdef>sd_bus_message *<parameter>m</parameter></paramdef> |
| 33 |
<paramdef>FILE *<parameter>f</parameter></paramdef> |
| 34 |
<paramdef>uint64_t <parameter>flags</parameter></paramdef> |
| 35 |
</funcprototype> |
| 36 |
|
| 37 |
<funcprototype> |
| 38 |
<funcdef>int sd_bus_message_dump_json</funcdef> |
| 39 |
<paramdef>sd_bus_message *<parameter>m</parameter></paramdef> |
| 40 |
<paramdef>uint64_t <parameter>flags</parameter></paramdef> |
| 41 |
<paramdef>sd_json_variant **<parameter>ret</parameter></paramdef> |
| 42 |
</funcprototype> |
| 43 |
</funcsynopsis> |
| 44 |
</refsynopsisdiv> |
| 45 |
|
| 46 |
<refsect1> |
| 47 |
<title>Description</title> |
| 48 |
|
| 49 |
<para>The <function>sd_bus_message_dump()</function> function writes a textual representation of the |
| 50 |
message <parameter>m</parameter> to the stream <parameter>f</parameter>. If <parameter>f</parameter> is |
| 51 |
<constant>NULL</constant>, standard output (<constant>stdio</constant>) will be used. This function is |
| 52 |
intended to be used for debugging purposes, and the output is neither stable nor designed to be machine |
| 53 |
readable.</para> |
| 54 |
|
| 55 |
<para>The <function>sd_bus_message_dump_json()</function> function converts the DBus message |
| 56 |
<parameter>m</parameter> to a JSON variant and stores it in <parameter>ret</parameter>. The caller should |
| 57 |
call <function>sd_json_variant_unref()</function> for the acquired JSON variant after use. Unlike |
| 58 |
<function>sd_bus_message_dump()</function>, the function itself does not print anything. To print the |
| 59 |
DBus message in the JSON format, please pass the returned JSON variant to |
| 60 |
<function>sd_json_variant_dump()</function>.</para> |
| 61 |
|
| 62 |
<para>The <parameter>flags</parameter> parameter may be used to modify the output, and is a combination |
| 63 |
of zero or more of the following flags:</para> |
| 64 |
|
| 65 |
<variablelist> |
| 66 |
<varlistentry> |
| 67 |
<term><constant>SD_BUS_MESSAGE_DUMP_WITH_HEADER</constant></term> |
| 68 |
|
| 69 |
<listitem><para>The header of the message that specifies the message type, flags, and several more |
| 70 |
additional metadata will be printed or included in the resulting JSON object.</para></listitem> |
| 71 |
</varlistentry> |
| 72 |
|
| 73 |
<varlistentry> |
| 74 |
<term><constant>SD_BUS_MESSAGE_DUMP_SUBTREE_ONLY</constant></term> |
| 75 |
|
| 76 |
<listitem><para>Only the current container will be printed or converted. When the flag is |
| 77 |
<emphasis>not</emphasis> specified, the contents of the whole message will be printed or converted. |
| 78 |
</para></listitem> |
| 79 |
</varlistentry> |
| 80 |
</variablelist> |
| 81 |
|
| 82 |
<para>Note that these functions move the read pointer of the message. It may be necessary to reset the |
| 83 |
position afterwards, for example with |
| 84 |
<citerefentry><refentrytitle>sd_bus_message_rewind</refentrytitle><manvolnum>3</manvolnum></citerefentry>. |
| 85 |
</para> |
| 86 |
|
| 87 |
</refsect1> |
| 88 |
|
| 89 |
<refsect1> |
| 90 |
<title>Examples</title> |
| 91 |
|
| 92 |
<para>Output for a signal message (with <constant>SD_BUS_MESSAGE_DUMP_WITH_HEADER</constant>): |
| 93 |
<programlisting> |
| 94 |
‣ Type=signal Endian=l Flags=1 Version=1 Cookie=22 |
| 95 |
Path=/value/a Interface=org.freedesktop.DBus.Properties Member=PropertiesChanged |
| 96 |
MESSAGE "sa{sv}as" { |
| 97 |
STRING "org.freedesktop.systemd.ValueTest"; |
| 98 |
ARRAY "{sv}" { |
| 99 |
DICT_ENTRY "sv" { |
| 100 |
STRING "Value"; |
| 101 |
VARIANT "s" { |
| 102 |
STRING "object 0x1e, path /value/a"; |
| 103 |
}; |
| 104 |
}; |
| 105 |
}; |
| 106 |
ARRAY "s" { |
| 107 |
STRING "Value2"; |
| 108 |
STRING "AnExplicitProperty"; |
| 109 |
}; |
| 110 |
}; |
| 111 |
</programlisting> |
| 112 |
</para> |
| 113 |
</refsect1> |
| 114 |
|
| 115 |
<refsect1> |
| 116 |
<title>Return Value</title> |
| 117 |
|
| 118 |
<para>On success, this function returns 0 or a positive integer. On failure, it returns a negative |
| 119 |
errno-style error code. No error codes are currently defined.</para> |
| 120 |
</refsect1> |
| 121 |
|
| 122 |
<xi:include href="libsystemd-pkgconfig.xml" /> |
| 123 |
|
| 124 |
<refsect1> |
| 125 |
<title>See Also</title> |
| 126 |
|
| 127 |
<para><simplelist type="inline"> |
| 128 |
<member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 129 |
<member><citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 130 |
<member><citerefentry><refentrytitle>sd-json</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 131 |
</simplelist></para> |
| 132 |
</refsect1> |
| 133 |
|
| 134 |
</refentry> |