Changed C-API for xml translation/print the internal cxobj tree data structure to other formats
New API is as follows: * `clixon_xml2file()` - Print internal tree as XML to file * `clixon_xml2cbuf()` - Print internal tree as XML to buffer * `clixon_json2file()` - Print internal tree as JSON to file * `clixon_json2cbuf()` - Print internal tree as JSON to buffer * `clixon_cli2file()` - Print internal tree as CLI format to file * `clixon_txt2file()` - Print internal tree as text format to file
This commit is contained in:
parent
87719c623c
commit
0c79298e76
49 changed files with 421 additions and 503 deletions
|
|
@ -366,7 +366,7 @@ from_client_edit_config(clicon_handle h,
|
|||
if ((ret = xml_bind_yang(xc, YB_MODULE, yspec, &xret)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){
|
||||
if (clicon_xml2cbuf(cbret, xret, 0, 0, -1, 0) < 0)
|
||||
if (clixon_xml2cbuf(cbret, xret, 0, 0, -1, 0) < 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
}
|
||||
|
|
@ -374,7 +374,7 @@ from_client_edit_config(clicon_handle h,
|
|||
if ((ret = xml_non_config_data(xc, &xret)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){
|
||||
if (clicon_xml2cbuf(cbret, xret, 0, 0, -1, 0) < 0)
|
||||
if (clixon_xml2cbuf(cbret, xret, 0, 0, -1, 0) < 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
}
|
||||
|
|
@ -387,7 +387,7 @@ from_client_edit_config(clicon_handle h,
|
|||
if ((ret = xml_yang_validate_list_key_only(xc, &xret)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){
|
||||
if (clicon_xml2cbuf(cbret, xret, 0, 0, -1, 0) < 0)
|
||||
if (clixon_xml2cbuf(cbret, xret, 0, 0, -1, 0) < 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
}
|
||||
|
|
@ -1241,7 +1241,7 @@ from_client_msg(clicon_handle h,
|
|||
goto reply;
|
||||
}
|
||||
if (ret == 0){
|
||||
if (clicon_xml2cbuf(cbret, xret, 0, 0, -1, 0) < 0)
|
||||
if (clixon_xml2cbuf(cbret, xret, 0, 0, -1, 0) < 0)
|
||||
goto done;
|
||||
goto reply;
|
||||
}
|
||||
|
|
@ -1303,7 +1303,7 @@ from_client_msg(clicon_handle h,
|
|||
if ((ret = xml_yang_validate_rpc(h, x, &xret)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){
|
||||
if (clicon_xml2cbuf(cbret, xret, 0, 0, -1, 0) < 0)
|
||||
if (clixon_xml2cbuf(cbret, xret, 0, 0, -1, 0) < 0)
|
||||
goto done;
|
||||
goto reply;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ startup_common(clicon_handle h,
|
|||
* See similar clause below
|
||||
*/
|
||||
}
|
||||
if (clicon_xml2cbuf(cbret, xerr, 0, 0, -1, 0) < 0)
|
||||
if (clixon_xml2cbuf(cbret, xerr, 0, 0, -1, 0) < 0)
|
||||
goto done;
|
||||
goto fail;
|
||||
}
|
||||
|
|
@ -276,7 +276,7 @@ startup_common(clicon_handle h,
|
|||
if ((ret = xml_bind_yang(xt, YB_MODULE, yspec, &xret)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){
|
||||
if (clicon_xml2cbuf(cbret, xret, 0, 0, -1, 0) < 0)
|
||||
if (clixon_xml2cbuf(cbret, xret, 0, 0, -1, 0) < 0)
|
||||
goto done;
|
||||
goto fail;
|
||||
}
|
||||
|
|
@ -284,7 +284,7 @@ startup_common(clicon_handle h,
|
|||
if ((ret = xml_non_config_data(xt, &xret)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){
|
||||
if (clicon_xml2cbuf(cbret, xret, 0, 0, -1, 0) < 0)
|
||||
if (clixon_xml2cbuf(cbret, xret, 0, 0, -1, 0) < 0)
|
||||
goto done;
|
||||
goto fail;
|
||||
}
|
||||
|
|
@ -319,7 +319,7 @@ startup_common(clicon_handle h,
|
|||
if ((ret = generic_validate(h, yspec, td, &xret)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){
|
||||
if (clicon_xml2cbuf(cbret, xret, 0, 0, -1, 0) < 0)
|
||||
if (clixon_xml2cbuf(cbret, xret, 0, 0, -1, 0) < 0)
|
||||
goto done;
|
||||
goto fail; /* STARTUP_INVALID */
|
||||
}
|
||||
|
|
@ -625,7 +625,7 @@ candidate_validate(clicon_handle h,
|
|||
clicon_err(OE_CFG, EINVAL, "xret is NULL");
|
||||
goto done;
|
||||
}
|
||||
if (clicon_xml2cbuf(cbret, xret, 0, 0, -1, 0) < 0)
|
||||
if (clixon_xml2cbuf(cbret, xret, 0, 0, -1, 0) < 0)
|
||||
goto done;
|
||||
if (!cbuf_len(cbret) &&
|
||||
netconf_operation_failed(cbret, "application", clicon_err_reason)< 0)
|
||||
|
|
@ -685,7 +685,7 @@ candidate_commit(clicon_handle h,
|
|||
if ((ret = validate_common(h, db, td, &xret)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){
|
||||
if (clicon_xml2cbuf(cbret, xret, 0, 0, -1, 0) < 0)
|
||||
if (clixon_xml2cbuf(cbret, xret, 0, 0, -1, 0) < 0)
|
||||
goto done;
|
||||
goto fail;
|
||||
}
|
||||
|
|
@ -957,7 +957,7 @@ from_client_restart_one(clicon_handle h,
|
|||
if ((ret = xml_yang_validate_all_top(h, td->td_target, &xerr)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){
|
||||
if (clicon_xml2cbuf(cbret, xerr, 0, 0, -1, 0) < 0)
|
||||
if (clixon_xml2cbuf(cbret, xerr, 0, 0, -1, 0) < 0)
|
||||
goto done;
|
||||
goto fail;
|
||||
}
|
||||
|
|
@ -1007,7 +1007,7 @@ from_client_restart_one(clicon_handle h,
|
|||
if ((ret = generic_validate(h, yspec, td, &xerr)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){
|
||||
if (clicon_xml2cbuf(cbret, xerr, 0, 0, -1, 0) < 0)
|
||||
if (clixon_xml2cbuf(cbret, xerr, 0, 0, -1, 0) < 0)
|
||||
goto done;
|
||||
goto fail;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -365,7 +365,7 @@ get_nacm_and_reply(clicon_handle h,
|
|||
if (xml_name_set(xret, NETCONF_OUTPUT_DATA) < 0)
|
||||
goto done;
|
||||
/* Top level is data, so add 1 to depth if significant */
|
||||
if (clicon_xml2cbuf(cbret, xret, 0, 0, depth>0?depth+1:depth, 0) < 0)
|
||||
if (clixon_xml2cbuf(cbret, xret, 0, 0, depth>0?depth+1:depth, 0) < 0)
|
||||
goto done;
|
||||
}
|
||||
cprintf(cbret, "</rpc-reply>");
|
||||
|
|
@ -605,7 +605,7 @@ get_list_pagination(clicon_handle h,
|
|||
clicon_err_reason);
|
||||
if (netconf_operation_failed_xml(&xerr, "application", cbuf_get(cberr)) < 0)
|
||||
goto done;
|
||||
if (clicon_xml2cbuf(cbret, xerr, 0, 0, -1, 0) < 0)
|
||||
if (clixon_xml2cbuf(cbret, xerr, 0, 0, -1, 0) < 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
}
|
||||
|
|
@ -620,7 +620,7 @@ get_list_pagination(clicon_handle h,
|
|||
". Internal error, state callback returned invalid XML",
|
||||
NULL) < 0)
|
||||
goto done;
|
||||
if (clicon_xml2cbuf(cbret, xerr, 0, 0, -1, 0) < 0)
|
||||
if (clixon_xml2cbuf(cbret, xerr, 0, 0, -1, 0) < 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
}
|
||||
|
|
@ -832,7 +832,7 @@ get_common(clicon_handle h,
|
|||
if ((ret = get_client_statedata(h, xpath?xpath:"/", nsc, &xret)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){ /* Error from callback (error in xret) */
|
||||
if (clicon_xml2cbuf(cbret, xret, 0, 0, -1, 0) < 0)
|
||||
if (clixon_xml2cbuf(cbret, xret, 0, 0, -1, 0) < 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
}
|
||||
|
|
@ -857,7 +857,7 @@ get_common(clicon_handle h,
|
|||
". Internal error, state callback returned invalid XML",
|
||||
NULL) < 0)
|
||||
goto done;
|
||||
if (clicon_xml2cbuf(cbret, xerr, 0, 0, -1, 0) < 0)
|
||||
if (clixon_xml2cbuf(cbret, xerr, 0, 0, -1, 0) < 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ restconf_pseudo_set_inline(clicon_handle h,
|
|||
clicon_err(OE_XML, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
if (clicon_xml2cbuf(cb, xrestconf, 0, 0, -1, 0) < 0)
|
||||
if (clixon_xml2cbuf(cb, xrestconf, 0, 0, -1, 0) < 0)
|
||||
goto done;
|
||||
if ((str = strdup(cbuf_get(cb))) == NULL){
|
||||
clicon_err(OE_XML, errno, "stdup");
|
||||
|
|
|
|||
|
|
@ -256,7 +256,8 @@ transaction_log(clicon_handle h,
|
|||
}
|
||||
for (i=0; i<td->td_dlen; i++){
|
||||
xn = td->td_dvec[i];
|
||||
clicon_xml2cbuf(cb, xn, 0, 0, -1, 0);
|
||||
if (clixon_xml2cbuf(cb, xn, 0, 0, -1, 0) < 0)
|
||||
goto done;
|
||||
}
|
||||
if (i)
|
||||
clicon_log(level, "%s %" PRIu64 " %s del: %s",
|
||||
|
|
@ -264,7 +265,8 @@ transaction_log(clicon_handle h,
|
|||
cbuf_reset(cb);
|
||||
for (i=0; i<td->td_alen; i++){
|
||||
xn = td->td_avec[i];
|
||||
clicon_xml2cbuf(cb, xn, 0, 0, -1, 0);
|
||||
if (clixon_xml2cbuf(cb, xn, 0, 0, -1, 0) < 0)
|
||||
goto done;
|
||||
}
|
||||
if (i)
|
||||
clicon_log(level, "%s %" PRIu64 " %s add: %s", __FUNCTION__, td->td_id, op, cbuf_get(cb));
|
||||
|
|
@ -272,10 +274,12 @@ transaction_log(clicon_handle h,
|
|||
for (i=0; i<td->td_clen; i++){
|
||||
if (td->td_scvec){
|
||||
xn = td->td_scvec[i];
|
||||
clicon_xml2cbuf(cb, xn, 0, 0, -1, 0);
|
||||
if (clixon_xml2cbuf(cb, xn, 0, 0, -1, 0) < 0)
|
||||
goto done;
|
||||
}
|
||||
xn = td->td_tcvec[i];
|
||||
clicon_xml2cbuf(cb, xn, 0, 0, -1, 0);
|
||||
if (clixon_xml2cbuf(cb, xn, 0, 0, -1, 0) < 0)
|
||||
goto done;
|
||||
}
|
||||
if (i)
|
||||
clicon_log(level, "%s %" PRIu64 " %s change: %s", __FUNCTION__, td->td_id, op, cbuf_get(cb));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue