25 #include "dbus-object-tree.h"
26 #include "dbus-connection-internal.h"
27 #include "dbus-internals.h"
28 #include "dbus-hash.h"
29 #include "dbus-protocol.h"
30 #include "dbus-string.h"
107 tree->
root = _dbus_object_subtree_new (
"/",
NULL,
NULL);
160 #define VERBOSE_FIND 0
166 int *index_in_parent,
172 return_deepest_match = exact_match !=
NULL;
174 _dbus_assert (!(return_deepest_match && create_if_not_found));
179 _dbus_verbose (
" path exhausted, returning %s\n",
182 if (exact_match !=
NULL)
188 _dbus_verbose (
" searching children of %s for %s\n",
189 subtree->
name, path[0]);
202 _dbus_verbose (
" %s cmp %s = %d\n",
212 _dbus_verbose (
" storing parent index %d\n", k);
214 *index_in_parent = k;
217 if (return_deepest_match)
221 next = find_subtree_recurse (subtree->
subtrees[k],
222 &path[1], create_if_not_found,
223 index_in_parent, exact_match);
228 _dbus_verbose (
" no deeper match found, returning %s\n",
231 if (exact_match !=
NULL)
232 *exact_match =
FALSE;
239 return find_subtree_recurse (subtree->
subtrees[k],
240 &path[1], create_if_not_found,
241 index_in_parent, exact_match);
254 _dbus_verbose (
" no match found, current tree %s, create_if_not_found = %d\n",
255 subtree->
name, create_if_not_found);
258 if (create_if_not_found)
261 int child_pos, new_n_subtrees;
264 _dbus_verbose (
" creating subtree %s\n",
268 child = _dbus_object_subtree_new (path[0],
276 int new_max_subtrees;
282 if (new_subtrees ==
NULL)
284 _dbus_object_subtree_unref (child);
295 new_n_subtrees <= subtree->max_subtrees);
296 if (child_pos + 1 < new_n_subtrees)
298 memmove (&subtree->
subtrees[child_pos+1],
300 (new_n_subtrees - child_pos - 1) *
303 subtree->
subtrees[child_pos] = child;
306 *index_in_parent = child_pos;
310 return find_subtree_recurse (child,
311 &path[1], create_if_not_found,
312 index_in_parent, exact_match);
316 if (exact_match !=
NULL)
317 *exact_match =
FALSE;
325 int *index_in_parent)
330 _dbus_verbose (
"Looking for exact registered subtree\n");
333 subtree = find_subtree_recurse (tree->
root, path,
FALSE, index_in_parent,
NULL);
346 _dbus_verbose (
"Looking for subtree\n");
357 _dbus_verbose (
"Looking for deepest handler\n");
361 *exact_match =
FALSE;
363 return find_subtree_recurse (tree->
root, path,
FALSE,
NULL, exact_match);
371 _dbus_verbose (
"Ensuring subtree\n");
376 static char *flatten_path (
const char **path);
404 subtree = ensure_subtree (tree, path);
407 _DBUS_SET_OOM (error);
415 char *complete_path = flatten_path (path);
418 "A handler is already registered for %s",
419 complete_path ? complete_path
420 :
"(cannot represent path: out of memory!)");
455 unregister_function =
NULL;
458 subtree = find_subtree (tree, path, &i);
460 #ifndef DBUS_DISABLE_CHECKS
463 _dbus_warn (
"Attempted to unregister path (path[0] = %s path[1] = %s) which isn't registered\n",
464 path[0] ? path[0] :
"null",
465 path[1] ? path[1] :
"null");
498 _dbus_object_subtree_unref (subtree);
506 #ifdef DBUS_BUILD_TESTS
511 _dbus_verbose (
"unlock\n");
515 if (unregister_function)
516 (* unregister_function) (connection, user_data);
518 #ifdef DBUS_BUILD_TESTS
540 free_subtree_recurse (connection, child);
553 _dbus_object_subtree_unref (subtree);
573 const char **parent_path,
574 char ***child_entries)
582 *child_entries =
NULL;
584 subtree = lookup_subtree (tree, parent_path);
596 while (i < subtree->n_subtrees)
599 if (retval[i] ==
NULL)
611 *child_entries = retval;
612 return retval !=
NULL;
626 const char *v_STRING;
631 already_unlocked =
FALSE;
633 _dbus_verbose (
" considering default Introspect() handler...\n");
641 #ifdef DBUS_BUILD_TESTS
645 _dbus_verbose (
"unlock\n");
652 _dbus_verbose (
" using default Introspect() handler!\n");
656 #ifdef DBUS_BUILD_TESTS
660 _dbus_verbose (
"unlock\n");
670 if (!_dbus_object_tree_list_registered_unlocked (tree, path, &children))
680 while (children[i] !=
NULL)
701 #ifdef DBUS_BUILD_TESTS
705 already_unlocked =
TRUE;
714 #ifdef DBUS_BUILD_TESTS
718 if (!already_unlocked)
720 _dbus_verbose (
"unlock\n");
759 _dbus_verbose (
"Dispatch of message by object path\n");
765 #ifdef DBUS_BUILD_TESTS
769 _dbus_verbose (
"unlock\n");
773 _dbus_verbose (
"No memory to get decomposed path\n");
780 #ifdef DBUS_BUILD_TESTS
784 _dbus_verbose (
"unlock\n");
788 _dbus_verbose (
"No path field in message\n");
793 subtree = find_handler (tree, (
const char**) path, &exact_match);
796 *found_object = !!subtree;
802 while (subtree !=
NULL)
806 _dbus_object_subtree_ref (subtree);
812 _dbus_object_subtree_unref (subtree);
813 goto free_and_return;
818 subtree = subtree->
parent;
821 _dbus_verbose (
"%d handlers in the path tree for this message\n",
832 subtree = link->
data;
846 _dbus_verbose (
" (invoking a handler)\n");
849 #ifdef DBUS_BUILD_TESTS
853 _dbus_verbose (
"unlock\n");
862 result = (* message_function) (tree->
connection,
866 #ifdef DBUS_BUILD_TESTS
872 goto free_and_return;
884 result = handle_default_introspect_and_unlock (tree, message,
885 (
const char**) path);
889 #ifdef DBUS_BUILD_TESTS
893 _dbus_verbose (
"unlock\n");
901 _dbus_object_subtree_unref (link->
data);
929 subtree = find_handler (tree, (
const char**) path, &exact_match);
931 if ((subtree ==
NULL) || !exact_match)
933 _dbus_verbose (
"No object at specified path found\n");
947 allocate_subtree_object (
const char *name)
962 memcpy (subtree->
name, name, len + 1);
968 _dbus_object_subtree_new (
const char *name,
974 subtree = allocate_subtree_object (name);
1009 #ifdef DBUS_DISABLE_ASSERT
1051 const char **parent_path,
1052 char ***child_entries)
1056 result = _dbus_object_tree_list_registered_unlocked (tree,
1060 #ifdef DBUS_BUILD_TESTS
1064 _dbus_verbose (
"unlock\n");
1073 #define VERBOSE_DECOMPOSE 0
1098 #if VERBOSE_DECOMPOSE
1099 _dbus_verbose (
"Decomposing path \"%s\"\n",
1116 retval =
dbus_new0 (
char*, n_components + 1);
1122 if (n_components == 0)
1126 while (comp < n_components)
1134 while (j < len && data[j] !=
'/')
1142 #if VERBOSE_DECOMPOSE
1143 _dbus_verbose (
" (component in [%d,%d))\n",
1148 if (retval[comp] ==
NULL)
1153 retval[comp][j-i] =
'\0';
1154 #if VERBOSE_DECOMPOSE
1155 _dbus_verbose (
" (component %d = \"%s\")\n",
1156 comp, retval[comp]);
1166 *path_len = n_components;
1174 flatten_path (
const char **path)
1182 if (path[0] ==
NULL)
1217 #ifdef DBUS_BUILD_TESTS
1219 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1221 #include "dbus-test.h"
1233 static StrComparison
1234 path_contains (
const char **container,
1240 while (child[i] !=
NULL)
1244 if (container[i] ==
NULL)
1253 v = strcmp (container[i], child[i]);
1256 return STR_DIFFERENT;
1266 if (container[i] ==
NULL)
1269 return STR_DIFFERENT;
1282 _dbus_verbose (
" ");
1286 _dbus_verbose (
"%s (%d children)\n",
1290 while (i < subtree->n_subtrees)
1292 spew_subtree_recurse (subtree->
subtrees[i], indent + 2);
1301 spew_subtree_recurse (tree->
root, 0);
1321 TreeTestData *ttd = user_data;
1323 ttd->handler_unregistered =
TRUE;
1331 TreeTestData *ttd = user_data;
1333 ttd->message_handled =
TRUE;
1343 TreeTestData *tree_test_data)
1346 test_message_function,
NULL };
1348 tree_test_data[i].message_handled =
FALSE;
1349 tree_test_data[i].handler_unregistered =
FALSE;
1350 tree_test_data[i].handler_fallback = fallback;
1351 tree_test_data[i].path = path;
1360 &tree_test_data[i]);
1369 TreeTestData *tree_test_data,
1379 flat = flatten_path (path);
1385 "org.freedesktop.TestInterface",
1388 if (message ==
NULL)
1392 while (j < n_test_data)
1394 tree_test_data[j].message_handled =
FALSE;
1405 while (j < n_test_data)
1407 if (tree_test_data[j].message_handled)
1409 if (tree_test_data[j].handler_fallback)
1411 path) != STR_DIFFERENT);
1413 _dbus_assert (path_contains (tree_test_data[j].path, path) == STR_EQUAL);
1417 if (tree_test_data[j].handler_fallback)
1419 path) == STR_DIFFERENT);
1421 _dbus_assert (path_contains (tree_test_data[j].path, path) != STR_EQUAL);
1438 string_array_length (
const char **array)
1441 for (i = 0; array[i]; i++) ;
1448 const char *result[20];
1449 } DecomposePathTest;
1451 static DecomposePathTest decompose_tests[] = {
1452 {
"/foo", {
"foo",
NULL } },
1453 {
"/foo/bar", {
"foo",
"bar",
NULL } },
1455 {
"/a/b", {
"a",
"b",
NULL } },
1456 {
"/a/b/c", {
"a",
"b",
"c",
NULL } },
1457 {
"/a/b/c/d", {
"a",
"b",
"c",
"d",
NULL } },
1458 {
"/foo/bar/q", {
"foo",
"bar",
"q",
NULL } },
1459 {
"/foo/bar/this/is/longer", {
"foo",
"bar",
"this",
"is",
"longer",
NULL } }
1463 run_decompose_tests (
void)
1475 strlen (decompose_tests[i].path),
1476 &result, &result_len))
1479 expected_len = string_array_length (decompose_tests[i].result);
1481 if (result_len != (
int) string_array_length ((
const char**)result) ||
1482 expected_len != result_len ||
1483 path_contains (decompose_tests[i].result,
1484 (
const char**) result) != STR_EQUAL)
1486 int real_len = string_array_length ((
const char**)result);
1487 _dbus_warn (
"Expected decompose of %s to have len %d, returned %d, appears to have %d\n",
1488 decompose_tests[i].path, expected_len, result_len,
1490 _dbus_warn (
"Decompose resulted in elements: { ");
1492 while (i < real_len)
1495 (i + 1) == real_len ?
"" :
", ");
1511 object_tree_test_iteration (
void *data)
1513 const char *path0[] = {
NULL };
1514 const char *path1[] = {
"foo",
NULL };
1515 const char *path2[] = {
"foo",
"bar",
NULL };
1516 const char *path3[] = {
"foo",
"bar",
"baz",
NULL };
1517 const char *path4[] = {
"foo",
"bar",
"boo",
NULL };
1518 const char *path5[] = {
"blah",
NULL };
1519 const char *path6[] = {
"blah",
"boof",
NULL };
1520 const char *path7[] = {
"blah",
"boof",
"this",
"is",
"really",
"long",
NULL };
1521 const char *path8[] = {
"childless",
NULL };
1523 TreeTestData tree_test_data[9];
1527 if (!run_decompose_tests ())
1536 if (!do_register (tree, path0,
TRUE, 0, tree_test_data))
1549 _dbus_assert (find_handler (tree, path0, &exact_match) && exact_match);
1550 _dbus_assert (find_handler (tree, path1, &exact_match) == tree->
root && !exact_match);
1551 _dbus_assert (find_handler (tree, path2, &exact_match) == tree->
root && !exact_match);
1552 _dbus_assert (find_handler (tree, path3, &exact_match) == tree->
root && !exact_match);
1553 _dbus_assert (find_handler (tree, path4, &exact_match) == tree->
root && !exact_match);
1554 _dbus_assert (find_handler (tree, path5, &exact_match) == tree->
root && !exact_match);
1555 _dbus_assert (find_handler (tree, path6, &exact_match) == tree->
root && !exact_match);
1556 _dbus_assert (find_handler (tree, path7, &exact_match) == tree->
root && !exact_match);
1557 _dbus_assert (find_handler (tree, path8, &exact_match) == tree->
root && !exact_match);
1559 if (!do_register (tree, path1,
TRUE, 1, tree_test_data))
1572 _dbus_assert (find_handler (tree, path0, &exact_match) && exact_match);
1573 _dbus_assert (find_handler (tree, path1, &exact_match) && exact_match);
1574 _dbus_assert (find_handler (tree, path2, &exact_match) && !exact_match);
1575 _dbus_assert (find_handler (tree, path3, &exact_match) && !exact_match);
1576 _dbus_assert (find_handler (tree, path4, &exact_match) && !exact_match);
1577 _dbus_assert (find_handler (tree, path5, &exact_match) == tree->
root && !exact_match);
1578 _dbus_assert (find_handler (tree, path6, &exact_match) == tree->
root && !exact_match);
1579 _dbus_assert (find_handler (tree, path7, &exact_match) == tree->
root && !exact_match);
1580 _dbus_assert (find_handler (tree, path8, &exact_match) == tree->
root && !exact_match);
1582 if (!do_register (tree, path2,
TRUE, 2, tree_test_data))
1594 if (!do_register (tree, path3,
TRUE, 3, tree_test_data))
1607 if (!do_register (tree, path4,
TRUE, 4, tree_test_data))
1620 if (!do_register (tree, path5,
TRUE, 5, tree_test_data))
1633 _dbus_assert (find_handler (tree, path0, &exact_match) == tree->
root && exact_match);
1634 _dbus_assert (find_handler (tree, path1, &exact_match) != tree->
root && exact_match);
1635 _dbus_assert (find_handler (tree, path2, &exact_match) != tree->
root && exact_match);
1636 _dbus_assert (find_handler (tree, path3, &exact_match) != tree->
root && exact_match);
1637 _dbus_assert (find_handler (tree, path4, &exact_match) != tree->
root && exact_match);
1638 _dbus_assert (find_handler (tree, path5, &exact_match) != tree->
root && exact_match);
1639 _dbus_assert (find_handler (tree, path6, &exact_match) != tree->
root && !exact_match);
1640 _dbus_assert (find_handler (tree, path7, &exact_match) != tree->
root && !exact_match);
1641 _dbus_assert (find_handler (tree, path8, &exact_match) == tree->
root && !exact_match);
1643 if (!do_register (tree, path6,
TRUE, 6, tree_test_data))
1656 if (!do_register (tree, path7,
TRUE, 7, tree_test_data))
1669 if (!do_register (tree, path8,
TRUE, 8, tree_test_data))
1682 _dbus_assert (find_handler (tree, path0, &exact_match) == tree->
root && exact_match);
1683 _dbus_assert (find_handler (tree, path1, &exact_match) != tree->
root && exact_match);
1684 _dbus_assert (find_handler (tree, path2, &exact_match) != tree->
root && exact_match);
1685 _dbus_assert (find_handler (tree, path3, &exact_match) != tree->
root && exact_match);
1686 _dbus_assert (find_handler (tree, path4, &exact_match) != tree->
root && exact_match);
1687 _dbus_assert (find_handler (tree, path5, &exact_match) != tree->
root && exact_match);
1688 _dbus_assert (find_handler (tree, path6, &exact_match) != tree->
root && exact_match);
1689 _dbus_assert (find_handler (tree, path7, &exact_match) != tree->
root && exact_match);
1690 _dbus_assert (find_handler (tree, path8, &exact_match) != tree->
root && exact_match);
1695 const char *root[] = {
NULL };
1696 char **child_entries;
1699 _dbus_object_tree_list_registered_unlocked (tree, path1, &child_entries);
1700 if (child_entries !=
NULL)
1702 nb = string_array_length ((
const char**)child_entries);
1707 _dbus_object_tree_list_registered_unlocked (tree, path2, &child_entries);
1708 if (child_entries !=
NULL)
1710 nb = string_array_length ((
const char**)child_entries);
1715 _dbus_object_tree_list_registered_unlocked (tree, path8, &child_entries);
1716 if (child_entries !=
NULL)
1718 nb = string_array_length ((
const char**)child_entries);
1723 _dbus_object_tree_list_registered_unlocked (tree, root, &child_entries);
1724 if (child_entries !=
NULL)
1726 nb = string_array_length ((
const char**)child_entries);
1748 if (!do_register (tree, path0,
TRUE, 0, tree_test_data))
1750 if (!do_register (tree, path1,
TRUE, 1, tree_test_data))
1752 if (!do_register (tree, path2,
TRUE, 2, tree_test_data))
1754 if (!do_register (tree, path3,
TRUE, 3, tree_test_data))
1756 if (!do_register (tree, path4,
TRUE, 4, tree_test_data))
1758 if (!do_register (tree, path5,
TRUE, 5, tree_test_data))
1760 if (!do_register (tree, path6,
TRUE, 6, tree_test_data))
1762 if (!do_register (tree, path7,
TRUE, 7, tree_test_data))
1764 if (!do_register (tree, path8,
TRUE, 8, tree_test_data))
1894 if (!do_register (tree, path0,
TRUE, 0, tree_test_data))
1896 if (!do_register (tree, path1,
FALSE, 1, tree_test_data))
1898 if (!do_register (tree, path2,
TRUE, 2, tree_test_data))
1900 if (!do_register (tree, path3,
TRUE, 3, tree_test_data))
1902 if (!do_register (tree, path4,
TRUE, 4, tree_test_data))
1904 if (!do_register (tree, path5,
TRUE, 5, tree_test_data))
1906 if (!do_register (tree, path6,
FALSE, 6, tree_test_data))
1908 if (!do_register (tree, path7,
TRUE, 7, tree_test_data))
1910 if (!do_register (tree, path8,
TRUE, 8, tree_test_data))
1917 if (!do_test_dispatch (tree, path0, 0, tree_test_data,
_DBUS_N_ELEMENTS (tree_test_data)))
1919 if (!do_test_dispatch (tree, path1, 1, tree_test_data,
_DBUS_N_ELEMENTS (tree_test_data)))
1921 if (!do_test_dispatch (tree, path2, 2, tree_test_data,
_DBUS_N_ELEMENTS (tree_test_data)))
1923 if (!do_test_dispatch (tree, path3, 3, tree_test_data,
_DBUS_N_ELEMENTS (tree_test_data)))
1925 if (!do_test_dispatch (tree, path4, 4, tree_test_data,
_DBUS_N_ELEMENTS (tree_test_data)))
1927 if (!do_test_dispatch (tree, path5, 5, tree_test_data,
_DBUS_N_ELEMENTS (tree_test_data)))
1929 if (!do_test_dispatch (tree, path6, 6, tree_test_data,
_DBUS_N_ELEMENTS (tree_test_data)))
1931 if (!do_test_dispatch (tree, path7, 7, tree_test_data,
_DBUS_N_ELEMENTS (tree_test_data)))
1933 if (!do_test_dispatch (tree, path8, 8, tree_test_data,
_DBUS_N_ELEMENTS (tree_test_data)))
1954 _dbus_object_tree_test (
void)
1956 _dbus_test_oom_handling (
"object tree",
1957 object_tree_test_iteration,
dbus_bool_t _dbus_string_append(DBusString *str, const char *buffer)
Appends a nul-terminated C-style string to a DBusString.
DBusHandlerResult _dbus_object_tree_dispatch_and_unlock(DBusObjectTree *tree, DBusMessage *message, dbus_bool_t *found_object)
Tries to dispatch a message by directing it to handler for the object path listed in the message head...
An atomic integer safe to increment or decrement from multiple threads.
int max_subtrees
Number of allocated entries in subtrees.
#define NULL
A null pointer, defined appropriately for C or C++.
#define DBUS_INTERFACE_INTROSPECTABLE
The interface supported by introspectable objects.
void _dbus_object_tree_free_all_unlocked(DBusObjectTree *tree)
Free all the handlers in the tree.
void * dbus_realloc(void *memory, size_t bytes)
Resizes a block of memory previously allocated by dbus_malloc() or dbus_malloc0().
void dbus_free(void *memory)
Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().
DBusConnection * connection
Connection this tree belongs to.
void _dbus_connection_lock(DBusConnection *connection)
Acquires the connection lock.
void _dbus_list_remove_link(DBusList **list, DBusList *link)
Removes a link from the list.
#define DBUS_TYPE_STRING
Type code marking a UTF-8 encoded, nul-terminated Unicode string.
DBusObjectPathMessageFunction message_function
Function to handle messages.
#define _dbus_assert(condition)
Aborts with an error message if the condition is false.
void * data
Data stored at this element.
DBusObjectPathUnregisterFunction unregister_function
Function to call on unregister.
#define DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
XML document type declaration of the introspection format version 1.0.
unsigned int invoke_as_fallback
Whether to invoke message_function when child nodes don't handle the message.
Message has not had any effect - see if other handlers want it.
void dbus_message_iter_init_append(DBusMessage *message, DBusMessageIter *iter)
Initializes a DBusMessageIter for appending arguments to the end of a message.
Struct representing a single registered subtree handler, or node that's a parent of a registered subt...
void _dbus_object_tree_unregister_and_unlock(DBusObjectTree *tree, const char **path)
Unregisters an object subtree that was registered with the same path.
char name[1]
Allocated as large as necessary.
Implementation details of DBusConnection.
DBusObjectSubtree * root
Root of the tree ("/" node)
dbus_bool_t _dbus_string_init(DBusString *str)
Initializes a string.
DBusHandlerResult
Results that a message handler can return.
DBusMessageIter struct; contains no public fields.
#define _dbus_list_get_next_link(list, link)
Gets the next link in the list, or NULL if there are no more links.
dbus_int32_t _dbus_atomic_dec(DBusAtomic *atomic)
Atomically decrement an integer.
Virtual table that must be implemented to handle a portion of the object path hierarchy.
Internals of DBusMessage.
int n_subtrees
Number of child nodes.
DBusObjectPathUnregisterFunction unregister_function
Function to unregister this handler.
#define DBUS_ERROR_OBJECT_PATH_IN_USE
There's already an object with the requested object path.
#define dbus_new0(type, count)
Safe macro for using dbus_malloc0().
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
dbus_bool_t _dbus_object_tree_list_registered_and_unlock(DBusObjectTree *tree, const char **parent_path, char ***child_entries)
Lists the registered fallback handlers and object path handlers at the given parent_path.
dbus_bool_t dbus_message_get_path_decomposed(DBusMessage *message, char ***path)
Gets the object path this message is being sent to (for DBUS_MESSAGE_TYPE_METHOD_CALL) or being emitt...
Internals of DBusObjectTree.
void _dbus_warn(const char *format,...)
Prints a warning message to stderr.
DBusObjectTree * _dbus_object_tree_ref(DBusObjectTree *tree)
Increment the reference count.
dbus_bool_t _dbus_list_append(DBusList **list, void *data)
Appends a value to the list.
dbus_bool_t _dbus_decompose_path(const char *data, int len, char ***path, int *path_len)
Decompose an object path.
void * _dbus_memdup(const void *mem, size_t n_bytes)
Duplicates a block of memory.
dbus_bool_t _dbus_string_append_printf(DBusString *str, const char *format,...)
Appends a printf-style formatted string to the DBusString.
DBusObjectSubtree ** subtrees
Child nodes.
Object representing an exception.
void dbus_set_error(DBusError *error, const char *name, const char *format,...)
Assigns an error name and message to a DBusError.
DBusObjectPathMessageFunction message_function
Function to handle messages.
void * user_data
Data for functions.
dbus_bool_t _dbus_connection_send_and_unlock(DBusConnection *connection, DBusMessage *message, dbus_uint32_t *client_serial)
Like dbus_connection_send(), but assumes the connection is already locked on function entry...
dbus_int32_t _dbus_atomic_inc(DBusAtomic *atomic)
Atomically increments an integer.
#define _DBUS_N_ELEMENTS(array)
Computes the number of elements in a fixed-size array using sizeof().
dbus_bool_t _dbus_string_append_byte(DBusString *str, unsigned char byte)
Appends a single byte to the string, returning FALSE if not enough memory.
DBusObjectSubtree * parent
Parent node.
void _dbus_string_free(DBusString *str)
Frees a string created by _dbus_string_init().
#define TRUE
Expands to "1".
#define _dbus_assert_not_reached(explanation)
Aborts with an error message if called.
dbus_bool_t dbus_message_is_method_call(DBusMessage *message, const char *interface, const char *method)
Checks whether the message is a method call with the given interface and member fields.
void * _dbus_object_tree_get_user_data_unlocked(DBusObjectTree *tree, const char **path)
Looks up the data passed to _dbus_object_tree_register() for a handler at the given path...
dbus_bool_t _dbus_object_tree_register(DBusObjectTree *tree, dbus_bool_t fallback, const char **path, const DBusObjectPathVTable *vtable, void *user_data, DBusError *error)
Registers a new subtree in the global object tree.
DBusHandlerResult(* DBusObjectPathMessageFunction)(DBusConnection *connection, DBusMessage *message, void *user_data)
Called when a message is sent to a registered object path.
int refcount
Reference count.
DBusObjectTree * _dbus_object_tree_new(DBusConnection *connection)
Creates a new object tree, representing a mapping from paths to handler vtables.
void dbus_free_string_array(char **str_array)
Frees a NULL-terminated array of strings.
DBusAtomic refcount
Reference count.
int _dbus_list_get_length(DBusList **list)
Gets the length of a list.
dbus_bool_t dbus_message_iter_append_basic(DBusMessageIter *iter, int type, const void *value)
Appends a basic-typed value to the message.
DBusList * _dbus_list_get_first_link(DBusList **list)
Gets the first link in the list.
#define FALSE
Expands to "0".
void * dbus_malloc0(size_t bytes)
Allocates the given number of bytes, as with standard malloc(), but all bytes are initialized to zero...
dbus_bool_t _dbus_string_steal_data(DBusString *str, char **data_return)
Like _dbus_string_get_data(), but removes the gotten data from the original string.
void dbus_connection_unref(DBusConnection *connection)
Decrements the reference count of a DBusConnection, and finalizes it if the count reaches zero...
void _dbus_object_tree_unref(DBusObjectTree *tree)
Decrement the reference count.
DBusConnection * _dbus_connection_ref_unlocked(DBusConnection *connection)
Increments the reference count of a DBusConnection.
Message has had its effect - no need to run more handlers.
int dbus_int32_t
A 32-bit signed integer on all platforms.
char * _dbus_strdup(const char *str)
Duplicates a string.
void _dbus_connection_unlock(DBusConnection *connection)
Releases the connection lock.
const char * _dbus_string_get_const_data(const DBusString *str)
Gets the raw character buffer from a const string.
void dbus_message_unref(DBusMessage *message)
Decrements the reference count of a DBusMessage, freeing the message if the count reaches 0...
Need more memory in order to return DBUS_HANDLER_RESULT_HANDLED or DBUS_HANDLER_RESULT_NOT_YET_HANDLE...
DBusMessage * dbus_message_new_method_call(const char *destination, const char *path, const char *interface, const char *method)
Constructs a new message to invoke a method on a remote object.
DBusMessage * dbus_message_new_method_return(DBusMessage *method_call)
Constructs a message that is a reply to a method call.
void(* DBusObjectPathUnregisterFunction)(DBusConnection *connection, void *user_data)
Called when a DBusObjectPathVTable is unregistered (or its connection is freed).