From f6284ac933d07c46f2a9960403a819e73f867ca6 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Wed, 17 Jan 2018 22:59:54 +0100 Subject: [PATCH] restconf PUT delta --- apps/restconf/restconf_methods.c | 8 ++++---- lib/src/clixon_xml.c | 12 +++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/apps/restconf/restconf_methods.c b/apps/restconf/restconf_methods.c index f796d8c3..48313a9f 100644 --- a/apps/restconf/restconf_methods.c +++ b/apps/restconf/restconf_methods.c @@ -587,12 +587,13 @@ api_data_put(clicon_handle h, if ((xa = xml_new("operation", x, NULL)) == NULL) goto done; xml_type_set(xa, CX_ATTR); - if (xml_value_set(xa, xml_operation2str(op)) < 0) + if (xml_value_set(xa, xml_operation2str(op)) < 0) goto done; - /* Replace xbot with x */ + /* XXX Special case path=/restconf/data xml_name(x) == data */ + /* Replace xbot with x */ xp = xml_parent(xbot); xml_purge(xbot); - if (xml_addsub(xp, x) < 0) + if (xml_addsub(xp, x) < 0) goto done; if ((cbx = cbuf_new()) == NULL) goto done; @@ -605,7 +606,6 @@ api_data_put(clicon_handle h, notfound(r); goto ok; } - if (clicon_rpc_validate(h, "candidate") < 0){ if (clicon_rpc_discard_changes(h) < 0) goto done; diff --git a/lib/src/clixon_xml.c b/lib/src/clixon_xml.c index c412bebf..635498cc 100644 --- a/lib/src/clixon_xml.c +++ b/lib/src/clixon_xml.c @@ -595,7 +595,7 @@ xml_find(cxobj *x_up, } /*! Append xc as child to xp. Remove xc from previous parent. - * @param[in] xp Parent xml node + * @param[in] xp Parent xml node. If NULL just remove from old parent. * @param[in] xc Child xml node to insert under xp * @retval 0 OK * @retval -1 Error @@ -618,10 +618,12 @@ xml_addsub(cxobj *xp, xml_child_rm(oldp, i); } /* Add xc to new parent */ - if (xml_child_append(xp, xc) < 0) - return -1; - /* Set new parent in child */ - xml_parent_set(xc, xp); + if (xp){ + if (xml_child_append(xp, xc) < 0) + return -1; + /* Set new parent in child */ + xml_parent_set(xc, xp); + } return 0; }