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
|
### C/CLI-API changes on existing features
|
||||||
Developers may need to change their code
|
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
|
* New `clixon-lib@2024-01-01.yang` revision
|
||||||
* Replaced container creators to grouping/uses
|
* Replaced container creators to grouping/uses
|
||||||
* Changed ca_errmsg callback to a more generic variant
|
* 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_prefix_by_namespace(yang_stmt *ys, char *ns, char **prefix);
|
||||||
int yang_find_namespace_by_prefix(yang_stmt *ys, char *prefix, char **ns);
|
int yang_find_namespace_by_prefix(yang_stmt *ys, char *prefix, char **ns);
|
||||||
yang_stmt *yang_myroot(yang_stmt *ys);
|
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);
|
yang_stmt *yang_choice(yang_stmt *y);
|
||||||
int yang_order(yang_stmt *y);
|
int yang_order(yang_stmt *y);
|
||||||
int yang_print_cb(FILE *f, yang_stmt *yn, clicon_output_cb *fn);
|
int yang_print_cb(FILE *f, yang_stmt *yn, clicon_output_cb *fn);
|
||||||
|
|
|
||||||
|
|
@ -357,13 +357,13 @@ choice_is_other(yang_stmt *y0c,
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* First recurse y0 */
|
/* 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,
|
if (choice_is_other(y0choice, ycase, ychoice,
|
||||||
y1c, y1case, y1choice) == 1)
|
y1c, y1case, y1choice) == 1)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/* Second recurse y1 */
|
/* 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,
|
if (choice_is_other(y0choice, y0case, y0choice,
|
||||||
y1choice, ycase, ychoice) == 1)
|
y1choice, ycase, ychoice) == 1)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -402,7 +402,7 @@ choice_delete_other(cxobj *x0,
|
||||||
yang_stmt *y1case = NULL;
|
yang_stmt *y1case = NULL;
|
||||||
yang_stmt *y1choice = NULL;
|
yang_stmt *y1choice = NULL;
|
||||||
|
|
||||||
if (choice_case_get(y1c, &y1case, &y1choice) == 0)
|
if (yang_choice_case_get(y1c, &y1case, &y1choice) == 0)
|
||||||
goto ok;
|
goto ok;
|
||||||
x0prev = NULL;
|
x0prev = NULL;
|
||||||
x0c = NULL;
|
x0c = NULL;
|
||||||
|
|
@ -412,7 +412,7 @@ choice_delete_other(cxobj *x0,
|
||||||
x0prev = x0c;
|
x0prev = x0c;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (choice_case_get(y0c, &y0case, &y0choice) == 0){
|
if (yang_choice_case_get(y0c, &y0case, &y0choice) == 0){
|
||||||
x0prev = x0c;
|
x0prev = x0c;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -187,7 +187,7 @@ xml_default_choice(yang_stmt *yc,
|
||||||
continue;
|
continue;
|
||||||
/* Check if this child is a child of yc */
|
/* Check if this child is a child of yc */
|
||||||
yca = ych = NULL;
|
yca = ych = NULL;
|
||||||
if (choice_case_get(y, &yca, &ych) == 1 &&
|
if (yang_choice_case_get(y, &yca, &ych) == 1 &&
|
||||||
ych == yc){
|
ych == yc){
|
||||||
x0 = x;
|
x0 = x;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -1544,12 +1544,18 @@ yang_myroot(yang_stmt *ys)
|
||||||
return NULL;
|
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
|
int
|
||||||
choice_case_get(yang_stmt *yc,
|
yang_choice_case_get(yang_stmt *yc,
|
||||||
yang_stmt **ycase,
|
yang_stmt **ycase,
|
||||||
yang_stmt **ychoice)
|
yang_stmt **ychoice)
|
||||||
{
|
{
|
||||||
yang_stmt *yp;
|
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
|
/*! If a given yang stmt has a choice/case as parent, return the choice statement
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @see yang_choice_case_get
|
||||||
*/
|
*/
|
||||||
yang_stmt *
|
yang_stmt *
|
||||||
yang_choice(yang_stmt *y)
|
yang_choice(yang_stmt *y)
|
||||||
{
|
{
|
||||||
yang_stmt *yp;
|
yang_stmt *yp = NULL;
|
||||||
|
|
||||||
if ((yp = y->ys_parent) != NULL){
|
yang_choice_case_get(y, NULL, &yp);
|
||||||
switch (yang_keyword_get(yp)){
|
return yp;
|
||||||
case Y_CHOICE:
|
|
||||||
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
|
/*! 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