| 1 |
'\" t |
| 2 |
.TH "SD_BUS_ADD_NODE_ENUMERATOR" "3" "" "systemd 261~rc3" "sd_bus_add_node_enumerator" |
| 3 |
.\" ----------------------------------------------------------------- |
| 4 |
.\" * Define some portability stuff |
| 5 |
.\" ----------------------------------------------------------------- |
| 6 |
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 7 |
.\" http://bugs.debian.org/507673 |
| 8 |
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html |
| 9 |
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 10 |
.ie \n(.g .ds Aq \(aq |
| 11 |
.el .ds Aq ' |
| 12 |
.\" ----------------------------------------------------------------- |
| 13 |
.\" * set default formatting |
| 14 |
.\" ----------------------------------------------------------------- |
| 15 |
.\" disable hyphenation |
| 16 |
.nh |
| 17 |
.\" disable justification (adjust text to left margin only) |
| 18 |
.ad l |
| 19 |
.\" ----------------------------------------------------------------- |
| 20 |
.\" * MAIN CONTENT STARTS HERE * |
| 21 |
.\" ----------------------------------------------------------------- |
| 22 |
.SH "NAME" |
| 23 |
sd_bus_add_node_enumerator \- Add a node enumerator for a D\-Bus object path prefix |
| 24 |
.SH "SYNOPSIS" |
| 25 |
.sp |
| 26 |
.ft B |
| 27 |
.nf |
| 28 |
#include <systemd/sd\-bus\&.h> |
| 29 |
.fi |
| 30 |
.ft |
| 31 |
.HP \w'typedef\ int\ (*sd_bus_node_enumerator_t)('u |
| 32 |
.BI "typedef int (*sd_bus_node_enumerator_t)(sd_bus\ *" "bus" ", const\ char\ *" "prefix" ", void\ *" "userdata" ", char\ ***" "ret_nodes" ", sd_bus_error\ *" "ret_error" ");" |
| 33 |
.HP \w'int\ sd_bus_add_node_enumerator('u |
| 34 |
.BI "int sd_bus_add_node_enumerator(sd_bus\ *" "bus" ", sd_bus_slot\ **" "slot" ", const\ char\ *" "path" ", sd_bus_node_enumerator_t\ " "callback" ", void\ *" "userdata" ");" |
| 35 |
.SH "DESCRIPTION" |
| 36 |
.PP |
| 37 |
\fBsd_bus_add_node_enumerator()\fR |
| 38 |
adds a D\-Bus node enumerator for the given path prefix\&. The given callback is called to enumerate all the available objects with the given path prefix when required (e\&.g\&. when |
| 39 |
\fBorg\&.freedesktop\&.DBus\&.Introspectable\&.Introspect\fR |
| 40 |
or |
| 41 |
\fBorg\&.freedesktop\&.DBus\&.ObjectManager\&.GetManagedObjects\fR |
| 42 |
are called on a D\-Bus service managed by sd\-bus)\&. |
| 43 |
.PP |
| 44 |
\fIcallback\fR |
| 45 |
is called with the path and userdata pointer registered with |
| 46 |
\fBsd_bus_add_node_enumerator()\fR\&. When called, it should store all the child object paths of the given path prefix in |
| 47 |
\fIret_nodes\fR |
| 48 |
with a NULL terminator item\&. The callback should return a non\-negative value on success\&. If an error occurs, it can either return a negative integer, set |
| 49 |
\fIret_error\fR |
| 50 |
to a non\-empty error or do both\&. Any errors returned by the callback are encoded as D\-Bus errors and sent back to the caller\&. Errors in |
| 51 |
\fIret_error\fR |
| 52 |
take priority over negative return values\&. |
| 53 |
.PP |
| 54 |
Note that a node enumerator callback will only ever be called for a single path prefix and hence, for normal operation, |
| 55 |
\fIprefix\fR |
| 56 |
can be ignored\&. Also, a node enumerator is only used to enumerate the available child objects under a given prefix\&. To install a handler for a set of dynamic child objects, use |
| 57 |
\fBsd_bus_add_fallback_vtable\fR(3)\&. |
| 58 |
.PP |
| 59 |
When |
| 60 |
\fBsd_bus_add_node_enumerator()\fR |
| 61 |
succeeds, a slot is created internally\&. If the output parameter |
| 62 |
\fIslot\fR |
| 63 |
is |
| 64 |
\fBNULL\fR, a "floating" slot object is created, see |
| 65 |
\fBsd_bus_slot_set_floating\fR(3)\&. Otherwise, a pointer to the slot object is returned\&. In that case, the reference to the slot object should be dropped when the node enumerator is not needed anymore, see |
| 66 |
\fBsd_bus_slot_unref\fR(3)\&. |
| 67 |
.SH "RETURN VALUE" |
| 68 |
.PP |
| 69 |
On success, |
| 70 |
\fBsd_bus_add_node_enumerator()\fR |
| 71 |
returns a non\-negative integer\&. On failure, it returns a negative errno\-style error code\&. |
| 72 |
.SS "Errors" |
| 73 |
.PP |
| 74 |
Returned errors may indicate the following problems: |
| 75 |
.PP |
| 76 |
\fB\-EINVAL\fR |
| 77 |
.RS 4 |
| 78 |
One of the required parameters is |
| 79 |
\fBNULL\fR |
| 80 |
or |
| 81 |
\fIpath\fR |
| 82 |
is not a valid object path\&. |
| 83 |
.RE |
| 84 |
.PP |
| 85 |
\fB\-ENOPKG\fR |
| 86 |
.RS 4 |
| 87 |
The bus cannot be resolved\&. |
| 88 |
.RE |
| 89 |
.PP |
| 90 |
\fB\-ECHILD\fR |
| 91 |
.RS 4 |
| 92 |
The bus was created in a different process, library or module instance\&. |
| 93 |
.RE |
| 94 |
.PP |
| 95 |
\fB\-ENOMEM\fR |
| 96 |
.RS 4 |
| 97 |
Memory allocation failed\&. |
| 98 |
.RE |
| 99 |
.SH "NOTES" |
| 100 |
.PP |
| 101 |
Functions described here are available as a shared library, which can be compiled against and linked to with the |
| 102 |
\fBlibsystemd\fR\ \&\fBpkg-config\fR(1) |
| 103 |
file\&. |
| 104 |
.PP |
| 105 |
The code described here uses |
| 106 |
\fBgetenv\fR(3), which is declared to be not multi\-thread\-safe\&. This means that the code calling the functions described here must not call |
| 107 |
\fBsetenv\fR(3) |
| 108 |
from a parallel thread\&. It is recommended to only do calls to |
| 109 |
\fBsetenv()\fR |
| 110 |
from an early phase of the program when no other threads have been started\&. |
| 111 |
.SH "HISTORY" |
| 112 |
.PP |
| 113 |
\fBsd_bus_node_enumerator_t()\fR |
| 114 |
and |
| 115 |
\fBsd_bus_add_node_enumerator()\fR |
| 116 |
were added in version 221\&. |
| 117 |
.SH "SEE ALSO" |
| 118 |
.PP |
| 119 |
\fBsd-bus\fR(3), \fBbusctl\fR(1), \fBsd_bus_add_fallback_vtable\fR(3), \fBsd_bus_slot_unref\fR(3) |