Structural C-code change: Merged yang_spec and yang_node types into yang_stmt

This commit is contained in:
Olof hagsand 2019-04-02 12:27:33 +02:00
parent 4f9e942103
commit b5f1f7346e
52 changed files with 492 additions and 496 deletions

View file

@ -213,9 +213,9 @@ cli_dbxml(clicon_handle h,
int len;
cg_var *arg;
cbuf *cb = NULL;
yang_spec *yspec;
yang_stmt *yspec;
cxobj *xbot = NULL; /* xpath, NULL if datastore */
yang_node *y = NULL; /* yang spec of xpath */
yang_stmt *y = NULL; /* yang spec of xpath */
cxobj *xtop = NULL; /* xpath root */
cxobj *xa; /* attribute */
cxobj *xb; /* body */
@ -243,7 +243,7 @@ cli_dbxml(clicon_handle h,
xml_type_set(xa, CX_ATTR);
if (xml_value_set(xa, xml_operation2str(op)) < 0)
goto done;
if (y->yn_keyword != Y_LIST && y->yn_keyword != Y_LEAF_LIST){
if (y->ys_keyword != Y_LIST && y->ys_keyword != Y_LEAF_LIST){
len = cvec_len(cvv);
if (len > 1){
cval = cvec_i(cvv, len-1);

View file

@ -190,7 +190,7 @@ yang2cli_var_identityref(yang_stmt *ys,
cprintf(cb, ">");
if (helptext)
cprintf(cb, "(\"%s\")", helptext);
if ((ybaseref = yang_find((yang_node*)ytype, Y_BASE, NULL)) != NULL &&
if ((ybaseref = yang_find(ytype, Y_BASE, NULL)) != NULL &&
(ybaseid = yang_find_identity(ys, ybaseref->ys_argument)) != NULL){
if (cvec_len(ybaseid->ys_cvec) > 0){
cprintf(cb, "|<%s:%s choice:", ys->ys_argument, cvtypestr);
@ -329,7 +329,7 @@ yang2cli_var_sub(clicon_handle h,
cprintf(cb, " choice:");
i = 0;
yi = NULL;
while ((yi = yn_each((yang_node*)ytype, yi)) != NULL){
while ((yi = yn_each(ytype, yi)) != NULL){
if (yi->ys_keyword != Y_ENUM && yi->ys_keyword != Y_BIT)
continue;
if (i)
@ -443,7 +443,7 @@ yang2cli_var_union(clicon_handle h,
* not resolved types (unless they are built-in, but the resolve call is
* made in the union_one call.
*/
while ((ytsub = yn_each((yang_node*)ytype, ytsub)) != NULL){
while ((ytsub = yn_each(ytype, ytsub)) != NULL){
if (ytsub->ys_keyword != Y_TYPE)
continue;
if (i++)
@ -563,7 +563,7 @@ yang2cli_leaf(clicon_handle h,
char *s;
/* description */
if ((yd = yang_find((yang_node*)ys, Y_DESCRIPTION, NULL)) != NULL){
if ((yd = yang_find(ys, Y_DESCRIPTION, NULL)) != NULL){
if ((helptext = strdup(yd->ys_argument)) == NULL){
clicon_err(OE_UNIX, errno, "strdup");
goto done;
@ -618,7 +618,7 @@ yang2cli_container(clicon_handle h,
char *s;
cprintf(cb, "%*s%s", level*3, "", ys->ys_argument);
if ((yd = yang_find((yang_node*)ys, Y_DESCRIPTION, NULL)) != NULL){
if ((yd = yang_find(ys, Y_DESCRIPTION, NULL)) != NULL){
if ((helptext = strdup(yd->ys_argument)) == NULL){
clicon_err(OE_UNIX, errno, "strdup");
goto done;
@ -668,7 +668,7 @@ yang2cli_list(clicon_handle h,
char *s;
cprintf(cb, "%*s%s", level*3, "", ys->ys_argument);
if ((yd = yang_find((yang_node*)ys, Y_DESCRIPTION, NULL)) != NULL){
if ((yd = yang_find(ys, Y_DESCRIPTION, NULL)) != NULL){
if ((helptext = strdup(yd->ys_argument)) == NULL){
clicon_err(OE_UNIX, errno, "strdup");
goto done;
@ -683,7 +683,7 @@ yang2cli_list(clicon_handle h,
/* Iterate over individual keys */
while ((cvi = cvec_each(cvk, cvi)) != NULL) {
keyname = cv_string_get(cvi);
if ((yleaf = yang_find((yang_node*)ys, Y_LEAF, keyname)) == NULL){
if ((yleaf = yang_find(ys, Y_LEAF, keyname)) == NULL){
clicon_err(OE_XML, 0, "List statement \"%s\" has no key leaf \"%s\"",
ys->ys_argument, keyname);
goto done;
@ -836,7 +836,7 @@ yang2cli_stmt(clicon_handle h,
*/
int
yang2cli(clicon_handle h,
yang_spec *yspec,
yang_stmt *yspec,
parse_tree *ptnew,
enum genmodel_type gt)
{
@ -851,8 +851,8 @@ yang2cli(clicon_handle h,
goto done;
}
/* Traverse YANG, loop through all modules and generate CLI */
for (i=0; i<yspec->yp_len; i++)
if ((ymod = yspec->yp_stmt[i]) != NULL){
for (i=0; i<yspec->ys_len; i++)
if ((ymod = yspec->ys_stmt[i]) != NULL){
if (yang2cli_stmt(h, ymod, gt, 0, cb) < 0)
goto done;
}

View file

@ -39,7 +39,7 @@
/*
* Prototypes
*/
int yang2cli(clicon_handle h, yang_spec *yspec, parse_tree *ptnew,
int yang2cli(clicon_handle h, yang_stmt *yspec, parse_tree *ptnew,
enum genmodel_type gt);
#endif /* _CLI_GENERATE_H_ */

View file

@ -162,7 +162,7 @@ cli_history_save(clicon_handle h)
static int
cli_terminate(clicon_handle h)
{
yang_spec *yspec;
yang_stmt *yspec;
cxobj *x;
clicon_rpc_close_session(h);
@ -279,8 +279,8 @@ main(int argc, char **argv)
int help = 0;
int logdst = CLICON_LOG_STDERR;
char *restarg = NULL; /* what remains after options */
yang_spec *yspec;
yang_spec *yspecfg = NULL; /* For config XXX clixon bug */
yang_stmt *yspec;
yang_stmt *yspecfg = NULL; /* For config XXX clixon bug */
struct passwd *pw;
char *str;

View file

@ -112,10 +112,10 @@ expand_dbvar(void *h,
int j;
int k;
cg_var *cv;
yang_spec *yspec;
yang_stmt *yspec;
cxobj *xtop = NULL; /* xpath root */
cxobj *xbot = NULL; /* xpath, NULL if datastore */
yang_node *y = NULL; /* yang spec of xpath */
yang_stmt *y = NULL; /* yang spec of xpath */
yang_stmt *ytype;
yang_stmt *ypath;
cxobj *xcur;
@ -183,9 +183,9 @@ expand_dbvar(void *h,
* Here the whole syntax tree is loaded, and it would be better to offload
* such operations to the datastore by a generic xpath function.
*/
if ((ytype = yang_find((yang_node*)y, Y_TYPE, NULL)) != NULL)
if ((ytype = yang_find(y, Y_TYPE, NULL)) != NULL)
if (strcmp(ytype->ys_argument, "leafref")==0){
if ((ypath = yang_find((yang_node*)ytype, Y_PATH, NULL)) == NULL){
if ((ypath = yang_find(ytype, Y_PATH, NULL)) == NULL){
clicon_err(OE_DB, 0, "Leafref %s requires path statement", ytype->ys_argument);
goto done;
}
@ -394,17 +394,17 @@ show_yang(clicon_handle h,
cvec *cvv,
cvec *argv)
{
yang_node *yn;
yang_stmt *yn;
char *str = NULL;
yang_spec *yspec;
yang_stmt *yspec;
yspec = clicon_dbspec_yang(h);
if (cvec_len(argv) > 0){
str = cv_string_get(cvec_i(argv, 0));
yn = (yang_node*)yang_find((yang_node*)yspec, 0, str);
yn = yang_find(yspec, 0, str);
}
else
yn = (yang_node*)yspec;
yn = yspec;
yang_print(stdout, yn);
return 0;
}
@ -443,7 +443,7 @@ cli_show_config(clicon_handle h,
cxobj *xc;
cxobj *xerr;
enum genmodel_type gt;
yang_spec *yspec;
yang_stmt *yspec;
if (cvec_len(argv) != 3 && cvec_len(argv) != 4){
clicon_err(OE_PLUGIN, 0, "Got %d arguments. Expected: <dbname>,<format>,<xpath>[,<attr>]", cvec_len(argv));
@ -622,7 +622,7 @@ cli_show_auto(clicon_handle h,
cvec *argv)
{
int retval = 1;
yang_spec *yspec;
yang_stmt *yspec;
char *api_path_fmt; /* xml key format */
// char *api_path = NULL; /* xml key */
char *db;