diff --git a/src/libsrx/src/lyx.c b/src/libsrx/src/lyx.c index 4e42b009..cf064bc8 100644 --- a/src/libsrx/src/lyx.c +++ b/src/libsrx/src/lyx.c @@ -176,6 +176,16 @@ const char *lydx_get_attrf(struct lyd_node *sibling, const char *namefmt, ...) return val; } +bool lydx_get_bool(struct lyd_node *parent, const char *name) +{ + const char *value = lydx_get_cattr(parent,name); + if(!value) + return false; + if(!strcmp(value, "true")) + return true; + return false; +} + int lydx_new_path(const struct ly_ctx *ctx, struct lyd_node **parent, char *xpath_base, char *node, const char *fmt, ...) { diff --git a/src/libsrx/src/lyx.h b/src/libsrx/src/lyx.h index 409804b6..e5319989 100644 --- a/src/libsrx/src/lyx.h +++ b/src/libsrx/src/lyx.h @@ -41,6 +41,8 @@ const char *lydx_get_mattr(struct lyd_node *node, const char *name); const char *lydx_get_attr(struct lyd_node *sibling, const char *name); const char *lydx_get_cattr(struct lyd_node *parent, const char *name); +bool lydx_get_bool(struct lyd_node *parent, const char *name); + const char *lydx_get_vattrf(struct lyd_node *sibling, const char *namefmt, va_list ap); const char *lydx_get_attrf(struct lyd_node *sibling, const char *namefmt, ...) __attribute__ ((format (printf, 2, 3)));