yumapro  20.10-12
YumaPro SDK
var.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008 - 2012, Andy Bierman, All Rights Reserved.
3  * Copyright (c) 2012 - 2021, YumaWorks, Inc., All Rights Reserved.
4  *
5  * Unless required by applicable law or agreed to in writing,
6  * software distributed under the License is distributed on an
7  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8  * KIND, either express or implied. See the License for the
9  * specific language governing permissions and limitations
10  * under the License.
11  */
12 #ifndef _H_var
13 #define _H_var
14 
15 /* FILE: var.h
16 *********************************************************************
17 * *
18 * P U R P O S E *
19 * *
20 *********************************************************************/
21 
28 /*********************************************************************
29 * *
30 * C H A N G E H I S T O R Y *
31 * *
32 *********************************************************************
33 
34 date init comment
35 ----------------------------------------------------------------------
36 23-aug-07 abb Begun
37 09-mar-09 abb Add more support for yangcli
38 */
39 
40 #include <xmlstring.h>
41 
42 #ifndef _H_cli
43 #include "cli.h"
44 #endif
45 
46 #ifndef _H_dlq
47 #include "dlq.h"
48 #endif
49 
50 #ifndef _H_ncxtypes
51 #include "ncxtypes.h"
52 #endif
53 
54 #ifndef _H_obj
55 #include "obj.h"
56 #endif
57 
58 #ifndef _H_runstack
59 #include "runstack.h"
60 #endif
61 
62 #ifndef _H_val
63 #include "val.h"
64 #endif
65 
66 #ifdef __cplusplus
67 extern "C" {
68 #endif
69 
70 /********************************************************************
71 * *
72 * C O N S T A N T S *
73 * *
74 *********************************************************************/
75 
76 
77 /* top or parm values for the istop parameter */
78 #define ISTOP TRUE
79 #define ISPARM FALSE
80 
81 #define VAR_VAL(V) (V)->val
82 
83 
84 /********************************************************************
85 * *
86 * T Y P E S *
87 * *
88 *********************************************************************/
89 
101 typedef enum var_type_t_ {
109 
114 
119 
124 
127 } var_type_t;
128 
129 
131 typedef struct ncx_var_t_ {
132  dlq_hdr_t hdr;
135  var_type_t vartype;
136 
141  xmlChar *name;
142 
144  val_value_t *val;
145 } ncx_var_t;
146 
147 
149 typedef enum var_side_t_ {
152 } var_side_t;
153 
154 
171 typedef ncx_var_t *
172  (*var_getvar_fn_t) (const xmlChar *varname,
173  uint32 varlen,
174  void *cookie,
175  status_t *res);
176 
177 
178 /********************************************************************
179 * *
180 * F U N C T I O N S *
181 * *
182 *********************************************************************/
183 
184 
190 extern void
191  var_free (ncx_var_t *var);
192 
193 
199 extern void
200  var_clean_varQ (dlq_hdr_t *varQ);
201 
202 
209 extern void
210  var_clean_type_from_varQ (dlq_hdr_t *varQ,
211  var_type_t vartype);
212 
213 
224 extern status_t
225  var_set_str (runstack_context_t *rcxt,
226  const xmlChar *name,
227  uint32 namelen,
228  const val_value_t *value,
229  var_type_t vartype);
230 
231 
241 extern status_t
242  var_set (runstack_context_t *rcxt,
243  const xmlChar *name,
244  const val_value_t *value,
245  var_type_t vartype);
246 
247 
257 extern status_t
258  var_set_str_que (dlq_hdr_t *varQ,
259  const xmlChar *name,
260  uint32 namelen,
261  const val_value_t *value);
262 
263 
272 extern status_t
273  var_set_que (dlq_hdr_t *varQ,
274  const xmlChar *name,
275  const val_value_t *value);
276 
277 
286 extern status_t
287  var_set_move_que (dlq_hdr_t *varQ,
288  const xmlChar *name,
289  val_value_t *value);
290 
291 
300 extern status_t
301  var_set_move_que_global (dlq_hdr_t *varQ,
302  const xmlChar *name,
303  val_value_t *value);
304 
305 
319 extern status_t
320  var_set_move (runstack_context_t *rcxt,
321  const xmlChar *name,
322  uint32 namelen,
323  var_type_t vartype,
324  val_value_t *value);
325 
326 
335 extern status_t
336  var_set_sys (runstack_context_t *rcxt,
337  const xmlChar *name,
338  const val_value_t *value);
339 
340 
351 extern status_t
352  var_set_from_string (runstack_context_t *rcxt,
353  const xmlChar *name,
354  const xmlChar *valstr,
355  var_type_t vartype);
356 
357 
369 extern status_t
370  var_unset (runstack_context_t *rcxt,
371  const xmlChar *name,
372  uint32 namelen,
373  var_type_t vartype);
374 
375 
385 extern status_t
386  var_unset_que (dlq_hdr_t *varQ,
387  const xmlChar *name,
388  uint32 namelen,
389  xmlns_id_t nsid);
390 
391 
401 extern val_value_t *
402  var_get_str (runstack_context_t *rcxt,
403  const xmlChar *name,
404  uint32 namelen,
405  var_type_t vartype);
406 
407 
416 extern val_value_t *
417  var_get (runstack_context_t *rcxt,
418  const xmlChar *name,
419  var_type_t vartype);
420 
421 
432 extern var_type_t
433  var_get_type_str (runstack_context_t *rcxt,
434  const xmlChar *name,
435  uint32 namelen,
436  boolean globalonly);
437 
438 
448 extern var_type_t
449  var_get_type (runstack_context_t *rcxt,
450  const xmlChar *name,
451  boolean globalonly);
452 
453 
463 extern val_value_t *
464  var_get_str_que (dlq_hdr_t *varQ,
465  const xmlChar *name,
466  uint32 namelen,
467  xmlns_id_t nsid);
468 
469 
478 extern val_value_t *
479  var_get_que (dlq_hdr_t *varQ,
480  const xmlChar *name,
481  xmlns_id_t nsid);
482 
483 
493 extern ncx_var_t *
494  var_get_que_raw (dlq_hdr_t *varQ,
495  xmlns_id_t nsid,
496  const xmlChar *name);
497 
498 
506 extern val_value_t *
507  var_get_local (runstack_context_t *rcxt,
508  const xmlChar *name);
509 
510 
519 extern val_value_t *
520  var_get_local_str (runstack_context_t *rcxt,
521  const xmlChar *name,
522  uint32 namelen);
523 
524 
556 extern status_t
557  var_check_ref (runstack_context_t *rcxt,
558  const xmlChar *line,
559  var_side_t side,
560  uint32 *len,
561  var_type_t *vartype,
562  const xmlChar **name,
563  uint32 *namelen,
564  val_value_t **foundval);
565 
566 
589 extern val_value_t *
590  var_get_script_val (runstack_context_t *rcxt,
591  obj_template_t *obj,
592  val_value_t *val,
593  const xmlChar *strval,
594  boolean istop,
595  status_t *res);
596 
597 
627 extern val_value_t *
628  var_get_script_val_ex (runstack_context_t *rcxt,
629  obj_template_t *parentobj,
630  obj_template_t *obj,
631  val_value_t *val,
632  const xmlChar *strval,
633  boolean istop,
634  val_value_t *fillval,
635  status_t *res);
636 
637 
663 extern val_value_t *
664  var_check_script_val (runstack_context_t *rcxt,
665  obj_template_t *obj,
666  const xmlChar *strval,
667  boolean istop,
668  boolean handleEscapedCharacters,
669  cli_xml_buffer_fn_t cbfn,
670  status_t *res);
671 
672 
679 extern void
680  var_cvt_generic (dlq_hdr_t *varQ);
681 
682 
691 extern ncx_var_t *
692  var_find (runstack_context_t *rcxt,
693  const xmlChar *varname,
694  xmlns_id_t nsid);
695 
696 
707 extern ncx_var_t *
708  var_find_global (runstack_context_t *rcxt,
709  const xmlChar *varname,
710  uint32 namelen,
711  xmlns_id_t nsid);
712 
713 
722 extern ncx_var_t *
723  var_get_first (runstack_context_t *rcxt,
724  boolean islocal);
725 
726 
733 extern ncx_var_t *
734  var_get_next (ncx_var_t *curvar);
735 
736 
743 extern const xmlChar *
744  var_get_name (const ncx_var_t *curvar);
745 
746 
753 extern var_type_t
754  var_get_vartype (const ncx_var_t *curvar);
755 
756 
761 extern void
762  var_init (void);
763 
764 
771 extern void
773  void *cookie);
774 
775 
782 extern void *
784 
785 
791 extern var_getvar_fn_t
792  var_get_getvar_cb (void);
793 
794 
804 extern boolean
805  var_string_is_var_expr (const xmlChar *varstring,
806  uint32 varlen,
807  boolean *plainvar);
808 
809 
817 extern status_t
818  var_replace_subtree (runstack_context_t *rcxt,
819  val_value_t *val);
820 
821 
825 #ifdef __cplusplus
826 } /* end extern 'C' */
827 #endif
828 
829 #endif /* _H_var */
cli_xml_buffer_fn_t
val_value_t *(* cli_xml_buffer_fn_t)(const xmlChar *xmlbuff, obj_template_t *targetobj, status_t *res)
Read an XML buffer and convert it into a real data structure.
Definition: cli.h:153
ERR_NCX_SKIPPED
@ ERR_NCX_SKIPPED
2001
Definition: status_enum.h:551
xml_strlen
uint32 xml_strlen(const xmlChar *str)
Get the String len for xmlChar.
Definition: xml_util.c:1406
var_check_script_val
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,...
Definition: var.c:2426
var_set_move
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.
Definition: var.c:1416
xml_strncpy
uint32 xml_strncpy(xmlChar *copyTo, const xmlChar *copyFrom, uint32 maxlen)
String copy for xmlChar – checks for buffer overflow.
Definition: xml_util.c:1518
val_move_children
void val_move_children(val_value_t *srcval, val_value_t *destval)
Move all the child nodes from src to dest Source and dest must both be containers!
Definition: val.c:12651
val_value_t_::res
status_t res
validation result
Definition: val.h:910
OBJ_TYP_LIST
@ OBJ_TYP_LIST
list: last real database object
Definition: obj.h:617
var_set_move_que
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.
Definition: var.c:1354
var_side_t_
var_side_t_
values for isleft parameter in var_check_ref
Definition: var.h:149
var_get_script_val_ex
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 A...
Definition: var.c:2113
obj_get_typdef
typ_def_t * obj_get_typdef(obj_template_t *obj)
Get the typdef for the leaf or leaf-list.
Definition: obj.c:11991
xml_strdup
xmlChar * xml_strdup(const xmlChar *copyFrom)
String duplicate for xmlChar.
Definition: xml_util.c:1553
ncx_warning_enabled
boolean ncx_warning_enabled(status_t res)
Check if a specific status_t code is enabled.
Definition: ncx.c:9394
val_set_name
void val_set_name(val_value_t *val, const xmlChar *name, uint32 namelen)
Set (or reset) the name of a value struct.
Definition: val.c:2875
ncx_var_t_::name
xmlChar * name
variable name
Definition: var.h:141
var_set_getvar_cb
void var_set_getvar_cb(var_getvar_fn_t getcb, void *cookie)
Set the getvar callback function used for data templates.
Definition: var.c:2899
ncxmod_find_data_file
xmlChar * ncxmod_find_data_file(const xmlChar *fname, boolean generrors, boolean backup_file, status_t *res)
Determine the location of the specified data file.
Definition: ncxmod.c:5068
VAL_NSID
#define VAL_NSID(V)
Access the namespace ID.
Definition: val.h:396
ERR_NCX_DEF_NOT_FOUND
@ ERR_NCX_DEF_NOT_FOUND
250
Definition: status_enum.h:289
RUNSTACK_QUE_LOCAL
@ RUNSTACK_QUE_LOCAL
local variables
Definition: runstack.h:135
var_set_que
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.
Definition: var.c:1330
log_error
void log_error(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_ERROR log entry.
var_get_type_str
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.
Definition: var.c:1708
val.h
Value Node Basic Support.
VAL_VAREXPR
#define VAL_VAREXPR(V)
get the value var expression
Definition: val.h:560
OBJ_TYP_CHOICE
@ OBJ_TYP_CHOICE
choice
Definition: obj.h:618
var_free
void var_free(ncx_var_t *var)
Free a ncx_var_t struct.
Definition: var.c:1148
var_cvt_generic
void var_cvt_generic(dlq_hdr_t *varQ)
Cleanup after a yangcli session has ended.
Definition: var.c:2683
val_set_string2
status_t val_set_string2(val_value_t *val, const xmlChar *valname, typ_def_t *typdef, const xmlChar *valstr, uint32 valstrlen)
set a string with any typdef Set an initialized val_value_t as a simple type namespace set to 0 !...
Definition: val.c:6675
ncx_data_templates_ok
boolean ncx_data_templates_ok(void)
Get the use-data-templates flag.
Definition: ncx.c:12393
var_get_type
var_type_t var_get_type(runstack_context_t *rcxt, const xmlChar *name, boolean globalonly)
Get the var type of a specified var name.
Definition: var.c:1750
log_debug3
void void void void void void void void void void void log_debug3(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG3 log entry.
obj_next_child_deep
obj_template_t * obj_next_child_deep(obj_template_t *obj)
Get the next child object if the specified object has any children.
Definition: obj.c:7138
var_set_from_string
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 stru...
Definition: var.c:1488
runstack.h
CLI run stack manager.
NCX_BT_ANYDATA
@ NCX_BT_ANYDATA
YANG 1.1 anydata.
Definition: ncxtypes.h:229
ERR_NCX_DUP_ENTRY
@ ERR_NCX_DUP_ENTRY
224
Definition: status_enum.h:263
ncx_var_t_::nsid
xmlns_id_t nsid
namespace ID for this variable
Definition: var.h:138
VAL_NAME
#define VAL_NAME(V)
Access the value name.
Definition: val.h:399
ncxconst.h
Contains NCX constants.
ncxmod.h
NCX Module Load Manager.
var_type_t_
var_type_t_
different types of variables supported
Definition: var.h:101
RUNSTACK_QUE_GROUP
@ RUNSTACK_QUE_GROUP
group variables
Definition: runstack.h:137
var_string_is_var_expr
boolean var_string_is_var_expr(const xmlChar *varstring, uint32 varlen, boolean *plainvar)
Check if the string is a variable reference.
Definition: var.c:2950
var_unset
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.
Definition: var.c:1550
var_get_name
const xmlChar * var_get_name(const ncx_var_t *curvar)
Get the name string for the specified variable.
Definition: var.c:2846
OBJ_TYP_CONTAINER
@ OBJ_TYP_CONTAINER
container
Definition: obj.h:614
ncx_var_t_
struct of NCX user variable mapping for yangcli
Definition: var.h:131
ERR_NCX_USING_STRING
@ ERR_NCX_USING_STRING
1043
Definition: status_enum.h:532
val_value_t_::obj
struct obj_template_t_ * obj
common fields
Definition: val.h:865
dlq_insertAhead
void dlq_insertAhead(void *newP, void *nodeP)
insert the new queue entry before the current entry
Definition: dlq.c:447
var_set_str_que
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.
Definition: var.c:1295
val_value_t_::name
const xmlChar * name
back pointer to elname the dname field is moved to val_extra_t and only used when the value is constr...
Definition: val.h:867
VAL_TYPDEF
#define VAL_TYPDEF(V)
Access the typedef (simple types only)
Definition: val.h:393
xmlns_id_t
uint16 xmlns_id_t
integer handle for registered namespaces
Definition: xmlns.h:89
ncx_valid_fname_ch
boolean ncx_valid_fname_ch(uint32 ch)
Check if an xmlChar is a valid NCX name string first char.
Definition: ncx.c:7573
ncx_warning_elevated
boolean ncx_warning_elevated(status_t res)
Check if a specific status_t code is elevated.
Definition: ncx.c:9439
log_debug2
void void void void void void void void void log_debug2(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG2 log entry.
var_getvar_fn_t
ncx_var_t *(* var_getvar_fn_t)(const xmlChar *varname, uint32 varlen, void *cookie, status_t *res)
Get Variable Callback.
Definition: var.h:172
typ_get_basetype_typdef
typ_def_t * typ_get_basetype_typdef(ncx_btype_t btyp)
Get the default typdef for the specified base type.
Definition: typ.c:2039
var_get_str
val_value_t * var_get_str(runstack_context_t *rcxt, const xmlChar *name, uint32 namelen, var_type_t vartype)
Find a global user variable.
Definition: var.c:1633
obj_is_leafy
boolean obj_is_leafy(const obj_template_t *obj)
Check if object is a proper leaf or leaflist.
Definition: obj.c:13478
NO_ERR
@ NO_ERR
000
Definition: status_enum.h:188
NCX_BT_LIST
@ NCX_BT_LIST
internal, YANG list
Definition: ncxtypes.h:228
var_replace_subtree
status_t var_replace_subtree(runstack_context_t *rcxt, val_value_t *val)
Replace all the simple node variable usage with the var value.
Definition: var.c:3006
ncx_get_gen_anyxml
obj_template_t * ncx_get_gen_anyxml(void)
Get the object template for the NCX generic anyxml container.
Definition: ncx.c:6664
ncx_var_t_::hdr
dlq_hdr_t hdr
queue header
Definition: var.h:132
var_get_getvar_cb_cookie
void * var_get_getvar_cb_cookie(void)
Get the cookie parameter for the getvar callback function used for data templates.
Definition: var.c:2934
xml_strndup
xmlChar * xml_strndup(const xmlChar *copyFrom, uint32 maxlen)
String duplicate for max N xmlChars.
Definition: xml_util.c:1663
var_get_que_raw
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.
Definition: var.c:1839
val_get_nsid
xmlns_id_t val_get_nsid(const val_value_t *val)
Get the namespace ID for the specified value node.
Definition: val.c:12277
log_debug4
void void void void void void void void void void void void void log_debug4(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG4 log entry.
obj_get_name
const xmlChar * obj_get_name(const obj_template_t *obj)
Get the name field for this obj.
Definition: obj.c:10511
ERR_NCX_OPERATION_FAILED
@ ERR_NCX_OPERATION_FAILED
274
Definition: status_enum.h:315
val_replace_str
status_t val_replace_str(const xmlChar *str, uint32 stringlen, val_value_t *copy)
Replace a specified val_value_t struct with a string type.
Definition: val.c:8085
var_get_first
ncx_var_t * var_get_first(runstack_context_t *rcxt, boolean islocal)
Find the first local or global variable.
Definition: var.c:2793
LOGDEBUG2
#define LOGDEBUG2
Check if at least log-level=debug2.
Definition: log.h:292
val_gen_index_chain
status_t val_gen_index_chain(const obj_template_t *obj, val_value_t *val)
Create an index chain for the just-parsed table or container struct.
Definition: val_util.c:2632
dlq_createSQue
void dlq_createSQue(dlq_hdrT *queAddr)
create a static queue header
Definition: dlq.c:177
log_warn
void void void log_warn(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_WARN log entry.
ERR_INTERNAL_VAL
@ ERR_INTERNAL_VAL
004
Definition: status_enum.h:194
runstack_get_parm_que
dlq_hdr_t * runstack_get_parm_que(runstack_context_t *rcxt)
Get the parameter queue for the current stack level.
Definition: runstack.c:970
dlq_remove
void dlq_remove(void *nodeP)
remove the queue entry from its queue list entry MUST have been enqueued somehow before this function...
Definition: dlq.c:519
val_child_add
status_t val_child_add(val_value_t *child, val_value_t *parent)
Add a child value node to a parent value node.
Definition: val_child.c:1542
val_util.h
Value Node Utilities.
ERR_NCX_WRONG_TYPE
@ ERR_NCX_WRONG_TYPE
231
Definition: status_enum.h:270
var_find
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.
Definition: var.c:2721
OBJ_TYP_ANYDATA
@ OBJ_TYP_ANYDATA
anydata: YANG 1.1 only
Definition: obj.h:626
ERR_NCX_INVALID_VALUE
@ ERR_NCX_INVALID_VALUE
258
Definition: status_enum.h:299
NCX_BT_EMPTY
@ NCX_BT_EMPTY
empty
Definition: ncxtypes.h:205
var_find_global
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.
Definition: var.c:2759
ERR_INTERNAL_MEM
@ ERR_INTERNAL_MEM
003
Definition: status_enum.h:193
ncx_var_t_::vartype
var_type_t vartype
variable type for this entry
Definition: var.h:135
xml_strncmp
int xml_strncmp(const xmlChar *s1, const xmlChar *s2, uint32 maxlen)
String compare for xmlChar for at most 'maxlen' xmlChars.
Definition: xml_util.c:1824
var_unset_que
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.
Definition: var.c:1596
val_clone
val_value_t * val_clone(const val_value_t *val)
Clone a specified val_value_t struct and sub-trees.
Definition: val.c:7836
json_parse_buffer
status_t json_parse_buffer(xmlChar *buff, obj_template_t *obj, dlq_hdr_t *returnQ)
Parse buffer of JSON into val_value_t structs.
Definition: json_parse.c:2639
VAR_TYP_NONE
@ VAR_TYP_NONE
not set
Definition: var.h:102
ncx_ok_for_inline_data
boolean ncx_ok_for_inline_data(obj_template_t *obj)
Check if the object is OK for inline data.
Definition: ncx.c:14405
val_child.h
Value Node Child Access Support.
RUNSTACK_MAX_PARMS
#define RUNSTACK_MAX_PARMS
this is an arbitrary limit, but it must match the yangcli:run rpc P1 - Pn variables,...
Definition: runstack.h:78
get_error_string
const char * get_error_string(status_t res)
Get the error message for a specific internal error.
Definition: status.c:239
var_get_str_que
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.
Definition: var.c:1775
ERR_INTERNAL_PTR
@ ERR_INTERNAL_PTR
002
Definition: status_enum.h:192
NCX_BT_CONTAINER
@ NCX_BT_CONTAINER
internal container
Definition: ncxtypes.h:225
log_debug
void void void void void void void log_debug(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG log entry.
val_cvt_generic
status_t val_cvt_generic(val_value_t *val)
Convert all the database object pointers to generic object pointers.
Definition: val.c:12718
obj_is_anydata
boolean obj_is_anydata(const obj_template_t *obj)
Check if object is an anydata.
Definition: obj.c:13284
obj_is_case
boolean obj_is_case(const obj_template_t *obj)
Check if object is a YANG case.
Definition: obj.c:13445
ncx_var_t_::val
val_value_t * val
variable value
Definition: var.h:144
OBJ_TYP_CASE
@ OBJ_TYP_CASE
case: last named database object
Definition: obj.h:619
dlq_nextEntry
#define dlq_nextEntry(nodeP)
get the next queue entry after the current entry
Definition: dlq.h:265
var_set_move_que_global
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.
Definition: var.c:1383
OBJ_TYP_LEAF_LIST
@ OBJ_TYP_LEAF_LIST
leaf-list
Definition: obj.h:616
val_make_sprintf_string
xmlChar * val_make_sprintf_string(const val_value_t *val)
Malloc a buffer and then sprintf the xmlChar string NETCONF representation of a simple value.
Definition: val.c:10323
ISRIGHT
@ ISRIGHT
right-hand-side
Definition: var.h:150
var_init
void var_init(void)
Init the var module.
Definition: var.c:2881
obj_is_anyxml
boolean obj_is_anyxml(const obj_template_t *obj)
Check if object is an anyxml.
Definition: obj.c:13271
ERR_NCX_OPERATION_NOT_SUPPORTED
@ ERR_NCX_OPERATION_NOT_SUPPORTED
273
Definition: status_enum.h:314
OBJ_TYP_ANYXML
@ OBJ_TYP_ANYXML
anyxml
Definition: obj.h:613
obj_get_mod_name
const xmlChar * obj_get_mod_name(const obj_template_t *obj)
Get the module name for this object.
Definition: obj.c:12176
typ_is_simple
boolean typ_is_simple(ncx_btype_t btyp)
Check if this is a simple data type.
Definition: typ.c:3107
NCX_BT_ANY
@ NCX_BT_ANY
anyxml
Definition: ncxtypes.h:202
ncx_get_source_ex
xmlChar * ncx_get_source_ex(const xmlChar *fspec, boolean expand_cwd, status_t *res)
Expand a filespec into an absolute path.
Definition: ncx.c:8163
EMPTY_STRING
#define EMPTY_STRING
empty string used to get const xmlChar * cast
Definition: ncxconst.h:289
obj_find_child
obj_template_t * obj_find_child(obj_template_t *obj, const xmlChar *modname, const xmlChar *objname)
Find a child object with the specified Qname.
Definition: obj.c:6116
VAR_TYP_LOCAL
@ VAR_TYP_LOCAL
local variables have one dollar sign like $foo They exist only in the current runstack frame and get ...
Definition: var.h:108
xml_strcmp
int xml_strcmp(const xmlChar *s1, const xmlChar *s2)
String compare for xmlChar.
Definition: xml_util.c:1746
val_get_next_child
val_value_t * val_get_next_child(const val_value_t *curchild)
Get the next child node.
Definition: val.c:8496
var_check_ref
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.
Definition: var.c:1936
obj_is_choice
boolean obj_is_choice(const obj_template_t *obj)
Check if object is a YANG choice.
Definition: obj.c:13425
var_get
val_value_t * var_get(runstack_context_t *rcxt, const xmlChar *name, var_type_t vartype)
Find a local or global user variable.
Definition: var.c:1682
LOGDEBUG4
#define LOGDEBUG4
Check if at least log-level=debug4.
Definition: log.h:302
log.h
NCX System Logging Manager.
val_set_extern
void val_set_extern(val_value_t *val, xmlChar *fname)
Setup an NCX_BT_EXTERN value.
Definition: val.c:10893
ncxtypes.h
YANG module data structures Many internal representations of YANG module constructs.
var_get_script_val
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.
Definition: var.c:2058
obj_template_t_::objtype
obj_type_t objtype
object type (def)
Definition: obj.h:1058
var_clean_type_from_varQ
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.
Definition: var.c:1192
cli.h
command line interpreter parsing to internal val_value_t format
val_set_string
status_t val_set_string(val_value_t *val, const xmlChar *valname, const xmlChar *valstr)
set a generic string using the builtin string typdef Set an initialized val_value_t as a simple type ...
Definition: val.c:6622
val_clean_valQ
void val_clean_valQ(dlq_hdr_t *valQ)
Clean a queue of val_value_t.
Definition: val.c:13911
dlq_deque
void * dlq_deque(dlq_hdrT *listP)
remove the first queue node from the queue list
Definition: dlq.c:286
val_get_first_child
val_value_t * val_get_first_child(const val_value_t *parent)
Get the first child node.
Definition: val.c:8477
typ_is_string
boolean typ_is_string(ncx_btype_t btyp)
Check if the base type is a simple string (not list)
Definition: typ.c:4097
dlq_empty
#define dlq_empty(listP)
check if queue list is empty
Definition: dlq.h:367
ISLEFT
@ ISLEFT
left-hand-side
Definition: var.h:151
NCX_INLINE_TAG
#define NCX_INLINE_TAG
start/end inline XML or JSON data
Definition: ncxconst.h:1672
runstack_get_que
dlq_hdr_t * runstack_get_que(runstack_context_t *rcxt, runstack_queue_type_t quetype)
Read the current runstack context and figure out which queue to get.
Definition: runstack.c:921
VAR_TYP_GLOBAL
@ VAR_TYP_GLOBAL
user global variables are visible in every context stack frame and can persist across program reboots
Definition: var.h:118
ncx_get_gen_string
obj_template_t * ncx_get_gen_string(void)
Get the object template for the NCX generic string leaf.
Definition: ncx.c:6692
VAL_TYPE
#define VAL_TYPE(V)
Access the base type : same as VAL_BTYPE.
Definition: val.h:387
obj_get_basetype
ncx_btype_t obj_get_basetype(const obj_template_t *obj)
Get the NCX base type enum for the object type.
Definition: obj.c:12077
obj_first_child_deep
obj_template_t * obj_first_child_deep(obj_template_t *obj)
Get the first child object if the specified object has any children.
Definition: obj.c:7084
ERR_NCX_VAR_NOT_FOUND
@ ERR_NCX_VAR_NOT_FOUND
360
Definition: status_enum.h:403
dlq_firstEntry
#define dlq_firstEntry(listP)
get the first entry in the queue list
Definition: dlq.h:337
var_get_vartype
var_type_t var_get_vartype(const ncx_var_t *curvar)
Get the variable type for the specified variable.
Definition: var.c:2866
val_new_value
val_value_t * val_new_value(void)
Malloc and initialize the fields in a val_value_t.
Definition: val.c:2697
var_get_local_str
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.
Definition: var.c:1889
ncx.h
YANG module utility functions.
var_get_getvar_cb
var_getvar_fn_t var_get_getvar_cb(void)
Get the getvar callback function used for data templates.
Definition: var.c:2917
obj.h
Data Object Support.
json_parse.h
JSON input stream parser module.
ERR_NCX_VAR_READ_ONLY
@ ERR_NCX_VAR_READ_ONLY
361
Definition: status_enum.h:404
var_set_str
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.
Definition: var.c:1228
val_init_from_template
void val_init_from_template(val_value_t *val, struct obj_template_t_ *obj)
Initialize a value node from its object template.
RUNSTACK_QUE_GLOBAL
@ RUNSTACK_QUE_GLOBAL
global variables
Definition: runstack.h:138
dlq_enque
void dlq_enque(REG void *newP, REG dlq_hdrT *listP)
add a queue node to the end of a queue list Add newP to listP
Definition: dlq.c:246
ERR_NCX_WRONG_DATATYP
@ ERR_NCX_WRONG_DATATYP
285
Definition: status_enum.h:328
var_get_next
ncx_var_t * var_get_next(ncx_var_t *curvar)
Find the next local or global variable.
Definition: var.c:2826
val_clear_varexpr
void val_clear_varexpr(val_value_t *val)
Clear the varexpr field in the value node.
Definition: val.c:15538
val_sprintf_simval_nc
status_t val_sprintf_simval_nc(xmlChar *buff, const val_value_t *val, uint32 *len)
Sprintf the xmlChar string NETCONF representation of a simple value.
Definition: val.c:9931
RUNSTACK_QUE_SESSION
@ RUNSTACK_QUE_SESSION
session variables
Definition: runstack.h:136
VAL_STR
#define VAL_STR(V)
Access the value as a string ONLY if typ_is_string() is true.
Definition: val.h:464
SET_ERROR
#define SET_ERROR(E)
macro SET_ERROR
Definition: status_enum.h:103
var_clean_varQ
void var_clean_varQ(dlq_hdr_t *varQ)
Clean a Q of ncx_var_t.
Definition: var.c:1170
OBJ_TYP_LEAF
@ OBJ_TYP_LEAF
leaf
Definition: obj.h:615
ncx_parse_name
status_t ncx_parse_name(const xmlChar *str, uint32 *len)
Check if the next N chars represent a valid NcxName.
Definition: ncx.c:7657
NCX_BT_STRING
@ NCX_BT_STRING
string
Definition: ncxtypes.h:217
val_set_simval
status_t val_set_simval(val_value_t *val, typ_def_t *typdef, xmlns_id_t nsid, const xmlChar *valname, const xmlChar *valstr)
set any simple value with any typdef Set an initialized val_value_t as a simple type
Definition: val.c:6836
VAR_TYP_CONFIG
@ VAR_TYP_CONFIG
config variables are used within yangcli-pro and yp-shell for its own CLI parameters.
Definition: var.h:113
VAR_TYP_SYSTEM
@ VAR_TYP_SYSTEM
system variables are read-only and cannot even be set, let alone deleted by a user
Definition: var.h:123
VAR_TYP_QUEUE
@ VAR_TYP_QUEUE
queue variables are used internally DO NOT USE
Definition: var.h:126
obj_get_typestr
const xmlChar * obj_get_typestr(const obj_template_t *obj)
Get the name of the object type.
Definition: obj.c:11392
val_free_value
void val_free_value(val_value_t *val)
Scrub the memory in a val_value_t by freeing all the sub-fields and then freeing the entire struct it...
Definition: val.c:2842
var_set_sys
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.
Definition: var.c:1451
obj_is_root
boolean obj_is_root(const obj_template_t *obj)
Check if object is marked as a root object.
Definition: obj.c:14152
var_get_que
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.
Definition: var.c:1808
status.h
Global error messages for status code enumerations.
val_set_intern
void val_set_intern(val_value_t *val, xmlChar *intbuff)
Setup an NCX_BT_INTERN value.
Definition: val.c:10921
var_get_local
val_value_t * var_get_local(runstack_context_t *rcxt, const xmlChar *name)
Find a local user variable.
Definition: var.c:1862
obj_get_nsid
xmlns_id_t obj_get_nsid(const obj_template_t *obj)
Get the namespace ID for this object.
Definition: obj.c:12395
dlq.h
dlq provides general double-linked list and queue support:
var.h
NCX Variable Support. Used within a runstack by a CLI user or script.
val_value_t_::nsid
xmlns_id_t nsid
namespace ID for this node
Definition: val.h:880
val_replace
status_t val_replace(val_value_t *val, val_value_t *copy)
Replace a specified val_value_t struct and sub-trees.
Definition: val.c:7974
var_set
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.
Definition: var.c:1269
LOGDEBUG3
#define LOGDEBUG3
Check if at least log-level=debug3.
Definition: log.h:297