printer REFACTOR remove ctx and status (#1170)
diff --git a/src/printer_xml.c b/src/printer_xml.c
index 345776f..51942fc 100644
--- a/src/printer_xml.c
+++ b/src/printer_xml.c
@@ -89,7 +89,7 @@
if (i == -1) {
/* suitable namespace not found, must be printed */
- ly_print(ctx->out, " xmlns%s%s=\"%s\"", new_prefix ? ":" : "", new_prefix ? new_prefix : "", ns);
+ ly_print_(ctx->out, " xmlns%s%s=\"%s\"", new_prefix ? ":" : "", new_prefix ? new_prefix : "", ns);
/* and added into namespaces */
if (new_prefix) {
@@ -155,7 +155,7 @@
/* 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) {
- ly_print(ctx->out, " %s:default=\"true\"", xml_print_ns(ctx, mod->ns, mod->prefix, 0));
+ ly_print_(ctx->out, " %s:default=\"true\"", xml_print_ns(ctx, mod->ns, mod->prefix, 0));
}
}
}
@@ -188,17 +188,17 @@
}
for (i = 0; i < ns_count; ++i) {
- ly_print(out, " xmlns:%s=\"%s\"", prefs[i], nss[i]);
+ ly_print_(out, " xmlns:%s=\"%s\"", prefs[i], nss[i]);
}
free(prefs);
free(nss);
}
- ly_print(out, " %s=\"", meta->name);
+ ly_print_(out, " %s=\"", meta->name);
} else {
#endif
/* print the metadata with its namespace */
mod = meta->annotation->module;
- ly_print(ctx->out, " %s:%s=\"", xml_print_ns(ctx, mod->ns, mod->prefix, 1), meta->name);
+ ly_print_(ctx->out, " %s:%s=\"", xml_print_ns(ctx, mod->ns, mod->prefix, 1), meta->name);
#if 0
}
#endif
@@ -207,7 +207,7 @@
if (value && value[0]) {
lyxml_dump_text(ctx->out, value, 1);
}
- ly_print(ctx->out, "\"");
+ ly_print_(ctx->out, "\"");
if (dynamic) {
free((void *)value);
}
@@ -226,7 +226,7 @@
xml_print_node_open(struct xmlpr_ctx *ctx, const struct lyd_node *node)
{
/* print node name */
- ly_print(ctx->out, "%*s<%s", INDENT, node->schema->name);
+ ly_print_(ctx->out, "%*s<%s", INDENT, node->schema->name);
/* print default namespace */
xml_print_ns(ctx, node->schema->module->ns, NULL, 0);
@@ -257,7 +257,7 @@
}
/* print the attribute with its prefix and value */
- ly_print(ctx->out, " %s%s%s=\"%s\"", pref ? pref : "", pref ? ":" : "", attr->name, attr->value);
+ ly_print_(ctx->out, " %s%s%s=\"%s\"", pref ? pref : "", pref ? ":" : "", attr->name, attr->value);
}
return LY_SUCCESS;
@@ -267,7 +267,7 @@
xml_print_opaq_open(struct xmlpr_ctx *ctx, const struct lyd_node_opaq *node)
{
/* print node name */
- ly_print(ctx->out, "%*s<%s", INDENT, node->name);
+ ly_print_(ctx->out, "%*s<%s", INDENT, node->name);
/* print default namespace */
xml_print_ns_opaq(ctx, node->format, &node->prefix, LYXML_PREFIX_DEFAULT);
@@ -300,16 +300,16 @@
/* print namespaces connected with the values's prefixes */
for (u = 0; u < ns_list.count; ++u) {
const struct lys_module *mod = (const struct lys_module *)ns_list.objs[u];
- ly_print(ctx->out, " xmlns:%s=\"%s\"", mod->prefix, mod->ns);
+ ly_print_(ctx->out, " xmlns:%s=\"%s\"", mod->prefix, mod->ns);
}
ly_set_erase(&ns_list, NULL);
if (!value || !value[0]) {
- ly_print(ctx->out, "/>%s", DO_FORMAT ? "\n" : "");
+ ly_print_(ctx->out, "/>%s", DO_FORMAT ? "\n" : "");
} else {
- ly_print(ctx->out, ">");
+ ly_print_(ctx->out, ">");
lyxml_dump_text(ctx->out, value, 0);
- ly_print(ctx->out, "</%s>%s", node->schema->name, DO_FORMAT ? "\n" : "");
+ ly_print_(ctx->out, "</%s>%s", node->schema->name, DO_FORMAT ? "\n" : "");
}
if (dynamic) {
free((void *)value);
@@ -332,12 +332,12 @@
xml_print_node_open(ctx, (struct lyd_node *)node);
if (!node->child) {
- ly_print(ctx->out, "/>%s", DO_FORMAT ? "\n" : "");
+ ly_print_(ctx->out, "/>%s", DO_FORMAT ? "\n" : "");
return LY_SUCCESS;
}
/* children */
- ly_print(ctx->out, ">%s", DO_FORMAT ? "\n" : "");
+ ly_print_(ctx->out, ">%s", DO_FORMAT ? "\n" : "");
LEVEL_INC;
LY_LIST_FOR(node->child, child) {
@@ -346,7 +346,7 @@
}
LEVEL_DEC;
- ly_print(ctx->out, "%*s</%s>%s", INDENT, node->schema->name, DO_FORMAT ? "\n" : "");
+ ly_print_(ctx->out, "%*s</%s>%s", INDENT, node->schema->name, DO_FORMAT ? "\n" : "");
return LY_SUCCESS;
}
@@ -364,7 +364,7 @@
if (!any->value.tree) {
/* no content */
no_content:
- ly_print(ctx->out, "/>%s", DO_FORMAT ? "\n" : "");
+ ly_print_(ctx->out, "/>%s", DO_FORMAT ? "\n" : "");
return LY_SUCCESS;
} else {
if (any->value_type == LYD_ANYDATA_LYB) {
@@ -390,7 +390,7 @@
ctx->options &= ~LYD_PRINT_WITHSIBLINGS;
LEVEL_INC;
- ly_print(ctx->out, ">%s", DO_FORMAT ? "\n" : "");
+ ly_print_(ctx->out, ">%s", DO_FORMAT ? "\n" : "");
LY_LIST_FOR(any->value.tree, iter) {
ret = xml_print_node(ctx, iter);
LY_CHECK_ERR_RET(ret, LEVEL_DEC, ret);
@@ -405,7 +405,7 @@
goto no_content;
}
/* close opening tag and print data */
- ly_print(ctx->out, ">");
+ ly_print_(ctx->out, ">");
lyxml_dump_text(ctx->out, any->value.str, 0);
break;
case LYD_ANYDATA_XML:
@@ -413,7 +413,7 @@
if (!any->value.str[0]) {
goto no_content;
}
- ly_print(ctx->out, ">%s", any->value.str);
+ ly_print_(ctx->out, ">%s", any->value.str);
break;
case LYD_ANYDATA_JSON:
case LYD_ANYDATA_LYB:
@@ -424,9 +424,9 @@
/* closing tag */
if (any->value_type == LYD_ANYDATA_DATATREE) {
- ly_print(ctx->out, "%*s</%s>%s", INDENT, node->schema->name, DO_FORMAT ? "\n" : "");
+ ly_print_(ctx->out, "%*s</%s>%s", INDENT, node->schema->name, DO_FORMAT ? "\n" : "");
} else {
- ly_print(ctx->out, "</%s>%s", node->schema->name, DO_FORMAT ? "\n" : "");
+ ly_print_(ctx->out, "</%s>%s", node->schema->name, DO_FORMAT ? "\n" : "");
}
}
@@ -450,13 +450,13 @@
}
}
- ly_print(ctx->out, ">%s", node->value);
+ ly_print_(ctx->out, ">%s", node->value);
}
if (node->child) {
/* children */
if (!node->value[0]) {
- ly_print(ctx->out, ">%s", DO_FORMAT ? "\n" : "");
+ ly_print_(ctx->out, ">%s", DO_FORMAT ? "\n" : "");
}
LEVEL_INC;
@@ -466,12 +466,12 @@
}
LEVEL_DEC;
- ly_print(ctx->out, "%*s</%s>%s", INDENT, node->name, DO_FORMAT ? "\n" : "");
+ ly_print_(ctx->out, "%*s</%s>%s", INDENT, node->name, DO_FORMAT ? "\n" : "");
} else if (node->value[0]) {
- ly_print(ctx->out, "</%s>%s", node->name, DO_FORMAT ? "\n" : "");
+ ly_print_(ctx->out, "</%s>%s", node->name, DO_FORMAT ? "\n" : "");
} else {
/* no value or children */
- ly_print(ctx->out, "/>%s", DO_FORMAT ? "\n" : "");
+ ly_print_(ctx->out, "/>%s", DO_FORMAT ? "\n" : "");
}
return LY_SUCCESS;
@@ -542,7 +542,7 @@
if (!root) {
if (out->type == LY_OUT_MEMORY || out->type == LY_OUT_CALLBACK) {
- ly_print(out, "");
+ ly_print_(out, "");
}
goto finish;
}