Fixed: [Defaults in choice does not work properly](https://github.com/clicon/clixon/issues/390)

C: Added new file clixon_xml_default.[ch] and moved all default handling there
This commit is contained in:
Olof hagsand 2022-12-22 09:15:10 +01:00
parent 7e92f67f4f
commit ffe918dd0e
16 changed files with 1015 additions and 667 deletions

View file

@ -963,7 +963,7 @@ yn_insert1(yang_stmt *ys_parent,
/*! Iterate through all yang statements from a yang node
*
* @param[in] yparent yang statement whose children should be iterated
* @param[in] yparent yang statement whose children are iterated
* @param[in] yprev previous child, or NULL on init
* @code
* yang_stmt *yprev = NULL;
@ -1431,6 +1431,32 @@ yang_myroot(yang_stmt *ys)
return NULL;
}
/*! Get closest yang case and choice, if any
*/
int
choice_case_get(yang_stmt *yc,
yang_stmt **ycase,
yang_stmt **ychoice)
{
yang_stmt *yp;
if ((yp = yang_parent_get(yc)) == NULL)
return 0;
if (yang_keyword_get(yp) == Y_CASE){
if (ycase)
*ycase = yp;
*ychoice = yang_parent_get(yp);
return 1;
}
else if (yang_keyword_get(yp) == Y_CHOICE){
if (ycase)
*ycase = NULL;
*ychoice = yp;
return 1;
}
return 0;
}
/*! If a given yang stmt has a choice/case as parent, return the choice statement
*/
yang_stmt *