1<?xml version='1.0'?> <!--*-nxml-*-->
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 -->
5
6<refentry id="sd_bus_message_get_type" xmlns:xi="http://www.w3.org/2001/XInclude">
7
8  <refentryinfo>
9    <title>sd_bus_message_get_type</title>
10    <productname>systemd</productname>
11  </refentryinfo>
12
13  <refmeta>
14    <refentrytitle>sd_bus_message_get_type</refentrytitle>
15    <manvolnum>3</manvolnum>
16  </refmeta>
17
18  <refnamediv>
19    <refname>sd_bus_message_get_type</refname>
20    <refname>sd_bus_message_get_error</refname>
21    <refname>sd_bus_message_get_errno</refname>
22    <refname>sd_bus_message_get_creds</refname>
23    <refname>sd_bus_message_is_signal</refname>
24    <refname>sd_bus_message_is_method_call</refname>
25    <refname>sd_bus_message_is_method_error</refname>
26
27    <refpurpose>Query bus message addressing/credentials metadata</refpurpose>
28  </refnamediv>
29
30  <refsynopsisdiv>
31    <funcsynopsis>
32      <funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
33
34      <funcprototype>
35        <funcdef>int <function>sd_bus_message_get_type</function></funcdef>
36        <paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
37        <paramdef>uint8_t *<parameter>type</parameter></paramdef>
38      </funcprototype>
39
40      <funcprototype>
41        <funcdef>sd_bus_error* <function>sd_bus_message_get_error</function></funcdef>
42        <paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
43      </funcprototype>
44
45      <funcprototype>
46        <funcdef>int <function>sd_bus_message_get_errno</function></funcdef>
47        <paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
48      </funcprototype>
49
50      <funcprototype>
51        <funcdef>sd_bus_creds* <function>sd_bus_message_get_creds</function></funcdef>
52        <paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
53      </funcprototype>
54
55      <funcprototype>
56        <funcdef>int <function>sd_bus_message_is_signal</function></funcdef>
57        <paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
58        <paramdef>const char *<parameter>interface</parameter></paramdef>
59        <paramdef>const char *<parameter>member</parameter></paramdef>
60      </funcprototype>
61
62      <funcprototype>
63        <funcdef>int <function>sd_bus_message_is_method_call</function></funcdef>
64        <paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
65        <paramdef>const char *<parameter>interface</parameter></paramdef>
66        <paramdef>const char *<parameter>member</parameter></paramdef>
67      </funcprototype>
68
69      <funcprototype>
70        <funcdef>int <function>sd_bus_message_is_method_error</function></funcdef>
71        <paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
72        <paramdef>const char *<parameter>name</parameter></paramdef>
73      </funcprototype>
74    </funcsynopsis>
75
76  </refsynopsisdiv>
77
78  <refsect1>
79    <title>Description</title>
80
81    <para><function>sd_bus_message_get_type()</function> returns the type of a message in the output
82    parameter <parameter>type</parameter>, one of <constant>SD_BUS_MESSAGE_METHOD_CALL</constant>,
83    <constant>SD_BUS_MESSAGE_METHOD_RETURN</constant>, <constant>SD_BUS_MESSAGE_METHOD_ERROR</constant>,
84    <constant>SD_BUS_MESSAGE_SIGNAL</constant>. This type is either specified as a parameter when the message
85    is created using
86    <citerefentry><refentrytitle>sd_bus_message_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
87    or is set automatically when the message is created using
88    <citerefentry><refentrytitle>sd_bus_message_new_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
89    <citerefentry><refentrytitle>sd_bus_message_new_method_call</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
90    <citerefentry><refentrytitle>sd_bus_message_new_method_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>
91    and similar functions.</para>
92
93    <para><function>sd_bus_message_get_error()</function> returns the error stored in the message
94    <parameter>m</parameter>, if there is any. Otherwise, it returns <constant>NULL</constant>.
95    <function>sd_bus_message_get_errno()</function> returns the error stored in the message
96    <parameter>m</parameter> as a positive errno-style value, if there is any. Otherwise, it returns zero.
97    Errors are mapped to errno values according to the default and any additional registered error mappings.
98    See <citerefentry><refentrytitle>sd-bus-errors</refentrytitle><manvolnum>3</manvolnum></citerefentry> and
99    <citerefentry><refentrytitle>sd_bus_error_add_map</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
100    </para>
101
102    <para><function>sd_bus_message_get_creds()</function> returns the message credentials attached to the
103    message <parameter>m</parameter>. If no credentials are attached to the message, it returns
104    <constant>NULL</constant>. Ownership of the credentials instance is not transferred to the caller and
105    hence should not be freed.</para>
106
107    <para><function>sd_bus_message_is_signal()</function> checks if message <parameter>m</parameter> is a
108    signal message. If <parameter>interface</parameter> is non-null, it also checks if the message has the
109    same interface set. If <parameter>member</parameter> is non-null, it also checks if the message has the
110    same member set. Also see
111    <citerefentry><refentrytitle>sd_bus_message_new_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
112    It returns true when all checks pass.</para>
113
114    <para><function>sd_bus_message_is_method_call()</function> checks if message <parameter>m</parameter>
115    is a method call message. If <parameter>interface</parameter> is non-null, it also checks if the message
116    has the same interface set. If <parameter>member</parameter> is non-null, it also checks if the message
117    has the same member set. Also see
118    <citerefentry><refentrytitle>sd_bus_message_new_method_call</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
119    It returns true when all checks pass.</para>
120
121    <para><function>sd_bus_message_is_method_error()</function> checks if message <parameter>m</parameter>
122    is an error reply message. If <parameter>name</parameter> is non-null, it also checks if the message has
123    the same error identifier set. Also see
124    <citerefentry><refentrytitle>sd_bus_message_new_method_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
125    It returns true when all checks pass.</para>
126  </refsect1>
127
128  <refsect1>
129    <title>Return Value</title>
130
131    <para>On success, these functions (except <function>sd_bus_message_get_error()</function> and
132    <function>sd_bus_message_get_creds()</function>) return a non-negative integer. On failure, they return a
133    negative errno-style error code. <function>sd_bus_message_get_errno()</function> always returns a
134    non-negative integer, even on failure.</para>
135
136    <refsect2>
137      <title>Errors</title>
138
139      <para>Returned errors may indicate the following problems:</para>
140
141      <variablelist>
142        <varlistentry>
143          <term><constant>-EINVAL</constant></term>
144
145          <listitem><para>The message parameter <parameter>m</parameter> or an output parameter is
146          <constant>NULL</constant>.</para></listitem>
147        </varlistentry>
148      </variablelist>
149    </refsect2>
150  </refsect1>
151
152  <xi:include href="libsystemd-pkgconfig.xml" />
153
154  <refsect1>
155    <title>See Also</title>
156
157    <para>
158      <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
159      <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
160      <citerefentry><refentrytitle>sd_bus_message_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
161      <citerefentry><refentrytitle>sd_bus_message_set_destination</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
162      <citerefentry><refentrytitle>sd-bus-errors</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
163      <citerefentry><refentrytitle>sd_bus_error_add_map</refentrytitle><manvolnum>3</manvolnum></citerefentry>
164    </para>
165  </refsect1>
166
167</refentry>
168