Changed function name: choice_case_get() -> yang_choice_case_get()
Rewrote yang_choice()
This commit is contained in:
parent
9e6557aad1
commit
465a5999fe
5 changed files with 24 additions and 25 deletions
|
|
@ -28,6 +28,7 @@ Expected: February 2024
|
|||
### C/CLI-API changes on existing features
|
||||
Developers may need to change their code
|
||||
|
||||
* Changed function name: `choice_case_get()` -> `yang_choice_case_get()`
|
||||
* New `clixon-lib@2024-01-01.yang` revision
|
||||
* Replaced container creators to grouping/uses
|
||||
* Changed ca_errmsg callback to a more generic variant
|
||||
|
|
|
|||
|
|
@ -291,7 +291,7 @@ char *yang_find_mynamespace(yang_stmt *ys);
|
|||
int yang_find_prefix_by_namespace(yang_stmt *ys, char *ns, char **prefix);
|
||||
int yang_find_namespace_by_prefix(yang_stmt *ys, char *prefix, char **ns);
|
||||
yang_stmt *yang_myroot(yang_stmt *ys);
|
||||
int choice_case_get(yang_stmt *yc, yang_stmt **ycase, yang_stmt **ychoice);
|
||||
int yang_choice_case_get(yang_stmt *yc, yang_stmt **ycase, yang_stmt **ychoice);
|
||||
yang_stmt *yang_choice(yang_stmt *y);
|
||||
int yang_order(yang_stmt *y);
|
||||
int yang_print_cb(FILE *f, yang_stmt *yn, clicon_output_cb *fn);
|
||||
|
|
|
|||
|
|
@ -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)){
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -1544,10 +1544,16 @@ 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_choice_case_get(yang_stmt *yc,
|
||||
yang_stmt **ycase,
|
||||
yang_stmt **ychoice)
|
||||
{
|
||||
|
|
@ -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:
|
||||
yang_choice_case_get(y, NULL, &yp);
|
||||
return yp;
|
||||
break;
|
||||
case Y_CASE:
|
||||
return yang_parent_get(yp);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*! Find matching y in yp:s children, "yang order" of y when y is choice
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue