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

@ -35,6 +35,9 @@
### API changes on existing features (you may need to change your code)
* Structural C-code change: Merged yang_spec and yang_node types into yang_stmt
* Change all yn_* and yp_ to ys_*
* Change all references to yang_node/yang_spec to yang_stmt
* Structural change: removed datastore plugin and directory, and merged into regulat clixon lib code.
* The CLICON_XMLDB_PLUGIN config option is obsolete, you should remove it from your config file
* The datastore directory is removed, code is moved to lib/src/clixon_datastore*.c

View file

@ -163,7 +163,7 @@ backend_client_rm(clicon_handle h,
*/
static int
client_get_streams(clicon_handle h,
yang_spec *yspec,
yang_stmt *yspec,
char *xpath,
char *module,
char *top,
@ -175,11 +175,11 @@ client_get_streams(clicon_handle h,
cxobj *x = NULL;
cbuf *cb = NULL;
if ((ystream = yang_find((yang_node*)yspec, Y_MODULE, module)) == NULL){
if ((ystream = yang_find(yspec, Y_MODULE, module)) == NULL){
clicon_err(OE_YANG, 0, "%s yang module not found", module);
goto done;
}
if ((yns = yang_find((yang_node*)ystream, Y_NAMESPACE, NULL)) == NULL){
if ((yns = yang_find(ystream, Y_NAMESPACE, NULL)) == NULL){
clicon_err(OE_YANG, 0, "%s yang namespace not found", module);
goto done;
}
@ -224,7 +224,7 @@ client_statedata(clicon_handle h,
cxobj **xvec = NULL;
size_t xlen;
int i;
yang_spec *yspec;
yang_stmt *yspec;
if ((yspec = clicon_dbspec_yang(h)) == NULL){
clicon_err(OE_YANG, ENOENT, "No yang spec");
@ -379,7 +379,7 @@ from_client_edit_config(clicon_handle h,
enum operation_type operation = OP_MERGE;
int piddb;
int non_config = 0;
yang_spec *yspec;
yang_stmt *yspec;
cbuf *cbx = NULL; /* Assist cbuf */
int ret;
char *username;
@ -1061,7 +1061,7 @@ from_client_msg(clicon_handle h,
cbuf *cbret = NULL; /* return message */
int ret;
char *username;
yang_spec *yspec;
yang_stmt *yspec;
yang_stmt *ye;
yang_stmt *ymod;
cxobj *xnacm = NULL;

View file

@ -87,7 +87,7 @@
* @retval 1 Validation OK
*/
static int
generic_validate(yang_spec *yspec,
generic_validate(yang_stmt *yspec,
transaction_data_t *td,
cbuf *cbret)
{
@ -168,7 +168,7 @@ startup_common(clicon_handle h,
cbuf *cbret)
{
int retval = -1;
yang_spec *yspec;
yang_stmt *yspec;
int ret;
modstate_diff_t *msd = NULL;
cxobj *xt = NULL;
@ -341,7 +341,7 @@ from_validate_common(clicon_handle h,
cbuf *cbret)
{
int retval = -1;
yang_spec *yspec;
yang_stmt *yspec;
int i;
cxobj *xn;
int ret;

View file

@ -85,7 +85,7 @@
static int
backend_terminate(clicon_handle h)
{
yang_spec *yspec;
yang_stmt *yspec;
char *pidfile = clicon_backend_pidfile(h);
int sockfamily = clicon_sock_family(h);
char *sockpath = clicon_sock(h);
@ -174,7 +174,7 @@ nacm_load_external(clicon_handle h)
{
int retval = -1;
char *filename; /* NACM config file */
yang_spec *yspec = NULL;
yang_stmt *yspec = NULL;
cxobj *xt = NULL;
struct stat st;
FILE *f = NULL;
@ -325,8 +325,8 @@ main(int argc,
int sockfamily;
char *nacm_mode;
int logdst = CLICON_LOG_SYSLOG|CLICON_LOG_STDERR;
yang_spec *yspec = NULL;
yang_spec *yspecfg = NULL; /* For config XXX clixon bug */
yang_stmt *yspec = NULL;
yang_stmt *yspecfg = NULL; /* For config XXX clixon bug */
char *str;
int ss = -1; /* server socket */
cbuf *cbret = NULL; /* startup cbuf if invalid */

View file

@ -121,7 +121,7 @@ clixon_plugin_reset(clicon_handle h,
*/
int
clixon_plugin_statedata(clicon_handle h,
yang_spec *yspec,
yang_stmt *yspec,
char *xpath,
cxobj **xret)
{

View file

@ -71,7 +71,7 @@ int backend_plugin_initiate(clicon_handle h);
int clixon_plugin_reset(clicon_handle h, char *db);
int clixon_plugin_statedata(clicon_handle h, yang_spec *yspec, char *xpath, cxobj **xtop);
int clixon_plugin_statedata(clicon_handle h, yang_stmt *yspec, char *xpath, cxobj **xtop);
transaction_data_t * transaction_new(void);
int transaction_free(transaction_data_t *);

View file

@ -327,7 +327,7 @@ startup_failsafe(clicon_handle h)
*/
int
startup_module_state(clicon_handle h,
yang_spec *yspec)
yang_stmt *yspec)
{
int retval = -1;
cxobj *x = NULL;

View file

@ -44,6 +44,6 @@ int startup_db_reset(clicon_handle h, char *db);
int startup_mode_startup(clicon_handle h, char *db, cbuf *cbret);
int startup_extraxml(clicon_handle h, char *file, cbuf *cbret);
int startup_failsafe(clicon_handle h);
int startup_module_state(clicon_handle h, yang_spec *yspec);
int startup_module_state(clicon_handle h, yang_stmt *yspec);
#endif /* _BACKEND_STARTUP_H_ */

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;

View file

@ -92,7 +92,7 @@ netconf_input_packet(clicon_handle h,
cxobj *xret = NULL; /* Return (out) */
cxobj *xrpc;
cxobj *xc;
yang_spec *yspec;
yang_stmt *yspec;
int ret;
cxobj *xa;
cxobj *xa2;
@ -290,7 +290,7 @@ send_hello(clicon_handle h,
static int
netconf_terminate(clicon_handle h)
{
yang_spec *yspec;
yang_stmt *yspec;
cxobj *x;
clixon_plugin_exit(h);
@ -357,8 +357,8 @@ main(int argc,
int logdst = CLICON_LOG_STDERR;
struct passwd *pw;
struct timeval tv = {0,}; /* timeout */
yang_spec *yspec = NULL;
yang_spec *yspecfg = NULL; /* For config XXX clixon bug */
yang_stmt *yspec = NULL;
yang_stmt *yspecfg = NULL; /* For config XXX clixon bug */
char *str;
/* Create handle */

View file

@ -427,7 +427,7 @@ netconf_notification_cb(int s,
cxobj *xn = NULL; /* event xml */
cxobj *xt = NULL; /* top xml */
clicon_handle h = (clicon_handle)arg;
yang_spec *yspec = NULL;
yang_stmt *yspec = NULL;
clicon_debug(1, "%s", __FUNCTION__);
/* get msg (this is the reason this function is called) */
@ -541,7 +541,7 @@ netconf_application_rpc(clicon_handle h,
cxobj **xret)
{
int retval = -1;
yang_spec *yspec = NULL; /* application yspec */
yang_stmt *yspec = NULL; /* application yspec */
yang_stmt *yrpc = NULL;
yang_stmt *ymod = NULL;
yang_stmt *yinput;
@ -579,11 +579,11 @@ netconf_application_rpc(clicon_handle h,
"</rpc-error></rpc-reply>", xml_name(xn));
goto ok;
}
yrpc = yang_find((yang_node*)ymod, Y_RPC, xml_name(xn));
yrpc = yang_find(ymod, Y_RPC, xml_name(xn));
/* Check if found */
if (yrpc != NULL){
/* 1. Check xn arguments with input statement. */
if ((yinput = yang_find((yang_node*)yrpc, Y_INPUT, NULL)) != NULL){
if ((yinput = yang_find(yrpc, Y_INPUT, NULL)) != NULL){
xml_spec_set(xn, yinput); /* needed for xml_spec_populate */
if (xml_apply(xn, CX_ELMNT, xml_spec_populate, yspec) < 0)
goto done;
@ -616,7 +616,7 @@ netconf_application_rpc(clicon_handle h,
* (2) Uncertain how validation errors should be logged/handled
*/
if (0)
if ((youtput = yang_find((yang_node*)yrpc, Y_OUTPUT, NULL)) != NULL){
if ((youtput = yang_find(yrpc, Y_OUTPUT, NULL)) != NULL){
xoutput=xpath_first(*xret, "/");
xml_spec_set(xoutput, youtput); /* needed for xml_spec_populate */
if (xml_apply(xoutput, CX_ELMNT, xml_spec_populate, yspec) < 0)

View file

@ -478,7 +478,7 @@ api_return_err(clicon_handle h,
int
restconf_terminate(clicon_handle h)
{
yang_spec *yspec;
yang_stmt *yspec;
cxobj *x;
int fs; /* fgcx socket */

View file

@ -521,8 +521,8 @@ main(int argc,
clicon_handle h;
char *dir;
int logdst = CLICON_LOG_SYSLOG;
yang_spec *yspec = NULL;
yang_spec *yspecfg = NULL; /* For config XXX clixon bug */
yang_stmt *yspec = NULL;
yang_stmt *yspecfg = NULL; /* For config XXX clixon bug */
char *stream_path;
int finish;
char *str;

View file

@ -188,7 +188,7 @@ api_data_get2(clicon_handle h,
cbuf *cbpath = NULL;
char *path;
cbuf *cbx = NULL;
yang_spec *yspec;
yang_stmt *yspec;
cxobj *xret = NULL;
cxobj *xerr = NULL; /* malloced */
cxobj *xe = NULL;
@ -443,8 +443,8 @@ api_data_post(clicon_handle h,
cxobj *xtop = NULL; /* xpath root */
cxobj *xbot = NULL;
cxobj *x;
yang_node *y = NULL;
yang_spec *yspec;
yang_stmt *y = NULL;
yang_stmt *yspec;
cxobj *xa;
cxobj *xret = NULL;
cxobj *xretcom = NULL; /* return from commit */
@ -710,8 +710,8 @@ api_data_put(clicon_handle h,
cxobj *xbot = NULL;
cxobj *xparent;
cxobj *x;
yang_node *y = NULL;
yang_spec *yspec;
yang_stmt *y = NULL;
yang_stmt *yspec;
cxobj *xa;
char *api_path;
cxobj *xret = NULL;
@ -847,7 +847,7 @@ api_data_put(clicon_handle h,
goto ok;
}
/* If list or leaf-list, api-path keys must match data keys */
if (y && (y->yn_keyword == Y_LIST ||y->yn_keyword == Y_LEAF_LIST)){
if (y && (y->ys_keyword == Y_LIST ||y->ys_keyword == Y_LEAF_LIST)){
if (match_list_keys((yang_stmt*)y, x, xbot) < 0){
if (netconf_operation_failed_xml(&xerr, "protocol", "api-path keys do not match data keys") < 0)
goto done;
@ -988,8 +988,8 @@ api_data_delete(clicon_handle h,
cxobj *xbot = NULL;
cxobj *xa;
cbuf *cbx = NULL;
yang_node *y = NULL;
yang_spec *yspec;
yang_stmt *y = NULL;
yang_stmt *yspec;
enum operation_type op = OP_DELETE;
cxobj *xret = NULL;
cxobj *xretcom = NULL; /* return from commmit */
@ -1128,7 +1128,7 @@ api_operations_get(clicon_handle h,
int use_xml)
{
int retval = -1;
yang_spec *yspec;
yang_stmt *yspec;
yang_stmt *ymod; /* yang module */
yang_stmt *yc;
char *namespace;
@ -1146,10 +1146,10 @@ api_operations_get(clicon_handle h,
cprintf(cbx, "{\"operations\": {");
ymod = NULL;
i = 0;
while ((ymod = yn_each((yang_node*)yspec, ymod)) != NULL) {
while ((ymod = yn_each(yspec, ymod)) != NULL) {
namespace = yang_find_mynamespace(ymod);
yc = NULL;
while ((yc = yn_each((yang_node*)ymod, yc)) != NULL) {
while ((yc = yn_each(ymod, yc)) != NULL) {
if (yc->ys_keyword != Y_RPC)
continue;
if (use_xml)
@ -1207,7 +1207,7 @@ static int
api_operations_post_input(clicon_handle h,
FCGX_Request *r,
char *data,
yang_spec *yspec,
yang_stmt *yspec,
yang_stmt *yrpc,
cxobj *xrpc,
int pretty,
@ -1342,7 +1342,7 @@ static int
api_operations_post_output(clicon_handle h,
FCGX_Request *r,
cxobj *xret,
yang_spec *yspec,
yang_stmt *yspec,
yang_stmt *youtput,
char *namespace,
int pretty,
@ -1511,14 +1511,14 @@ api_operations_post(clicon_handle h,
int retval = -1;
int i;
char *oppath = path;
yang_spec *yspec;
yang_stmt *yspec;
yang_stmt *youtput = NULL;
yang_stmt *yrpc = NULL;
cxobj *xret = NULL;
cxobj *xerr = NULL; /* malloced must be freed */
cxobj *xtop = NULL; /* xpath root */
cxobj *xbot = NULL;
yang_node *y = NULL;
yang_stmt *y = NULL;
cxobj *xoutput = NULL;
cxobj *xa;
cxobj *xe;
@ -1561,7 +1561,7 @@ api_operations_post(clicon_handle h,
*/
if (nodeid_split(oppath+1, &prefix, &id) < 0) /* +1 skip / */
goto done;
if ((ys = yang_find((yang_node*)yspec, Y_MODULE, prefix)) == NULL){
if ((ys = yang_find(yspec, Y_MODULE, prefix)) == NULL){
if (netconf_operation_failed_xml(&xerr, "protocol", "yang module not found") < 0)
goto done;
if ((xe = xpath_first(xerr, "rpc-error")) == NULL){
@ -1572,7 +1572,7 @@ api_operations_post(clicon_handle h,
goto done;
goto ok;
}
if ((yrpc = yang_find((yang_node*)ys, Y_RPC, id)) == NULL){
if ((yrpc = yang_find(ys, Y_RPC, id)) == NULL){
if (netconf_missing_element_xml(&xerr, "application", id, "RPC not defined") < 0)
goto done;
if ((xe = xpath_first(xerr, "rpc-error")) == NULL){
@ -1704,7 +1704,7 @@ api_operations_post(clicon_handle h,
clicon_debug(1, "%s 8. Receive reply:%s", __FUNCTION__, cbuf_get(ccc));
}
#endif
youtput = yang_find((yang_node*)yrpc, Y_OUTPUT, NULL);
youtput = yang_find(yrpc, Y_OUTPUT, NULL);
if ((ret = api_operations_post_output(h, r, xret, yspec, youtput, namespace,
pretty, use_xml, &xoutput)) < 0)
goto done;

View file

@ -285,7 +285,7 @@ upgrade_2016(clicon_handle h,
cbuf *cbret)
{
int retval = -1;
yang_spec *yspec;
yang_stmt *yspec;
yang_stmt *ym;
cxobj **vec = NULL;
cxobj *xc;
@ -384,7 +384,7 @@ upgrade_2018(clicon_handle h,
cbuf *cbret)
{
int retval = -1;
yang_spec *yspec;
yang_stmt *yspec;
yang_stmt *ym;
cxobj **vec = NULL;
cxobj *xc;

View file

@ -58,14 +58,14 @@ typedef struct {
/*
* Prototypes
*/
yang_spec * clicon_dbspec_yang(clicon_handle h);
int clicon_dbspec_yang_set(clicon_handle h, struct yang_spec *ys);
yang_stmt * clicon_dbspec_yang(clicon_handle h);
int clicon_dbspec_yang_set(clicon_handle h, yang_stmt *ys);
cxobj * clicon_nacm_ext(clicon_handle h);
int clicon_nacm_ext_set(clicon_handle h, cxobj *xn);
yang_spec * clicon_config_yang(clicon_handle h);
int clicon_config_yang_set(clicon_handle h, struct yang_spec *ys);
yang_stmt * clicon_config_yang(clicon_handle h);
int clicon_config_yang_set(clicon_handle h, yang_stmt *ys);
cxobj *clicon_conf_xml(clicon_handle h);
int clicon_conf_xml_set(clicon_handle h, cxobj *x);

View file

@ -43,8 +43,8 @@ int xml2json_cbuf(cbuf *cb, cxobj *x, int pretty);
int xml2json_cbuf_vec(cbuf *cb, cxobj **vec, size_t veclen, int pretty);
int xml2json(FILE *f, cxobj *x, int pretty);
int xml2json_vec(FILE *f, cxobj **vec, size_t veclen, int pretty);
int json2xml_ns(yang_spec *yspec, cxobj *x, cxobj **xerr);
int json2xml_ns(yang_stmt *yspec, cxobj *x, cxobj **xerr);
int json_parse_str(char *str, cxobj **xt);
int json_parse_file(int fd, yang_spec *yspec, cxobj **xt);
int json_parse_file(int fd, yang_stmt *yspec, cxobj **xt);
#endif /* _CLIXON_JSON_H */

View file

@ -66,7 +66,7 @@ int netconf_operation_failed(cbuf *cb, char *type, char *message);
int netconf_operation_failed_xml(cxobj **xret, char *type, char *message);
int netconf_malformed_message(cbuf *cb, char *message);
int netconf_malformed_message_xml(cxobj **xret, char *message);
int netconf_trymerge(cxobj *x, yang_spec *yspec, cxobj **xret);
int netconf_trymerge(cxobj *x, yang_stmt *yspec, cxobj **xret);
int netconf_module_load(clicon_handle h);
char *netconf_db_find(cxobj *xn, char *name);

View file

@ -84,7 +84,7 @@ int clicon_option_dump(clicon_handle h, int dblevel);
int clicon_option_add(clicon_handle h, char *name, char *value);
/* Initialize options: set defaults, read config-file, etc */
int clicon_options_main(clicon_handle h, yang_spec *yspec);
int clicon_options_main(clicon_handle h, yang_stmt *yspec);
/*! Check if a clicon option has a value */
int clicon_option_exists(clicon_handle h, const char *name);

View file

@ -66,7 +66,7 @@ struct clicon_msg *clicon_msg_encode(char *format, ...) __attribute__ ((format (
#else
struct clicon_msg *clicon_msg_encode(char *format, ...);
#endif
int clicon_msg_decode(struct clicon_msg *msg, yang_spec *yspec, cxobj **xml);
int clicon_msg_decode(struct clicon_msg *msg, yang_stmt *yspec, cxobj **xml);
int clicon_connect_unix(char *sockpath);

View file

@ -153,12 +153,12 @@ int xml_free(cxobj *xn);
int xml_print(FILE *f, cxobj *xn);
int clicon_xml2file(FILE *f, cxobj *xn, int level, int prettyprint);
int clicon_xml2cbuf(cbuf *xf, cxobj *xn, int level, int prettyprint);
int xml_parse_file(int fd, char *endtag, yang_spec *yspec, cxobj **xt);
int xml_parse_string(const char *str, yang_spec *yspec, cxobj **xml_top);
int xml_parse_file(int fd, char *endtag, yang_stmt *yspec, cxobj **xt);
int xml_parse_string(const char *str, yang_stmt *yspec, cxobj **xml_top);
#if defined(__GNUC__) && __GNUC__ >= 3
int xml_parse_va(cxobj **xt, yang_spec *yspec, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
int xml_parse_va(cxobj **xt, yang_stmt *yspec, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
#else
int xml_parse_va(cxobj **xt, yang_spec *yspec, const char *format, ...);
int xml_parse_va(cxobj **xt, yang_stmt *yspec, const char *format, ...);
#endif
int xmltree2cbuf(cbuf *cb, cxobj *x, int level);
int xml_copy_one(cxobj *xn0, cxobj *xn1);

View file

@ -51,7 +51,7 @@ int xml_yang_validate_all(cxobj *xt, cbuf *cbret);
int xml_yang_validate_all_top(cxobj *xt, cbuf *cbret);
int xml2cvec(cxobj *xt, yang_stmt *ys, cvec **cvv0);
int cvec2xml_1(cvec *cvv, char *toptag, cxobj *xp, cxobj **xt0);
int xml_diff(yang_spec *yspec, cxobj *xt1, cxobj *xt2,
int xml_diff(yang_stmt *yspec, cxobj *xt1, cxobj *xt2,
cxobj ***first, size_t *firstlen,
cxobj ***second, size_t *secondlen,
cxobj ***changed1, cxobj ***changed2, size_t *changedlen);
@ -63,12 +63,12 @@ int xml_tree_prune_flagged(cxobj *xt, int flag, int test);
int xml_default(cxobj *x, void *arg);
int xml_sanity(cxobj *x, void *arg);
int xml_non_config_data(cxobj *xt, void *arg);
int xml_spec_populate_rpc(clicon_handle h, cxobj *x, yang_spec *yspec);
int xml_spec_populate_rpc(clicon_handle h, cxobj *x, yang_stmt *yspec);
int xml_spec_populate(cxobj *x, void *arg);
int api_path2xpath(yang_spec *yspec, cvec *cvv, int offset, cbuf *xpath);
int api_path2xml(char *api_path, yang_spec *yspec, cxobj *xtop,
yang_class nodeclass, cxobj **xpathp, yang_node **ypathp);
int xml_merge(cxobj *x0, cxobj *x1, yang_spec *yspec, char **reason);
int api_path2xpath(yang_stmt *yspec, cvec *cvv, int offset, cbuf *xpath);
int api_path2xml(char *api_path, yang_stmt *yspec, cxobj *xtop,
yang_class nodeclass, cxobj **xpathp, yang_stmt **ypathp);
int xml_merge(cxobj *x0, cxobj *x1, yang_stmt *yspec, char **reason);
int yang_enum_int_value(cxobj *node, int32_t *val);
#endif /* _CLIXON_XML_MAP_H_ */

View file

@ -39,7 +39,7 @@
/*
* Prototypes
*/
int xml_child_spec(cxobj *x, cxobj *xp, yang_spec *yspec, yang_stmt **yp);
int xml_child_spec(cxobj *x, cxobj *xp, yang_stmt *yspec, yang_stmt **yp);
int xml_sort(cxobj *x0, void *arg);
cxobj *xml_search(cxobj *x, char *name, int yangi, enum rfc_6020 keyword, int keynr, char **keyvec, char **keyval);
int xml_insert_pos(cxobj *x0, char *name, int yangi, enum rfc_6020 keyword,

View file

@ -192,7 +192,7 @@ typedef struct yang_type_cache yang_type_cache;
struct yang_stmt{
int ys_len; /* Number of children */
struct yang_stmt **ys_stmt; /* Vector of children statement pointers */
struct yang_node *ys_parent; /* Backpointer to parent: yang-stmt or yang-spec */
struct yang_stmt *ys_parent; /* Backpointer to parent: yang-stmt or yang-spec */
enum rfc_6020 ys_keyword; /* See clicon_yang_parse.tab.h */
char *ys_argument; /* String / argument depending on keyword */
@ -220,68 +220,64 @@ struct yang_stmt{
yang_type_cache *ys_typecache; /* If ys_keyword==Y_TYPE, cache all typedef data except unions */
};
/*! top-level yang parse-tree */
struct yang_spec{
int yp_len; /* Number of children */
struct yang_stmt **yp_stmt; /* Vector of children statement pointers */
struct yang_node *yp_parent; /* Backpointer to parent: always NULL. See yang_stmt */
enum rfc_6020 yp_keyword; /* SHOULD BE Y_SPEC */
char *yp_argument; /* XXX String / argument depending on keyword */
int yp_flags; /* Flags according to YANG_FLAG_* above */
};
typedef struct yang_spec yang_spec;
#if 0 /* Backward compatible */
typedef struct yang_stmt yang_node;
typedef struct yang_stmt yang_spec;
/*! super-class of yang_stmt and yang_spec: it must start exactly as those two classes */
struct yang_node{
int yn_len; /* Number of children */
struct yang_stmt **yn_stmt; /* Vector of children statement pointers */
struct yang_node *yn_parent; /* Backpointer to parent: yang-stmt or yang-spec */
enum rfc_6020 yn_keyword; /* See clicon_yang_parse.tab.h */
char *yn_argument; /* XXX String / argument depending on keyword */
int yn_flags; /* Flags according to YANG_FLAG_* above */
};
typedef struct yang_node yang_node;
#define yn_len ys_len
#define yn_stmt ys_stmt
#define yn_parent ys_parent
#define yn_keyword ys_keyword
#define yn_argument ys_argument
#define yn_flags ys_flags
#define yp_len ys_len
#define yp_stmt ys_stmt
#define yp_parent ys_parent
#define yp_keyword ys_keyword
#define yp_argument ys_argument
#define yp_flags ys_flags
#endif
typedef int (yang_applyfn_t)(yang_stmt *ys, void *arg);
/*
* Prototypes
*/
yang_spec *yspec_new(void);
yang_stmt *yspec_new(void);
yang_stmt *ys_new(enum rfc_6020 keyw);
int ys_free(yang_stmt *ys);
int yspec_free(yang_spec *yspec);
int yspec_free(yang_stmt *yspec);
int ys_cp(yang_stmt *new, yang_stmt *old);
yang_stmt *ys_dup(yang_stmt *old);
int yn_insert(yang_node *yn_parent, yang_stmt *ys_child);
yang_stmt *yn_each(yang_node *yn, yang_stmt *ys);
int yn_insert(yang_stmt *ys_parent, yang_stmt *ys_child);
yang_stmt *yn_each(yang_stmt *yn, yang_stmt *ys);
char *yang_key2str(int keyword);
char *yarg_prefix(yang_stmt *ys);
char *yarg_id(yang_stmt *ys);
int ys_module_by_xml(yang_spec *ysp, struct xml *xt, yang_stmt **ymodp);
int ys_module_by_xml(yang_stmt *ysp, struct xml *xt, yang_stmt **ymodp);
yang_stmt *ys_module(yang_stmt *ys);
yang_spec *ys_spec(yang_stmt *ys);
yang_stmt *ys_spec(yang_stmt *ys);
yang_stmt *yang_find_module_by_prefix(yang_stmt *ys, char *prefix);
yang_stmt *yang_find_module_by_namespace(yang_spec *yspec, char *namespace);
yang_stmt *yang_find_module_by_name(yang_spec *yspec, char *name);
yang_stmt *yang_find(yang_node *yn, int keyword, const char *argument);
int yang_match(yang_node *yn, int keyword, char *argument);
yang_stmt *yang_find_datanode(yang_node *yn, char *argument);
yang_stmt *yang_find_schemanode(yang_node *yn, char *argument);
yang_stmt *yang_find_module_by_namespace(yang_stmt *yspec, char *namespace);
yang_stmt *yang_find_module_by_name(yang_stmt *yspec, char *name);
yang_stmt *yang_find(yang_stmt *yn, int keyword, const char *argument);
int yang_match(yang_stmt *yn, int keyword, char *argument);
yang_stmt *yang_find_datanode(yang_stmt *yn, char *argument);
yang_stmt *yang_find_schemanode(yang_stmt *yn, char *argument);
char *yang_find_myprefix(yang_stmt *ys);
char *yang_find_mynamespace(yang_stmt *ys);
yang_node *yang_choice(yang_stmt *y);
yang_stmt *yang_choice(yang_stmt *y);
int yang_order(yang_stmt *y);
int yang_print(FILE *f, yang_node *yn);
int yang_print_cbuf(cbuf *cb, yang_node *yn, int marginal);
int yang_print(FILE *f, yang_stmt *yn);
int yang_print_cbuf(cbuf *cb, yang_stmt *yn, int marginal);
int ys_populate(yang_stmt *ys, void *arg);
yang_stmt *yang_parse_file(int fd, const char *name, yang_spec *ysp);
int yang_apply(yang_node *yn, enum rfc_6020 key, yang_applyfn_t fn,
yang_stmt *yang_parse_file(int fd, const char *name, yang_stmt *ysp);
int yang_apply(yang_stmt *yn, enum rfc_6020 key, yang_applyfn_t fn,
void *arg);
int yang_abs_schema_nodeid(yang_spec *yspec, yang_stmt *ys,
int yang_abs_schema_nodeid(yang_stmt *yspec, yang_stmt *ys,
char *schema_nodeid,
enum rfc_6020 keyword, yang_stmt **yres);
int yang_desc_schema_nodeid(yang_node *yn, char *schema_nodeid,
int yang_desc_schema_nodeid(yang_stmt *yn, char *schema_nodeid,
enum rfc_6020 keyword, yang_stmt **yres);
int ys_parse_date_arg(char *datearg, uint32_t *dateint);
@ -290,10 +286,10 @@ int ys_parse_sub(yang_stmt *ys, char *extra);
int yang_mandatory(yang_stmt *ys);
int yang_config(yang_stmt *ys);
int yang_spec_parse_module(clicon_handle h, const char *module,
const char *revision, yang_spec *yspec);
int yang_spec_parse_file(clicon_handle h, char *filename, yang_spec *yspec);
int yang_spec_load_dir(clicon_handle h, char *dir, yang_spec *yspec);
const char *revision, yang_stmt *yspec);
int yang_spec_parse_file(clicon_handle h, char *filename, yang_stmt *yspec);
int yang_spec_load_dir(clicon_handle h, char *dir, yang_stmt *yspec);
cvec *yang_arg2cvec(yang_stmt *ys, char *delimi);
int yang_key_match(yang_node *yn, char *name);
int yang_key_match(yang_stmt *yn, char *name);
#endif /* _CLIXON_YANG_H_ */

View file

@ -64,7 +64,7 @@ int modstate_diff_free(modstate_diff_t *);
int yang_modules_init(clicon_handle h);
char *yang_modules_revision(clicon_handle h);
int yang_modules_state_get(clicon_handle h, yang_spec *yspec, char *xpath,
int yang_modules_state_get(clicon_handle h, yang_stmt *yspec, char *xpath,
int brief, cxobj **xret);
int clixon_module_upgrade(clicon_handle h, cxobj *xt, modstate_diff_t *msd, cbuf *cb);

View file

@ -76,7 +76,7 @@
/*! Get YANG specification for application
* Must use hash functions directly since they are not strings.
*/
yang_spec *
yang_stmt *
clicon_dbspec_yang(clicon_handle h)
{
clicon_hash_t *cdat = clicon_data(h);
@ -84,7 +84,7 @@ clicon_dbspec_yang(clicon_handle h)
void *p;
if ((p = hash_value(cdat, "dbspec_yang", &len)) != NULL)
return *(yang_spec **)p;
return *(yang_stmt **)p;
return NULL;
}
@ -93,7 +93,7 @@ clicon_dbspec_yang(clicon_handle h)
*/
int
clicon_dbspec_yang_set(clicon_handle h,
struct yang_spec *ys)
yang_stmt *ys)
{
clicon_hash_t *cdat = clicon_data(h);
@ -151,7 +151,7 @@ clicon_nacm_ext_set(clicon_handle h,
/*! Get YANG specification for clixon config
* Must use hash functions directly since they are not strings.
*/
yang_spec *
yang_stmt *
clicon_config_yang(clicon_handle h)
{
clicon_hash_t *cdat = clicon_data(h);
@ -159,7 +159,7 @@ clicon_config_yang(clicon_handle h)
void *p;
if ((p = hash_value(cdat, "control_yang", &len)) != NULL)
return *(yang_spec **)p;
return *(yang_stmt **)p;
return NULL;
}
@ -168,7 +168,7 @@ clicon_config_yang(clicon_handle h)
*/
int
clicon_config_yang_set(clicon_handle h,
struct yang_spec *ys)
yang_stmt *ys)
{
clicon_hash_t *cdat = clicon_data(h);

View file

@ -186,7 +186,7 @@ xml_copy_marked(cxobj *x0,
* node in list is marked */
if (mark && yt && yt->ys_keyword == Y_LIST){
/* XXX: I think yang_key_match is suboptimal here */
if ((iskey = yang_key_match((yang_node*)yt, name)) < 0)
if ((iskey = yang_key_match(yt, name)) < 0)
goto done;
if (iskey){
if ((xcopy = xml_new(name, x1, xml_spec(x))) == NULL)
@ -220,7 +220,7 @@ xml_copy_marked(cxobj *x0,
*/
static int
text_read_modstate(clicon_handle h,
yang_spec *yspec,
yang_stmt *yspec,
cxobj *xt,
modstate_diff_t *msd)
{
@ -306,7 +306,7 @@ text_read_modstate(clicon_handle h,
int
xmldb_readfile(clicon_handle h,
const char *db,
yang_spec *yspec,
yang_stmt *yspec,
cxobj **xp,
modstate_diff_t *msd)
{
@ -391,7 +391,7 @@ xmldb_get_nocache(clicon_handle h,
{
int retval = -1;
char *dbfile = NULL;
yang_spec *yspec;
yang_stmt *yspec;
cxobj *xt = NULL;
cxobj *x;
int fd = -1;
@ -513,7 +513,7 @@ xmldb_get_cache(clicon_handle h,
modstate_diff_t *msd)
{
int retval = -1;
yang_spec *yspec;
yang_stmt *yspec;
cxobj *x0t = NULL; /* (cached) top of tree */
cxobj *x0;
cxobj **xvec = NULL;

View file

@ -41,6 +41,6 @@
*/
int xmldb_get_cache(clicon_handle h, const char *db, char *xpath, int config, cxobj **xret, modstate_diff_t *msd);
int xmldb_get_nocache(clicon_handle h, const char *db, char *xpath, int config, cxobj **xret, modstate_diff_t *msd);
int xmldb_readfile(clicon_handle h, const char *db, yang_spec *yspec, cxobj **xp, modstate_diff_t *msd);
int xmldb_readfile(clicon_handle h, const char *db, yang_stmt *yspec, cxobj **xp, modstate_diff_t *msd);
#endif /* _CLIXON_DATASTORE_READ_H */

View file

@ -111,7 +111,7 @@ valgrind --tool=callgrind datastore_client -d candidate -b /tmp/text -p ../datas
static int
text_modify(clicon_handle h,
cxobj *x0,
yang_node *y0,
yang_stmt *y0,
cxobj *x0p,
cxobj *x1,
enum operation_type op,
@ -144,7 +144,7 @@ text_modify(clicon_handle h,
if (xml_operation(opstr, &op) < 0)
goto done;
x1name = xml_name(x1);
if (y0->yn_keyword == Y_LEAF_LIST || y0->yn_keyword == Y_LEAF){
if (y0->ys_keyword == Y_LEAF_LIST || y0->ys_keyword == Y_LEAF){
x1bstr = xml_body(x1);
switch(op){
case OP_CREATE:
@ -181,7 +181,7 @@ text_modify(clicon_handle h,
#if 0
/* If it is key I dont want to mark it */
if ((iamkey=yang_key_match(y0->yn_parent, x1name)) < 0)
if ((iamkey=yang_key_match(y0->ys_parent, x1name)) < 0)
goto done;
if (!iamkey && op==OP_NONE)
#else
@ -262,7 +262,7 @@ text_modify(clicon_handle h,
can be modified in its entirety only.
Any "operation" attributes present on subelements of an anyxml
node are ignored by the NETCONF server.*/
if (y0->yn_keyword == Y_ANYXML || y0->yn_keyword == Y_ANYDATA){
if (y0->ys_keyword == Y_ANYXML || y0->ys_keyword == Y_ANYDATA){
if (op == OP_NONE)
break;
if (op==OP_MERGE && !permit && xnacm){
@ -344,7 +344,7 @@ text_modify(clicon_handle h,
x1cname = xml_name(x1c);
x0c = x0vec[i++];
yc = yang_find_datanode(y0, x1cname);
if ((ret = text_modify(h, x0c, (yang_node*)yc, x0, x1c, op,
if ((ret = text_modify(h, x0c, yc, x0, x1c, op,
username, xnacm, permit, cbret)) < 0)
goto done;
/* If xml return - ie netconf error xml tree, then stop and return OK */
@ -404,7 +404,7 @@ static int
text_modify_top(clicon_handle h,
cxobj *x0,
cxobj *x1,
yang_spec *yspec,
yang_stmt *yspec,
enum operation_type op,
char *username,
cxobj *xnacm,
@ -489,7 +489,7 @@ text_modify_top(clicon_handle h,
if (ys_module_by_xml(yspec, x1c, &ymod) <0)
goto done;
if (ymod != NULL)
yc = yang_find_datanode((yang_node*)ymod, x1cname);
yc = yang_find_datanode(ymod, x1cname);
if (yc == NULL){
if (netconf_unknown_element(cbret, "application", x1cname, "Unassigned yang spec") < 0)
goto done;
@ -506,7 +506,7 @@ text_modify_top(clicon_handle h,
x0c = NULL;
}
#endif
if ((ret = text_modify(h, x0c, (yang_node*)yc, x0, x1c, op,
if ((ret = text_modify(h, x0c, yc, x0, x1c, op,
username, xnacm, permit, cbret)) < 0)
goto done;
/* If xml return - ie netconf error xml tree, then stop and return OK */
@ -552,7 +552,7 @@ xml_container_presence(cxobj *x,
/* Mark node that is: container, have no children, dont have presence */
if (y->ys_keyword == Y_CONTAINER &&
xml_child_nr_notype(x, CX_ATTR)==0 &&
yang_find((yang_node*)y, Y_PRESENCE, NULL) == NULL)
yang_find(y, Y_PRESENCE, NULL) == NULL)
xml_flag_set(x, XML_FLAG_MARK); /* Mark, remove later */
retval = 0;
done:
@ -597,7 +597,7 @@ xmldb_put(clicon_handle h,
char *dbfile = NULL;
FILE *f = NULL;
cbuf *cb = NULL;
yang_spec *yspec;
yang_stmt *yspec;
cxobj *x0 = NULL;
db_elmnt *de = NULL;
int ret;

View file

@ -318,7 +318,7 @@ xml2json1_cbuf(cbuf *cb,
enum array_element_type xc_arraytype;
yang_stmt *ys;
yang_stmt *ymod; /* yang module */
yang_spec *yspec = NULL; /* yang spec */
yang_stmt *yspec = NULL; /* yang spec */
int bodystr0=1;
char *prefix=NULL; /* prefix / local namespace name */
char *namespace=NULL; /* namespace uri */
@ -728,7 +728,7 @@ xml2json_vec(FILE *f,
* @note the opposite - xml2ns is made inline in xml2json1_cbuf
*/
int
json2xml_ns(yang_spec *yspec,
json2xml_ns(yang_stmt *yspec,
cxobj *x,
cxobj **xerr)
{
@ -860,7 +860,7 @@ json_parse_str(char *str,
*/
int
json_parse_file(int fd,
yang_spec *yspec,
yang_stmt *yspec,
cxobj **xt)
{
int retval = -1;

View file

@ -976,7 +976,7 @@ netconf_malformed_message_xml(cxobj **xret,
*/
int
netconf_trymerge(cxobj *x,
yang_spec *yspec,
yang_stmt *yspec,
cxobj **xret)
{
int retval = -1;
@ -1018,7 +1018,7 @@ netconf_module_load(clicon_handle h)
{
int retval = -1;
cxobj *xc;
yang_spec *yspec;
yang_stmt *yspec;
yspec = clicon_dbspec_yang(h);
if ((xc = clicon_conf_xml(h)) == NULL){

View file

@ -131,7 +131,7 @@ clicon_option_dump(clicon_handle h,
static int
parse_configfile(clicon_handle h,
const char *filename,
yang_spec *yspec,
yang_stmt *yspec,
cxobj **xconfig)
{
struct stat st;
@ -290,7 +290,7 @@ clicon_option_add(clicon_handle h,
*/
int
clicon_options_main(clicon_handle h,
yang_spec *yspec)
yang_stmt *yspec)
{
int retval = -1;
char *configfile;

View file

@ -165,7 +165,7 @@ clicon_msg_encode(char *format, ...)
*/
int
clicon_msg_decode(struct clicon_msg *msg,
yang_spec *yspec,
yang_stmt *yspec,
cxobj **xml)
{
int retval = -1;

View file

@ -92,7 +92,7 @@ clicon_rpc_msg(clicon_handle h,
int port;
char *retdata = NULL;
cxobj *xret = NULL;
yang_spec *yspec;
yang_stmt *yspec;
#ifdef RPC_USERNAME_ASSERT
assert(strstr(msg->op_body, "username")!=NULL); /* XXX */

View file

@ -546,7 +546,7 @@ stream_notify(clicon_handle h,
va_list args;
int len;
cxobj *xev = NULL;
yang_spec *yspec = NULL;
yang_stmt *yspec = NULL;
char *str = NULL;
cbuf *cb = NULL;
char timestr[28];
@ -621,7 +621,7 @@ stream_notify_xml(clicon_handle h,
int retval = -1;
cxobj *xev = NULL;
cxobj *xml2; /* copy */
yang_spec *yspec = NULL;
yang_stmt *yspec = NULL;
char *str = NULL;
cbuf *cb = NULL;
char timestr[28];

View file

@ -1605,7 +1605,7 @@ xmltree2cbuf(cbuf *cb,
*/
static int
_xml_parse(const char *str,
yang_spec *yspec,
yang_stmt *yspec,
cxobj *xt)
{
int retval = -1;
@ -1685,7 +1685,7 @@ FSM(char *tag,
int
xml_parse_file(int fd,
char *endtag,
yang_spec *yspec,
yang_stmt *yspec,
cxobj **xt)
{
int retval = -1;
@ -1772,7 +1772,7 @@ xml_parse_file(int fd,
*/
int
xml_parse_string(const char *str,
yang_spec *yspec,
yang_stmt *yspec,
cxobj **xtop)
{
if (*xtop == NULL)
@ -1804,7 +1804,7 @@ xml_parse_string(const char *str,
*/
int
xml_parse_va(cxobj **xtop,
yang_spec *yspec,
yang_stmt *yspec,
const char *format, ...)
{
int retval = -1;

View file

@ -423,7 +423,7 @@ clixon_xml_changelog_init(clicon_handle h)
char *filename;
int fd = -1;
cxobj *xt = NULL;
yang_spec *yspec;
yang_stmt *yspec;
cbuf *cbret = NULL;
int ret;

View file

@ -213,7 +213,7 @@ xml2cli(FILE *f,
/* If list then first loop through keys */
xe = NULL;
while ((xe = xml_child_each(x, xe, -1)) != NULL){
if ((match = yang_key_match((yang_node*)ys, xml_name(xe))) < 0)
if ((match = yang_key_match(ys, xml_name(xe))) < 0)
goto done;
if (!match)
continue;
@ -226,7 +226,7 @@ xml2cli(FILE *f,
xe = NULL;
while ((xe = xml_child_each(x, xe, -1)) != NULL){
if (ys->ys_keyword == Y_LIST){
if ((match = yang_key_match((yang_node*)ys, xml_name(xe))) < 0)
if ((match = yang_key_match(ys, xml_name(xe))) < 0)
goto done;
if (match){
fprintf(f, "%s\n", cbuf_get(cbpre));
@ -268,7 +268,7 @@ validate_leafref(cxobj *xt,
if ((leafrefbody = xml_body(xt)) == NULL)
goto ok;
if ((ypath = yang_find((yang_node*)ytype, Y_PATH, NULL)) == NULL){
if ((ypath = yang_find(ytype, Y_PATH, NULL)) == NULL){
if (netconf_missing_element(cbret, "application", ytype->ys_argument, "Leafref requires path statement") < 0)
goto done;
goto fail;
@ -348,7 +348,7 @@ validate_identityref(cxobj *xt,
node = cbuf_get(cb);
}
/* This is the type's base reference */
if ((ybaseref = yang_find((yang_node*)ytype, Y_BASE, NULL)) == NULL){
if ((ybaseref = yang_find(ytype, Y_BASE, NULL)) == NULL){
if (netconf_missing_element(cbret, "application", ytype->ys_argument, "Identityref validation failed, no base") < 0)
goto done;
goto fail;
@ -501,9 +501,9 @@ check_choice(cxobj *xt,
cbuf *cbret)
{
int retval = -1;
yang_node *yc;
yang_stmt *yc;
yang_stmt *y;
yang_node *yp;
yang_stmt *yp;
cxobj *x;
cxobj *xp;
@ -516,7 +516,7 @@ check_choice(cxobj *xt,
if ((x != xt) &&
(y = xml_spec(x)) != NULL &&
(yp = yang_choice(y)) != NULL &&
yp == (yang_node*)yc){
yp == yc){
if (netconf_bad_element(cbret, "application", xml_name(x), "Element in choice statement already exists") < 0)
goto done;
goto fail;
@ -549,7 +549,7 @@ check_mandatory(cxobj *xt,
cxobj *x;
yang_stmt *y;
yang_stmt *yc;
yang_node *yp;
yang_stmt *yp;
cvec *cvk = NULL; /* vector of index keys */
cg_var *cvi;
char *keyname;
@ -598,7 +598,7 @@ check_mandatory(cxobj *xt,
while ((x = xml_child_each(xt, x, CX_ELMNT)) != NULL) {
if ((y = xml_spec(x)) != NULL &&
(yp = yang_choice(y)) != NULL &&
yp == (yang_node*)yc){
yp == yc){
break; /* leave loop with x set */
}
}
@ -777,7 +777,7 @@ xml_yang_validate_all(cxobj *xt,
/* Special case if leaf is leafref, then first check against
current xml tree
*/
if ((yc = yang_find((yang_node*)ys, Y_TYPE, NULL)) != NULL){
if ((yc = yang_find(ys, Y_TYPE, NULL)) != NULL){
if (strcmp(yc->ys_argument, "leafref") == 0){
if (validate_leafref(xt, yc, cbret) < 0)
goto done;
@ -787,7 +787,7 @@ xml_yang_validate_all(cxobj *xt,
goto done;
}
}
if ((yc = yang_find((yang_node*)ys, Y_MIN_ELEMENTS, NULL)) != NULL){
if ((yc = yang_find(ys, Y_MIN_ELEMENTS, NULL)) != NULL){
/* The behavior of the constraint depends on the type of the
* leaf-list's or list's closest ancestor node in the schema tree
* that is not a non-presence container (see Section 7.5.1):
@ -811,7 +811,7 @@ xml_yang_validate_all(cxobj *xt,
}
#endif
}
if ((yc = yang_find((yang_node*)ys, Y_MAX_ELEMENTS, NULL)) != NULL){
if ((yc = yang_find(ys, Y_MAX_ELEMENTS, NULL)) != NULL){
}
break;
@ -821,14 +821,14 @@ xml_yang_validate_all(cxobj *xt,
/* must sub-node RFC 7950 Sec 7.5.3. Can be several.
* XXX. use yang path instead? */
yc = NULL;
while ((yc = yn_each((yang_node*)ys, yc)) != NULL) {
while ((yc = yn_each(ys, yc)) != NULL) {
if (yc->ys_keyword != Y_MUST)
continue;
xpath = yc->ys_argument; /* "must" has xpath argument */
if ((nr = xpath_vec_bool(xt, "%s", xpath)) < 0)
goto done;
if (!nr){
ye = yang_find((yang_node*)yc, Y_ERROR_MESSAGE, NULL);
ye = yang_find(yc, Y_ERROR_MESSAGE, NULL);
if (netconf_operation_failed(cbret, "application",
ye?ye->ys_argument:"must xpath validation failed") < 0)
goto done;
@ -836,7 +836,7 @@ xml_yang_validate_all(cxobj *xt,
}
}
/* "when" sub-node RFC 7950 Sec 7.21.5. Can only be one. */
if ((yc = yang_find((yang_node*)ys, Y_WHEN, NULL)) != NULL){
if ((yc = yang_find(ys, Y_WHEN, NULL)) != NULL){
xpath = yc->ys_argument; /* "when" has xpath argument */
if ((nr = xpath_vec_bool(xt, "%s", xpath)) < 0)
goto done;
@ -932,7 +932,7 @@ xml2cvec(cxobj *xt,
/* Go through all children of the xml tree */
while ((xc = xml_child_each(xt, xc, CX_ELMNT)) != NULL){
name = xml_name(xc);
if ((ys = yang_find_datanode((yang_node*)yt, name)) == NULL){
if ((ys = yang_find_datanode(yt, name)) == NULL){
clicon_debug(0, "%s: yang sanity problem: %s in xml but not present in yang under %s",
__FUNCTION__, name, yt->ys_argument);
if ((body = xml_body(xc)) != NULL){
@ -1161,7 +1161,7 @@ xml_diff1(yang_stmt *ys,
* Bot xml trees should be freed with xml_free()
*/
int
xml_diff(yang_spec *yspec,
xml_diff(yang_stmt *yspec,
cxobj *x1,
cxobj *x2,
cxobj ***first,
@ -1215,7 +1215,7 @@ yang2api_path_fmt_1(yang_stmt *ys,
int inclkey,
cbuf *cb)
{
yang_node *yp; /* parent */
yang_stmt *yp; /* parent */
int i;
cvec *cvk = NULL; /* vector of index keys */
int retval = -1;
@ -1225,15 +1225,15 @@ yang2api_path_fmt_1(yang_stmt *ys,
goto done;
}
if (yp != NULL && /* XXX rm */
yp->yn_keyword != Y_MODULE &&
yp->yn_keyword != Y_SUBMODULE){
yp->ys_keyword != Y_MODULE &&
yp->ys_keyword != Y_SUBMODULE){
if (yang2api_path_fmt_1((yang_stmt *)yp, 1, cb) < 0) /* recursive call */
goto done;
if (yp->yn_keyword != Y_CHOICE && yp->yn_keyword != Y_CASE)
if (yp->ys_keyword != Y_CHOICE && yp->ys_keyword != Y_CASE)
cprintf(cb, "/");
}
else /* top symbol - mark with name prefix */
cprintf(cb, "/%s:", yp->yn_argument);
cprintf(cb, "/%s:", yp->ys_argument);
if (inclkey){
if (ys->ys_keyword != Y_CHOICE && ys->ys_keyword != Y_CASE)
@ -1241,7 +1241,7 @@ yang2api_path_fmt_1(yang_stmt *ys,
}
else{
if (ys->ys_keyword == Y_LEAF && yp &&
yp->yn_keyword == Y_LIST){
yp->ys_keyword == Y_LIST){
if (yang_key_match(yp, ys->ys_argument) == 0)
cprintf(cb, "%s", ys->ys_argument); /* Not if leaf and key */
}
@ -1521,7 +1521,7 @@ xml_tree_prune_flagged_sub(cxobj *xt,
}
/* If it is key dont remove it yet (see second round) */
if (yt){
if ((iskey = yang_key_match((yang_node*)yt, xml_name(x))) < 0)
if ((iskey = yang_key_match(yt, xml_name(x))) < 0)
goto done;
if (iskey){
anykey++;
@ -1549,7 +1549,7 @@ xml_tree_prune_flagged_sub(cxobj *xt,
while ((x = xml_child_each(xt, x, CX_ELMNT)) != NULL) {
/* If it is key remove it here */
if (yt){
if ((iskey = yang_key_match((yang_node*)yt, xml_name(x))) < 0)
if ((iskey = yang_key_match(yt, xml_name(x))) < 0)
goto done;
if (iskey && xml_purge(x) < 0)
goto done;
@ -1726,7 +1726,7 @@ xml_non_config_data(cxobj *xt,
int
xml_spec_populate_rpc(clicon_handle h,
cxobj *xrpc,
yang_spec *yspec)
yang_stmt *yspec)
{
int retval = -1;
yang_stmt *yrpc = NULL; /* yang node */
@ -1743,12 +1743,12 @@ xml_spec_populate_rpc(clicon_handle h,
if (ys_module_by_xml(yspec, x, &ymod) < 0)
goto done;
if (ymod != NULL)
yrpc = yang_find((yang_node*)ymod, Y_RPC, xml_name(x));
yrpc = yang_find(ymod, Y_RPC, xml_name(x));
/* Non-strict semantics: loop through all modules to find the node
*/
if (yrpc){
xml_spec_set(x, yrpc);
if ((yi = yang_find((yang_node*)yrpc, Y_INPUT, NULL)) != NULL){
if ((yi = yang_find(yrpc, Y_INPUT, NULL)) != NULL){
/* kludge rpc -> input XXX THIS HIDES AN ERROR IN xml_spec_populate */
xml_spec_set(x, yi);
if (xml_apply(x, CX_ELMNT, xml_spec_populate, yspec) < 0)
@ -1777,25 +1777,25 @@ xml_spec_populate(cxobj *x,
{
int retval = -1;
// clicon_handle h = (clicon_handle)arg;
yang_spec *yspec = NULL; /* yang spec */
yang_stmt *yspec = NULL; /* yang spec */
yang_stmt *y = NULL; /* yang node */
yang_stmt *yparent; /* yang parent */
yang_stmt *ymod; /* yang module */
cxobj *xp = NULL; /* xml parent */
char *name;
yspec = (yang_spec*)arg;
yspec = (yang_stmt*)arg;
if (xml_spec(x))
; // goto ok;
xp = xml_parent(x);
name = xml_name(x);
if (xp && (yparent = xml_spec(xp)) != NULL)
y = yang_find_datanode((yang_node*)yparent, name);
y = yang_find_datanode(yparent, name);
else if (yspec){
if (ys_module_by_xml(yspec, x, &ymod) < 0)
goto done;
if (ymod != NULL)
y = yang_find_schemanode((yang_node*)ymod, name);
y = yang_find_schemanode(ymod, name);
}
if (y)
xml_spec_set(x, y);
@ -1848,7 +1848,7 @@ xml_spec_populate(cxobj *x,
* @see api_path2xml For api-path to xml tree
*/
int
api_path2xpath(yang_spec *yspec,
api_path2xpath(yang_stmt *yspec,
cvec *cvv,
int offset,
cbuf *xpath)
@ -1881,10 +1881,10 @@ api_path2xpath(yang_spec *yspec,
clicon_err(OE_YANG, ENOENT, "No such yang module: %s", prefix);
goto fail;
}
y = yang_find_datanode((yang_node*)ymod, name);
y = yang_find_datanode(ymod, name);
}
else
y = yang_find_datanode((yang_node*)y, name);
y = yang_find_datanode(y, name);
if (y == NULL){
clicon_err(OE_YANG, errno, "Unknown element: '%s'", name);
goto fail;
@ -1955,10 +1955,10 @@ static int
api_path2xml_vec(char **vec,
int nvec,
cxobj *x0,
yang_node *y0,
yang_stmt *y0,
yang_class nodeclass,
cxobj **xpathp,
yang_node **ypathp)
yang_stmt **ypathp)
{
int retval = -1;
int j;
@ -1997,22 +1997,22 @@ api_path2xml_vec(char **vec,
/* Split into prefix and localname */
if (nodeid_split(nodeid, &prefix, &name) < 0)
goto done;
if (y0->yn_keyword == Y_SPEC){ /* top-node */
if (y0->ys_keyword == Y_SPEC){ /* top-node */
if (prefix == NULL){
clicon_err(OE_XML, EINVAL, "api-path element '%s', expected prefix:name", nodeid);
goto fail;
}
if ((ymod = yang_find_module_by_name((yang_spec*)y0, prefix)) == NULL){
if ((ymod = yang_find_module_by_name(y0, prefix)) == NULL){
clicon_err(OE_YANG, EINVAL, "api-path element prefix: '%s', no such yang module", prefix);
goto fail;
}
namespace = yang_find_mynamespace(ymod);
y0 = (yang_node*)ymod;
y0 = ymod;
}
y = (nodeclass==YC_SCHEMANODE)?
yang_find_schemanode((yang_node*)y0, name):
yang_find_datanode((yang_node*)y0, name);
yang_find_schemanode(y0, name):
yang_find_datanode(y0, name);
if (y == NULL){
clicon_err(OE_YANG, EINVAL, "api-path name: '%s', no such yang element", name);
goto fail;
@ -2082,7 +2082,7 @@ api_path2xml_vec(char **vec,
goto done;
}
if ((retval = api_path2xml_vec(vec+1, nvec-1,
x, (yang_node*)y,
x, y,
nodeclass,
xpathp, ypathp)) < 1)
goto done;
@ -2127,11 +2127,11 @@ api_path2xml_vec(char **vec,
*/
int
api_path2xml(char *api_path,
yang_spec *yspec,
yang_stmt *yspec,
cxobj *xtop,
yang_class nodeclass,
cxobj **xbotp,
yang_node **ybotp)
yang_stmt **ybotp)
{
int retval = -1;
char **vec = NULL;
@ -2155,7 +2155,7 @@ api_path2xml(char *api_path,
}
nvec--; /* NULL-terminated */
if ((retval = api_path2xml_vec(vec+1, nvec,
xtop, (yang_node*)yspec, nodeclass,
xtop, yspec, nodeclass,
xbotp, ybotp)) < 1)
goto done;
xml_yang_root(*xbotp, &xroot);
@ -2229,7 +2229,7 @@ xmlns_assign(cxobj *x)
*/
static int
xml_merge1(cxobj *x0,
yang_node *y0,
yang_stmt *y0,
cxobj *x0p,
cxobj *x1,
char **reason)
@ -2250,7 +2250,7 @@ xml_merge1(cxobj *x0,
assert(y0);
x1name = xml_name(x1);
if (y0->yn_keyword == Y_LEAF_LIST || y0->yn_keyword == Y_LEAF){
if (y0->ys_keyword == Y_LEAF_LIST || y0->ys_keyword == Y_LEAF){
x1bstr = xml_body(x1);
if (x0==NULL){
if ((x0 = xml_new(x1name, x0p, (yang_stmt*)y0)) == NULL)
@ -2300,7 +2300,7 @@ xml_merge1(cxobj *x0,
x0c = NULL;
if (yc && match_base_child(x0, x1c, yc, &x0c) < 0)
goto done;
if (xml_merge1(x0c, (yang_node*)yc, x0, x1c, reason) < 0)
if (xml_merge1(x0c, yc, x0, x1c, reason) < 0)
goto done;
if (*reason != NULL)
goto ok;
@ -2339,7 +2339,7 @@ xml_merge1(cxobj *x0,
int
xml_merge(cxobj *x0,
cxobj *x1,
yang_spec *yspec,
yang_stmt *yspec,
char **reason)
{
int retval = -1;
@ -2370,7 +2370,7 @@ xml_merge(cxobj *x0,
goto ok;
}
/* Get yang spec of the child */
if ((yc = yang_find_datanode((yang_node*)ymod, x1cname)) == NULL){
if ((yc = yang_find_datanode(ymod, x1cname)) == NULL){
if (reason){
if ((cbr = cbuf_new()) == NULL){
clicon_err(OE_XML, errno, "cbuf_new");
@ -2391,7 +2391,7 @@ xml_merge(cxobj *x0,
* it is treated as a match, and x0c will remain
* If it is overwritten, then x0c should be removed here.
*/
if (xml_merge1(x0c, (yang_node*)yc, x0, x1c, reason) < 0)
if (xml_merge1(x0c, yc, x0, x1c, reason) < 0)
goto done;
if (*reason != NULL)
break;
@ -2422,7 +2422,7 @@ yang_enum_int_value(cxobj *node,
int32_t *val)
{
int retval = -1;
yang_spec *yspec;
yang_stmt *yspec;
yang_stmt *ys;
yang_stmt *ytype;
yang_stmt *yrestype; /* resolved type */
@ -2436,17 +2436,17 @@ yang_enum_int_value(cxobj *node,
goto done;
if ((yspec = ys_spec(ys)) == NULL)
goto done;
if ((ytype = yang_find((yang_node *)ys, Y_TYPE, NULL)) == NULL)
if ((ytype = yang_find(ys, Y_TYPE, NULL)) == NULL)
goto done;
if (yang_type_resolve(ys, ys, ytype, &yrestype,
NULL, NULL, NULL, NULL) < 0)
goto done;
if (yrestype==NULL || strcmp(yrestype->ys_argument, "enumeration"))
goto done;
if ((yenum = yang_find((yang_node *)yrestype, Y_ENUM, xml_body(node))) == NULL)
if ((yenum = yang_find(yrestype, Y_ENUM, xml_body(node))) == NULL)
goto done;
/* Should assign value if yval not found */
if ((yval = yang_find((yang_node *)yenum, Y_VALUE, NULL)) == NULL)
if ((yval = yang_find(yenum, Y_VALUE, NULL)) == NULL)
goto done;
/* reason is string containing why int could not be parsed */
if (parse_int32(yval->ys_argument, val, &reason) < 0)

View file

@ -50,7 +50,7 @@ struct xml_parse_yacc_arg{
cxobj *ya_xelement; /* xml active element */
cxobj *ya_xparent; /* xml parent element*/
int ya_skipspace; /* If set, remove all non-terminal bodies (strip pretty-print) */
yang_spec *ya_yspec; /* If set, top-level yang-spec */
yang_stmt *ya_yspec; /* If set, top-level yang-spec */
int ya_lex_state; /* lex start condition (AMPERSAND) */
};

View file

@ -145,7 +145,7 @@ xml_cv_cache(cxobj *x,
int
xml_child_spec(cxobj *x,
cxobj *xp,
yang_spec *yspec,
yang_stmt *yspec,
yang_stmt **yresult)
{
int retval = -1;
@ -161,11 +161,11 @@ xml_child_spec(cxobj *x,
/* First case: parent already has an associated yang statement,
* then find matching child of that */
if (yparent->ys_keyword == Y_RPC){
if ((yi = yang_find((yang_node*)yparent, Y_INPUT, NULL)) != NULL)
y = yang_find_datanode((yang_node*)yi, name);
if ((yi = yang_find(yparent, Y_INPUT, NULL)) != NULL)
y = yang_find_datanode(yi, name);
}
else
y = yang_find_datanode((yang_node*)yparent, name);
y = yang_find_datanode(yparent, name);
}
else if (yspec){
/* Second case, this is a "root", need to find yang stmt from spec
@ -173,13 +173,13 @@ xml_child_spec(cxobj *x,
if (ys_module_by_xml(yspec, xp, &ymod) < 0)
goto done;
if (ymod != NULL)
y = yang_find_schemanode((yang_node*)ymod, name);
y = yang_find_schemanode(ymod, name);
}
else
y = NULL;
/* kludge rpc -> input */
if (y && y->ys_keyword == Y_RPC && yang_find((yang_node*)y, Y_INPUT, NULL))
y = yang_find((yang_node*)y, Y_INPUT, NULL);
if (y && y->ys_keyword == Y_RPC && yang_find(y, Y_INPUT, NULL))
y = yang_find(y, Y_INPUT, NULL);
*yresult = y;
retval = 0;
done:
@ -256,7 +256,7 @@ xml_cmp(const void* arg1,
* otherwise sort according to key
*/
if (yang_config(y1)==0 ||
yang_find((yang_node*)y1, Y_ORDERED_BY, "user") != NULL){
yang_find(y1, Y_ORDERED_BY, "user") != NULL){
equal = nr1-nr2;
goto done; /* Ordered by user or state data : maintain existing order */
}
@ -349,7 +349,7 @@ xml_cmp1(cxobj *x,
match = strcmp(name, xml_name(x));
break;
case Y_LEAF_LIST: /* Match with name and value */
if (userorder && yang_find((yang_node*)y, Y_ORDERED_BY, "user") != NULL)
if (userorder && yang_find(y, Y_ORDERED_BY, "user") != NULL)
*userorder=1;
if ((b=xml_body(x)) == NULL)
match = 1;
@ -357,7 +357,7 @@ xml_cmp1(cxobj *x,
match = strcmp(keyval[0], b);
break;
case Y_LIST: /* Match with array of key values */
if (userorder && yang_find((yang_node*)y, Y_ORDERED_BY, "user") != NULL)
if (userorder && yang_find(y, Y_ORDERED_BY, "user") != NULL)
*userorder=1;
/* All must match */
for (i=0; i<keynr; i++){
@ -719,8 +719,8 @@ match_base_child(cxobj *x0,
int yorder;
cxobj *x0c = NULL;
yang_stmt *y0c;
yang_node *y0p;
yang_node *yp; /* yang parent */
yang_stmt *y0p;
yang_stmt *yp; /* yang parent */
*x0cp = NULL; /* init return value */
/* Special case is if yc parent (yp) is choice/case

File diff suppressed because it is too large Load diff

View file

@ -524,7 +524,7 @@ yang_cardinality(clicon_handle h,
/* 2) For all in 1 and 1..n list, if 0 such children ->ERROR */
for (yc = &ycplist[0]; (int)yc->yc_parent == pk; yc++){
if (yc->yc_min &&
yang_find((yang_node*)yt, yc->yc_child, NULL) == NULL){
yang_find(yt, yc->yc_child, NULL) == NULL){
clicon_err(OE_YANG, 0, "%s: \"%s\" is missing but is mandatory child of \"%s\"",
modname, yang_key2str(yc->yc_child), yang_key2str(pk));
goto done;
@ -533,7 +533,7 @@ yang_cardinality(clicon_handle h,
/* 3) For all in 0..1 and 1 list, if >1 such children ->ERROR */
for (yc = &ycplist[0]; (int)yc->yc_parent == pk; yc++){
if (yc->yc_max<NMAX &&
(nr = yang_match((yang_node*)yt, yc->yc_child, NULL)) > yc->yc_max){
(nr = yang_match(yt, yc->yc_child, NULL)) > yc->yc_max){
clicon_err(OE_YANG, 0, "%s: \"%s\" has %d children of type \"%s\", but only %d allowed",
modname,
yang_key2str(pk),

View file

@ -111,7 +111,7 @@ int
yang_modules_init(clicon_handle h)
{
int retval = -1;
yang_spec *yspec;
yang_stmt *yspec;
yspec = clicon_dbspec_yang(h);
if (!clicon_option_bool(h, "CLICON_MODULE_LIBRARY_RFC7895"))
@ -143,15 +143,15 @@ yang_modules_init(clicon_handle h)
char *
yang_modules_revision(clicon_handle h)
{
yang_spec *yspec;
yang_stmt *yspec;
yang_stmt *ymod;
yang_stmt *yrev;
char *revision = NULL;
yspec = clicon_dbspec_yang(h);
if ((ymod = yang_find((yang_node*)yspec, Y_MODULE, "ietf-yang-library")) != NULL ||
(ymod = yang_find((yang_node*)yspec, Y_SUBMODULE, "ietf-yang-library")) != NULL){
if ((yrev = yang_find((yang_node*)ymod, Y_REVISION, NULL)) != NULL){
if ((ymod = yang_find(yspec, Y_MODULE, "ietf-yang-library")) != NULL ||
(ymod = yang_find(yspec, Y_SUBMODULE, "ietf-yang-library")) != NULL){
if ((yrev = yang_find(ymod, Y_REVISION, NULL)) != NULL){
revision = yrev->ys_argument;
}
}
@ -162,7 +162,7 @@ yang_modules_revision(clicon_handle h)
*/
static int
yms_build(clicon_handle h,
yang_spec *yspec,
yang_stmt *yspec,
char *msid,
int brief,
cbuf *cb)
@ -175,12 +175,12 @@ yms_build(clicon_handle h,
yang_stmt *ymod; /* generic module */
yang_stmt *yns = NULL; /* namespace */
if ((ylib = yang_find((yang_node*)yspec, Y_MODULE, module)) == NULL &&
(ylib = yang_find((yang_node*)yspec, Y_SUBMODULE, module)) == NULL){
if ((ylib = yang_find(yspec, Y_MODULE, module)) == NULL &&
(ylib = yang_find(yspec, Y_SUBMODULE, module)) == NULL){
clicon_err(OE_YANG, 0, "%s not found", module);
goto done;
}
if ((yns = yang_find((yang_node*)ylib, Y_NAMESPACE, NULL)) == NULL){
if ((yns = yang_find(ylib, Y_NAMESPACE, NULL)) == NULL){
clicon_err(OE_YANG, 0, "%s yang namespace not found", module);
goto done;
}
@ -189,17 +189,17 @@ yms_build(clicon_handle h,
cprintf(cb,"<module-set-id>%s</module-set-id>", msid);
ymod = NULL;
while ((ymod = yn_each((yang_node*)yspec, ymod)) != NULL) {
while ((ymod = yn_each(yspec, ymod)) != NULL) {
if (ymod->ys_keyword != Y_MODULE &&
ymod->ys_keyword != Y_SUBMODULE)
continue;
cprintf(cb,"<module>");
cprintf(cb,"<name>%s</name>", ymod->ys_argument);
if ((ys = yang_find((yang_node*)ymod, Y_REVISION, NULL)) != NULL)
if ((ys = yang_find(ymod, Y_REVISION, NULL)) != NULL)
cprintf(cb,"<revision>%s</revision>", ys->ys_argument);
else
cprintf(cb,"<revision></revision>");
if ((ys = yang_find((yang_node*)ymod, Y_NAMESPACE, NULL)) != NULL)
if ((ys = yang_find(ymod, Y_NAMESPACE, NULL)) != NULL)
cprintf(cb,"<namespace>%s</namespace>", ys->ys_argument);
else
cprintf(cb,"<namespace></namespace>");
@ -207,7 +207,7 @@ yms_build(clicon_handle h,
submodules */
if (!brief){
yc = NULL;
while ((yc = yn_each((yang_node*)ymod, yc)) != NULL) {
while ((yc = yn_each(ymod, yc)) != NULL) {
switch(yc->ys_keyword){
case Y_FEATURE:
if (yc->ys_cv && cv_bool_get(yc->ys_cv))
@ -220,12 +220,12 @@ yms_build(clicon_handle h,
cprintf(cb, "<conformance-type>implement</conformance-type>");
}
yc = NULL;
while ((yc = yn_each((yang_node*)ymod, yc)) != NULL) {
while ((yc = yn_each(ymod, yc)) != NULL) {
switch(yc->ys_keyword){
case Y_SUBMODULE:
cprintf(cb,"<submodule>");
cprintf(cb,"<name>%s</name>", yc->ys_argument);
if ((ys = yang_find((yang_node*)yc, Y_REVISION, NULL)) != NULL)
if ((ys = yang_find(yc, Y_REVISION, NULL)) != NULL)
cprintf(cb,"<revision>%s</revision>", ys->ys_argument);
else
cprintf(cb,"<revision></revision>");
@ -273,7 +273,7 @@ x +--ro namespace inet:uri
*/
int
yang_modules_state_get(clicon_handle h,
yang_spec *yspec,
yang_stmt *yspec,
char *xpath,
int brief,
cxobj **xret)
@ -362,7 +362,7 @@ mod_ns_upgrade(clicon_handle h,
uint32_t from = 0;
uint32_t to = 0;
int ret;
yang_spec *yspec;
yang_stmt *yspec;
/* Make upgrade callback for this XML, specifying the module
* namespace, from and to revision.
@ -376,7 +376,7 @@ mod_ns_upgrade(clicon_handle h,
yspec = clicon_dbspec_yang(h);
if ((ymod = yang_find_module_by_namespace(yspec, ns)) == NULL)
goto fail;
if ((yrev = yang_find((yang_node*)ymod, Y_REVISION, NULL)) == NULL)
if ((yrev = yang_find(ymod, Y_REVISION, NULL)) == NULL)
goto fail;
if (ys_parse_date_arg(yrev->ys_argument, &to) < 0)
goto done;

View file

@ -47,7 +47,7 @@
struct ys_stack{
struct ys_stack *ys_next;
struct yang_node *ys_node;
yang_stmt *ys_node;
};
struct clicon_yang_yacc_arg{ /* XXX: mostly unrelevant */
@ -88,7 +88,7 @@ extern char *clixon_yang_parsetext;
int yang_scan_init(struct clicon_yang_yacc_arg *ya);
int yang_scan_exit(struct clicon_yang_yacc_arg *ya);
int yang_parse_init(struct clicon_yang_yacc_arg *ya, yang_spec *ysp);
int yang_parse_init(struct clicon_yang_yacc_arg *ya, yang_stmt *ysp);
int yang_parse_exit(struct clicon_yang_yacc_arg *ya);
int clixon_yang_parselex(void *_ya);
@ -96,6 +96,6 @@ int clixon_yang_parseparse(void *);
void clixon_yang_parseerror(void *_ya, char*);
int ystack_pop(struct clicon_yang_yacc_arg *ya);
struct ys_stack *ystack_push(struct clicon_yang_yacc_arg *ya, yang_node *yn);
struct ys_stack *ystack_push(struct clicon_yang_yacc_arg *ya, yang_stmt *yn);
#endif /* _CLIXON_YANG_PARSE_H_ */

View file

@ -218,7 +218,7 @@ clixon_yang_parseerror(void *_yy,
int
yang_parse_init(struct clicon_yang_yacc_arg *yy,
yang_spec *ysp)
yang_stmt *ysp)
{
return 0;
}
@ -246,7 +246,7 @@ ystack_pop(struct clicon_yang_yacc_arg *yy)
struct ys_stack *
ystack_push(struct clicon_yang_yacc_arg *yy,
yang_node *yn)
yang_stmt *yn)
{
struct ys_stack *ystack;
@ -278,7 +278,7 @@ ysp_add(struct clicon_yang_yacc_arg *yy,
{
struct ys_stack *ystack = yy->yy_stack;
yang_stmt *ys = NULL;
yang_node *yn;
yang_stmt *yn;
ystack = yy->yy_stack;
if (ystack == NULL){
@ -317,7 +317,7 @@ ysp_add_push(struct clicon_yang_yacc_arg *yy,
if ((ys = ysp_add(yy, keyword, argument, extra)) == NULL)
return NULL;
if (ystack_push(yy, (yang_node*)ys) == NULL)
if (ystack_push(yy, ys) == NULL)
return NULL;
return ys;
}

View file

@ -474,7 +474,7 @@ cv_validate1(cg_var *cv,
if (strcmp(restype, "enumeration") == 0){
found = 0;
yi = NULL;
while ((yi = yn_each((yang_node*)yrestype, yi)) != NULL){
while ((yi = yn_each(yrestype, yi)) != NULL){
if (yi->ys_keyword != Y_ENUM)
continue;
if (strcmp(yi->ys_argument, str) == 0){
@ -500,7 +500,7 @@ cv_validate1(cg_var *cv,
continue;
found = 0;
yi = NULL;
while ((yi = yn_each((yang_node*)yrestype, yi)) != NULL){
while ((yi = yn_each(yrestype, yi)) != NULL){
if (yi->ys_keyword != Y_BIT)
continue;
if (strcmp(yi->ys_argument, v) == 0){
@ -630,7 +630,7 @@ ys_cv_validate_union(yang_stmt *ys,
yang_stmt *yt = NULL;
char *reason1 = NULL; /* saved reason */
while ((yt = yn_each((yang_node*)yrestype, yt)) != NULL){
while ((yt = yn_each(yrestype, yt)) != NULL){
if (yt->ys_keyword != Y_TYPE)
continue;
if ((retval = ys_cv_validate_union_one(ys, reason, yt, type, val)) < 0)
@ -744,12 +744,12 @@ ys_typedef(yang_stmt *ys)
static yang_stmt *
ys_typedef_up(yang_stmt *ys)
{
yang_node *yn;
yang_stmt *yn;
while (ys != NULL && !ys_typedef(ys)){
yn = ys->ys_parent;
/* Some extra stuff to ensure ys is a stmt */
if (yn && yn->yn_keyword == Y_SPEC)
if (yn && yn->ys_keyword == Y_SPEC)
yn = NULL;
ys = (yang_stmt*)yn;
}
@ -791,7 +791,7 @@ yang_find_identity(yang_stmt *ys,
char *prefix = NULL;
yang_stmt *ymodule;
yang_stmt *yid = NULL;
yang_node *yn;
yang_stmt *yn;
if ((id = strchr(identity, ':')) == NULL)
id = identity;
@ -804,7 +804,7 @@ yang_find_identity(yang_stmt *ys,
if (prefix){ /* Go to top and find import that matches */
if ((ymodule = yang_find_module_by_prefix(ys, prefix)) == NULL)
goto done;
yid = yang_find((yang_node*)ymodule, Y_IDENTITY, id);
yid = yang_find(ymodule, Y_IDENTITY, id);
}
else{
while (1){
@ -812,11 +812,11 @@ yang_find_identity(yang_stmt *ys,
if ((ys = ys_typedef_up(ys)) == NULL) /* If reach top */
break;
/* Here find identity */
if ((yid = yang_find((yang_node*)ys, Y_IDENTITY, id)) != NULL)
if ((yid = yang_find(ys, Y_IDENTITY, id)) != NULL)
break;
/* Did not find a matching typedef there, proceed to next level */
yn = ys->ys_parent;
if (yn && yn->yn_keyword == Y_SPEC)
if (yn && yn->ys_keyword == Y_SPEC)
yn = NULL;
ys = (yang_stmt*)yn;
}
@ -910,7 +910,7 @@ yang_type_resolve(yang_stmt *yorig,
char *type;
char *prefix = NULL;
int retval = -1;
yang_node *yn;
yang_stmt *yn;
yang_stmt *yrmod; /* module where resolved type is looked for */
if (options)
@ -926,10 +926,10 @@ yang_type_resolve(yang_stmt *yorig,
goto ok;
}
/* Resolving type restrictions */
yrange = yang_find((yang_node*)ytype, Y_RANGE, NULL);
ylength = yang_find((yang_node*)ytype, Y_LENGTH, NULL);
ypattern = yang_find((yang_node*)ytype, Y_PATTERN, NULL);
yfraction = yang_find((yang_node*)ytype, Y_FRACTION_DIGITS, NULL);
yrange = yang_find(ytype, Y_RANGE, NULL);
ylength = yang_find(ytype, Y_LENGTH, NULL);
ypattern = yang_find(ytype, Y_PATTERN, NULL);
yfraction = yang_find(ytype, Y_FRACTION_DIGITS, NULL);
/* Check if type is basic type. If so, return that */
if (prefix == NULL && yang_builtin(type)){
@ -946,7 +946,7 @@ yang_type_resolve(yang_stmt *yorig,
prefix, type, ys_module(yorig)->ys_argument);
goto done;
}
if ((rytypedef = yang_find((yang_node*)yrmod, Y_TYPEDEF, type)) == NULL)
if ((rytypedef = yang_find(yrmod, Y_TYPEDEF, type)) == NULL)
goto ok; /* unresolved */
ys = rytypedef;
}
@ -958,17 +958,17 @@ yang_type_resolve(yang_stmt *yorig,
break;
}
/* Here find typedef */
if ((rytypedef = yang_find((yang_node*)ys, Y_TYPEDEF, type)) != NULL)
if ((rytypedef = yang_find(ys, Y_TYPEDEF, type)) != NULL)
break;
/* Did not find a matching typedef there, proceed to next level */
yn = ys->ys_parent;
if (yn && (yn->yn_keyword == Y_SPEC))
if (yn && (yn->ys_keyword == Y_SPEC))
yn = NULL;
ys = (yang_stmt*)yn;
}
if (rytypedef != NULL){ /* We have found a typedef */
/* Find associated type statement */
if ((rytype = yang_find((yang_node*)rytypedef, Y_TYPE, NULL)) == NULL){
if ((rytype = yang_find(rytypedef, Y_TYPE, NULL)) == NULL){
clicon_err(OE_DB, 0, "mandatory type object is not found");
goto done;
}
@ -1045,7 +1045,7 @@ yang_type_get(yang_stmt *ys,
if (options)
*options = 0x0;
/* Find mandatory type */
if ((ytype = yang_find((yang_node*)ys, Y_TYPE, NULL)) == NULL){
if ((ytype = yang_find(ys, Y_TYPE, NULL)) == NULL){
clicon_err(OE_DB, 0, "mandatory type object is not found");
goto done;
}

View file

@ -103,7 +103,7 @@ main(int argc, char **argv)
char *argv0;
char *db = "running";
char *cmd = NULL;
yang_spec *yspec = NULL;
yang_stmt *yspec = NULL;
char *yangfilename = NULL;
char *dbdir = NULL;
int ret;

View file

@ -79,7 +79,7 @@ usage(char *argv0)
int
main(int argc, char **argv)
{
yang_spec *yspec = NULL;
yang_stmt *yspec = NULL;
int c;
int logdst = CLICON_LOG_STDERR;
@ -109,7 +109,7 @@ main(int argc, char **argv)
fprintf(stderr, "yang parse error %s\n", clicon_err_reason);
return -1;
}
yang_print(stdout, (yang_node*)yspec);
yang_print(stdout, yspec);
done:
if (yspec)
yspec_free(yspec);