yumapro  20.10-10
YumaPro SDK

Management of a hierarchy of (name, value) pairs. More...

Collaboration diagram for CLI Variables:

Data Structures

struct  ncx_var_t
 struct of NCX user variable mapping for yangcli More...
 

Typedefs

typedef ncx_var_t *(* var_getvar_fn_t) (const xmlChar *varname, uint32 varlen, void *cookie, status_t *res)
 Get Variable Callback. More...
 

Enumerations

Functions

void var_free (ncx_var_t *var)
 Free a ncx_var_t struct. More...
 
void var_clean_varQ (dlq_hdr_t *varQ)
 Clean a Q of ncx_var_t. More...
 
void var_clean_type_from_varQ (dlq_hdr_t *varQ, var_type_t vartype)
 Clean all entries of one type from a Q of ncx_var_t. More...
 
status_t var_set_str (runstack_context_t *rcxt, const xmlChar *name, uint32 namelen, const val_value_t *value, var_type_t vartype)
 Find and set (or create a new) global user variable. More...
 
status_t var_set (runstack_context_t *rcxt, const xmlChar *name, const val_value_t *value, var_type_t vartype)
 Find and set (or create a new) global user variable. More...
 
status_t var_set_str_que (dlq_hdr_t *varQ, const xmlChar *name, uint32 namelen, const val_value_t *value)
 Find and set (or create a new) global user variable. More...
 
status_t var_set_que (dlq_hdr_t *varQ, const xmlChar *name, const val_value_t *value)
 Find and set (or create a new) Q-based user variable. More...
 
status_t var_set_move_que (dlq_hdr_t *varQ, const xmlChar *name, val_value_t *value)
 Find or create and set a Q-based user variable. More...
 
status_t var_set_move_que_global (dlq_hdr_t *varQ, const xmlChar *name, val_value_t *value)
 Find or create and set a Q-based user variable. More...
 
status_t var_set_move (runstack_context_t *rcxt, const xmlChar *name, uint32 namelen, var_type_t vartype, val_value_t *value)
 Find and set (or create a new) global user variable. More...
 
status_t var_set_sys (runstack_context_t *rcxt, const xmlChar *name, const val_value_t *value)
 Find and set (or create a new) global system variable. More...
 
status_t var_set_from_string (runstack_context_t *rcxt, const xmlChar *name, const xmlChar *valstr, var_type_t vartype)
 Find and set (or create a new) global user variable from a string value instead of a val_value_t struct. More...
 
status_t var_unset (runstack_context_t *rcxt, const xmlChar *name, uint32 namelen, var_type_t vartype)
 Find and remove a local or global user variable. More...
 
status_t var_unset_que (dlq_hdr_t *varQ, const xmlChar *name, uint32 namelen, xmlns_id_t nsid)
 Find and remove a Q-based user variable. More...
 
val_value_tvar_get_str (runstack_context_t *rcxt, const xmlChar *name, uint32 namelen, var_type_t vartype)
 Find a global user variable. More...
 
val_value_tvar_get (runstack_context_t *rcxt, const xmlChar *name, var_type_t vartype)
 Find a local or global user variable. More...
 
var_type_t var_get_type_str (runstack_context_t *rcxt, const xmlChar *name, uint32 namelen, boolean globalonly)
 Find a user variable; get its var type. More...
 
var_type_t var_get_type (runstack_context_t *rcxt, const xmlChar *name, boolean globalonly)
 Get the var type of a specified var name. More...
 
val_value_tvar_get_str_que (dlq_hdr_t *varQ, const xmlChar *name, uint32 namelen, xmlns_id_t nsid)
 Find a global user variable in a varQ. More...
 
val_value_tvar_get_que (dlq_hdr_t *varQ, const xmlChar *name, xmlns_id_t nsid)
 Find a Q-based user variable in q varQ. More...
 
ncx_var_tvar_get_que_raw (dlq_hdr_t *varQ, xmlns_id_t nsid, const xmlChar *name)
 Find a Q-based user variable; return the var struct instead of just the value. More...
 
val_value_tvar_get_local (runstack_context_t *rcxt, const xmlChar *name)
 Find a local user variable. More...
 
val_value_tvar_get_local_str (runstack_context_t *rcxt, const xmlChar *name, uint32 namelen)
 Find a local user variable, count-based name string. More...
 
status_t var_check_ref (runstack_context_t *rcxt, const xmlChar *line, var_side_t side, uint32 *len, var_type_t *vartype, const xmlChar **name, uint32 *namelen, val_value_t **foundval)
 Check if the immediate command sub-string is a variable reference. More...
 
val_value_tvar_get_script_val (runstack_context_t *rcxt, obj_template_t *obj, val_value_t *val, const xmlChar *strval, boolean istop, status_t *res)
 Create or fill in a val_value_t struct for a parameter assignment within the script processing mode. More...
 
val_value_tvar_get_script_val_ex (runstack_context_t *rcxt, obj_template_t *parentobj, obj_template_t *obj, val_value_t *val, const xmlChar *strval, boolean istop, val_value_t *fillval, status_t *res)
 Create or fill in a val_value_t struct for a parameter assignment within the script processing mode Allow external values. More...
 
val_value_tvar_check_script_val (runstack_context_t *rcxt, obj_template_t *obj, const xmlChar *strval, boolean istop, boolean handleEscapedCharacters, cli_xml_buffer_fn_t cbfn, status_t *res)
 Create a val_value_t struct for a parameter assignment within the script processing mode, if a var ref is found. More...
 
void var_cvt_generic (dlq_hdr_t *varQ)
 Cleanup after a yangcli session has ended. More...
 
ncx_var_tvar_find (runstack_context_t *rcxt, const xmlChar *varname, xmlns_id_t nsid)
 Find a complete var struct for use with XPath. More...
 
ncx_var_tvar_find_global (runstack_context_t *rcxt, const xmlChar *varname, uint32 namelen, xmlns_id_t nsid)
 Find a complete var struct for use with XPath or data templates. More...
 
ncx_var_tvar_get_first (runstack_context_t *rcxt, boolean islocal)
 Find the first local or global variable. More...
 
ncx_var_tvar_get_next (ncx_var_t *curvar)
 Find the next local or global variable. More...
 
const xmlChar * var_get_name (const ncx_var_t *curvar)
 Get the name string for the specified variable. More...
 
var_type_t var_get_vartype (const ncx_var_t *curvar)
 Get the variable type for the specified variable. More...
 
void var_init (void)
 Init the var module. More...
 
void var_set_getvar_cb (var_getvar_fn_t getcb, void *cookie)
 Set the getvar callback function used for data templates. More...
 
void * var_get_getvar_cb_cookie (void)
 Get the cookie parameter for the getvar callback function used for data templates. More...
 
var_getvar_fn_t var_get_getvar_cb (void)
 Get the getvar callback function used for data templates. More...
 
boolean var_string_is_var_expr (const xmlChar *varstring, uint32 varlen, boolean *plainvar)
 Check if the string is a variable reference. More...
 
status_t var_replace_subtree (runstack_context_t *rcxt, val_value_t *val)
 Replace all the simple node variable usage with the var value. More...
 

Detailed Description

Management of a hierarchy of (name, value) pairs.

THe names are NcxIdentifier types and the values are val_value_t structures or strings

Typedef Documentation

typedef ncx_var_t*(* var_getvar_fn_t) (const xmlChar *varname, uint32 varlen, void *cookie, status_t *res)

Get Variable Callback.

var_getvar_fn_t

Callback function for retrieval of a variable binding within a data template

Parameters
varnamevariable name requested
varlenlength of varname string
cookieregistered app-specific cookie parameter
resaddress of return status
Return values
*resreturn status
Returns
pointer to the ncx_var_t data structure for the specified varbind (back-ptr to found entry)

Enumeration Type Documentation

enum var_side_t

values for isleft parameter in var_check_ref

Enumerator
ISRIGHT 

right-hand-side

ISLEFT 

left-hand-side

enum var_type_t

different types of variables supported

Enumerator
VAR_TYP_NONE 

not set

VAR_TYP_LOCAL 

local variables have one dollar sign like $foo They exist only in the current runstack frame and get deleted when the frame is popped

VAR_TYP_CONFIG 

config variables are used within yangcli-pro and yp-shell for its own CLI parameters.

These cannot be deleted

VAR_TYP_GLOBAL 

user global variables are visible in every context stack frame and can persist across program reboots

VAR_TYP_SYSTEM 

system variables are read-only and cannot even be set, let alone deleted by a user

VAR_TYP_QUEUE 

queue variables are used internally DO NOT USE

Function Documentation

status_t var_check_ref ( runstack_context_t rcxt,
const xmlChar *  line,
var_side_t  side,
uint32 *  len,
var_type_t vartype,
const xmlChar **  name,
uint32 *  namelen,
val_value_t **  foundval 
)

Check if the immediate command sub-string is a variable reference.

If so, return the (vartype, name, namelen) tuple that identifies the reference. Also return the total number of chars consumed from the input line.

<verbatim> E.g.,

$foo = get-config filter=.xml

</verbatim>

Parameters
rcxtrunstack context to use
linecommand line string to expand
sideTRUE if left hand side of an expression
FALSE if right hand side ($1 type vars allowed)
lenaddress of number chars parsed so far in line
vartypeaddress of return variable Q type
nameaddress of string start return val
namelenaddress of name length return val
foundvaladdress of found variable value return val
Return values
*lennumber chars consumed by this function
*vartypevariable type enum
*namestart of name string
*namelenlength of *name string
*foundvalpointer to the value for the var that was found
Returns
status

Here is the call graph for this function:

Here is the caller graph for this function:

val_value_t* var_check_script_val ( runstack_context_t rcxt,
obj_template_t obj,
const xmlChar *  strval,
boolean  istop,
boolean  handleEscapedCharacters,
cli_xml_buffer_fn_t  cbfn,
status_t res 
)

Create a val_value_t struct for a parameter assignment within the script processing mode, if a var ref is found.

See yangcli documentation for details on the script syntax

Parameters
rcxtrunstack context to use
objexpected object template
NULL and will be set to NCX_BT_STRING for simple types
strvalstring value to check
istopTRUE if calling from top level assignment An unquoted string is the start of a command
FALSE if calling from a parameter parse An unquoted string is just a string
handleEscapedCharactersin a double-quoted string (only!), translate <verbatim> " \\, \",
, and ". </verbatim>
cbfncallback function to use
resaddress of status result
Return values
*resreturn status
Returns
If no error, then returns pointer to new malloced val
If error, then returns NULL

Here is the call graph for this function:

void var_clean_type_from_varQ ( dlq_hdr_t *  varQ,
var_type_t  vartype 
)

Clean all entries of one type from a Q of ncx_var_t.

Parameters
varQQ of var structs to free
vartypevariable type to delete

Here is the call graph for this function:

void var_clean_varQ ( dlq_hdr_t *  varQ)

Clean a Q of ncx_var_t.

Parameters
varQQ of var structs to free

Here is the call graph for this function:

Here is the caller graph for this function:

void var_cvt_generic ( dlq_hdr_t *  varQ)

Cleanup after a yangcli session has ended.

Parameters
varQQ of ncx_var_t to cleanup and change to generic object pointers

Here is the call graph for this function:

Here is the caller graph for this function:

ncx_var_t* var_find ( runstack_context_t rcxt,
const xmlChar *  varname,
xmlns_id_t  nsid 
)

Find a complete var struct for use with XPath.

Parameters
rcxtrunstack context to use
varnamevariable name string
nsidnamespace ID for varname (0 is OK)
Returns
pointer to ncx_var_t for the first match found (local or global)

Here is the call graph for this function:

ncx_var_t* var_find_global ( runstack_context_t rcxt,
const xmlChar *  varname,
uint32  namelen,
xmlns_id_t  nsid 
)

Find a complete var struct for use with XPath or data templates.

INPUTS:

Parameters
rcxtrunstack context to use
varnamevariable name string
namelenlength of name string
nsidnamespace ID for varname (0 is OK)
Returns
pointer to ncx_var_t for the first match found
void var_free ( ncx_var_t var)

Free a ncx_var_t struct.

Parameters
varvar struct to free

Here is the call graph for this function:

Here is the caller graph for this function:

val_value_t* var_get ( runstack_context_t rcxt,
const xmlChar *  name,
var_type_t  vartype 
)

Find a local or global user variable.

Parameters
rcxtrunstack context to use
namevar name to set
vartypevariable type
Returns
pointer to value, or NULL if not found

Here is the call graph for this function:

ncx_var_t* var_get_first ( runstack_context_t rcxt,
boolean  islocal 
)

Find the first local or global variable.

Parameters
rcxtrunstack context to use
islocalTRUE for local variables
FALSE for global variables
Returns
pointer to ncx_var_t for the first variable or NULL if none

Here is the call graph for this function:

var_getvar_fn_t var_get_getvar_cb ( void  )

Get the getvar callback function used for data templates.

Returns
registered getvars callback function address or NULL if none

Here is the caller graph for this function:

void* var_get_getvar_cb_cookie ( void  )

Get the cookie parameter for the getvar callback function used for data templates.

Returns
pointer to registered cookie or NULL if none

Here is the caller graph for this function:

val_value_t* var_get_local ( runstack_context_t rcxt,
const xmlChar *  name 
)

Find a local user variable.

Parameters
rcxtrunstack context to use
namevar name to get
Returns
pointer to value, or NULL if not found

Here is the call graph for this function:

val_value_t* var_get_local_str ( runstack_context_t rcxt,
const xmlChar *  name,
uint32  namelen 
)

Find a local user variable, count-based name string.

Parameters
rcxtrunstack context to use
namevar name to get
namelenlegth of name string
Returns
pointer to value, or NULL if not found
const xmlChar* var_get_name ( const ncx_var_t curvar)

Get the name string for the specified variable.

Parameters
curvarcurrent var to check
Returns
pointer to name string or NULL if none
ncx_var_t* var_get_next ( ncx_var_t curvar)

Find the next local or global variable.

Parameters
curvarcurrent var to check
Returns
pointer to ncx_var_t for the next variable or NULL if none
val_value_t* var_get_que ( dlq_hdr_t *  varQ,
const xmlChar *  name,
xmlns_id_t  nsid 
)

Find a Q-based user variable in q varQ.

Parameters
varQqueue of ncx_var_t to use
namevar name to get
nsidnamespace ID for name (0 if not used)
Returns
pointer to value, or NULL if not found

Here is the call graph for this function:

ncx_var_t* var_get_que_raw ( dlq_hdr_t *  varQ,
xmlns_id_t  nsid,
const xmlChar *  name 
)

Find a Q-based user variable; return the var struct instead of just the value.

Parameters
varQqueue of ncx_var_t to use
nsidnamespace ID for name (0 if not used)
namevar name to get
Returns
pointer to value, or NULL if not found

Here is the call graph for this function:

val_value_t* var_get_script_val ( runstack_context_t rcxt,
obj_template_t obj,
val_value_t val,
const xmlChar *  strval,
boolean  istop,
status_t res 
)

Create or fill in a val_value_t struct for a parameter assignment within the script processing mode.

See ncxcli.c for details on the script syntax

Parameters
rcxtrunstack context to use
objexpected type template
NULL and will be set to NCX_BT_STRING for simple types
valvalue to fill in :: val->obj MUST be set
NULL to create a new one
strvalstring value to check
istopTRUE (ISTOP) if calling from top level assignment An unquoted string is the start of a command
FALSE (ISPARM) if calling from a parameter parse An unquoted string is just a string
resaddress of status result
Return values
*resreturn status
Returns
If error, then returns NULL; If no error, then returns pointer to new val or filled in 'val'

Here is the call graph for this function:

val_value_t* var_get_script_val_ex ( runstack_context_t rcxt,
obj_template_t parentobj,
obj_template_t obj,
val_value_t val,
const xmlChar *  strval,
boolean  istop,
val_value_t fillval,
status_t res 
)

Create or fill in a val_value_t struct for a parameter assignment within the script processing mode Allow external values.

See ncxcli.c for details on the script syntax

Parameters
rcxtrunstack context to use
parentobjcontainer or list real node parent of 'obj'
NULL and will be set to NCX_BT_STRING for simple types
objexpected type template
NULL and will be set to NCX_BT_STRING for simple types
valvalue to fill in :: val->obj MUST be set
NULL to create a new one
strvalstring value to check
istopTRUE (ISTOP) if calling from top level assignment An unquoted string is the start of a command
FALSE (ISPARM) if calling from a parameter parse An unquoted string is just a string
fillvalvalue from yangcli, could be NCX_BT_EXTERN; used instead of strval!
NULL: not used
resaddress of status result
Return values
*resreturn status
Returns
If error, then returns NULL; If no error, then returns pointer to new val or filled in 'val'

Here is the call graph for this function:

Here is the caller graph for this function:

val_value_t* var_get_str ( runstack_context_t rcxt,
const xmlChar *  name,
uint32  namelen,
var_type_t  vartype 
)

Find a global user variable.

Parameters
rcxtrunstack context to use
namevar name to set
namelenlength of name string
vartypevariable type
Returns
pointer to value, or NULL if not found

Here is the call graph for this function:

Here is the caller graph for this function:

val_value_t* var_get_str_que ( dlq_hdr_t *  varQ,
const xmlChar *  name,
uint32  namelen,
xmlns_id_t  nsid 
)

Find a global user variable in a varQ.

Parameters
varQqueue of ncx_var_t to use
namevar name to get
namelenlength of name
nsidnamespace ID for name (0 if not used)
Returns
pointer to value, or NULL if not found
var_type_t var_get_type ( runstack_context_t rcxt,
const xmlChar *  name,
boolean  globalonly 
)

Get the var type of a specified var name.

Parameters
rcxtrunstack context to use
namevar name to get
globalonlyTRUE to check only the global Q
FALSE to check local, then global Q
Returns
var type if found, or VAR_TYP_NONE

Here is the call graph for this function:

var_type_t var_get_type_str ( runstack_context_t rcxt,
const xmlChar *  name,
uint32  namelen,
boolean  globalonly 
)

Find a user variable; get its var type.

Parameters
rcxtrunstack context to use
namevar name to get
namelenlength of name
globalonlyTRUE to check only the global Q
FALSE to check local, then global Q
Returns
var type if found, or VAR_TYP_NONE

Here is the caller graph for this function:

var_type_t var_get_vartype ( const ncx_var_t curvar)

Get the variable type for the specified variable.

Parameters
curvarcurrent var to check
Returns
enumeration for variable type
void var_init ( void  )

Init the var module.

Here is the caller graph for this function:

status_t var_replace_subtree ( runstack_context_t rcxt,
val_value_t val 
)

Replace all the simple node variable usage with the var value.

Parameters
rcxtrunstack contect to use
valvalue subtree to check; expecting container or list
Returns
status

Here is the call graph for this function:

Here is the caller graph for this function:

status_t var_set ( runstack_context_t rcxt,
const xmlChar *  name,
const val_value_t value,
var_type_t  vartype 
)

Find and set (or create a new) global user variable.

Parameters
rcxtrunstack context to use to find the var
namevar name to set
valuevar value to set
vartypevariable type
Returns
status

Here is the call graph for this function:

status_t var_set_from_string ( runstack_context_t rcxt,
const xmlChar *  name,
const xmlChar *  valstr,
var_type_t  vartype 
)

Find and set (or create a new) global user variable from a string value instead of a val_value_t struct.

Parameters
rcxtrunstack context to use to find the var
namevar name to set
valstrvalue string to set
vartypevariable type
Returns
status

Here is the call graph for this function:

void var_set_getvar_cb ( var_getvar_fn_t  getcb,
void *  cookie 
)

Set the getvar callback function used for data templates.

Parameters
getcbgetvars callback function address
cookiecookie parameter to pass to callback
status_t var_set_move ( runstack_context_t rcxt,
const xmlChar *  name,
uint32  namelen,
var_type_t  vartype,
val_value_t value 
)

Find and set (or create a new) global user variable.

Use the provided entry which will be freed later This function will not clone the value like var_set

Parameters
rcxtrunstack context to use to find the var
namevar name to set
namelenlength of name string
vartypevariable type
valuevar value to set (pass off memory, do not clone!)
Returns
status

Here is the call graph for this function:

Here is the caller graph for this function:

status_t var_set_move_que ( dlq_hdr_t *  varQ,
const xmlChar *  name,
val_value_t value 
)

Find or create and set a Q-based user variable.

Parameters
varQvariable binding Q to use instead of runstack
namevar name to set
value== var value to set (pass off memory, do not clone!)
Returns
status

Here is the call graph for this function:

Here is the caller graph for this function:

status_t var_set_move_que_global ( dlq_hdr_t *  varQ,
const xmlChar *  name,
val_value_t value 
)

Find or create and set a Q-based user variable.

Parameters
varQvariable binding Q to use instead of runstack
namevar name to set
value== var value to set (pass off memory, do not clone!)
Returns
status

Here is the call graph for this function:

status_t var_set_que ( dlq_hdr_t *  varQ,
const xmlChar *  name,
const val_value_t value 
)

Find and set (or create a new) Q-based user variable.

Parameters
varQvariable binding Q to use instead of runstack
namevar name to set
valuevar value to set
Returns
status

Here is the call graph for this function:

status_t var_set_str ( runstack_context_t rcxt,
const xmlChar *  name,
uint32  namelen,
const val_value_t value,
var_type_t  vartype 
)

Find and set (or create a new) global user variable.

Parameters
rcxtrunstack context to use to find the var
namevar name to set
namelenlength of name
valuevar value to set
vartypevariable type
Returns
status

Here is the call graph for this function:

Here is the caller graph for this function:

status_t var_set_str_que ( dlq_hdr_t *  varQ,
const xmlChar *  name,
uint32  namelen,
const val_value_t value 
)

Find and set (or create a new) global user variable.

Parameters
varQvariable binding Q to use instead of runstack
namevar name to set
namelenlength of name
valuevar value to set
Returns
status

Here is the call graph for this function:

Here is the caller graph for this function:

status_t var_set_sys ( runstack_context_t rcxt,
const xmlChar *  name,
const val_value_t value 
)

Find and set (or create a new) global system variable.

Parameters
rcxtrunstack context to use to find the var
namevar name to set
valuevar value to set
Returns
status

Here is the call graph for this function:

boolean var_string_is_var_expr ( const xmlChar *  varstring,
uint32  varlen,
boolean *  plainvar 
)

Check if the string is a variable reference.

Parameters
varstringstring to check
varlenlength of varstring to check
plainvaraddress of return flag
Return values
*plainvartrue if found plainvar; FALSE full expr
Returns
TRUE if appears to be a variable expression; FALSE if not

Here is the call graph for this function:

status_t var_unset ( runstack_context_t rcxt,
const xmlChar *  name,
uint32  namelen,
var_type_t  vartype 
)

Find and remove a local or global user variable.

!!! This function does not try global if local fails !!!

Parameters
rcxtrunstack context to use to find the var
namevar name to set
namelenlength of name string
vartypevariable type
Returns
status

Here is the call graph for this function:

status_t var_unset_que ( dlq_hdr_t *  varQ,
const xmlChar *  name,
uint32  namelen,
xmlns_id_t  nsid 
)

Find and remove a Q-based user variable.

Parameters
varQQ of ncx_var_t to use
namevar name to set
namelenlength of name string
nsidnamespace ID to check if non-zero
Returns
status

Here is the call graph for this function: