| 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_call_method" |
| 7 |
xmlns:xi="http://www.w3.org/2001/XInclude"> |
| 8 |
|
| 9 |
<refentryinfo> |
| 10 |
<title>sd_bus_call_method</title> |
| 11 |
<productname>systemd</productname> |
| 12 |
</refentryinfo> |
| 13 |
|
| 14 |
<refmeta> |
| 15 |
<refentrytitle>sd_bus_call_method</refentrytitle> |
| 16 |
<manvolnum>3</manvolnum> |
| 17 |
</refmeta> |
| 18 |
|
| 19 |
<refnamediv> |
| 20 |
<refname>sd_bus_call_method</refname> |
| 21 |
<refname>sd_bus_call_methodv</refname> |
| 22 |
<refname>sd_bus_call_method_async</refname> |
| 23 |
<refname>sd_bus_call_method_asyncv</refname> |
| 24 |
|
| 25 |
<refpurpose>Initialize a bus message object and invoke the corresponding D-Bus method call |
| 26 |
</refpurpose> |
| 27 |
</refnamediv> |
| 28 |
|
| 29 |
<refsynopsisdiv> |
| 30 |
<funcsynopsis> |
| 31 |
<funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo> |
| 32 |
|
| 33 |
<xi:include href="sd_bus_add_match.xml" xpointer="sd_bus_message_handler_t"/> |
| 34 |
|
| 35 |
<funcprototype> |
| 36 |
<funcdef>int <function>sd_bus_call_method</function></funcdef> |
| 37 |
<paramdef>sd_bus *<parameter>bus</parameter></paramdef> |
| 38 |
<paramdef>const char *<parameter>destination</parameter></paramdef> |
| 39 |
<paramdef>const char *<parameter>path</parameter></paramdef> |
| 40 |
<paramdef>const char *<parameter>interface</parameter></paramdef> |
| 41 |
<paramdef>const char *<parameter>member</parameter></paramdef> |
| 42 |
<paramdef>sd_bus_error *<parameter>ret_error</parameter></paramdef> |
| 43 |
<paramdef>sd_bus_message **<parameter>reply</parameter></paramdef> |
| 44 |
<paramdef>const char *<parameter>types</parameter></paramdef> |
| 45 |
<paramdef>...</paramdef> |
| 46 |
</funcprototype> |
| 47 |
|
| 48 |
<funcprototype> |
| 49 |
<funcdef>int <function>sd_bus_call_methodv</function></funcdef> |
| 50 |
<paramdef>sd_bus *<parameter>bus</parameter></paramdef> |
| 51 |
<paramdef>const char *<parameter>destination</parameter></paramdef> |
| 52 |
<paramdef>const char *<parameter>path</parameter></paramdef> |
| 53 |
<paramdef>const char *<parameter>interface</parameter></paramdef> |
| 54 |
<paramdef>const char *<parameter>member</parameter></paramdef> |
| 55 |
<paramdef>sd_bus_error *<parameter>ret_error</parameter></paramdef> |
| 56 |
<paramdef>sd_bus_message **<parameter>reply</parameter></paramdef> |
| 57 |
<paramdef>const char *<parameter>types</parameter></paramdef> |
| 58 |
<paramdef>va_list <parameter>ap</parameter></paramdef> |
| 59 |
</funcprototype> |
| 60 |
|
| 61 |
<funcprototype> |
| 62 |
<funcdef>int <function>sd_bus_call_method_async</function></funcdef> |
| 63 |
<paramdef>sd_bus *<parameter>bus</parameter></paramdef> |
| 64 |
<paramdef>sd_bus_slot **<parameter>slot</parameter></paramdef> |
| 65 |
<paramdef>const char *<parameter>destination</parameter></paramdef> |
| 66 |
<paramdef>const char *<parameter>path</parameter></paramdef> |
| 67 |
<paramdef>const char *<parameter>interface</parameter></paramdef> |
| 68 |
<paramdef>const char *<parameter>member</parameter></paramdef> |
| 69 |
<paramdef>sd_bus_message_handler_t <parameter>callback</parameter></paramdef> |
| 70 |
<paramdef>void *<parameter>userdata</parameter></paramdef> |
| 71 |
<paramdef>const char *<parameter>types</parameter></paramdef> |
| 72 |
<paramdef>...</paramdef> |
| 73 |
</funcprototype> |
| 74 |
|
| 75 |
<funcprototype> |
| 76 |
<funcdef>int <function>sd_bus_call_method_asyncv</function></funcdef> |
| 77 |
<paramdef>sd_bus *<parameter>bus</parameter></paramdef> |
| 78 |
<paramdef>sd_bus_slot **<parameter>slot</parameter></paramdef> |
| 79 |
<paramdef>const char *<parameter>destination</parameter></paramdef> |
| 80 |
<paramdef>const char *<parameter>path</parameter></paramdef> |
| 81 |
<paramdef>const char *<parameter>interface</parameter></paramdef> |
| 82 |
<paramdef>const char *<parameter>member</parameter></paramdef> |
| 83 |
<paramdef>sd_bus_message_handler_t <parameter>callback</parameter></paramdef> |
| 84 |
<paramdef>void *<parameter>userdata</parameter></paramdef> |
| 85 |
<paramdef>const char *<parameter>types</parameter></paramdef> |
| 86 |
<paramdef>va_list <parameter>ap</parameter></paramdef> |
| 87 |
</funcprototype> |
| 88 |
</funcsynopsis> |
| 89 |
</refsynopsisdiv> |
| 90 |
|
| 91 |
<refsect1> |
| 92 |
<title>Description</title> |
| 93 |
|
| 94 |
<para><function>sd_bus_call_method()</function> is a convenience function for initializing a |
| 95 |
bus message object and calling the corresponding D-Bus method. It combines the |
| 96 |
<citerefentry><refentrytitle>sd_bus_message_new_method_call</refentrytitle><manvolnum>3</manvolnum></citerefentry>, |
| 97 |
<citerefentry><refentrytitle>sd_bus_message_append</refentrytitle><manvolnum>3</manvolnum></citerefentry> and |
| 98 |
<citerefentry><refentrytitle>sd_bus_call</refentrytitle><manvolnum>3</manvolnum></citerefentry> |
| 99 |
functions into a single function call.</para> |
| 100 |
|
| 101 |
<para><function>sd_bus_call_method_async()</function> is a convenience function for initializing |
| 102 |
a bus message object and calling the corresponding D-Bus method asynchronously. It combines the |
| 103 |
<citerefentry><refentrytitle>sd_bus_message_new_method_call</refentrytitle><manvolnum>3</manvolnum></citerefentry>, |
| 104 |
<citerefentry><refentrytitle>sd_bus_message_append</refentrytitle><manvolnum>3</manvolnum></citerefentry> and |
| 105 |
<citerefentry><refentrytitle>sd_bus_call_async</refentrytitle><manvolnum>3</manvolnum></citerefentry> |
| 106 |
functions into a single function call.</para> |
| 107 |
</refsect1> |
| 108 |
|
| 109 |
<refsect1> |
| 110 |
<title>Return Value</title> |
| 111 |
|
| 112 |
<para>On success, these functions return a non-negative integer. On failure, they return a |
| 113 |
negative errno-style error code.</para> |
| 114 |
|
| 115 |
<refsect2 id='errors'> |
| 116 |
<title>Errors</title> |
| 117 |
|
| 118 |
<para>See the man pages of |
| 119 |
<citerefentry><refentrytitle>sd_bus_message_new_method_call</refentrytitle><manvolnum>3</manvolnum></citerefentry>, |
| 120 |
<citerefentry><refentrytitle>sd_bus_message_append</refentrytitle><manvolnum>3</manvolnum></citerefentry>, |
| 121 |
<citerefentry><refentrytitle>sd_bus_call</refentrytitle><manvolnum>3</manvolnum></citerefentry> and |
| 122 |
<citerefentry><refentrytitle>sd_bus_call_async</refentrytitle><manvolnum>3</manvolnum></citerefentry> |
| 123 |
for a list of possible errors.</para> |
| 124 |
</refsect2> |
| 125 |
</refsect1> |
| 126 |
|
| 127 |
<xi:include href="libsystemd-pkgconfig.xml" /> |
| 128 |
|
| 129 |
<refsect1> |
| 130 |
<title>Examples</title> |
| 131 |
|
| 132 |
<example> |
| 133 |
<title>Make a call to a D-Bus method that takes a single parameter</title> |
| 134 |
|
| 135 |
<programlisting><xi:include href="print-unit-path-call-method.c" parse="text" /></programlisting> |
| 136 |
<para>This defines a minimally useful program that will open a connection to the bus, call a method, |
| 137 |
wait for the reply, and finally extract and print the answer. It does error handling and proper |
| 138 |
memory management.</para> |
| 139 |
</example> |
| 140 |
</refsect1> |
| 141 |
|
| 142 |
<refsect1> |
| 143 |
<title>History</title> |
| 144 |
<para><function>sd_bus_call_method()</function>, and |
| 145 |
<function>sd_bus_call_method_async()</function> were added in version 221.</para> |
| 146 |
<para><function>sd_bus_call_methodv()</function>, |
| 147 |
<function>sd_bus_call_method_asyncv()</function> were added in version 246.</para> |
| 148 |
</refsect1> |
| 149 |
|
| 150 |
<refsect1> |
| 151 |
<title>See Also</title> |
| 152 |
|
| 153 |
<para><simplelist type="inline"> |
| 154 |
<member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 155 |
<member><citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 156 |
<member><citerefentry><refentrytitle>sd_bus_message_new_method_call</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 157 |
<member><citerefentry><refentrytitle>sd_bus_message_append</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 158 |
<member><citerefentry><refentrytitle>sd_bus_call</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 159 |
<member><citerefentry><refentrytitle>sd_bus_set_property</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 160 |
<member><citerefentry><refentrytitle>sd_bus_emit_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 161 |
</simplelist></para> |
| 162 |
</refsect1> |
| 163 |
|
| 164 |
</refentry> |