libyang CHANGE rename ambiguous lyp_ prefixed functions and structures
The 'p' in the lyp_ prefix is not unique since it may refer to printer
as well as parser. Some of the objects are connected with libyang output
object, so they are now prefixed by 'ly_out_' prefix. The rest
(lyp_print() or lyp_write()) is so generic that only the `ly_` prefix
can be used for them.
diff --git a/src/printer_xml.c b/src/printer_xml.c
index b1d187c..2e5182e 100644
--- a/src/printer_xml.c
+++ b/src/printer_xml.c
@@ -32,7 +32,7 @@
* @brief XML printer context.
*/
struct xmlpr_ctx {
- struct lyp_out *out; /**< output specification */
+ struct ly_out *out; /**< output specification */
unsigned int level; /**< current indentation level: 0 - no formatting, >= 1 indentation levels */
int options; /**< [Data printer flags](@ref dataprinterflags) */
const struct ly_ctx *ctx; /**< libyang context */
@@ -89,7 +89,7 @@
if (i == -1) {
/* suitable namespace not found, must be printed */
- lyp_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) {
@@ -144,7 +144,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) {
- lyp_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));
}
}
}
@@ -177,17 +177,17 @@
}
for (i = 0; i < ns_count; ++i) {
- lyp_print(out, " xmlns:%s=\"%s\"", prefs[i], nss[i]);
+ ly_print(out, " xmlns:%s=\"%s\"", prefs[i], nss[i]);
}
free(prefs);
free(nss);
}
- lyp_print(out, " %s=\"", meta->name);
+ ly_print(out, " %s=\"", meta->name);
} else {
#endif
/* print the metadata with its namespace */
mod = meta->annotation->module;
- lyp_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
@@ -196,7 +196,7 @@
if (value && value[0]) {
lyxml_dump_text(ctx->out, value, 1);
}
- lyp_print(ctx->out, "\"");
+ ly_print(ctx->out, "\"");
if (dynamic) {
free((void *)value);
}
@@ -215,7 +215,7 @@
xml_print_node_open(struct xmlpr_ctx *ctx, const struct lyd_node *node)
{
/* print node name */
- lyp_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);
@@ -254,7 +254,7 @@
}
/* print the attribute with its prefix and value */
- lyp_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;
@@ -264,7 +264,7 @@
xml_print_opaq_open(struct xmlpr_ctx *ctx, const struct lyd_node_opaq *node)
{
/* print node name */
- lyp_print(ctx->out, "%*s<%s", INDENT, node->name);
+ ly_print(ctx->out, "%*s<%s", INDENT, node->name);
/* print default namespace */
switch (node->format) {
@@ -305,16 +305,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];
- lyp_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]) {
- lyp_print(ctx->out, "/>%s", LEVEL ? "\n" : "");
+ ly_print(ctx->out, "/>%s", LEVEL ? "\n" : "");
} else {
- lyp_print(ctx->out, ">");
+ ly_print(ctx->out, ">");
lyxml_dump_text(ctx->out, value, 0);
- lyp_print(ctx->out, "</%s>%s", node->schema->name, LEVEL ? "\n" : "");
+ ly_print(ctx->out, "</%s>%s", node->schema->name, LEVEL ? "\n" : "");
}
if (dynamic) {
free((void *)value);
@@ -337,12 +337,12 @@
xml_print_node_open(ctx, (struct lyd_node *)node);
if (!node->child) {
- lyp_print(ctx->out, "/>%s", ctx->level ? "\n" : "");
+ ly_print(ctx->out, "/>%s", ctx->level ? "\n" : "");
return LY_SUCCESS;
}
/* children */
- lyp_print(ctx->out, ">%s", ctx->level ? "\n" : "");
+ ly_print(ctx->out, ">%s", ctx->level ? "\n" : "");
LEVEL_INC;
LY_LIST_FOR(node->child, child) {
@@ -351,7 +351,7 @@
}
LEVEL_DEC;
- lyp_print(ctx->out, "%*s</%s>%s", INDENT, node->schema->name, LEVEL ? "\n" : "");
+ ly_print(ctx->out, "%*s</%s>%s", INDENT, node->schema->name, LEVEL ? "\n" : "");
return LY_SUCCESS;
}
@@ -369,7 +369,7 @@
if (!any->value.tree) {
/* no content */
no_content:
- lyp_print(ctx->out, "/>%s", LEVEL ? "\n" : "");
+ ly_print(ctx->out, "/>%s", LEVEL ? "\n" : "");
return LY_SUCCESS;
} else {
switch (any->value_type) {
@@ -379,7 +379,7 @@
ctx->options &= ~LYDP_WITHSIBLINGS;
LEVEL_INC;
- lyp_print(ctx->out, ">%s", LEVEL ? "\n" : "");
+ ly_print(ctx->out, ">%s", LEVEL ? "\n" : "");
LY_LIST_FOR(any->value.tree, iter) {
ret = xml_print_node(ctx, iter);
LY_CHECK_ERR_RET(ret, LEVEL_DEC, ret);
@@ -394,7 +394,7 @@
goto no_content;
}
/* close opening tag and print data */
- lyp_print(ctx->out, ">");
+ ly_print(ctx->out, ">");
lyxml_dump_text(ctx->out, any->value.str, 0);
break;
case LYD_ANYDATA_XML:
@@ -402,7 +402,7 @@
if (!any->value.str[0]) {
goto no_content;
}
- lyp_print(ctx->out, ">%s", any->value.str);
+ ly_print(ctx->out, ">%s", any->value.str);
break;
case LYD_ANYDATA_JSON:
#if 0 /* TODO LYB format */
@@ -415,9 +415,9 @@
/* closing tag */
if (any->value_type == LYD_ANYDATA_DATATREE) {
- lyp_print(ctx->out, "%*s</%s>%s", INDENT, node->schema->name, LEVEL ? "\n" : "");
+ ly_print(ctx->out, "%*s</%s>%s", INDENT, node->schema->name, LEVEL ? "\n" : "");
} else {
- lyp_print(ctx->out, "</%s>%s", node->schema->name, LEVEL ? "\n" : "");
+ ly_print(ctx->out, "</%s>%s", node->schema->name, LEVEL ? "\n" : "");
}
}
@@ -441,13 +441,13 @@
}
}
- lyp_print(ctx->out, ">%s", node->value);
+ ly_print(ctx->out, ">%s", node->value);
}
if (node->child) {
/* children */
if (!node->value[0]) {
- lyp_print(ctx->out, ">%s", ctx->level ? "\n" : "");
+ ly_print(ctx->out, ">%s", ctx->level ? "\n" : "");
}
LEVEL_INC;
@@ -457,12 +457,12 @@
}
LEVEL_DEC;
- lyp_print(ctx->out, "%*s</%s>%s", INDENT, node->name, LEVEL ? "\n" : "");
+ ly_print(ctx->out, "%*s</%s>%s", INDENT, node->name, LEVEL ? "\n" : "");
} else if (node->value[0]) {
- lyp_print(ctx->out, "</%s>%s", node->name, LEVEL ? "\n" : "");
+ ly_print(ctx->out, "</%s>%s", node->name, LEVEL ? "\n" : "");
} else {
/* no value or children */
- lyp_print(ctx->out, "/>%s", ctx->level ? "\n" : "");
+ ly_print(ctx->out, "/>%s", ctx->level ? "\n" : "");
}
return LY_SUCCESS;
@@ -526,14 +526,14 @@
}
LY_ERR
-xml_print_data(struct lyp_out *out, const struct lyd_node *root, int options)
+xml_print_data(struct ly_out *out, const struct lyd_node *root, int options)
{
const struct lyd_node *node;
struct xmlpr_ctx ctx = {0};
if (!root) {
- if (out->type == LYP_OUT_MEMORY || out->type == LYP_OUT_CALLBACK) {
- lyp_print(out, "");
+ if (out->type == LY_OUT_MEMORY || out->type == LY_OUT_CALLBACK) {
+ ly_print(out, "");
}
goto finish;
}