* Protyped netconf native pagination

This commit is contained in:
Olof hagsand 2021-08-19 13:37:45 +02:00
parent 6bf3112fe7
commit b03cf426a4
8 changed files with 493 additions and 85 deletions

View file

@ -1543,6 +1543,11 @@ netconf_module_load(clicon_handle h)
if (yang_spec_parse_module(h, "ietf-list-pagination", NULL, yspec)< 0)
goto done;
#endif
#ifdef CLIXON_PAGINATION
/* Load clixon netconf list pagination */
if (yang_spec_parse_module(h, "clixon-netconf-list-pagination", NULL, yspec)< 0)
goto done;
#endif
#endif
retval = 0;
done:

View file

@ -75,6 +75,7 @@
#include <stdint.h>
#include <syslog.h>
#include <fcntl.h>
#include <math.h> /* NaN */
/* cligen */
#include <cligen/cligen.h>
@ -1064,3 +1065,41 @@ xpath2canonical(const char *xpath0,
xpath_tree_free(xpt);
return retval;
}
/*! Return a count(xpath)
*
* @param[in] xcur xml-tree where to search
* @param[in] nsc External XML namespace context, or NULL
* @param[in] xpath XPATH syntax
* @param[oit] count Nr of elements of xpath
* @note This function is made for making optimizations in certain circumstances, such as a list
*/
int
xpath_count(cxobj *xcur,
cvec *nsc,
const char *xpath,
uint32_t *count)
{
int retval = -1;
xp_ctx *xc = NULL;
cbuf *cb = NULL;
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_UNIX, errno, "cbuf_new");
goto done;
}
cprintf(cb, "count(%s)", xpath);
if (xpath_vec_ctx(xcur, nsc, cbuf_get(cb), 0, &xc) < 0)
goto done;
if (xc && xc->xc_type == XT_NUMBER && xc->xc_number != NAN)
*count = (uint32_t)xc->xc_number;
else
*count = 0;
retval = 0;
done:
if (cb)
cbuf_free(cb);
if (xc)
ctx_free(xc);
return retval;
}