* C-API change: xml_new() changed from xml_new(name, xp, ys) to xml_new(name, prefix, xp, type)

* If you have used, `ys`, add `xml_spec_set(x, ys)` after the statement
  * If you have `xml_type_set(x, TYPE)` or `xml_prefix_set(x, PREFIX)` immediately after the statement, you can remove those and set them directly as: `xml_new(name, PREFIX, xp, TYPE)`
This commit is contained in:
Olof hagsand 2020-03-12 22:29:28 +01:00
parent 71efe18f94
commit 7425a3b520
26 changed files with 135 additions and 155 deletions

View file

@ -120,7 +120,7 @@ clixon_plugin_statedata(clicon_handle h,
while ((cp = clixon_plugin_each(h, cp)) != NULL) {
if ((fn = cp->cp_api.ca_statedata) == NULL)
continue;
if ((x = xml_new("config", NULL, NULL)) == NULL)
if ((x = xml_new("config", NULL, NULL, CX_ELMNT)) == NULL)
goto done;
if (fn(h, nsc, xpath, x) < 0)
goto fail; /* Dont quit here on user callbacks */

View file

@ -200,9 +200,8 @@ dbxml_body(cxobj *xbot,
clicon_err(OE_UNIX, errno, "cv2str_dup");
goto done;
}
if ((xb = xml_new("body", xbot, NULL)) == NULL)
if ((xb = xml_new("body", NULL, xbot, CX_BODY)) == NULL)
goto done;
xml_type_set(xb, CX_BODY);
if (xml_value_set(xb, str) < 0)
goto done;
retval = 0;
@ -259,7 +258,7 @@ cli_dbxml(clicon_handle h,
if (api_path_fmt2api_path(api_path_fmt, cvv, &api_path) < 0)
goto done;
/* Create config top-of-tree */
if ((xtop = xml_new("config", NULL, NULL)) == NULL)
if ((xtop = xml_new("config", NULL, NULL, CX_ELMNT)) == NULL)
goto done;
xbot = xtop;
if (api_path){
@ -277,10 +276,8 @@ cli_dbxml(clicon_handle h,
goto done;
}
}
if ((xa = xml_new("operation", xbot, NULL)) == NULL)
if ((xa = xml_new("operation", NETCONF_BASE_PREFIX, xbot, CX_ATTR)) == NULL)
goto done;
xml_type_set(xa, CX_ATTR);
xml_prefix_set(xa, NETCONF_BASE_PREFIX);
if (xml_value_set(xa, xml_operation2str(op)) < 0)
goto done;
if (yang_keyword_get(y) != Y_LIST && yang_keyword_get(y) != Y_LEAF_LIST){
@ -1234,7 +1231,7 @@ cli_copy_config(clicon_handle h,
}
toname = cv_string_get(tocv);
/* Create copy xml tree x2 */
if ((x2 = xml_new("new", NULL, NULL)) == NULL)
if ((x2 = xml_new("config", NULL, NULL, CX_ELMNT)) == NULL)
goto done;
if (xml_copy(x1, x2) < 0)
goto done;

View file

@ -165,7 +165,7 @@ expand_dbvar(void *h,
xcur = xt; /* default top-of-tree */
xpathcur = xpath;
/* Create config top-of-tree */
if ((xtop = xml_new("config", NULL, NULL)) == NULL)
if ((xtop = xml_new("config", NULL, NULL, CX_ELMNT)) == NULL)
goto done;
xbot = xtop;
/* This is primarily to get "y",

View file

@ -671,9 +671,8 @@ netconf_rpc_dispatch(clicon_handle h,
* It may even be wrong if something else is done with the incoming message?
*/
if ((username = clicon_username_get(h)) != NULL){
if ((xa = xml_new("username", xn, NULL)) == NULL)
if ((xa = xml_new("username", NULL, xn, CX_ATTR)) == NULL)
goto done;
xml_type_set(xa, CX_ATTR);
if (xml_value_set(xa, username) < 0)
goto done;
}

View file

@ -685,11 +685,8 @@ restconf_insert_attributes(cxobj *xdata,
if (xmlns_set(xdata, "yang", YANG_XML_NAMESPACE) < 0)
goto done;
/* Then add insert attribute */
if ((xa = xml_new("insert", xdata, NULL)) == NULL)
if ((xa = xml_new("insert", "yang", xdata, CX_ATTR)) == NULL)
goto done;
if (xml_prefix_set(xa, "yang") < 0)
goto done;
xml_type_set(xa, CX_ATTR);
if (xml_value_set(xa, instr) < 0)
goto done;
}
@ -703,11 +700,8 @@ restconf_insert_attributes(cxobj *xdata,
else
attrname="value";
/* Then add value/key attribute */
if ((xa = xml_new(attrname, xdata, NULL)) == NULL)
if ((xa = xml_new(attrname, "yang", xdata, CX_ATTR)) == NULL)
goto done;
if (xml_prefix_set(xa, "yang") < 0)
goto done;
xml_type_set(xa, CX_ATTR);
if ((ret = api_path2xpath(pstr, ys_spec(y), &xpath, &nsc, NULL)) < 0)
goto done;
if ((cb = cbuf_new()) == NULL){

View file

@ -327,7 +327,7 @@ api_data_write(clicon_handle h,
xret = NULL;
}
/* Create config top-of-tree */
if ((xtop = xml_new("config", NULL, NULL)) == NULL)
if ((xtop = xml_new("config", NULL, NULL, CX_ELMNT)) == NULL)
goto done;
/* Translate api_path to xml in the form of xtop/xbot */
xbot = xtop;
@ -362,7 +362,7 @@ api_data_write(clicon_handle h,
}
/* Create a dummy data tree parent to hook in the parsed data.
*/
if ((xdata0 = xml_new("data0", NULL, NULL)) == NULL)
if ((xdata0 = xml_new("data0", NULL, NULL, CX_ELMNT)) == NULL)
goto done;
if (api_path){ /* XXX mv to copy? */
cxobj *xfrom;
@ -373,7 +373,7 @@ api_data_write(clicon_handle h,
goto done;
xa = NULL;
while ((xa = xml_child_each(xfrom, xa, CX_ATTR)) != NULL) {
if ((xac = xml_new(xml_name(xa), xdata0, NULL)) == NULL)
if ((xac = xml_new(xml_name(xa), NULL, xdata0, CX_ATTR)) == NULL)
goto done;
if (xml_copy(xa, xac) < 0) /* recursion */
goto done;
@ -479,11 +479,8 @@ api_data_write(clicon_handle h,
/* Add operation create as attribute. If that fails with Conflict, then
* try "replace" (see comment in function header)
*/
if ((xa = xml_new("operation", xdata, NULL)) == NULL)
if ((xa = xml_new("operation", NETCONF_BASE_PREFIX, xdata, CX_ATTR)) == NULL)
goto done;
xml_type_set(xa, CX_ATTR);
xml_prefix_set(xa, NETCONF_BASE_PREFIX);
if (xml_value_set(xa, xml_operation2str(op)) < 0)
goto done;
@ -839,7 +836,7 @@ api_data_delete(clicon_handle h,
for (i=0; i<pi; i++)
api_path = index(api_path+1, '/');
/* Create config top-of-tree */
if ((xtop = xml_new("config", NULL, NULL)) == NULL)
if ((xtop = xml_new("config", NULL, NULL, CX_ELMNT)) == NULL)
goto done;
xbot = xtop;
if (api_path){
@ -855,9 +852,8 @@ api_data_delete(clicon_handle h,
goto ok;
}
}
if ((xa = xml_new("operation", xbot, NULL)) == NULL)
if ((xa = xml_new("operation", NULL, xbot, CX_ATTR)) == NULL)
goto done;
xml_type_set(xa, CX_ATTR);
if (xml_value_set(xa, xml_operation2str(op)) < 0)
goto done;
if (xml_namespace_change(xa, NETCONF_BASE_NAMESPACE, NETCONF_BASE_PREFIX) < 0)

View file

@ -131,7 +131,7 @@ api_data_get2(clicon_handle h,
for (i=0; i<pi; i++)
api_path = index(api_path+1, '/');
if (api_path){
if ((xtop = xml_new("top", NULL, NULL)) == NULL)
if ((xtop = xml_new("top", NULL, NULL, CX_ELMNT)) == NULL)
goto done;
/* Translate api-path to xml, but to validate the api-path, note: strict=1
* xtop and xbot unnecessary fir this function but neede by function

View file

@ -139,7 +139,7 @@ api_data_post(clicon_handle h,
for (i=0; i<pi; i++)
api_path = index(api_path+1, '/');
/* Create config top-of-tree */
if ((xtop = xml_new("config", NULL, NULL)) == NULL)
if ((xtop = xml_new("config", NULL, NULL, CX_ELMNT)) == NULL)
goto done;
/* Translate api_path to xtop/xbot */
xbot = xtop;
@ -265,9 +265,8 @@ api_data_post(clicon_handle h,
}
/* Add operation (create/replace) as attribute */
if ((xa = xml_new("operation", xdata, NULL)) == NULL)
if ((xa = xml_new("operation", NULL, xdata, CX_ATTR)) == NULL)
goto done;
xml_type_set(xa, CX_ATTR);
if (xml_value_set(xa, xml_operation2str(op)) < 0)
goto done;
if (xml_namespace_change(xa, NETCONF_BASE_NAMESPACE, NETCONF_BASE_PREFIX) < 0)
@ -789,14 +788,13 @@ api_operations_post(clicon_handle h,
/* 3. Build xml tree with user and rpc:
* <rpc username="foo"><myfn xmlns="uri"/>
*/
if ((xtop = xml_new("rpc", NULL, NULL)) == NULL)
if ((xtop = xml_new("rpc", NULL, NULL, CX_ELMNT)) == NULL)
goto done;
xbot = xtop;
/* Here xtop is: <rpc/> */
if ((username = clicon_username_get(h)) != NULL){
if ((xa = xml_new("username", xtop, NULL)) == NULL)
if ((xa = xml_new("username", NULL, xtop, CX_ATTR)) == NULL)
goto done;
xml_type_set(xa, CX_ATTR);
if (xml_value_set(xa, username) < 0)
goto done;
/* Here xtop is: <rpc username="foo"/> */