completing the function of hide for autocli-op in the yang files
This commit is contained in:
parent
8ca5944111
commit
c370ac8706
16 changed files with 98 additions and 44 deletions
|
|
@ -713,7 +713,7 @@ xmldb_get_nocache(clicon_handle h,
|
|||
clicon_log(LOG_NOTICE, "%s: sort verify failed #2", __FUNCTION__);
|
||||
#endif
|
||||
if (clicon_debug_get()>1)
|
||||
clicon_xml2file(stderr, xt, 0, 1);
|
||||
clicon_xml2file(stderr, xt, 0, 1, 0);
|
||||
*xtop = xt;
|
||||
xt = NULL;
|
||||
retval = 1;
|
||||
|
|
@ -872,7 +872,7 @@ xmldb_get_cache(clicon_handle h,
|
|||
* If cache was empty, also update to datastore cache
|
||||
*/
|
||||
if (clicon_debug_get()>1)
|
||||
clicon_xml2file(stderr, x1t, 0, 1);
|
||||
clicon_xml2file(stderr, x1t, 0, 1, 0);
|
||||
*xtop = x1t;
|
||||
retval = 1;
|
||||
done:
|
||||
|
|
@ -971,7 +971,7 @@ xmldb_get_zerocopy(clicon_handle h,
|
|||
goto done;
|
||||
}
|
||||
if (clicon_debug_get()>1)
|
||||
clicon_xml2file(stderr, x0t, 0, 1);
|
||||
clicon_xml2file(stderr, x0t, 0, 1, 0);
|
||||
*xtop = x0t;
|
||||
retval = 1;
|
||||
done:
|
||||
|
|
|
|||
|
|
@ -1043,7 +1043,7 @@ xmldb_put(clicon_handle h,
|
|||
if (xml2json(f, x0, pretty) < 0)
|
||||
goto done;
|
||||
}
|
||||
else if (clicon_xml2file(f, x0, 0, pretty) < 0)
|
||||
else if (clicon_xml2file(f, x0, 0, pretty, 0) < 0)
|
||||
goto done;
|
||||
/* Remove modules state after writing to file
|
||||
*/
|
||||
|
|
@ -1101,7 +1101,7 @@ xmldb_dump(clicon_handle h,
|
|||
if (xml2json(f, xt, pretty) < 0)
|
||||
goto done;
|
||||
}
|
||||
else if (clicon_xml2file(f, xt, 0, pretty) < 0)
|
||||
else if (clicon_xml2file(f, xt, 0, pretty, 0) < 0)
|
||||
goto done;
|
||||
retval = 0;
|
||||
done:
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@
|
|||
* @param[in] level how many spaces to insert before each line
|
||||
* @param[in] prettyprint insert \n and spaces tomake the xml more readable.
|
||||
* @param[in] fn Callback to make print function
|
||||
* @param[in] used_for_show_command is the function used for a cli show command.
|
||||
* @see clicon_xml2cbuf
|
||||
* One can use clicon_xml2cbuf to get common code, but using fprintf is
|
||||
* much faster than using cbuf and then printing that,...
|
||||
|
|
@ -103,7 +104,8 @@ xml2file_recurse(FILE *f,
|
|||
cxobj *x,
|
||||
int level,
|
||||
int prettyprint,
|
||||
clicon_output_cb *fn)
|
||||
clicon_output_cb *fn,
|
||||
int used_for_show_command)
|
||||
{
|
||||
int retval = -1;
|
||||
char *name;
|
||||
|
|
@ -113,9 +115,17 @@ xml2file_recurse(FILE *f,
|
|||
int haselement;
|
||||
char *val;
|
||||
char *encstr = NULL; /* xml encoded string */
|
||||
|
||||
char *opext = NULL;
|
||||
|
||||
if (x == NULL)
|
||||
goto ok;
|
||||
/* Look for autocli-op defined in clixon-lib.yang */
|
||||
if (yang_extension_value(xml_spec(x), "autocli-op", CLIXON_LIB_NS, &opext) < 0) {
|
||||
goto ok;
|
||||
}
|
||||
if ((used_for_show_command == 1) && (opext != NULL) && ((strcmp(opext, "hide-database") == 0) || (strcmp(opext, "hide-database-auto-completion") == 0))){
|
||||
goto ok;
|
||||
}
|
||||
name = xml_name(x);
|
||||
namespace = xml_prefix(x);
|
||||
switch(xml_type(x)){
|
||||
|
|
@ -144,7 +154,7 @@ xml2file_recurse(FILE *f,
|
|||
while ((xc = xml_child_each(x, xc, -1)) != NULL) {
|
||||
switch (xml_type(xc)){
|
||||
case CX_ATTR:
|
||||
if (xml2file_recurse(f, xc, level+1, prettyprint, fn) <0)
|
||||
if (xml2file_recurse(f, xc, level+1, prettyprint, fn, used_for_show_command) <0)
|
||||
goto done;
|
||||
break;
|
||||
case CX_BODY:
|
||||
|
|
@ -169,7 +179,7 @@ xml2file_recurse(FILE *f,
|
|||
xc = NULL;
|
||||
while ((xc = xml_child_each(x, xc, -1)) != NULL) {
|
||||
if (xml_type(xc) != CX_ATTR)
|
||||
if (xml2file_recurse(f, xc, level+1, prettyprint, fn) <0)
|
||||
if (xml2file_recurse(f, xc, level+1, prettyprint, fn, used_for_show_command) <0)
|
||||
goto done;
|
||||
}
|
||||
if (prettyprint && hasbody==0)
|
||||
|
|
@ -199,6 +209,7 @@ xml2file_recurse(FILE *f,
|
|||
* @param[in] xn clicon xml tree
|
||||
* @param[in] level how many spaces to insert before each line
|
||||
* @param[in] prettyprint insert \n and spaces tomake the xml more readable.
|
||||
* @param[in] used_for_show_command is the function used for a cli show command.
|
||||
* @see clicon_xml2cbuf print to a cbuf string
|
||||
* @see clicon_xml2cbuf_cb print using a callback
|
||||
*/
|
||||
|
|
@ -206,9 +217,10 @@ int
|
|||
clicon_xml2file(FILE *f,
|
||||
cxobj *x,
|
||||
int level,
|
||||
int prettyprint)
|
||||
int prettyprint,
|
||||
int used_for_show_command)
|
||||
{
|
||||
return xml2file_recurse(f, x, level, prettyprint, fprintf);
|
||||
return xml2file_recurse(f, x, level, prettyprint, fprintf, used_for_show_command);
|
||||
}
|
||||
|
||||
/*! Print an XML tree structure to an output stream and encode chars "<>&"
|
||||
|
|
@ -217,6 +229,7 @@ clicon_xml2file(FILE *f,
|
|||
* @param[in] xn clicon xml tree
|
||||
* @param[in] level how many spaces to insert before each line
|
||||
* @param[in] prettyprint insert \n and spaces tomake the xml more readable.
|
||||
* @param[in] used_for_show_command is the function used for a cli show command.
|
||||
* @see clicon_xml2cbuf
|
||||
*/
|
||||
int
|
||||
|
|
@ -224,9 +237,10 @@ clicon_xml2file_cb(FILE *f,
|
|||
cxobj *x,
|
||||
int level,
|
||||
int prettyprint,
|
||||
clicon_output_cb *fn)
|
||||
clicon_output_cb *fn,
|
||||
int used_for_show_command)
|
||||
{
|
||||
return xml2file_recurse(f, x, level, prettyprint, fn);
|
||||
return xml2file_recurse(f, x, level, prettyprint, fn, used_for_show_command);
|
||||
}
|
||||
|
||||
/*! Print an XML tree structure to an output stream
|
||||
|
|
@ -235,6 +249,7 @@ clicon_xml2file_cb(FILE *f,
|
|||
*
|
||||
* @param[in] f UNIX output stream
|
||||
* @param[in] xn clicon xml tree
|
||||
* used_for_show_command
|
||||
* @see clicon_xml2cbuf
|
||||
* @see clicon_xml2cbuf_cb print using a callback
|
||||
*/
|
||||
|
|
@ -242,7 +257,7 @@ int
|
|||
xml_print(FILE *f,
|
||||
cxobj *x)
|
||||
{
|
||||
return xml2file_recurse(f, x, 0, 1, fprintf);
|
||||
return xml2file_recurse(f, x, 0, 1, fprintf, 0);
|
||||
}
|
||||
|
||||
/*! Print an XML tree structure to a cligen buffer and encode chars "<>&"
|
||||
|
|
|
|||
|
|
@ -144,11 +144,19 @@ xml2txt_recurse(FILE *f,
|
|||
cxobj *xc = NULL;
|
||||
int children=0;
|
||||
int retval = -1;
|
||||
char *opext = NULL;
|
||||
|
||||
if (f == NULL || x == NULL || fn == NULL){
|
||||
clicon_err(OE_XML, EINVAL, "f, x or fn is NULL");
|
||||
goto done;
|
||||
}
|
||||
/* Look for autocli-op defined in clixon-lib.yang */
|
||||
if (yang_extension_value(xml_spec(x), "autocli-op", CLIXON_LIB_NS, &opext) < 0) {
|
||||
goto ok;
|
||||
}
|
||||
if ((opext != NULL) && ((strcmp(opext, "hide-database") == 0) || (strcmp(opext, "hide-database-auto-completion") == 0))){
|
||||
goto ok;
|
||||
}
|
||||
xc = NULL; /* count children (elements and bodies, not attributes) */
|
||||
while ((xc = xml_child_each(x, xc, -1)) != NULL)
|
||||
if (xml_type(xc) == CX_ELMNT || xml_type(xc) == CX_BODY)
|
||||
|
|
@ -233,11 +241,19 @@ xml2cli_recurse(FILE *f,
|
|||
yang_stmt *ys;
|
||||
int match;
|
||||
char *body;
|
||||
char *opext = NULL;
|
||||
|
||||
if (xml_type(x)==CX_ATTR)
|
||||
goto ok;
|
||||
if ((ys = xml_spec(x)) == NULL)
|
||||
goto ok;
|
||||
/* Look for autocli-op defined in clixon-lib.yang */
|
||||
if (yang_extension_value(xml_spec(x), "autocli-op", CLIXON_LIB_NS, &opext) < 0) {
|
||||
goto ok;
|
||||
}
|
||||
if ((opext != NULL) && ((strcmp(opext, "hide-database") == 0) || (strcmp(opext, "hide-database-auto-completion") == 0))){
|
||||
goto ok;
|
||||
}
|
||||
/* If leaf/leaf-list or presence container, then print line */
|
||||
if (yang_keyword_get(ys) == Y_LEAF ||
|
||||
yang_keyword_get(ys) == Y_LEAF_LIST){
|
||||
|
|
|
|||
|
|
@ -341,7 +341,7 @@ clixon_xvec_print(FILE *f,
|
|||
int i;
|
||||
|
||||
for (i=0; i<xv->xv_len; i++)
|
||||
clicon_xml2file(f, xv->xv_vec[i], 0, 1);
|
||||
clicon_xml2file(f, xv->xv_vec[i], 0, 1, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue