FAQ and example

This commit is contained in:
Olof hagsand 2016-02-23 22:49:22 +01:00
parent 33fac8a4c6
commit 554c1cb9de
7 changed files with 124 additions and 6 deletions

View file

@ -55,3 +55,31 @@ plugin_init(clicon_handle h)
return 0;
}
/*! Example cli function */
int
mycallback(clicon_handle h, cvec *cvv, cg_var *arg)
{
int retval = -1;
cxobj *xt = NULL;
yang_spec *yspec;
cg_var *myvar;
/* Access cligen callback variables */
myvar = cvec_find(cvv, "var"); /* get a cligen variable from vector */
cli_output(stderr, "%s: %d\n", __FUNCTION__, cv_int32_get(myvar)); /* get int value */
cli_output(stderr, "arg = %s\n", cv_string_get(arg)); /* get string value */
/* Show eth0 interfaces config using XPATH */
yspec = clicon_dbspec_yang(h);
if (xmldb_get(clicon_candidate_db(h),
"/interfaces/interface[name=eth0]",
yspec,
&xt) < 0)
goto done;
clicon_xml2file(stdout, xt, 0, 1);
retval = 0;
done:
if (xt)
xml_free(xt);
return retval;
}