yumapro  20.10-12
YumaPro SDK
xml_val.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_xml_val
13 #define _H_xml_val
14 
15 /* FILE: xml_val.h
16 *********************************************************************
17 * *
18 * P U R P O S E *
19 * *
20 *********************************************************************/
21 
27 /*********************************************************************
28 * *
29 * C H A N G E H I S T O R Y *
30 * *
31 *********************************************************************
32 
33 date init comment
34 ----------------------------------------------------------------------
35 24-nov-06 abb Begun; split from xsd.c
36 16-jan-07 abb Moved from ncxdump/xml_val_util.h
37 */
38 
39 #include <xmlstring.h>
40 
41 #ifndef _H_status
42 #include "status.h"
43 #endif
44 
45 #ifndef _H_val
46 #include "val.h"
47 #endif
48 
49 #ifndef _H_xmlns
50 #include "xmlns.h"
51 #endif
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 /********************************************************************
58 * *
59 * F U N C T I O N S *
60 * *
61 *********************************************************************/
62 
63 
87 extern xmlChar *
89  const xmlChar *name);
90 
91 
100 extern uint32
102  const xmlChar *name);
103 
104 
114 extern uint32
115  xml_val_sprintf_qname (xmlChar *buff,
116  uint32 bufflen,
117  xmlns_id_t nsid,
118  const xmlChar *name);
119 
120 
131 extern status_t
132  xml_val_add_attr (const xmlChar *name,
133  xmlns_id_t nsid,
134  xmlChar *attrval,
135  val_value_t *val);
136 
137 
148 extern status_t
149  xml_val_add_cattr (const xmlChar *name,
150  xmlns_id_t nsid,
151  const xmlChar *cattrval,
152  val_value_t *val);
153 
154 
166 extern val_value_t *
167  xml_val_new_struct (const xmlChar *name,
168  xmlns_id_t nsid);
169 
170 
182 extern val_value_t *
183  xml_val_new_struct2 (const xmlChar *name,
184  xmlns_id_t nsid);
185 
186 
199 extern val_value_t *
200  xml_val_new_root (const xmlChar *name,
201  xmlns_id_t nsid);
202 
203 
218 extern val_value_t *
219  xml_val_new_string (const xmlChar *name,
220  xmlns_id_t nsid,
221  xmlChar *strval);
222 
223 
238 extern val_value_t *
239  xml_val_new_cstring (const xmlChar *name,
240  xmlns_id_t nsid,
241  const xmlChar *strval);
242 
243 
258 extern val_value_t *
259  xml_val_new_cstring2 (const xmlChar *name,
260  xmlns_id_t nsid,
261  const xmlChar *strval);
262 
263 
278 extern val_value_t *
279  xml_val_new_leaflist_string (const xmlChar *name,
280  xmlns_id_t nsid,
281  xmlChar *strval);
282 
283 
296 extern val_value_t *
297  xml_val_new_flag (const xmlChar *name,
298  xmlns_id_t nsid);
299 
300 
313 extern val_value_t *
314  xml_val_new_flag2 (const xmlChar *name,
315  xmlns_id_t nsid);
316 
317 
331 extern val_value_t *
332  xml_val_new_boolean (const xmlChar *name,
333  xmlns_id_t nsid,
334  boolean boo);
335 
336 
351 extern val_value_t *
352  xml_val_new_number (const xmlChar *name,
353  xmlns_id_t nsid,
354  ncx_num_t *num,
355  ncx_btype_t btyp);
356 
360 #ifdef __cplusplus
361 } /* end extern 'C' */
362 #endif
363 
364 #endif /* _H_xml_val */
xml_strlen
uint32 xml_strlen(const xmlChar *str)
Get the String len for xmlChar.
Definition: xml_util.c:1406
val_set_dname
status_t val_set_dname(val_value_t *val, const xmlChar *dname)
Set the dname field.
Definition: val.c:15387
xml_val_new_root
val_value_t * xml_val_new_root(const xmlChar *name, xmlns_id_t nsid)
Set up a new struct as an ncx:root.
Definition: xml_val.c:390
cfg.h
xml_val_new_cstring
val_value_t * xml_val_new_cstring(const xmlChar *name, xmlns_id_t nsid, const xmlChar *strval)
Set up a new string from a const string copy a const string.
Definition: xml_val.c:451
tstamp.h
Timestamp utilities.
xml_strdup
xmlChar * xml_strdup(const xmlChar *copyFrom)
String duplicate for xmlChar.
Definition: xml_util.c:1553
val.h
Value Node Basic Support.
xml_util.h
XML Utilities.
ncx_num.h
NCX Module Library Number Utility Functions.
val_init_complex
void val_init_complex(val_value_t *val, ncx_btype_t btyp)
Initialize the fields in a complex val_value_t this is deprecated and should only be called by val_in...
Definition: val.c:2746
ncxconst.h
Contains NCX constants.
ncxmod.h
NCX Module Load Manager.
xml_val_new_boolean
val_value_t * xml_val_new_boolean(const xmlChar *name, xmlns_id_t nsid, boolean boo)
Set up a new boolean.
Definition: xml_val.c:625
xmlns_id_t
uint16 xmlns_id_t
integer handle for registered namespaces
Definition: xmlns.h:89
val_get_dname
const xmlChar * val_get_dname(const val_value_t *val)
Get the dname field if set; NULL if not set.
Definition: val.c:15363
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
def_reg.h
Definition Registry module.
NO_ERR
@ NO_ERR
000
Definition: status_enum.h:188
xml_val.h
Utility functions for creating value structs.
xml_val_new_string
val_value_t * xml_val_new_string(const xmlChar *name, xmlns_id_t nsid, xmlChar *strval)
Set up a new string element; reuse the value instead of copying it hand off a malloced string.
Definition: xml_val.c:423
ERR_INTERNAL_VAL
@ ERR_INTERNAL_VAL
004
Definition: status_enum.h:194
xml_val_new_leaflist_string
val_value_t * xml_val_new_leaflist_string(const xmlChar *name, xmlns_id_t nsid, xmlChar *strval)
Set up a new string element; reuse the value instead of copying it hand off a malloced string.
Definition: xml_val.c:527
xml_val_new_number
val_value_t * xml_val_new_number(const xmlChar *name, xmlns_id_t nsid, ncx_num_t *num, ncx_btype_t btyp)
Set up a new number.
Definition: xml_val.c:657
ncx_get_gen_container
obj_template_t * ncx_get_gen_container(void)
Get the object template for the NCX generic container.
Definition: ncx.c:6678
xml_val_qname_len
uint32 xml_val_qname_len(xmlns_id_t nsid, const xmlChar *name)
Determine the length of the qname string that would be generated with the xml_val_make_qname function...
Definition: xml_val.c:178
NCX_BT_EMPTY
@ NCX_BT_EMPTY
empty
Definition: ncxtypes.h:205
rpc.h
NETCONF protocol remote procedure call common definitions.
ERR_INTERNAL_MEM
@ ERR_INTERNAL_MEM
003
Definition: status_enum.h:193
NCX_BT_CONTAINER
@ NCX_BT_CONTAINER
internal container
Definition: ncxtypes.h:225
typ.h
Parameter Type Handler.
xmlns_get_ns_prefix
const xmlChar * xmlns_get_ns_prefix(xmlns_id_t ns_id)
Get the prefix for the specified namespace.
Definition: xmlns.c:669
val_add_meta
status_t val_add_meta(val_value_t *metaval, val_value_t *val)
Add a meta value to a value node.
Definition: val.c:15157
ncx_get_gen_root
obj_template_t * ncx_get_gen_root(void)
Get the object template for the NCX generic root container.
Definition: ncx.c:6720
ncx_get_gen_leaflist
obj_template_t * ncx_get_gen_leaflist(void)
Get the object template for the NCX generic leaf-list string.
Definition: ncx.c:6750
xml_val_make_qname
xmlChar * xml_val_make_qname(xmlns_id_t nsid, const xmlChar *name)
Make a Q-name string.
Definition: xml_val.c:134
xml_val_new_flag2
val_value_t * xml_val_new_flag2(const xmlChar *name, xmlns_id_t nsid)
Set up a new flag; malloc name!
Definition: xml_val.c:587
xml_val_new_struct
val_value_t * xml_val_new_struct(const xmlChar *name, xmlns_id_t nsid)
Set up a new generic struct.
Definition: xml_val.c:323
xml_val_add_cattr
status_t xml_val_add_cattr(const xmlChar *name, xmlns_id_t nsid, const xmlChar *cattrval, val_value_t *val)
Set up a new attr val and add it to the specified val const version copies string.
Definition: xml_val.c:292
xml_val_new_flag
val_value_t * xml_val_new_flag(const xmlChar *name, xmlns_id_t nsid)
Set up a new flag (NCX_NT_EMPTY)
Definition: xml_val.c:553
ERR_BUFF_OVFL
@ ERR_BUFF_OVFL
106
Definition: status_enum.h:218
ncxtypes.h
YANG module data structures Many internal representations of YANG module constructs.
ncx_get_gen_empty
obj_template_t * ncx_get_gen_empty(void)
Get the object template for the NCX generic empty leaf.
Definition: ncx.c:6706
xml_val_add_attr
status_t xml_val_add_attr(const xmlChar *name, xmlns_id_t nsid, xmlChar *attrval, val_value_t *val)
Set up a new attr val and add it to the specified val hand off a malloced attribute string.
Definition: xml_val.c:252
xml_strcpy
uint32 xml_strcpy(xmlChar *copyTo, const xmlChar *copyFrom)
String copy for xmlChar.
Definition: xml_util.c:1486
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_new_value
val_value_t * val_new_value(void)
Malloc and initialize the fields in a val_value_t.
Definition: val.c:2697
ncx.h
YANG module utility functions.
ncx_copy_num
status_t ncx_copy_num(const ncx_num_t *num1, ncx_num_t *num2, ncx_btype_t btyp)
Copy the contents of num1 to num2.
Definition: ncx_num.c:1451
xml_val_sprintf_qname
uint32 xml_val_sprintf_qname(xmlChar *buff, uint32 bufflen, xmlns_id_t nsid, const xmlChar *name)
construct a QName into a buffer
Definition: xml_val.c:207
SET_ERROR
#define SET_ERROR(E)
macro SET_ERROR
Definition: status_enum.h:103
xml_val_new_struct2
val_value_t * xml_val_new_struct2(const xmlChar *name, xmlns_id_t nsid)
Set up a new generic struct; copy the name.
Definition: xml_val.c:354
NCX_BT_STRING
@ NCX_BT_STRING
string
Definition: ncxtypes.h:217
xmlns.h
XML namespace support.
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
xml_val_new_cstring2
val_value_t * xml_val_new_cstring2(const xmlChar *name, xmlns_id_t nsid, const xmlChar *strval)
Set up a new string from a const string copy a const string; malloc the name!
Definition: xml_val.c:486
status.h
Global error messages for status code enumerations.
dlq.h
dlq provides general double-linked list and queue support: