/*
* ext_current () -- Defines the Xpath extension current(),
* defined by Yang RFC.
*
* From Yang RFC 7950:
*
* The current() function takes no input parameters and returns a node
* set with the initial context node as its only member.
*/
static void
ext_current (xmlXPathParserContextPtr ctxt, int nargs)
{
/*
* This function takes 0 args.
*/
if (nargs != 0) {
return;
}
/* Push the current context node onto Xpath Stack */
valuePush(ctxt, xmlXPathNewNodeSet(ctxt->context->node));
}
/*
* register_yang_xpath_extensions () -- Registers extensions defined by Yang
* RFC. These extensions are implemented internally in Junos.
*/
static void
register_yang_xpath_extensions (xmlXPathContextPtr ctxt)
{
int rc = 0;
rc = xmlXPathRegisterFunc(ctxt, (const xmlChar *)"current",
ext_current);
if (rc != 0)
fprintf(stderr, "Error in registering current() func\n");
}