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/tests/utests/data/test_parser_xml.c b/tests/utests/data/test_parser_xml.c
index a40fdf5..0c51134 100644
--- a/tests/utests/data/test_parser_xml.c
+++ b/tests/utests/data/test_parser_xml.c
@@ -175,8 +175,8 @@
char *str;
struct lyd_node *tree;
- struct lyp_out *out;
- assert_non_null(out = lyp_new_memory(&str, 0));
+ struct ly_out *out;
+ assert_non_null(out = ly_out_new_memory(&str, 0));
data =
"<any xmlns=\"urn:tests:a\">"
@@ -199,10 +199,10 @@
"<element1a/>"
"</any>"
);
- lyp_out_reset(out);
+ ly_out_reset(out);
lyd_free_all(tree);
- lyp_free(out, NULL, 1);
+ ly_out_free(out, NULL, 1);
*state = NULL;
}
@@ -324,8 +324,8 @@
char *str;
struct lyd_node *tree;
- struct lyp_out *out;
- assert_non_null(out = lyp_new_memory(&str, 0));
+ struct ly_out *out;
+ assert_non_null(out = ly_out_new_memory(&str, 0));
/* invalid value, no flags */
data = "<foo3 xmlns=\"urn:tests:a\"/>";
@@ -342,7 +342,7 @@
lyd_print(out, tree, LYD_XML, 0);
assert_string_equal(str, "<foo3 xmlns=\"urn:tests:a\"/>");
- lyp_out_reset(out);
+ ly_out_reset(out);
lyd_free_all(tree);
/* missing key, no flags */
@@ -360,7 +360,7 @@
lyd_print(out, tree, LYD_XML, 0);
assert_string_equal(str, data);
- lyp_out_reset(out);
+ ly_out_reset(out);
lyd_free_all(tree);
/* invalid key, no flags */
@@ -378,7 +378,7 @@
lyd_print(out, tree, LYD_XML, 0);
assert_string_equal(str, data);
- lyp_out_reset(out);
+ ly_out_reset(out);
lyd_free_all(tree);
/* opaq flag and fail */
@@ -386,7 +386,7 @@
LYD_OPT_OPAQ | LYD_VALOPT_DATA_ONLY, &tree));
assert_null(tree);
- lyp_free(out, NULL, 1);
+ ly_out_free(out, NULL, 1);
*state = NULL;
}
@@ -401,8 +401,8 @@
struct lyd_node *tree, *op;
const struct lyd_node *node;
- struct lyp_out *out;
- assert_non_null(out = lyp_new_memory(&str, 0));
+ struct ly_out *out;
+ assert_non_null(out = ly_out_new_memory(&str, 0));
data =
"<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" msgid=\"25\" custom-attr=\"val\">"
@@ -466,13 +466,13 @@
"</config>"
"</edit-config>"
"</rpc>");
- lyp_out_reset(out);
+ ly_out_reset(out);
lyd_free_all(tree);
/* wrong namespace, element name, whatever... */
/* TODO */
- lyp_free(out, NULL, 1);
+ ly_out_free(out, NULL, 1);
*state = NULL;
}
@@ -487,8 +487,8 @@
struct lyd_node *tree, *op;
const struct lyd_node *node;
- struct lyp_out *out;
- assert_non_null(out = lyp_new_memory(&str, 0));
+ struct ly_out *out;
+ assert_non_null(out = ly_out_new_memory(&str, 0));
data =
"<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" msgid=\"25\" custom-attr=\"val\">"
@@ -525,13 +525,13 @@
"</c>"
"</action>"
"</rpc>");
- lyp_out_reset(out);
+ ly_out_reset(out);
lyd_free_all(tree);
/* wrong namespace, element name, whatever... */
/* TODO */
- lyp_free(out, NULL, 1);
+ ly_out_free(out, NULL, 1);
*state = NULL;
}
@@ -546,8 +546,8 @@
struct lyd_node *tree, *ntf;
const struct lyd_node *node;
- struct lyp_out *out;
- assert_non_null(out = lyp_new_memory(&str, 0));
+ struct ly_out *out;
+ assert_non_null(out = ly_out_new_memory(&str, 0));
data =
"<notification xmlns=\"urn:ietf:params:xml:ns:netconf:notification:1.0\">"
@@ -578,7 +578,7 @@
lyd_print(out, tree, LYD_XML, 0);
assert_string_equal(str, data);
- lyp_out_reset(out);
+ ly_out_reset(out);
lyd_free_all(tree);
/* top-level notif without envelope */
@@ -593,13 +593,13 @@
lyd_print(out, tree, LYD_XML, 0);
assert_string_equal(str, data);
- lyp_out_reset(out);
+ ly_out_reset(out);
lyd_free_all(tree);
/* wrong namespace, element name, whatever... */
/* TODO */
- lyp_free(out, NULL, 1);
+ ly_out_free(out, NULL, 1);
*state = NULL;
}
@@ -614,8 +614,8 @@
struct lyd_node *request, *tree, *op;
const struct lyd_node *node;
- struct lyp_out *out;
- assert_non_null(out = lyp_new_memory(&str, 0));
+ struct ly_out *out;
+ assert_non_null(out = ly_out_new_memory(&str, 0));
data =
"<c xmlns=\"urn:tests:a\">"
@@ -650,13 +650,13 @@
lyd_print(out, lyd_node_children(op), LYD_XML, 0);
assert_string_equal(str,
"<al xmlns=\"urn:tests:a\">25</al>");
- lyp_out_reset(out);
+ ly_out_reset(out);
lyd_free_all(tree);
/* wrong namespace, element name, whatever... */
/* TODO */
- lyp_free(out, NULL, 1);
+ ly_out_free(out, NULL, 1);
*state = NULL;
}
diff --git a/tests/utests/data/test_printer_xml.c b/tests/utests/data/test_printer_xml.c
index 084ac2c..16e9e5c 100644
--- a/tests/utests/data/test_printer_xml.c
+++ b/tests/utests/data/test_printer_xml.c
@@ -176,10 +176,10 @@
const char *result;
char *printed;
ssize_t len;
- struct lyp_out *out;
+ struct ly_out *out;
s->func = test_leaf;
- assert_non_null(out = lyp_new_memory(&printed, 0));
+ assert_non_null(out = ly_out_new_memory(&printed, 0));
data = "<int8 xmlns=\"urn:tests:types\">\n 15 \t\n </int8>";
result = "<int8 xmlns=\"urn:tests:types\">15</int8>";
@@ -189,7 +189,7 @@
assert_string_equal(printed, result);
lyd_free_all(tree);
- lyp_free(out, NULL, 1);
+ ly_out_free(out, NULL, 1);
s->func = NULL;
}
@@ -201,10 +201,10 @@
const char *data;
char *printed;
ssize_t len;
- struct lyp_out *out;
+ struct ly_out *out;
s->func = test_anydata;
- assert_non_null(out = lyp_new_memory(&printed, 0));
+ assert_non_null(out = ly_out_new_memory(&printed, 0));
data = "<any xmlns=\"urn:tests:types\"><somexml xmlns:x=\"url:x\" xmlns=\"example.com\"><x:x/></somexml></any>";
assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
@@ -213,7 +213,7 @@
/* canonized */
data = "<any xmlns=\"urn:tests:types\"><somexml xmlns=\"example.com\"><x xmlns=\"url:x\"/></somexml></any>";
assert_string_equal(printed, data);
- lyp_out_reset(out);
+ ly_out_reset(out);
lyd_free_all(tree);
data = "<any xmlns=\"urn:tests:types\"/>";
@@ -221,7 +221,7 @@
assert_true((len = lyd_print(out, tree, LYD_XML, 0)) >= 0);
assert_int_equal(len, strlen(printed));
assert_string_equal(printed, data);
- lyp_out_reset(out);
+ ly_out_reset(out);
lyd_free_all(tree);
data =
@@ -253,11 +253,11 @@
"</cont>"
"</any>";
assert_string_equal(printed, data);
- lyp_out_reset(out);
+ ly_out_reset(out);
lyd_free_all(tree);
- lyp_free(out, NULL, 1);
+ ly_out_free(out, NULL, 1);
s->func = NULL;
}
@@ -269,11 +269,11 @@
const char *data;
char *printed;
ssize_t len;
- struct lyp_out *out;
+ struct ly_out *out;
s->func = test_defaults;
- assert_non_null(out = lyp_new_memory(&printed, 0));
+ assert_non_null(out = ly_out_new_memory(&printed, 0));
/* standard default value */
data = "<c xmlns=\"urn:defaults\">aa</c>";
@@ -282,13 +282,13 @@
assert_true((len = lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_TRIM)) >= 0);
assert_int_equal(len, strlen(printed));
assert_string_equal(printed, data);
- lyp_out_reset(out);
+ ly_out_reset(out);
assert_true((len = lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_ALL)) >= 0);
assert_int_equal(len, strlen(printed));
data = "<c xmlns=\"urn:defaults\">aa</c><a xmlns=\"urn:defaults\" xmlns:d=\"urn:defaults\">/d:b</a>";
assert_string_equal(printed, data);
- lyp_out_reset(out);
+ ly_out_reset(out);
assert_true((len = lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_ALL_TAG)) >= 0);
assert_int_equal(len, strlen(printed));
@@ -296,7 +296,7 @@
"<a xmlns=\"urn:defaults\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\""
" ncwd:default=\"true\" xmlns:d=\"urn:defaults\">/d:b</a>";
assert_string_equal(printed, data);
- lyp_out_reset(out);
+ ly_out_reset(out);
assert_true((len = lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_IMPL_TAG)) >= 0);
assert_int_equal(len, strlen(printed));
@@ -304,7 +304,7 @@
"<a xmlns=\"urn:defaults\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\""
" ncwd:default=\"true\" xmlns:d=\"urn:defaults\">/d:b</a>";
assert_string_equal(printed, data);
- lyp_out_reset(out);
+ ly_out_reset(out);
lyd_free_all(tree);
@@ -315,22 +315,22 @@
assert_true((len = lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_TRIM)) >= 0);
assert_int_equal(len, strlen(printed));
assert_string_equal(printed, data);
- lyp_out_reset(out);
+ ly_out_reset(out);
assert_true((len = lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_ALL)) >= 0);
assert_int_equal(len, strlen(printed));
assert_string_equal(printed, data);
- lyp_out_reset(out);
+ ly_out_reset(out);
assert_true((len = lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_ALL_TAG)) >= 0);
assert_int_equal(len, strlen(printed));
assert_string_equal(printed, data);
- lyp_out_reset(out);
+ ly_out_reset(out);
assert_true((len = lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_IMPL_TAG)) >= 0);
assert_int_equal(len, strlen(printed));
assert_string_equal(printed, data);
- lyp_out_reset(out);
+ ly_out_reset(out);
lyd_free_all(tree);
@@ -342,13 +342,13 @@
assert_int_equal(len, strlen(printed));
data = "<c xmlns=\"urn:defaults\">aa</c><b xmlns=\"urn:defaults\">val</b>";
assert_string_equal(printed, data);
- lyp_out_reset(out);
+ ly_out_reset(out);
assert_true((len = lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_ALL)) >= 0);
assert_int_equal(len, strlen(printed));
data = "<c xmlns=\"urn:defaults\">aa</c><a xmlns=\"urn:defaults\" xmlns:d=\"urn:defaults\">/d:b</a><b xmlns=\"urn:defaults\">val</b>";
assert_string_equal(printed, data);
- lyp_out_reset(out);
+ ly_out_reset(out);
assert_true((len = lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_ALL_TAG)) >= 0);
assert_int_equal(len, strlen(printed));
@@ -357,16 +357,16 @@
" ncwd:default=\"true\" xmlns:d=\"urn:defaults\">/d:b</a>"
"<b xmlns=\"urn:defaults\">val</b>";
assert_string_equal(printed, data);
- lyp_out_reset(out);
+ ly_out_reset(out);
assert_true((len = lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_IMPL_TAG)) >= 0);
assert_int_equal(len, strlen(printed));
data = "<c xmlns=\"urn:defaults\">aa</c><a xmlns=\"urn:defaults\" xmlns:d=\"urn:defaults\">/d:b</a><b xmlns=\"urn:defaults\">val</b>";
assert_string_equal(printed, data);
- lyp_out_reset(out);
+ ly_out_reset(out);
lyd_free_all(tree);
- lyp_free(out, NULL, 1);
+ ly_out_free(out, NULL, 1);
s->func = NULL;
}
@@ -384,10 +384,10 @@
const char *reply, *result;
char *printed;
ssize_t len;
- struct lyp_out *out;
+ struct ly_out *out;
s->func = test_rpc;
- assert_non_null(out = lyp_new_memory(&printed, 0));
+ assert_non_null(out = ly_out_new_memory(&printed, 0));
request = "<sum xmlns=\"urn:tests:types\"><x>10</x><y>20</y></sum>";
reply = "<result xmlns=\"urn:tests:types\">30</result>";
@@ -396,13 +396,13 @@
assert_true((len = lyd_print(out, tree1, LYD_XML, 0)) >= 0);
assert_int_equal(len, strlen(printed));
assert_string_equal(printed, request);
- lyp_out_reset(out);
+ ly_out_reset(out);
assert_non_null(trees = lyd_trees_new(1, tree1));
assert_non_null(tree2 = lyd_parse_mem(s->ctx, reply, LYD_XML, LYD_OPT_RPCREPLY, trees));
assert_true((len = lyd_print(out, tree2, LYD_XML, 0)) >= 0);
assert_int_equal(len, strlen(printed));
assert_string_equal(printed, result);
- lyp_out_reset(out);
+ ly_out_reset(out);
lyd_trees_free(trees, 0);
lyd_free_all(tree1);
lyd_free_all(tree2);
@@ -415,13 +415,13 @@
assert_true((len = lyd_print(out, tree1, LYD_XML, 0)) >= 0);
assert_int_equal(len, strlen(printed));
assert_string_equal(printed, request);
- lyp_out_reset(out);
+ ly_out_reset(out);
assert_non_null(trees = lyd_trees_new(1, tree1));
assert_non_null(tree2 = lyd_parse_mem(s->ctx, reply, LYD_XML, LYD_OPT_RPCREPLY, trees));
assert_true((len = lyd_print(out, tree2, LYD_XML, 0)) >= 0);
assert_int_equal(len, strlen(printed));
assert_string_equal(printed, result);
- lyp_out_reset(out);
+ ly_out_reset(out);
lyd_trees_free(trees, 0);
lyd_free_all(tree1);
lyd_free_all(tree2);
@@ -439,18 +439,18 @@
assert_true((len = lyd_print(out, tree1, LYD_XML, 0)) >= 0);
assert_int_equal(len, strlen(printed));
assert_string_equal(printed, request);
- lyp_out_reset(out);
+ ly_out_reset(out);
assert_non_null(trees = lyd_trees_new(1, tree1));
assert_non_null(tree2 = lyd_parse_mem(s->ctx, reply, LYD_XML, LYD_OPT_RPCREPLY, trees));
assert_true((len = lyd_print(out, tree2, LYD_XML, 0)) >= 0);
assert_int_equal(len, strlen(printed));
assert_string_equal(printed, result);
- lyp_out_reset(out);
+ ly_out_reset(out);
lyd_trees_free(trees, 0);
lyd_free_all(tree1);
lyd_free_all(tree2);
- lyp_free(out, NULL, 1);
+ ly_out_free(out, NULL, 1);
s->func = NULL;
}
diff --git a/tests/utests/data/test_validation.c b/tests/utests/data/test_validation.c
index 16d742a..fde40de 100644
--- a/tests/utests/data/test_validation.c
+++ b/tests/utests/data/test_validation.c
@@ -1019,8 +1019,8 @@
struct lyd_node *tree, *node;
const struct lys_module *mod = ly_ctx_get_module_latest(ctx, "f");
- struct lyp_out *out;
- assert_non_null(out = lyp_new_memory(&str, 0));
+ struct ly_out *out;
+ assert_non_null(out = ly_out_new_memory(&str, 0));
/* get defaults */
tree = NULL;
@@ -1044,7 +1044,7 @@
"<ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt1</ll2>"
"<ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt2</ll2>"
"</cont>");
- lyp_out_reset(out);
+ ly_out_reset(out);
/* create another explicit case and validate */
node = lyd_new_term(NULL, mod, "l", "value");
@@ -1067,7 +1067,7 @@
"<ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt2</ll2>"
"</cont>"
"<l xmlns=\"urn:tests:f\">value</l>");
- lyp_out_reset(out);
+ ly_out_reset(out);
/* create explicit leaf-list and leaf and validate */
node = lyd_new_term(NULL, mod, "d", "15");
@@ -1092,7 +1092,7 @@
"<l xmlns=\"urn:tests:f\">value</l>"
"<d xmlns=\"urn:tests:f\">15</d>"
"<ll2 xmlns=\"urn:tests:f\">dflt2</ll2>");
- lyp_out_reset(out);
+ ly_out_reset(out);
/* create first explicit container, which should become implicit */
node = lyd_new_inner(NULL, mod, "cont");
@@ -1115,7 +1115,7 @@
"<l xmlns=\"urn:tests:f\">value</l>"
"<d xmlns=\"urn:tests:f\">15</d>"
"<ll2 xmlns=\"urn:tests:f\">dflt2</ll2>");
- lyp_out_reset(out);
+ ly_out_reset(out);
/* create second explicit container, which should become implicit, so the first tree node should be removed */
node = lyd_new_inner(NULL, mod, "cont");
@@ -1137,7 +1137,7 @@
"<l xmlns=\"urn:tests:f\">value</l>"
"<d xmlns=\"urn:tests:f\">15</d>"
"<ll2 xmlns=\"urn:tests:f\">dflt2</ll2>");
- lyp_out_reset(out);
+ ly_out_reset(out);
/* similar changes for nested defaults */
assert_non_null(lyd_new_term(tree, NULL, "ll1", "def3"));
@@ -1156,10 +1156,10 @@
"<l xmlns=\"urn:tests:f\">value</l>"
"<d xmlns=\"urn:tests:f\">15</d>"
"<ll2 xmlns=\"urn:tests:f\">dflt2</ll2>");
- lyp_out_reset(out);
+ ly_out_reset(out);
lyd_free_siblings(tree);
- lyp_free(out, NULL, 1);
+ ly_out_free(out, NULL, 1);
*state = NULL;
}