diff --git a/lib/clixon/clixon_xml_nsctx.h b/lib/clixon/clixon_xml_nsctx.h index 5c815f25..8d7d3f13 100644 --- a/lib/clixon/clixon_xml_nsctx.h +++ b/lib/clixon/clixon_xml_nsctx.h @@ -59,6 +59,7 @@ int xml_nsctx_add(cvec *nsc, char *prefix, char *ns); int xml_nsctx_node(cxobj *x, cvec **ncp); int xml_nsctx_yang(yang_stmt *yn, cvec **ncp); int xml_nsctx_yangspec(yang_stmt *yspec, cvec **ncp); +int xml_nsctx_cbuf(cbuf *cb, cvec *nsc); int xml2ns(cxobj *x, char *localname, char **ns); int xml2ns_recurse(cxobj *x); diff --git a/lib/src/clixon_proc.c b/lib/src/clixon_proc.c index 30709bab..dd1c28a7 100644 --- a/lib/src/clixon_proc.c +++ b/lib/src/clixon_proc.c @@ -234,8 +234,10 @@ clixon_proc_background(char **argv, goto done; } if (child == 0) { /* Child */ +#ifdef HAVE_SETNS char nsfile[PATH_MAX]; int nsfd; +#endif clicon_debug(1, "%s child", __FUNCTION__); clicon_signal_unblock(0); diff --git a/lib/src/clixon_proto_client.c b/lib/src/clixon_proto_client.c index 8d7b4758..d5a079f6 100644 --- a/lib/src/clixon_proto_client.c +++ b/lib/src/clixon_proto_client.c @@ -327,8 +327,6 @@ clicon_rpc_get_config(clicon_handle h, cxobj *xret = NULL; cxobj *xerr = NULL; cxobj *xd; - cg_var *cv = NULL; - char *prefix; uint32_t session_id; int ret; yang_stmt *yspec; @@ -349,12 +347,8 @@ clicon_rpc_get_config(clicon_handle h, cprintf(cb, "<%s:filter %s:type=\"xpath\" %s:select=\"%s\"", NETCONF_BASE_PREFIX, NETCONF_BASE_PREFIX, NETCONF_BASE_PREFIX, xpath); - while ((cv = cvec_each(nsc, cv)) != NULL){ - cprintf(cb, " xmlns"); - if ((prefix = cv_name_get(cv))) - cprintf(cb, ":%s", prefix); - cprintf(cb, "=\"%s\"", cv_string_get(cv)); - } + if (xml_nsctx_cbuf(cb, nsc) < 0) + goto done; cprintf(cb, "/>"); } cprintf(cb, ""); @@ -689,8 +683,6 @@ clicon_rpc_get(clicon_handle h, cxobj *xerr = NULL; cxobj *xd; char *username; - cg_var *cv = NULL; - char *prefix; uint32_t session_id; int ret; yang_stmt *yspec; @@ -716,13 +708,8 @@ clicon_rpc_get(clicon_handle h, cprintf(cb, "<%s:filter %s:type=\"xpath\" %s:select=\"%s\"", NETCONF_BASE_PREFIX, NETCONF_BASE_PREFIX, NETCONF_BASE_PREFIX, xpath); - - while ((cv = cvec_each(nsc, cv)) != NULL){ - cprintf(cb, " xmlns"); - if ((prefix = cv_name_get(cv))) - cprintf(cb, ":%s", prefix); - cprintf(cb, "=\"%s\"", cv_string_get(cv)); - } + if (xml_nsctx_cbuf(cb, nsc) < 0) + goto done; cprintf(cb, "/>"); } cprintf(cb, ""); diff --git a/lib/src/clixon_xml_nsctx.c b/lib/src/clixon_xml_nsctx.c index 77e6161d..a877a9e7 100644 --- a/lib/src/clixon_xml_nsctx.c +++ b/lib/src/clixon_xml_nsctx.c @@ -440,6 +440,33 @@ xml_nsctx_yangspec(yang_stmt *yspec, return retval; } +/*! Print a namespace context to a cbuf using xmlns notation + * @param[in] *cb CLIgen buf written to + * @param[in] *nsc Namespace context + * @retval 0 OK + * @code + * cbuf *cb = cbuf_new(); + * cprintf(cb, " $cfg $cfg