Browse Source

Add klyd_is_oneliner

Serj Kalichev 10 months ago
parent
commit
941b8845e8
2 changed files with 22 additions and 0 deletions
  1. 21 0
      src/kly.c
  2. 1 0
      src/private.h

+ 21 - 0
src/kly.c

@@ -389,3 +389,24 @@ char *klysc_leafref_xpath(const struct lysc_node *node,
 	return compl_xpath;
 }
 
+
+bool_t klyd_is_oneliner(const struct lyd_node *node)
+{
+	const struct lyd_node *nodes_list = NULL;
+	const struct lyd_node *iter = NULL;
+	size_t i = 0;
+
+	if (!node)
+		return BOOL_TRUE;
+	nodes_list = lyd_child(node);
+	if(!nodes_list)
+		return BOOL_TRUE;
+
+	LY_LIST_FOR(nodes_list, iter) {
+		i++;
+		if (i > 1)
+			return BOOL_FALSE;
+	}
+
+	return BOOL_TRUE;
+}

+ 1 - 0
src/private.h

@@ -94,6 +94,7 @@ char *klysc_leafref_xpath(const struct lysc_node *node,
 	const struct lysc_type *type, const char *node_path);
 const char *klysc_identityref_prefix(struct lysc_type_identityref *type,
 	const char *name);
+bool_t klyd_is_oneliner(const struct lyd_node *node);
 
 C_DECL_END