C-API: clixon_xml2file and clixon_xml2cbuf added prefix argument

Added in-mem xml diff function: `xml_tree_diff_print`
This commit is contained in:
Olof hagsand 2023-04-12 09:54:37 +02:00
parent 819a0b5a9e
commit 6335f810d3
43 changed files with 309 additions and 149 deletions

View file

@ -278,13 +278,13 @@ api_return_err(clicon_handle h,
clicon_debug(1, "%s code:%d", __FUNCTION__, code);
if (pretty){
cprintf(cb, " <errors xmlns=\"urn:ietf:params:xml:ns:yang:ietf-restconf\">\n");
if (clixon_xml2cbuf(cb, xerr, 2, pretty, -1, 0) < 0)
if (clixon_xml2cbuf(cb, xerr, 2, pretty, NULL, -1, 0) < 0)
goto done;
cprintf(cb, " </errors>\r\n");
}
else {
cprintf(cb, "<errors xmlns=\"urn:ietf:params:xml:ns:yang:ietf-restconf\">");
if (clixon_xml2cbuf(cb, xerr, 2, pretty, -1, 0) < 0)
if (clixon_xml2cbuf(cb, xerr, 2, pretty, NULL, -1, 0) < 0)
goto done;
cprintf(cb, "</errors>\r\n");
}

View file

@ -532,7 +532,7 @@ api_data_write(clicon_handle h,
CLIXON_LIB_PREFIX, CLIXON_LIB_PREFIX, CLIXON_LIB_NS);
cprintf(cbx, "><target><candidate /></target>");
cprintf(cbx, "<default-operation>none</default-operation>");
if (clixon_xml2cbuf(cbx, xtop, 0, 0, -1, 0) < 0)
if (clixon_xml2cbuf(cbx, xtop, 0, 0, NULL, -1, 0) < 0)
goto done;
cprintf(cbx, "</edit-config></rpc>");
clicon_debug(1, "%s xml: %s api_path:%s",__FUNCTION__, cbuf_get(cbx), api_path);
@ -782,7 +782,7 @@ api_data_delete(clicon_handle h,
CLIXON_LIB_PREFIX, CLIXON_LIB_PREFIX, CLIXON_LIB_NS);
cprintf(cbx, "><target><candidate /></target>");
cprintf(cbx, "<default-operation>none</default-operation>");
if (clixon_xml2cbuf(cbx, xtop, 0, 0, -1, 0) < 0)
if (clixon_xml2cbuf(cbx, xtop, 0, 0, NULL, -1, 0) < 0)
goto done;
cprintf(cbx, "</edit-config></rpc>");
if (clicon_rpc_netconf(h, cbuf_get(cbx), &xret, NULL) < 0)

View file

@ -231,7 +231,7 @@ api_data_get2(clicon_handle h,
if (xpath==NULL || strcmp(xpath,"/")==0){ /* Special case: data root */
switch (media_out){
case YANG_DATA_XML:
if (clixon_xml2cbuf(cbx, xret, 0, pretty, -1, 0) < 0) /* Dont print top object? */
if (clixon_xml2cbuf(cbx, xret, 0, pretty, NULL, -1, 0) < 0) /* Dont print top object? */
goto done;
break;
case YANG_DATA_JSON:
@ -275,7 +275,7 @@ api_data_get2(clicon_handle h,
cvec_free(nscd);
nscd = NULL;
}
if (clixon_xml2cbuf(cbx, x, 0, pretty, -1, 0) < 0) /* Dont print top object? */
if (clixon_xml2cbuf(cbx, x, 0, pretty, NULL, -1, 0) < 0) /* Dont print top object? */
goto done;
}
break;
@ -541,7 +541,7 @@ api_data_pagination(clicon_handle h,
if (xml_insert(xpr, xp, INS_LAST, NULL, NULL) < 0)
goto done;
}
if (clixon_xml2cbuf(cbx, xpr, 0, pretty, -1, 0) < 0) /* Dont print top object? */
if (clixon_xml2cbuf(cbx, xpr, 0, pretty, NULL, -1, 0) < 0) /* Dont print top object? */
goto done;
break;
case YANG_DATA_JSON:

View file

@ -362,7 +362,7 @@ api_data_post(clicon_handle h,
CLIXON_LIB_PREFIX, CLIXON_LIB_PREFIX, CLIXON_LIB_NS);
cprintf(cbx, "><target><candidate /></target>");
cprintf(cbx, "<default-operation>none</default-operation>");
if (clixon_xml2cbuf(cbx, xtop, 0, 0, -1, 0) < 0)
if (clixon_xml2cbuf(cbx, xtop, 0, 0, NULL, -1, 0) < 0)
goto done;
cprintf(cbx, "</edit-config></rpc>");
clicon_debug(1, "%s xml: %s api_path:%s",__FUNCTION__, cbuf_get(cbx), api_path);
@ -871,7 +871,7 @@ api_operations_post(clicon_handle h,
cbuf_reset(cbret);
switch (media_out){
case YANG_DATA_XML:
if (clixon_xml2cbuf(cbret, xoutput, 0, pretty, -1, 0) < 0)
if (clixon_xml2cbuf(cbret, xoutput, 0, pretty, NULL, -1, 0) < 0)
goto done;
/* xoutput should now look: <output xmlns="uri"><x>0</x></output> */
break;

View file

@ -204,7 +204,7 @@ api_root_restconf_exact(clicon_handle h,
switch (media_out){
case YANG_DATA_XML:
case YANG_PATCH_XML:
if (clixon_xml2cbuf(cb, xt, 0, pretty, -1, 0) < 0)
if (clixon_xml2cbuf(cb, xt, 0, pretty, NULL, -1, 0) < 0)
goto done;
break;
case YANG_DATA_JSON:
@ -288,7 +288,7 @@ api_yang_library_version(clicon_handle h,
switch (media_out){
case YANG_DATA_XML:
case YANG_PATCH_XML:
if (clixon_xml2cbuf(cb, xt, 0, pretty, -1, 0) < 0)
if (clixon_xml2cbuf(cb, xt, 0, pretty, NULL, -1, 0) < 0)
goto done;
break;
case YANG_DATA_JSON:

View file

@ -254,7 +254,7 @@ restconf_stream_cb(int s,
FCGX_FPrintF(r->out, "M#id: %02d:0\r\n", tv.tv_sec);
}
#endif
if (clixon_xml2cbuf(cb, xn, 0, pretty, -1, 0) < 0)
if (clixon_xml2cbuf(cb, xn, 0, pretty, NULL, -1, 0) < 0)
goto done;
FCGX_FPrintF(r->out, "data: %s\r\n", cbuf_get(cb));
FCGX_FPrintF(r->out, "\r\n");