yumapro  23.10T-7
YumaPro SDK
Loading...
Searching...
No Matches
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
34date init comment
35----------------------------------------------------------------------
3623-aug-07 abb Begun
3709-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
67extern "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
101typedef enum var_type_t_ {
109
114
119
124
128
129
131typedef struct ncx_var_t_ {
132 dlq_hdr_t hdr;
136
141 xmlChar *name;
142
145} ncx_var_t;
146
147
149typedef enum var_side_t_ {
151 ISLEFT
153
154
171typedef 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
190extern void
191 var_free (ncx_var_t *var);
192
193
199extern void
200 var_clean_varQ (dlq_hdr_t *varQ);
201
202
209extern void
210 var_clean_type_from_varQ (dlq_hdr_t *varQ,
211 var_type_t vartype);
212
213
224extern status_t
226 const xmlChar *name,
227 uint32 namelen,
228 const val_value_t *value,
229 var_type_t vartype);
230
231
241extern status_t
243 const xmlChar *name,
244 const val_value_t *value,
245 var_type_t vartype);
246
247
257extern 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
272extern status_t
273 var_set_que (dlq_hdr_t *varQ,
274 const xmlChar *name,
275 const val_value_t *value);
276
277
286extern status_t
287 var_set_move_que (dlq_hdr_t *varQ,
288 const xmlChar *name,
289 val_value_t *value);
290
291
300extern status_t
301 var_set_move_que_global (dlq_hdr_t *varQ,
302 const xmlChar *name,
303 val_value_t *value);
304
305
319extern status_t
321 const xmlChar *name,
322 uint32 namelen,
323 var_type_t vartype,
324 val_value_t *value);
325
326
335extern status_t
337 const xmlChar *name,
338 const val_value_t *value);
339
340
351extern status_t
353 const xmlChar *name,
354 const xmlChar *valstr,
355 var_type_t vartype);
356
357
369extern status_t
371 const xmlChar *name,
372 uint32 namelen,
373 var_type_t vartype);
374
375
385extern status_t
386 var_unset_que (dlq_hdr_t *varQ,
387 const xmlChar *name,
388 uint32 namelen,
389 xmlns_id_t nsid);
390
391
401extern val_value_t *
403 const xmlChar *name,
404 uint32 namelen,
405 var_type_t vartype);
406
407
416extern val_value_t *
418 const xmlChar *name,
419 var_type_t vartype);
420
421
432extern var_type_t
434 const xmlChar *name,
435 uint32 namelen,
436 boolean globalonly);
437
438
448extern var_type_t
450 const xmlChar *name,
451 boolean globalonly);
452
453
463extern 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
478extern val_value_t *
479 var_get_que (dlq_hdr_t *varQ,
480 const xmlChar *name,
481 xmlns_id_t nsid);
482
483
493extern ncx_var_t *
494 var_get_que_raw (dlq_hdr_t *varQ,
495 xmlns_id_t nsid,
496 const xmlChar *name);
497
498
506extern val_value_t *
508 const xmlChar *name);
509
510
519extern val_value_t *
521 const xmlChar *name,
522 uint32 namelen);
523
524
555extern status_t
557 const xmlChar *line,
558 var_side_t side,
559 uint32 *len,
560 var_type_t *vartype,
561 const xmlChar **name,
562 uint32 *namelen,
563 val_value_t **foundval);
564
565
588extern val_value_t *
590 obj_template_t *obj,
591 val_value_t *val,
592 const xmlChar *strval,
593 boolean istop,
594 status_t *res);
595
596
626extern val_value_t *
628 obj_template_t *parentobj,
629 obj_template_t *obj,
630 val_value_t *val,
631 const xmlChar *strval,
632 boolean istop,
633 val_value_t *fillval,
634 status_t *res);
635
636
662extern val_value_t *
664 obj_template_t *obj,
665 const xmlChar *strval,
666 boolean istop,
667 boolean handleEscapedCharacters,
669 status_t *res);
670
671
678extern void
679 var_cvt_generic (dlq_hdr_t *varQ);
680
681
690extern ncx_var_t *
692 const xmlChar *varname,
693 xmlns_id_t nsid);
694
695
706extern ncx_var_t *
708 const xmlChar *varname,
709 uint32 namelen,
710 xmlns_id_t nsid);
711
712
721extern ncx_var_t *
723 boolean islocal);
724
725
732extern ncx_var_t *
733 var_get_next (ncx_var_t *curvar);
734
735
742extern const xmlChar *
743 var_get_name (const ncx_var_t *curvar);
744
745
752extern var_type_t
753 var_get_vartype (const ncx_var_t *curvar);
754
755
760extern void
761 var_init (void);
762
763
770extern void
772 void *cookie);
773
774
781extern void *
783
784
790extern var_getvar_fn_t
791 var_get_getvar_cb (void);
792
793
803extern boolean
804 var_string_is_var_expr (const xmlChar *varstring,
805 uint32 varlen,
806 boolean *plainvar);
807
808
816extern status_t
818 val_value_t *val);
819
820
824#ifdef __cplusplus
825} /* end extern 'C' */
826#endif
827
828#endif /* _H_var */
command line interpreter parsing to internal val_value_t format
dlq provides general double-linked list and queue support:
status_t
global error return code
Definition: status_enum.h:210
uint16 xmlns_id_t
integer handle for registered namespaces
Definition: xmlns.h:89
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:152
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:2481
void var_init(void)
Init the var module.
Definition: var.c:2954
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:2820
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:2133
var_type_t
different types of variables supported
Definition: var.h:101
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:2781
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:1238
void var_free(ncx_var_t *var)
Free a ncx_var_t struct.
Definition: var.c:1154
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:1854
const xmlChar * var_get_name(const ncx_var_t *curvar)
Get the name string for the specified variable.
Definition: var.c:2913
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:1688
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:1277
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:1637
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:1556
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:1717
boolean var_string_is_var_expr(const xmlChar *varstring, uint32 varlen, boolean *plainvar)
Check if the string is a variable reference.
Definition: var.c:3023
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:1338
void * var_get_getvar_cb_cookie(void)
Get the cookie parameter for the getvar callback function used for data templates.
Definition: var.c:3007
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:1959
val_value_t * var_get_local(runstack_context_t *rcxt, const xmlChar *name)
Find a local user variable.
Definition: var.c:1880
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:1305
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:1364
var_side_t
values for isleft parameter in var_check_ref
Definition: var.h:149
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:1493
ncx_var_t *(* var_getvar_fn_t)(const xmlChar *varname, uint32 varlen, void *cookie, status_t *res)
Get Variable Callback.
Definition: var.h:172
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:1424
ncx_var_t * var_get_next(ncx_var_t *curvar)
Find the next local or global variable.
Definition: var.c:2890
void var_cvt_generic(dlq_hdr_t *varQ)
Cleanup after a yangcli session has ended.
Definition: var.c:2741
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:1601
var_getvar_fn_t var_get_getvar_cb(void)
Get the getvar callback function used for data templates.
Definition: var.c:2990
void var_clean_varQ(dlq_hdr_t *varQ)
Clean a Q of ncx_var_t.
Definition: var.c:1176
var_type_t var_get_vartype(const ncx_var_t *curvar)
Get the variable type for the specified variable.
Definition: var.c:2936
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:1787
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:1759
void var_set_getvar_cb(var_getvar_fn_t getcb, void *cookie)
Set the getvar callback function used for data templates.
Definition: var.c:2972
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:1392
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:2078
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:1200
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:1820
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:3080
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:1457
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:1910
ncx_var_t * var_get_first(runstack_context_t *rcxt, boolean islocal)
Find the first local or global variable.
Definition: var.c:2855
@ 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_GLOBAL
user global variables are visible in every context stack frame and can persist across program reboots
Definition: var.h:118
@ VAR_TYP_NONE
not set
Definition: var.h:102
@ VAR_TYP_QUEUE
queue variables are used internally DO NOT USE
Definition: var.h:126
@ 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
@ VAR_TYP_CONFIG
config variables are used within yangcli-pro and yp-shell for its own CLI parameters.
Definition: var.h:113
@ ISLEFT
left-hand-side
Definition: var.h:151
@ ISRIGHT
right-hand-side
Definition: var.h:150
YANG module data structures Many internal representations of YANG module constructs.
Data Object Support.
CLI run stack manager.
struct of NCX user variable mapping for yangcli
Definition: var.h:131
xmlChar * name
variable name
Definition: var.h:141
dlq_hdr_t hdr
queue header
Definition: var.h:132
val_value_t * val
variable value
Definition: var.h:144
var_type_t vartype
variable type for this entry
Definition: var.h:135
xmlns_id_t nsid
namespace ID for this variable
Definition: var.h:138
One YANG data-def-stmt.
Definition: obj.h:1209
Main runstact context control block used by yangcli to process script input loops and conditional sta...
Definition: runstack.h:256
one value to match one type
Definition: val.h:911
Value Node Basic Support.