data tree CHANGE provide lyd_is_default()

Rename internal ly_is_default() to lyd_is_default() and make it public
as a replacement for lyd_wd_default() from libyang 1.x.
diff --git a/src/printer.c b/src/printer.c
index def1fa8..dd48e51 100644
--- a/src/printer.c
+++ b/src/printer.c
@@ -72,44 +72,6 @@
 };
 
 ly_bool
-ly_is_default(const struct lyd_node *node)
-{
-    const struct lysc_node_leaf *leaf;
-    const struct lysc_node_leaflist *llist;
-    const struct lyd_node_term *term;
-    LY_ARRAY_COUNT_TYPE u;
-
-    assert(node->schema->nodetype & LYD_NODE_TERM);
-    term = (const struct lyd_node_term *)node;
-
-    if (node->schema->nodetype == LYS_LEAF) {
-        leaf = (const struct lysc_node_leaf *)node->schema;
-        if (!leaf->dflt) {
-            return 0;
-        }
-
-        /* compare with the default value */
-        if (leaf->type->plugin->compare(&term->value, leaf->dflt)) {
-            return 0;
-        }
-    } else {
-        llist = (const struct lysc_node_leaflist *)node->schema;
-        if (!llist->dflts) {
-            return 0;
-        }
-
-        LY_ARRAY_FOR(llist->dflts, u) {
-            /* compare with each possible default value */
-            if (llist->type->plugin->compare(&term->value, llist->dflts[u])) {
-                return 0;
-            }
-        }
-    }
-
-    return 1;
-}
-
-ly_bool
 ly_should_print(const struct lyd_node *node, uint32_t options)
 {
     const struct lyd_node *elem;
@@ -120,7 +82,7 @@
             /* implicit default node/NP container with only default nodes */
             return 0;
         } else if (node->schema->nodetype & LYD_NODE_TERM) {
-            if (ly_is_default(node)) {
+            if (lyd_is_default(node)) {
                 /* explicit default node */
                 return 0;
             }
diff --git a/src/printer_internal.h b/src/printer_internal.h
index a4d12f0..ff02972 100644
--- a/src/printer_internal.h
+++ b/src/printer_internal.h
@@ -185,14 +185,6 @@
 LY_ERR lyb_print_data(struct ly_out *out, const struct lyd_node *root, uint32_t options);
 
 /**
- * @brief Check whether a node value equals to its default one.
- *
- * @param[in] node Term node to test.
- * @return false (no, it is not a default node) or true (yes, it is default)
- */
-ly_bool ly_is_default(const struct lyd_node *node);
-
-/**
  * @brief Check whether the node should even be printed.
  *
  * @param[in] node Node to check.
diff --git a/src/printer_lyb.c b/src/printer_lyb.c
index 1aa2314..d90fc9d 100644
--- a/src/printer_lyb.c
+++ b/src/printer_lyb.c
@@ -699,7 +699,7 @@
     /* with-defaults */
     if (node->schema->nodetype & LYD_NODE_TERM) {
         if (((node->flags & LYD_DEFAULT) && (lybctx->print_options & (LYD_PRINT_WD_ALL_TAG | LYD_PRINT_WD_IMPL_TAG))) ||
-                ((lybctx->print_options & LYD_PRINT_WD_ALL_TAG) && ly_is_default(node))) {
+                ((lybctx->print_options & LYD_PRINT_WD_ALL_TAG) && lyd_is_default(node))) {
             /* we have implicit OR explicit default node, print attribute only if context include with-defaults schema */
             wd_mod = ly_ctx_get_module_latest(node->schema->module->ctx, "ietf-netconf-with-defaults");
         }
diff --git a/src/printer_xml.c b/src/printer_xml.c
index 21d8dc5..26fa401 100644
--- a/src/printer_xml.c
+++ b/src/printer_xml.c
@@ -149,7 +149,7 @@
     /* with-defaults */
     if (node->schema->nodetype & LYD_NODE_TERM) {
         if (((node->flags & LYD_DEFAULT) && (ctx->options & (LYD_PRINT_WD_ALL_TAG | LYD_PRINT_WD_IMPL_TAG))) ||
-                ((ctx->options & LYD_PRINT_WD_ALL_TAG) && ly_is_default(node))) {
+                ((ctx->options & LYD_PRINT_WD_ALL_TAG) && lyd_is_default(node))) {
             /* we have implicit OR explicit default node, print attribute only if context include with-defaults schema */
             mod = ly_ctx_get_module_latest(node->schema->module->ctx, "ietf-netconf-with-defaults");
             if (mod) {
diff --git a/src/tree_data.c b/src/tree_data.c
index 4da6eb2..6514520 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -273,6 +273,44 @@
     return ret;
 }
 
+API ly_bool
+lyd_is_default(const struct lyd_node *node)
+{
+    const struct lysc_node_leaf *leaf;
+    const struct lysc_node_leaflist *llist;
+    const struct lyd_node_term *term;
+    LY_ARRAY_COUNT_TYPE u;
+
+    assert(node->schema->nodetype & LYD_NODE_TERM);
+    term = (const struct lyd_node_term *)node;
+
+    if (node->schema->nodetype == LYS_LEAF) {
+        leaf = (const struct lysc_node_leaf *)node->schema;
+        if (!leaf->dflt) {
+            return 0;
+        }
+
+        /* compare with the default value */
+        if (leaf->type->plugin->compare(&term->value, leaf->dflt)) {
+            return 0;
+        }
+    } else {
+        llist = (const struct lysc_node_leaflist *)node->schema;
+        if (!llist->dflts) {
+            return 0;
+        }
+
+        LY_ARRAY_FOR(llist->dflts, u) {
+            /* compare with each possible default value */
+            if (llist->type->plugin->compare(&term->value, llist->dflts[u])) {
+                return 0;
+            }
+        }
+    }
+
+    return 1;
+}
+
 static LYD_FORMAT
 lyd_parse_get_format(const struct ly_in *in, LYD_FORMAT format)
 {
diff --git a/src/tree_data.h b/src/tree_data.h
index b6d8c25..02e9252 100644
--- a/src/tree_data.h
+++ b/src/tree_data.h
@@ -496,6 +496,14 @@
 const struct lys_module *lyd_owner_module(const struct lyd_node *node);
 
 /**
+ * @brief Check whether a node value equals to its default one.
+ *
+ * @param[in] node Term node to test.
+ * @return false (no, it is not a default node) or true (yes, it is default)
+ */
+ly_bool lyd_is_default(const struct lyd_node *node);
+
+/**
  * @brief Learn the length of LYB data.
  *
  * @param[in] data LYB data to examine.