libsrx: factor out new function lydx_vdescend()

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2024-04-15 15:36:41 +02:00
parent 8bf78c2fbb
commit da67ea3695
2 changed files with 13 additions and 3 deletions
+12 -3
View File
@@ -101,13 +101,11 @@ struct lyd_node *lydx_get_child(struct lyd_node *parent, const char *name)
return lydx_get_sibling(lyd_child(parent), name);
}
struct lyd_node *lydx_get_descendant(struct lyd_node *from, ...)
struct lyd_node *lydx_vdescend(struct lyd_node *from, va_list ap)
{
struct lyd_node *node = NULL;
const char *name;
va_list ap;
va_start(ap, from);
while ((name = va_arg(ap, const char *))) {
node = lydx_get_sibling(from, name);
if (!node)
@@ -115,6 +113,17 @@ struct lyd_node *lydx_get_descendant(struct lyd_node *from, ...)
from = lyd_child(node);
}
return node;
}
struct lyd_node *lydx_get_descendant(struct lyd_node *from, ...)
{
struct lyd_node *node;
va_list ap;
va_start(ap, from);
node = lydx_vdescend(from, ap);
va_end(ap);
return node;
+1
View File
@@ -35,6 +35,7 @@ bool lydx_get_diff(struct lyd_node *node, struct lydx_diff *nd);
struct lyd_node *lydx_get_sibling(struct lyd_node *sibling, const char *name);
struct lyd_node *lydx_get_child(struct lyd_node *parent, const char *name);
struct lyd_node *lydx_vdescend(struct lyd_node *from, va_list ap);
struct lyd_node *lydx_get_descendant(struct lyd_node *from, ...);
struct lyd_node *lydx_find_by_name(struct lyd_node *from, const char *by, const char *name);