schema CHANGE allow printing compiled schema node/subtree

Print not only the complete schema, but also a specified node/subtree.

Introduces following API functions:
lys_node_print_clb()
lys_node_print_fd()
lys_node_print_file()
lys_node_print_mem()
lys_node_print_path()
diff --git a/src/printer_yang.c b/src/printer_yang.c
index 41fb7e9..066b75c 100755
--- a/src/printer_yang.c
+++ b/src/printer_yang.c
@@ -45,6 +45,7 @@
     unsigned int level;              /**< current indentation level: 0 - no formatting, >= 1 indentation levels */
     const struct lys_module *module; /**< schema to print */
     enum schema_type schema;         /**< type of the schema to print */
+    int options;                     /**< Schema output options (see @ref schemaprinterflags). */
 };
 
 #define LEVEL ctx->level             /**< current level */
@@ -1184,8 +1185,10 @@
         yprc_must(ctx, &inout->musts[u], NULL);
     }
 
-    LY_LIST_FOR(inout->data, data) {
-        yprc_node(ctx, data);
+    if (!(ctx->options & LYS_OUTPUT_NO_SUBST)) {
+        LY_LIST_FOR(inout->data, data) {
+            yprc_node(ctx, data);
+        }
     }
 
     LEVEL--;
@@ -1255,9 +1258,11 @@
     ypr_description(ctx, notif->dsc, notif->exts, &flag);
     ypr_reference(ctx, notif->ref, notif->exts, &flag);
 
-    LY_LIST_FOR(notif->data, data) {
-        ypr_open(ctx->out, &flag);
-        yprc_node(ctx, data);
+    if (!(ctx->options & LYS_OUTPUT_NO_SUBST)) {
+        LY_LIST_FOR(notif->data, data) {
+            ypr_open(ctx->out, &flag);
+            yprc_node(ctx, data);
+        }
     }
 
     LEVEL--;
@@ -1440,19 +1445,21 @@
 
     yprc_node_common2(ctx, node, &flag);
 
-    LY_LIST_FOR(cont->child, child) {
-        ypr_open(ctx->out, &flag);
-        yprc_node(ctx, child);
-    }
+    if (!(ctx->options & LYS_OUTPUT_NO_SUBST)) {
+        LY_LIST_FOR(cont->child, child) {
+            ypr_open(ctx->out, &flag);
+            yprc_node(ctx, child);
+        }
 
-    LY_ARRAY_FOR(cont->actions, u) {
-        ypr_open(ctx->out, &flag);
-        yprc_action(ctx, &cont->actions[u]);
-    }
+        LY_ARRAY_FOR(cont->actions, u) {
+            ypr_open(ctx->out, &flag);
+            yprc_action(ctx, &cont->actions[u]);
+        }
 
-    LY_ARRAY_FOR(cont->notifs, u) {
-        ypr_open(ctx->out, &flag);
-        yprc_notification(ctx, &cont->notifs[u]);
+        LY_ARRAY_FOR(cont->notifs, u) {
+            ypr_open(ctx->out, &flag);
+            yprc_notification(ctx, &cont->notifs[u]);
+        }
     }
 
     LEVEL--;
@@ -1487,9 +1494,11 @@
     yprc_node_common1(ctx, (struct lysc_node*)cs, &flag);
     yprc_node_common2(ctx, (struct lysc_node*)cs, &flag);
 
-    for (child = cs->child; child && child->parent == (struct lysc_node*)cs; child = child->next) {
-        ypr_open(ctx->out, &flag);
-        yprc_node(ctx, child);
+    if (!(ctx->options & LYS_OUTPUT_NO_SUBST)) {
+        for (child = cs->child; child && child->parent == (struct lysc_node*)cs; child = child->next) {
+            ypr_open(ctx->out, &flag);
+            yprc_node(ctx, child);
+        }
     }
 
     LEVEL--;
@@ -1786,19 +1795,21 @@
     ypr_description(ctx, node->dsc, node->exts, NULL);
     ypr_reference(ctx, node->ref, node->exts, NULL);
 
-    LY_LIST_FOR(list->child, child) {
-        ypr_open(ctx->out, &flag);
-        yprc_node(ctx, child);
-    }
+    if (!(ctx->options & LYS_OUTPUT_NO_SUBST)) {
+        LY_LIST_FOR(list->child, child) {
+            ypr_open(ctx->out, &flag);
+            yprc_node(ctx, child);
+        }
 
-    LY_ARRAY_FOR(list->actions, u) {
-        ypr_open(ctx->out, &flag);
-        yprc_action(ctx, &list->actions[u]);
-    }
+        LY_ARRAY_FOR(list->actions, u) {
+            ypr_open(ctx->out, &flag);
+            yprc_action(ctx, &list->actions[u]);
+        }
 
-    LY_ARRAY_FOR(list->notifs, u) {
-        ypr_open(ctx->out, &flag);
-        yprc_notification(ctx, &list->notifs[u]);
+        LY_ARRAY_FOR(list->notifs, u) {
+            ypr_open(ctx->out, &flag);
+            yprc_notification(ctx, &list->notifs[u]);
+        }
     }
 
     LEVEL--;
@@ -2289,12 +2300,23 @@
 }
 
 LY_ERR
-yang_print_compiled(struct lyout *out, const struct lys_module *module)
+yang_print_compiled_node(struct lyout *out, const struct lysc_node *node, int options)
+{
+    struct ypr_ctx ctx_ = {.out = out, .level = 0, .module = node->module, .options = options}, *ctx = &ctx_;
+
+    yprc_node(ctx, node);
+
+    ly_print_flush(out);
+    return LY_SUCCESS;
+}
+
+LY_ERR
+yang_print_compiled(struct lyout *out, const struct lys_module *module, int options)
 {
     LY_ARRAY_SIZE_TYPE u;
     struct lysc_node *data;
     struct lysc_module *modc = module->compiled;
-    struct ypr_ctx ctx_ = {.out = out, .level = 0, .module = module}, *ctx = &ctx_;
+    struct ypr_ctx ctx_ = {.out = out, .level = 0, .module = module, .options = options}, *ctx = &ctx_;
 
     ly_print(ctx->out, "%*smodule %s {\n", INDENT, module->name);
     LEVEL++;
@@ -2354,16 +2376,18 @@
         yprc_identity(ctx, &modc->identities[u]);
     }
 
-    LY_LIST_FOR(modc->data, data) {
-        yprc_node(ctx, data);
-    }
+    if (!(ctx->options & LYS_OUTPUT_NO_SUBST)) {
+        LY_LIST_FOR(modc->data, data) {
+            yprc_node(ctx, data);
+        }
 
-    LY_ARRAY_FOR(modc->rpcs, u) {
-        yprc_action(ctx, &modc->rpcs[u]);
-    }
+        LY_ARRAY_FOR(modc->rpcs, u) {
+            yprc_action(ctx, &modc->rpcs[u]);
+        }
 
-    LY_ARRAY_FOR(modc->notifs, u) {
-        yprc_notification(ctx, &modc->notifs[u]);
+        LY_ARRAY_FOR(modc->notifs, u) {
+            yprc_notification(ctx, &modc->notifs[u]);
+        }
     }
 
     LEVEL--;