]>
Commit | Line | Data |
---|---|---|
a3c0b9df DDM |
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+ --> | |
5 | ||
6 | <refentry id="sd_bus_add_node_enumerator" | |
7 | xmlns:xi="http://www.w3.org/2001/XInclude"> | |
8 | ||
9 | <refentryinfo> | |
10 | <title>sd_bus_add_node_enumerator</title> | |
11 | <productname>systemd</productname> | |
12 | </refentryinfo> | |
13 | ||
14 | <refmeta> | |
15 | <refentrytitle>sd_bus_add_node_enumerator</refentrytitle> | |
16 | <manvolnum>3</manvolnum> | |
17 | </refmeta> | |
18 | ||
19 | <refnamediv> | |
20 | <refname>sd_bus_add_node_enumerator</refname> | |
21 | ||
22 | <refpurpose>Add a node enumerator for a D-Bus object path prefix</refpurpose> | |
23 | </refnamediv> | |
24 | ||
25 | <refsynopsisdiv> | |
26 | <funcsynopsis> | |
27 | <funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo> | |
28 | ||
29 | <funcprototype> | |
30 | <funcdef>typedef int (*<function>sd_bus_node_enumerator_t</function>)</funcdef> | |
31 | <paramdef>sd_bus *<parameter>bus</parameter></paramdef> | |
32 | <paramdef>const char *<parameter>prefix</parameter></paramdef> | |
33 | <paramdef>void *<parameter>userdata</parameter></paramdef> | |
34 | <paramdef>char ***<parameter>ret_nodes</parameter></paramdef> | |
35 | <paramdef>sd_bus_error *<parameter>ret_error</parameter></paramdef> | |
36 | </funcprototype> | |
37 | ||
38 | <funcprototype> | |
39 | <funcdef>int <function>sd_bus_add_node_enumerator</function></funcdef> | |
40 | <paramdef>sd_bus *<parameter>bus</parameter></paramdef> | |
41 | <paramdef>sd_bus_slot **<parameter>slot</parameter></paramdef> | |
42 | <paramdef>const char *<parameter>path</parameter></paramdef> | |
43 | <paramdef>sd_bus_node_enumerator_t <parameter>callback</parameter></paramdef> | |
44 | <paramdef>void *<parameter>userdata</parameter></paramdef> | |
45 | </funcprototype> | |
46 | </funcsynopsis> | |
47 | </refsynopsisdiv> | |
48 | ||
49 | <refsect1> | |
50 | <title>Description</title> | |
51 | ||
52 | <para><function>sd_bus_add_node_enumerator()</function> adds a D-Bus node enumerator for the | |
53 | given path prefix. The given callback is called to enumerate all the available objects with | |
54 | the given path prefix when required (e.g. when | |
55 | <constant>org.freedesktop.DBus.Introspectable.Introspect</constant> or | |
56 | <constant>org.freedesktop.DBus.ObjectManager.GetManagedObjects</constant> are called on a | |
57 | D-Bus service managed by sd-bus).</para> | |
58 | ||
59 | <para><parameter>callback</parameter> is called with the path and userdata pointer registered | |
60 | with <function>sd_bus_add_node_enumerator()</function>. When called, it should store all the | |
61 | child object paths of the given path prefix in <parameter>ret_nodes</parameter> and return the | |
62 | number of child objects under the given prefix. If an error occurs, it can either return a | |
63 | negative integer, set <parameter>ret_error</parameter> to a non-empty error or do both. Any | |
64 | errors returned by the callback are encoded as D-Bus errors and sent back to the caller. Errors | |
65 | in <parameter>ret_error</parameter> take priority over negative return values.</para> | |
66 | ||
67 | <para>Note that a node enumerator callback will only ever be called for a single path prefix | |
68 | and hence, for normal operation, <parameter>prefix</parameter> can be ignored. Also, a node | |
69 | enumerator is only used to enumerate the available child objects under a given prefix. To | |
70 | install a handler for a set of dynamic child objects, use | |
71 | <citerefentry><refentrytitle>sd_bus_add_fallback_vtable</refentrytitle><manvolnum>3</manvolnum></citerefentry>. | |
72 | </para> | |
73 | ||
74 | <para>When <function>sd_bus_add_node_enumerator()</function> succeeds, a slot is created | |
75 | internally. If the output parameter <replaceable>slot</replaceable> is <constant>NULL</constant>, | |
76 | a "floating" slot object is created, see | |
77 | <citerefentry><refentrytitle>sd_bus_slot_set_floating</refentrytitle><manvolnum>3</manvolnum></citerefentry>. | |
78 | Otherwise, a pointer to the slot object is returned. In that case, the reference to the slot | |
79 | object should be dropped when the node enumerator is not needed anymore, see | |
80 | <citerefentry><refentrytitle>sd_bus_slot_unref</refentrytitle><manvolnum>3</manvolnum></citerefentry>. | |
81 | </para> | |
82 | </refsect1> | |
83 | ||
84 | <refsect1> | |
85 | <title>Return Value</title> | |
86 | ||
87 | <para>On success, <function>sd_bus_add_node_enumerator()</function> returns a non-negative | |
88 | integer. On failure, it returns a negative errno-style error code.</para> | |
89 | ||
90 | <refsect2> | |
91 | <title>Errors</title> | |
92 | ||
93 | <para>Returned errors may indicate the following problems:</para> | |
94 | ||
95 | <variablelist> | |
96 | <varlistentry> | |
97 | <term><constant>-EINVAL</constant></term> | |
98 | ||
99 | <listitem><para>One of the required parameters is <constant>NULL</constant> or | |
100 | <parameter>path</parameter> is not a valid object path. | |
101 | </para></listitem> | |
102 | </varlistentry> | |
103 | ||
104 | <varlistentry> | |
105 | <term><constant>-ENOPKG</constant></term> | |
106 | ||
107 | <listitem><para>The bus cannot be resolved.</para></listitem> | |
108 | </varlistentry> | |
109 | ||
110 | <varlistentry> | |
111 | <term><constant>-ECHILD</constant></term> | |
112 | ||
113 | <listitem><para>The bus was created in a different process.</para></listitem> | |
114 | </varlistentry> | |
115 | ||
116 | <varlistentry> | |
117 | <term><constant>-ENOMEM</constant></term> | |
118 | ||
119 | <listitem><para>Memory allocation failed.</para></listitem> | |
120 | </varlistentry> | |
121 | </variablelist> | |
122 | </refsect2> | |
123 | </refsect1> | |
124 | ||
125 | <xi:include href="libsystemd-pkgconfig.xml" /> | |
126 | ||
127 | <refsect1> | |
128 | <title>See Also</title> | |
129 | ||
130 | <para> | |
131 | <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
132 | <citerefentry><refentrytitle>busctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
133 | <citerefentry><refentrytitle>sd_bus_add_fallback_vtable</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
134 | <citerefentry><refentrytitle>sd_bus_slot_unref</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
135 | </para> | |
136 | </refsect1> | |
137 | </refentry> |