Pagination draft
This commit is contained in:
parent
ab0bc0ea4b
commit
78f5a6983c
15 changed files with 1206 additions and 86 deletions
|
|
@ -196,7 +196,7 @@ instance_id_parse(char *path,
|
|||
return retval;
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
clixon_path_free(clixon_path *cplist)
|
||||
{
|
||||
clixon_path *cp;
|
||||
|
|
@ -1765,7 +1765,7 @@ clixon_xml_find_instance_id(cxobj *xt,
|
|||
* example.
|
||||
* @param[in] yt Yang statement of top symbol (can be yang-spec if top-level)
|
||||
* @param[out] nsctx Namespace context (should be created on entry)
|
||||
* @param[in] format Format string for api-path syntax
|
||||
* @param[in] format Format string for xpath syntax
|
||||
* @retval -1 Error
|
||||
* @retval 0 Non-fatal failure, yang bind failures, etc,
|
||||
* @retval 1 OK with found xml nodes in xvec (if any)
|
||||
|
|
@ -1850,3 +1850,68 @@ clixon_instance_id_bind(yang_stmt *yt,
|
|||
retval = 0;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*! Given (instance-id) path and YANG, parse path, resolve YANG and return parse-tree
|
||||
*
|
||||
* Instance-identifier is a subset of XML XPaths and defined in Yang, used in NACM for
|
||||
* example.
|
||||
* @param[in] yt Yang statement of top symbol (can be yang-spec if top-level)
|
||||
* @param[out] cplistp Path parse-tree
|
||||
* @param[in] format Format string for xpath syntax
|
||||
* @retval -1 Error
|
||||
* @retval 0 Non-fatal failure, yang bind failures, etc,
|
||||
* @retval 1 OK with found xml nodes in xvec (if any)
|
||||
*/
|
||||
int
|
||||
clixon_instance_id_parse(yang_stmt *yt,
|
||||
clixon_path **cplistp,
|
||||
const char *format,
|
||||
...)
|
||||
{
|
||||
int retval = -1;
|
||||
va_list ap;
|
||||
size_t len;
|
||||
char *path = NULL;
|
||||
clixon_path *cplist = NULL;
|
||||
int ret;
|
||||
|
||||
va_start(ap, format);
|
||||
len = vsnprintf(NULL, 0, format, ap);
|
||||
va_end(ap);
|
||||
/* allocate a path string exactly fitting the length */
|
||||
if ((path = malloc(len+1)) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "malloc");
|
||||
goto done;
|
||||
}
|
||||
/* second round: actually compute api-path string content */
|
||||
va_start(ap, format);
|
||||
if (vsnprintf(path, len+1, format, ap) < 0){
|
||||
clicon_err(OE_UNIX, errno, "vsnprintf");
|
||||
va_end(ap);
|
||||
goto done;
|
||||
}
|
||||
va_end(ap);
|
||||
if (instance_id_parse(path, &cplist) < 0)
|
||||
goto done;
|
||||
if (clicon_debug_get())
|
||||
clixon_path_print(stderr, cplist);
|
||||
/* Resolve module:name to pointer to yang-stmt, fail if not successful */
|
||||
if ((ret = instance_id_resolve(cplist, yt)) < 0)
|
||||
goto done;
|
||||
if (ret == 0)
|
||||
goto fail;
|
||||
if (cplistp){
|
||||
*cplistp = cplist;
|
||||
cplist = NULL;
|
||||
}
|
||||
retval = 1;
|
||||
done:
|
||||
if (cplist)
|
||||
clixon_path_free(cplist);
|
||||
if (path)
|
||||
free(path);
|
||||
return retval;
|
||||
fail:
|
||||
retval = 0;
|
||||
goto done;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue