libsrx: add lydx_get_bool to parse bool values

This commit is contained in:
Mattias Walström
2023-12-26 12:11:37 +01:00
committed by Joachim Wiberg
parent 2b154c1825
commit 2e8ba44abc
2 changed files with 12 additions and 0 deletions
+10
View File
@@ -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, ...)
{
+2
View File
@@ -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)));