mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-30 04:33:00 +02:00
libsrx: new function, traverse the void to find an interface
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
committed by
Tobias Waldekranz
parent
29158ed2ef
commit
ce2e15e4d2
@@ -120,6 +120,24 @@ struct lyd_node *lydx_get_descendant(struct lyd_node *from, ...)
|
||||
return node;
|
||||
}
|
||||
|
||||
/*
|
||||
* Similar to lydx_get_decsendant() but for, e.g., finding a named
|
||||
* interface in ietf-interfaces from the top node.
|
||||
*/
|
||||
struct lyd_node *lydx_find_by_name(struct lyd_node *from, const char *by, const char *name)
|
||||
{
|
||||
struct lyd_node *node;
|
||||
|
||||
LY_LIST_FOR(lydx_get_sibling(lyd_child(from), by), node) {
|
||||
if (strcmp(lydx_get_cattr(node, "name"), name))
|
||||
continue;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *lydx_get_mattr(struct lyd_node *node, const char *name)
|
||||
{
|
||||
struct lyd_meta *meta;
|
||||
|
||||
@@ -36,6 +36,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_get_descendant(struct lyd_node *from, ...);
|
||||
struct lyd_node *lydx_find_by_name(struct lyd_node *from, const char *by, const char *name);
|
||||
|
||||
const char *lydx_get_mattr(struct lyd_node *node, const char *name);
|
||||
const char *lydx_get_attr(struct lyd_node *sibling, const char *name);
|
||||
|
||||
Reference in New Issue
Block a user