CliXoN
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Macros | Functions
cli_generate.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <assert.h>
#include <fcntl.h>
#include <sys/param.h>
#include <cligen/cligen.h>
#include <clixon/clixon.h>
#include "clixon_cli_api.h"
#include "cli_plugin.h"
#include "cli_generate.h"

Macros

#define GENERATE_CALLBACK   "cli_set"
 
#define GENERATE_EXPAND_XMLDB   "expand_dbvar"
 

Functions

static int cli_expand_var_generate (clicon_handle h, yang_stmt *ys, enum cv_type cvtype, cbuf *cb0, int options, uint8_t fraction_digits)
 
static int cli_callback_generate (clicon_handle h, yang_stmt *ys, cbuf *cb0)
 
static int yang2cli_stmt (clicon_handle h, yang_stmt *ys, cbuf *cb0, enum genmodel_type gt, int level)
 
static int yang2cli_var_sub (clicon_handle h, yang_stmt *ys, cbuf *cb0, char *helptext, enum cv_type cvtype, yang_stmt *ytype, int options, cg_var *mincv, cg_var *maxcv, char *pattern, uint8_t fraction_digits)
 
static int yang2cli_var (clicon_handle h, yang_stmt *ys, cbuf *cb0, char *helptext)
 
static int yang2cli_leaf (clicon_handle h, yang_stmt *ys, cbuf *cbuf, enum genmodel_type gt, int level, int callback)
 
static int yang2cli_container (clicon_handle h, yang_stmt *ys, cbuf *cbuf, enum genmodel_type gt, int level)
 
static int yang2cli_list (clicon_handle h, yang_stmt *ys, cbuf *cbuf, enum genmodel_type gt, int level)
 
static int yang2cli_choice (clicon_handle h, yang_stmt *ys, cbuf *cbuf, enum genmodel_type gt, int level)
 
int yang2cli (clicon_handle h, yang_spec *yspec, parse_tree *ptnew, enum genmodel_type gt)
 

Macro Definition Documentation

#define GENERATE_CALLBACK   "cli_set"
#define GENERATE_EXPAND_XMLDB   "expand_dbvar"

Function Documentation

static int cli_callback_generate ( clicon_handle  h,
yang_stmt *  ys,
cbuf *  cb0 
)
static

Create callback with xmlkey format string as argument

Parameters
[in]hclicon handle
[in]ysyang_stmt of the node at hand
[in]cb0The string where the result format string is inserted.
See Also
cli_dbxml This is where the xmlkeyfmt string is used
static int cli_expand_var_generate ( clicon_handle  h,
yang_stmt *  ys,
enum cv_type  cvtype,
cbuf *  cb0,
int  options,
uint8_t  fraction_digits 
)
static

Create cligen variable expand entry with xmlkey format string as argument

Parameters
[in]hclicon handle
[in]ysyang_stmt of the node at hand
[in]cvtypeType of the cligen variable
[in]cb0The string where the result format string is inserted.
[in]options
[in]fraction_digits
See Also
expand_dbvar This is where the expand string is used
Note
XXX only fraction_digits handled,should also have mincv, maxcv, pattern
int yang2cli ( clicon_handle  h,
yang_spec *  yspec,
parse_tree *  ptnew,
enum genmodel_type  gt 
)

Translate from a yang specification into a CLIgen syntax.

Print a CLIgen syntax to cbuf string, then parse it.

Parameters
gt- how to generate CLI: VARS: generate keywords for regular vars only not index ALL: generate keywords for all variables including index
static int yang2cli_choice ( clicon_handle  h,
yang_stmt *  ys,
cbuf *  cbuf,
enum genmodel_type  gt,
int  level 
)
static

Generate cli code for yang choice statement

Example: choice interface-type { container ethernet { ... } container fddi { ... } } Removes 'meta-syntax' from cli syntax. They are not shown when xml is translated to cli. and therefore input-syntax != output syntax. Which is bad

static int yang2cli_container ( clicon_handle  h,
yang_stmt *  ys,
cbuf *  cbuf,
enum genmodel_type  gt,
int  level 
)
static
static int yang2cli_leaf ( clicon_handle  h,
yang_stmt *  ys,
cbuf *  cbuf,
enum genmodel_type  gt,
int  level,
int  callback 
)
static
Parameters
[in]hClicon handle
[in]callbackIf set, include a "; cli_set()" callback, otherwise not.
static int yang2cli_list ( clicon_handle  h,
yang_stmt *  ys,
cbuf *  cbuf,
enum genmodel_type  gt,
int  level 
)
static
static int yang2cli_stmt ( clicon_handle  h,
yang_stmt *  ys,
cbuf *  cbuf,
enum genmodel_type  gt,
int  level 
)
static

Translate yang-stmt to CLIgen syntax.

static int yang2cli_var ( clicon_handle  h,
yang_stmt *  ys,
cbuf *  cb0,
char *  helptext 
)
static

Translate a yang leaf to cligen variable Make a type lookup and complete a cligen variable expression such as <a:string>. One complication is yang union, that needs a recursion since it consists of sub-types. eg type union{ type int32; type string } –> (<x:int32>| <x:string>)

static int yang2cli_var_sub ( clicon_handle  h,
yang_stmt *  ys,
cbuf *  cb0,
char *  helptext,
enum cv_type  cvtype,
yang_stmt *  ytype,
int  options,
cg_var *  mincv,
cg_var *  maxcv,
char *  pattern,
uint8_t  fraction_digits 
)
static