Modified backend exit strategy so that 2nd ^C actually exits

Copied creator cvec if modified with REPLACE
This commit is contained in:
Olof hagsand 2023-06-13 13:28:30 +02:00
parent 53ceb35d51
commit a1e7c6f126
5 changed files with 33 additions and 8 deletions

View file

@ -188,8 +188,7 @@ check_body_namespace(cxobj *x0,
if (ns0 != NULL && ns1 != NULL){ /* namespace exists in both x1 and x0 */
if (strcmp(ns0, ns1)){
/* prefixes in x1 and x0 refers to different namespaces
* XXX return netconf error instead
bad-attribue?
* XXX return netconf error instead bad-attribue?
*/
if ((cberr = cbuf_new()) == NULL){
clicon_err(OE_UNIX, errno, "cbuf_new");
@ -848,6 +847,8 @@ text_modify(clicon_handle h,
#ifdef XML_PARENT_CANDIDATE
xml_parent_candidate_set(x0, x0p);
#endif
if (xml_creator_copy(x1, x0) < 0)
goto done;
changed++;
/* Get namespace from x1
* Check if namespace exists in x0 parent

View file

@ -705,6 +705,29 @@ xml_creator_len(cxobj *xn)
return 0;
}
/*! Copy creator info from x0 to x1
*
* @param[in] x0 Source XML node
* @param[in] x1 Destination XML node
* @retval 0 OK
* @retval -1 Error
*/
int
xml_creator_copy(cxobj *x0,
cxobj *x1)
{
int retval = -1;
if (x0->x_creators)
if ((x1->x_creators = cvec_dup(x0->x_creators)) == NULL){
clicon_err(OE_UNIX, errno, "cvec_dup");
goto done;
}
retval = 0;
done:
return retval;
}
/*! Print XML and creator tags where they exists, apply help function
*
* @param[in] x XML tree
@ -737,7 +760,7 @@ int
xml_creator_print(FILE *f,
cxobj *xn)
{
return xml_apply(xn, CX_ELMNT, creator_print_fn, f);
return xml_apply0(xn, CX_ELMNT, creator_print_fn, f);
}
/*! Get value of xnode
@ -2079,11 +2102,8 @@ xml_copy_one(cxobj *x0,
switch (xml_type(x0)){
case CX_ELMNT:
xml_spec_set(x1, xml_spec(x0));
if (x0->x_creators)
if ((x1->x_creators = cvec_dup(x0->x_creators)) == NULL){
clicon_err(OE_UNIX, errno, "cvec_dup");
goto done;
}
if (xml_creator_copy(x0, x1) < 0)
goto done;
break;
case CX_BODY:
case CX_ATTR: