chiark / gitweb /
check for _POSIX_C_SOURCE instead of __USE_POSIX*
[elogind.git] / man / sd_bus_add_match.xml
1 <?xml version='1.0'?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5 <!--
6   This file is part of systemd.
7
8   Copyright 2016 Julian Orth
9
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.
14
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.
19
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/>.
22 -->
23
24 <refentry id="sd_bus_add_match">
25
26   <refentryinfo>
27     <title>sd_bus_add_match</title>
28     <productname>systemd</productname>
29
30     <authorgroup>
31       <author>
32         <firstname>Julian</firstname>
33         <surname>Orth</surname>
34         <email>ju.orth@gmail.com</email>
35       </author>
36     </authorgroup>
37   </refentryinfo>
38
39   <refmeta>
40     <refentrytitle>sd_bus_add_match</refentrytitle>
41     <manvolnum>3</manvolnum>
42   </refmeta>
43
44   <refnamediv>
45     <refname>sd_bus_add_match</refname>
46
47     <refpurpose>Add a match rule for message dispatching</refpurpose>
48   </refnamediv>
49
50   <refsynopsisdiv>
51     <funcsynopsis>
52       <funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
53
54       <funcprototype>
55         <funcdef>int <function>sd_bus_add_match</function></funcdef>
56         <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
57         <paramdef>sd_bus_slot **<parameter>slot</parameter></paramdef>
58         <paramdef>const char *<parameter>match</parameter></paramdef>
59         <paramdef>sd_bus_message_handler_t <parameter>callback</parameter></paramdef>
60         <paramdef>void *<parameter>userdata</parameter></paramdef>
61       </funcprototype>
62
63       <funcprototype>
64         <funcdef>typedef int (*<function>sd_bus_message_handler_t</function>)</funcdef>
65         <paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
66         <paramdef>void *<parameter>userdata</parameter></paramdef>
67         <paramdef>sd_bus_error *<parameter>ret_error</parameter></paramdef>
68       </funcprototype>
69     </funcsynopsis>
70   </refsynopsisdiv>
71
72   <refsect1>
73     <title>Description</title>
74
75     <para>
76       <function>sd_bus_add_match()</function> adds a match rule used to dispatch
77       incoming messages. The syntax of the rule passed in
78       <parameter>match</parameter> is described in the
79       <ulink url="https://dbus.freedesktop.org/doc/dbus-specification.html">D-Bus Specification</ulink>.
80     </para>
81
82     <para>
83       The message <parameter>m</parameter> passed to the callback is only
84       borrowed, that is, the callback should not call
85       <citerefentry><refentrytitle>sd_bus_message_unref</refentrytitle><manvolnum>3</manvolnum></citerefentry>
86       on it. If the callback wants to hold on to the message beyond the lifetime
87       of the callback, it needs to call
88       <citerefentry><refentrytitle>sd_bus_message_ref</refentrytitle><manvolnum>3</manvolnum></citerefentry>
89       to create a new reference.
90     </para>
91
92     <para>
93       If an error occurs during the callback invocation, the callback should
94       return a negative error number. If it wants other callbacks that match the
95       same rule to be called, it should return 0. Otherwise it should return a
96       positive integer.
97     </para>
98   </refsect1>
99
100   <refsect1>
101     <title>Return Value</title>
102
103     <para>
104       On success, <function>sd_bus_add_match()</function> returns 0 or a
105       positive integer. On failure, it returns a negative errno-style error
106       code.
107     </para>
108   </refsect1>
109
110   <refsect1>
111     <title>See Also</title>
112
113     <para>
114       <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
115       <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
116     </para>
117   </refsect1>
118
119 </refentry>