@@ -223,3 +223,20 @@ int tree_for_each(struct tree *tree, tree_cb_t cb, void *data)
return tree_for_each(tree->next, cb, data);
}
+
+struct tree *tree_find(struct tree *tree, const char *name)
+{
+ struct tree *t;
+
+ if (!tree)
+ return NULL;
+
+ if (!strcmp(tree->name, name))
+ return tree;
+
+ t = tree_find(tree->child, name);
+ if (t)
+ return t;
+
+ return tree_find(tree->next, name);
+}
@@ -42,4 +42,6 @@ typedef int (*tree_filter_t)(const char *name);
extern struct tree *tree_load(const char *path, tree_filter_t filter);
+extern struct tree *tree_find(struct tree *tree, const char *name);
+
extern int tree_for_each(struct tree *tree, tree_cb_t cb, void *data);
That will be useful to search for a specific node name. Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> --- tree.c | 17 +++++++++++++++++ tree.h | 2 ++ 2 files changed, 19 insertions(+), 0 deletions(-)