summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/libdom.c16
-rw-r--r--utils/libdom.h4
2 files changed, 12 insertions, 8 deletions
diff --git a/utils/libdom.c b/utils/libdom.c
index 9e7e7761a..a1465af19 100644
--- a/utils/libdom.c
+++ b/utils/libdom.c
@@ -211,7 +211,8 @@ dom_node *libdom_find_first_element(dom_node *parent, lwc_string *element_name)
}
/* exported interface documented in libdom.h */
-void libdom_iterate_child_elements(dom_node *parent,
+/* TODO: return appropriate errors */
+nserror libdom_iterate_child_elements(dom_node *parent,
libdom_iterate_cb cb, void *ctx)
{
dom_nodelist *children;
@@ -220,12 +221,12 @@ void libdom_iterate_child_elements(dom_node *parent,
error = dom_node_get_child_nodes(parent, &children);
if (error != DOM_NO_ERR || children == NULL)
- return;
+ return NSERROR_NOMEM;
error = dom_nodelist_get_length(children, &num_children);
if (error != DOM_NO_ERR) {
dom_nodelist_unref(children);
- return;
+ return NSERROR_NOMEM;
}
for (index = 0; index < num_children; index++) {
@@ -235,15 +236,16 @@ void libdom_iterate_child_elements(dom_node *parent,
error = dom_nodelist_item(children, index, &child);
if (error != DOM_NO_ERR) {
dom_nodelist_unref(children);
- return;
+ return NSERROR_NOMEM;
}
error = dom_node_get_node_type(child, &type);
if (error == DOM_NO_ERR && type == DOM_ELEMENT_NODE) {
- if (cb(child, ctx) == false) {
+ nserror err = cb(child, ctx);
+ if (err != NSERROR_OK) {
dom_node_unref(child);
dom_nodelist_unref(children);
- return;
+ return err;
}
}
@@ -251,6 +253,8 @@ void libdom_iterate_child_elements(dom_node *parent,
}
dom_nodelist_unref(children);
+
+ return NSERROR_OK;
}
/* exported interface documented in libdom.h */
diff --git a/utils/libdom.h b/utils/libdom.h
index 36caf01bf..dc8eacd12 100644
--- a/utils/libdom.h
+++ b/utils/libdom.h
@@ -61,9 +61,9 @@ dom_node *libdom_find_element(dom_node *node, lwc_string *element_name);
*/
dom_node *libdom_find_first_element(dom_node *parent, lwc_string *element_name);
-typedef bool (*libdom_iterate_cb)(dom_node *node, void *ctx);
+typedef nserror (*libdom_iterate_cb)(dom_node *node, void *ctx);
-void libdom_iterate_child_elements(dom_node *parent,
+nserror libdom_iterate_child_elements(dom_node *parent,
libdom_iterate_cb cb, void *ctx);
nserror libdom_parse_file(const char *filename, const char *encoding,