Changed function name: choice_case_get() -> yang_choice_case_get()

Rewrote yang_choice()
This commit is contained in:
Olof hagsand 2024-01-17 13:06:56 +01:00
parent 9e6557aad1
commit 465a5999fe
5 changed files with 24 additions and 25 deletions

View file

@ -357,13 +357,13 @@ choice_is_other(yang_stmt *y0c,
}
else {
/* First recurse y0 */
if (choice_case_get(y0choice, &ycase, &ychoice)){
if (yang_choice_case_get(y0choice, &ycase, &ychoice)){
if (choice_is_other(y0choice, ycase, ychoice,
y1c, y1case, y1choice) == 1)
return 1;
}
/* Second recurse y1 */
if (choice_case_get(y1choice, &ycase, &ychoice)){
/* Second recurse y1 */
if (yang_choice_case_get(y1choice, &ycase, &ychoice)){
if (choice_is_other(y0choice, y0case, y0choice,
y1choice, ycase, ychoice) == 1)
return 1;
@ -402,7 +402,7 @@ choice_delete_other(cxobj *x0,
yang_stmt *y1case = NULL;
yang_stmt *y1choice = NULL;
if (choice_case_get(y1c, &y1case, &y1choice) == 0)
if (yang_choice_case_get(y1c, &y1case, &y1choice) == 0)
goto ok;
x0prev = NULL;
x0c = NULL;
@ -412,7 +412,7 @@ choice_delete_other(cxobj *x0,
x0prev = x0c;
continue;
}
if (choice_case_get(y0c, &y0case, &y0choice) == 0){
if (yang_choice_case_get(y0c, &y0case, &y0choice) == 0){
x0prev = x0c;
continue;
}

View file

@ -187,7 +187,7 @@ xml_default_choice(yang_stmt *yc,
continue;
/* Check if this child is a child of yc */
yca = ych = NULL;
if (choice_case_get(y, &yca, &ych) == 1 &&
if (yang_choice_case_get(y, &yca, &ych) == 1 &&
ych == yc){
x0 = x;
break;

View file

@ -1544,12 +1544,18 @@ yang_myroot(yang_stmt *ys)
return NULL;
}
/*! Get closest yang case and choice, if any
/*! Given a YANG node, return closest yang case and choice, if any
*
* @param[in] yc Yang node
* @param[out] ycase case parent of yc
* @param[out] ychoice choice parent of yc (or grandparent)
* @retval 1 yc has case or choice parent (or both) as returned in ycase/ychoice
* @retval 0 yc has no parent or parent is neither case or choice
*/
int
choice_case_get(yang_stmt *yc,
yang_stmt **ycase,
yang_stmt **ychoice)
yang_choice_case_get(yang_stmt *yc,
yang_stmt **ycase,
yang_stmt **ychoice)
{
yang_stmt *yp;
@ -1571,25 +1577,17 @@ choice_case_get(yang_stmt *yc,
}
/*! If a given yang stmt has a choice/case as parent, return the choice statement
*
*
* @see yang_choice_case_get
*/
yang_stmt *
yang_choice(yang_stmt *y)
{
yang_stmt *yp;
yang_stmt *yp = NULL;
if ((yp = y->ys_parent) != NULL){
switch (yang_keyword_get(yp)){
case Y_CHOICE:
return yp;
break;
case Y_CASE:
return yang_parent_get(yp);
break;
default:
break;
}
}
return NULL;
yang_choice_case_get(y, NULL, &yp);
return yp;
}
/*! Find matching y in yp:s children, "yang order" of y when y is choice