yumapro  20.10-12
YumaPro SDK
xml_util.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_util
13 #define _H_xml_util
14 /* FILE: xml_util.h
15 *********************************************************************
16 * *
17 * P U R P O S E *
18 * *
19 *********************************************************************/
20 
26 /*********************************************************************
27 * *
28 * C H A N G E H I S T O R Y *
29 * *
30 *********************************************************************
31 
32 date init comment
33 ----------------------------------------------------------------------
34 14-oct-05 abb begun
35 2-jan-06 abb rewrite xml_consume_* API to use simpler
36  xml_node_t
37 */
38 
39 
40 /* From /usr/include/libxml2/libxml/ */
41 #include <xmlreader.h>
42 #include <xmlstring.h>
43 
44 #ifndef _H_ncxconst
45 #include "ncxconst.h"
46 #endif
47 
48 #ifndef _H_xmlns
49 #include "xmlns.h"
50 #endif
51 
52 #ifndef _H_log
53 #include "log.h"
54 #endif
55 
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59 
60 /********************************************************************
61 * *
62 * C O N S T A N T S *
63 * *
64 *********************************************************************/
65 
66 #define MAX_CHAR_ENT 8
67 
68 #define XML_START_MSG ((const xmlChar *)\
69  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
70 
71 #define XML_START_MSG_SIZE 38
72 
73 
74 /* XML_PARSE_NOCDATA option merge CDATA as text nodes, used to
75  * parse Confd get-schema reply properly
76  */
77 #define XML_READER_OPTIONS XML_PARSE_RECOVER+XML_PARSE_NOERROR+\
78  XML_PARSE_NOWARNING+XML_PARSE_NOBLANKS+XML_PARSE_NONET+ \
79  XML_PARSE_XINCLUDE+XML_PARSE_NOCDATA
80 
81 #define XML_SES_URL "netconf://pdu"
82 
83 /********************************************************************
84 * *
85 * T Y P E S *
86 * *
87 *********************************************************************/
88 
151 typedef dlq_hdr_t xml_attrs_t;
152 
153 
155 typedef struct xml_attr_t_ {
157  dlq_hdr_t attr_qhdr;
158 
161 
164 
166  const xmlChar *attr_qname;
167 
169  const xmlChar *attr_name;
170 
174  xmlChar *attr_dname;
175 
177  xmlChar *attr_val;
178 
185 } xml_attr_t;
186 
187 
189 typedef enum xml_nodetyp_t_ {
195 } xml_nodetyp_t;
196 
197 
203 typedef struct xml_node_t_ {
205  xml_nodetyp_t nodetyp;
206 
209 
212 
214  const xmlChar *module;
215 
217  const xmlChar *badns;
218 
220  xmlChar *qname;
221 
223  const xmlChar *elname;
224 
226  const xmlChar *simval;
227 
229  uint32 simlen;
230 
232  xmlChar *simfree;
233 
235  int depth;
236 
239 } xml_node_t;
240 
241 
242 /********************************************************************
243 * *
244 * F U N C T I O N S *
245 * *
246 *********************************************************************/
247 
248 
254 extern xml_node_t *
255  xml_new_node (void);
256 
257 
263 extern void
264  xml_init_node (xml_node_t *node);
265 
266 
272 extern void
273  xml_free_node (xml_node_t *node);
274 
275 
281 extern void
282  xml_clean_node (xml_node_t *node);
283 
284 
293 extern status_t
294  xml_get_reader_from_buff (const xmlChar *buff,
295  xmlTextReaderPtr *reader);
296 
297 
307 extern status_t
308  xml_get_reader_from_filespec (const char *filespec,
309  xmlTextReaderPtr *reader);
310 
311 
323 extern status_t
324  xml_get_reader_for_session (xmlInputReadCallback readfn,
325  xmlInputCloseCallback closefn,
326  void *context,
327  xmlTextReaderPtr *reader);
328 
329 
341 extern status_t
342  xml_reset_reader_for_session (xmlInputReadCallback readfn,
343  xmlInputCloseCallback closefn,
344  void *context,
345  xmlTextReaderPtr reader);
346 
347 
353 extern void
354  xml_free_reader (xmlTextReaderPtr reader);
355 
356 
364 extern const char *
365  xml_get_node_name (int nodeval);
366 
367 
375 extern boolean
376  xml_advance_reader (xmlTextReaderPtr reader);
377 
378 
388 extern status_t
389  xml_node_match (const xml_node_t *node,
390  xmlns_id_t nsid,
391  const xmlChar *elname,
392  xml_nodetyp_t nodetyp);
393 
394 
403 extern status_t
404  xml_endnode_match (const xml_node_t *startnode,
405  const xml_node_t *endnode);
406 
407 
416 extern boolean
417  xml_docdone (xmlTextReaderPtr reader);
418 
419 
426 extern void
427  xml_dump_node (const xml_node_t *node,
428  log_debug_t lvl);
429 
430 
436 extern void
437  xml_init_attrs (xml_attrs_t *attrs);
438 
439 
445 extern xml_attr_t *
446  xml_new_attr (void);
447 
448 
454 extern void
455  xml_free_attr (xml_attr_t *attr);
456 
457 
467 extern status_t
468  xml_add_attr (xml_attrs_t *attrs,
469  xmlns_id_t ns_id,
470  const xmlChar *attr_name,
471  const xmlChar *attr_val);
472 
473 
487 extern xml_attr_t *
488  xml_add_qattr (xml_attrs_t *attrs,
489  xmlns_id_t ns_id,
490  const xmlChar *attr_qname,
491  uint32 plen,
492  const xmlChar *attr_val,
493  status_t *res);
494 
495 
505 extern status_t
507  xmlns_id_t ns_id,
508  const xmlChar *pfix);
509 
510 
520 extern status_t
522  const xmlChar *ns,
523  const xmlChar *pfix);
524 
525 
538 extern status_t
540  xmlns_id_t ns_id,
541  const xmlChar *pfix,
542  const xmlChar *nsval);
543 
544 
551 extern xml_attr_t *
552  xml_first_attr (xml_attrs_t *attrs);
553 
554 
561 extern xml_attr_t *
562  xml_get_first_attr (const xml_node_t *node);
563 
564 
571 extern xml_attr_t *
572  xml_next_attr (xml_attr_t *attr);
573 
574 
580 extern void
581  xml_clean_attrs (xml_attrs_t *attrs);
582 
583 
590 extern void
591  xml_move_attrs (xml_attrs_t *src_attrs,
592  xml_attrs_t *dest_attrs);
593 
594 
595 
607 extern xml_attr_t *
608  xml_find_attr (xml_node_t *node,
609  xmlns_id_t nsid,
610  const xmlChar *attrname);
611 
612 
624 extern xml_attr_t *
626  xmlns_id_t nsid,
627  const xmlChar *attrname);
628 
629 
641 extern const xml_attr_t *
642  xml_find_ro_attr (const xml_node_t *node,
643  xmlns_id_t nsid,
644  const xmlChar *attrname);
645 
646 
655 extern uint32
656  xml_strlen (const xmlChar *str);
657 
658 
670 extern uint32
671  xml_strlen_sp (const xmlChar *str,
672  boolean *sp);
673 
674 
685 extern uint32
686  xml_strcpy (xmlChar *copyTo,
687  const xmlChar *copyFrom);
688 
689 
699 extern uint32
700  xml_strncpy (xmlChar *copyTo,
701  const xmlChar *copyFrom,
702  uint32 maxlen);
703 
704 
711 extern xmlChar *
712  xml_strdup (const xmlChar *copyFrom);
713 
714 
722 extern xmlChar *
723  xml_strcat (xmlChar *appendTo,
724  const xmlChar *appendFrom);
725 
726 
735 extern xmlChar *
736  xml_strncat (xmlChar *appendTo,
737  const xmlChar *appendFrom,
738  uint32 maxlen);
739 
740 
748 extern xmlChar *
749  xml_strndup (const xmlChar *copyFrom,
750  uint32 maxlen);
751 
752 
760 extern char *
761  xml_ch_strndup (const char *copyFrom,
762  uint32 maxlen);
763 
764 
778 extern int
779  xml_strcmp (const xmlChar *s1,
780  const xmlChar *s2);
781 
782 
796 extern int
797  xml_stricmp (const xmlChar *s1,
798  const xmlChar *s2);
799 
800 
814 extern int
815  xml_strncmp (const xmlChar *s1,
816  const xmlChar *s2,
817  uint32 maxlen);
818 
819 
834 extern int
835  xml_strnicmp (const xmlChar *s1,
836  const xmlChar *s2,
837  uint32 maxlen);
838 
839 
846 extern boolean
847  xml_isspace (uint32 ch);
848 
849 
856 extern boolean
857  xml_isspace_str (const xmlChar *str);
858 
859 
877 extern int
878  xml_strcmp_nosp (const xmlChar *s1,
879  const xmlChar *s2);
880 
881 
902 int
903  xml_strcmp_nosp2 (const xmlChar *s1,
904  const xmlChar *s2);
905 
906 
918 extern xmlChar *
919  xml_copy_clean_string (const xmlChar *str);
920 
921 
930 extern xmlChar
931  xml_convert_char_entity (const xmlChar *str,
932  uint32 *used);
933 
934 
954 extern status_t
955  xml_check_ns (xmlTextReaderPtr reader,
956  const xmlChar *elname,
957  xmlns_id_t *id,
958  uint32 *pfix_len,
959  const xmlChar **badns);
960 
961 
971 extern void
972  xml_check_qname_content (xmlTextReaderPtr reader,
973  xml_node_t *node);
974 
975 
991 extern status_t
992  xml_get_namespace_id (xmlTextReaderPtr reader,
993  const xmlChar *prefix,
994  uint32 prefixlen,
995  boolean register_missing,
996  xmlns_id_t *retnsid);
997 
998 
1013 extern status_t
1014  xml_consume_node (xmlTextReaderPtr reader,
1015  xml_node_t *xmlnode,
1016  boolean nserr,
1017  boolean adv);
1018 
1019 
1032 extern xmlChar * xml_trim_string (xmlChar *str);
1033 
1034 
1038 #ifdef __cplusplus
1039 } /* end extern 'C' */
1040 #endif
1041 
1042 #endif /* _H_xml_util */
xml_strlen
uint32 xml_strlen(const xmlChar *str)
Get the String len for xmlChar.
Definition: xml_util.c:1406
ERR_NCX_WRONG_NODEDEPTH
@ ERR_NCX_WRONG_NODEDEPTH
277
Definition: status_enum.h:320
xml_free_node
void xml_free_node(xml_node_t *node)
Free an xml_node_t struct.
Definition: xml_util.c:246
xpath_free_pcb
void xpath_free_pcb(xpath_pcb_t *pcb)
Free a malloced XPath parser control block.
Definition: xpath.c:2963
ERR_NCX_WRONG_NODETYP
@ ERR_NCX_WRONG_NODETYP
282
Definition: status_enum.h:325
dlq_block_enque
void dlq_block_enque(dlq_hdrT *srcP, dlq_hdrT *dstP)
add all the queue entries in the srcP queue list to the end of the dstP queue list
Definition: dlq.c:731
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
xml_reset_reader_for_session
status_t xml_reset_reader_for_session(xmlInputReadCallback readfn, xmlInputCloseCallback closefn, void *context, xmlTextReaderPtr reader)
Reset the xmlTextReader for parsing the input of a NETCONF session.
Definition: xml_util.c:418
xml_strdup
xmlChar * xml_strdup(const xmlChar *copyFrom)
String duplicate for xmlChar.
Definition: xml_util.c:1553
def_reg_find_ns
xmlns_t * def_reg_find_ns(const xmlChar *nsname)
find one xmlns_t in the registry find a xmlns_t by its value (name)
Definition: def_reg.c:397
xml_clean_node
void xml_clean_node(xml_node_t *node)
Clean an xml_node_t struct.
Definition: xml_util.c:266
xml_node_t_::qname
xmlChar * qname
qualified name of element
Definition: xml_util.h:220
xml_advance_reader
boolean xml_advance_reader(xmlTextReaderPtr reader)
Advance to the next node in the specified reader.
Definition: xml_util.c:517
xml_attr_t_::attr_val
xmlChar * attr_val
attribute value string
Definition: xml_util.h:177
log_error
void log_error(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_ERROR log entry.
xml_get_namespace_id
status_t xml_get_namespace_id(xmlTextReaderPtr reader, const xmlChar *prefix, uint32 prefixlen, boolean register_missing, xmlns_id_t *retnsid)
Get the namespace for the specified prefix (may be NULL) Use the current XML reader context to resolv...
Definition: xml_util.c:2360
ERR_NCX_UNKNOWN_ELEMENT
@ ERR_NCX_UNKNOWN_ELEMENT
265
Definition: status_enum.h:306
xml_util.h
XML Utilities.
xml_add_xmlns_attr_string
status_t xml_add_xmlns_attr_string(xml_attrs_t *attrs, const xmlChar *ns, const xmlChar *pfix)
add an xmlns decl to the attribute Queue
Definition: xml_util.c:1011
xml_add_inv_xmlns_attr
status_t xml_add_inv_xmlns_attr(xml_attrs_t *attrs, xmlns_id_t ns_id, const xmlChar *pfix, const xmlChar *nsval)
add an xmlns decl to the attribute Queue for an INVALID namespace.
Definition: xml_util.c:1090
xmlns_register_temp_ns
status_t xmlns_register_temp_ns(const xmlChar *ns, const xmlChar *pfix, xmlns_id_t *ns_id)
Register the specified temporary namespace.
Definition: xmlns.c:561
xmlns_ns_id
xmlns_id_t xmlns_ns_id(void)
Get the ID for the XMLNS namespace or 0 if it doesn't exist.
Definition: xmlns.c:914
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.
NCX_DEF_MODULE
#define NCX_DEF_MODULE
Internal default module for NETCONF.
Definition: ncxconst.h:292
XML_NT_END
@ XML_NT_END
end-tag of an element
Definition: xml_util.h:193
xml_strnicmp
int xml_strnicmp(const xmlChar *s1, const xmlChar *s2, uint32 maxlen)
Case insensitive string compare for xmlChar for at most 'maxlen' xmlChars.
Definition: xml_util.c:1865
xml_isspace_str
boolean xml_isspace_str(const xmlChar *str)
Check if an xmlChar string is all whitespace chars.
Definition: xml_util.c:1923
ncxconst.h
Contains NCX constants.
xml_isspace
boolean xml_isspace(uint32 ch)
Check if an xmlChar is a space char.
Definition: xml_util.c:1901
xml_node_t_::elname
const xmlChar * elname
element name without any prefix
Definition: xml_util.h:223
xml_stricmp
int xml_stricmp(const xmlChar *s1, const xmlChar *s2)
Case insensitive string compare for xmlChar.
Definition: xml_util.c:1785
xml_attr_t_::attr_xpcb
struct xpath_pcb_t_ * attr_xpcb
XPath PCB in case XPath was parsed.
Definition: xml_util.h:184
xml_strncat
xmlChar * xml_strncat(xmlChar *appendTo, const xmlChar *appendFrom, uint32 maxlen)
String concatenate for at most maxlen xmlChars.
Definition: xml_util.c:1630
xml_clean_attrs
void xml_clean_attrs(xml_attrs_t *attrs)
clean an xml_attrs_t variable
Definition: xml_util.c:1243
xml_node_t_::badns
const xmlChar * badns
set if nsid == xmlns_inv_id()
Definition: xml_util.h:217
xml_copy_clean_string
xmlChar * xml_copy_clean_string(const xmlChar *str)
Get a malloced string contained the converted string from the input.
Definition: xml_util.c:2119
xml_node_t_::contentnsid
xmlns_id_t contentnsid
namespace of content
Definition: xml_util.h:211
xmlns_get_module
const xmlChar * xmlns_get_module(xmlns_id_t nsid)
get the module name of the namespace ID
Definition: xmlns.c:1126
xmlns_id_t
uint16 xmlns_id_t
integer handle for registered namespaces
Definition: xmlns.h:89
xml_get_reader_from_filespec
status_t xml_get_reader_from_filespec(const char *filespec, xmlTextReaderPtr *reader)
Get a new xmlTextReader for parsing a debug test file.
Definition: xml_util.c:341
def_reg.h
Definition Registry module.
xml_node_t_::module
const xmlChar * module
YANG module found for this node.
Definition: xml_util.h:214
xml_get_reader_from_buff
status_t xml_get_reader_from_buff(const xmlChar *buff, xmlTextReaderPtr *reader)
Get a new xmlTextReader for parsing a debug test file.
Definition: xml_util.c:305
NO_ERR
@ NO_ERR
000
Definition: status_enum.h:188
xpath.h
Schema and data model Xpath search support.
xml_first_attr
xml_attr_t * xml_first_attr(xml_attrs_t *attrs)
get the first attribute in the list
Definition: xml_util.c:1167
xml_ch_strndup
char * xml_ch_strndup(const char *copyFrom, uint32 maxlen)
String duplicate for max N chars.
Definition: xml_util.c:1703
xml_node_t_::nsid
xmlns_id_t nsid
namespace ID
Definition: xml_util.h:208
xml_strndup
xmlChar * xml_strndup(const xmlChar *copyFrom, uint32 maxlen)
String duplicate for max N xmlChars.
Definition: xml_util.c:1663
xml_init_attrs
void xml_init_attrs(xml_attrs_t *attrs)
initialize an xml_attrs_t variable
Definition: xml_util.c:745
xml_check_ns
status_t xml_check_ns(xmlTextReaderPtr reader, const xmlChar *elname, xmlns_id_t *id, uint32 *pfix_len, const xmlChar **badns)
Check a namespace during parsing.
Definition: xml_util.c:2248
XML_NT_STRING
@ XML_NT_STRING
string content node
Definition: xml_util.h:194
ERR_NCX_OPERATION_FAILED
@ ERR_NCX_OPERATION_FAILED
274
Definition: status_enum.h:315
xml_node_t_::attrs
xml_attrs_t attrs
attributes parsed for this node if XML_NT_EMPTY or XML_NT_START
Definition: xml_util.h:238
dlq_createSQue
void dlq_createSQue(dlq_hdrT *queAddr)
create a static queue header
Definition: dlq.c:177
ERR_INTERNAL_VAL
@ ERR_INTERNAL_VAL
004
Definition: status_enum.h:194
xml_node_t_::depth
int depth
XML node depth.
Definition: xml_util.h:235
xml_add_xmlns_attr
status_t xml_add_xmlns_attr(xml_attrs_t *attrs, xmlns_id_t ns_id, const xmlChar *pfix)
add an xmlns decl to the attribute Queue
Definition: xml_util.c:928
xml_strlen_sp
uint32 xml_strlen_sp(const xmlChar *str, boolean *sp)
get length and check if any whitespace at the same time
Definition: xml_util.c:1443
xml_convert_char_entity
xmlChar xml_convert_char_entity(const xmlChar *str, uint32 *used)
Convert an XML character entity into a single xmlChar.
Definition: xml_util.c:2185
rpc.h
NETCONF protocol remote procedure call common definitions.
xml_node_t_::simlen
uint32 simlen
length of the simple value string
Definition: xml_util.h:229
ERR_INTERNAL_MEM
@ ERR_INTERNAL_MEM
003
Definition: status_enum.h:193
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
XML_NT_NONE
@ XML_NT_NONE
not set
Definition: xml_util.h:190
xml_node_t_
gather node data into a simple struct.
Definition: xml_util.h:203
get_error_string
const char * get_error_string(status_t res)
Get the error message for a specific internal error.
Definition: status.c:239
ERR_INTERNAL_PTR
@ ERR_INTERNAL_PTR
002
Definition: status_enum.h:192
xml_new_attr
xml_attr_t * xml_new_attr(void)
malloc and init an attribute struct
Definition: xml_util.c:764
xml_next_attr
xml_attr_t * xml_next_attr(xml_attr_t *attr)
get the next attribute in the list
Definition: xml_util.c:1218
ERR_XML_READER_NULLNAME
@ ERR_XML_READER_NULLNAME
215
Definition: status_enum.h:254
xml_find_attr_q
xml_attr_t * xml_find_attr_q(xml_attrs_t *attrs, xmlns_id_t nsid, const xmlChar *attrname)
Find an attribute in a Q.
Definition: xml_util.c:1324
xml_attr_t_::attr_ns
xmlns_id_t attr_ns
attribute namespace ID
Definition: xml_util.h:160
xml_node_t_::nodetyp
xml_nodetyp_t nodetyp
XML tag type.
Definition: xml_util.h:205
xml_free_attr
void xml_free_attr(xml_attr_t *attr)
free an attribute
Definition: xml_util.c:785
dlq_nextEntry
#define dlq_nextEntry(nodeP)
get the next queue entry after the current entry
Definition: dlq.h:265
ERR_XML_READER_NULLVAL
@ ERR_XML_READER_NULLVAL
216
Definition: status_enum.h:255
xml_trim_string
xmlChar * xml_trim_string(xmlChar *str)
trim leading and trailing whitespace inline in the same buffer
Definition: xml_util.c:2646
xml_nodetyp_t_
xml_nodetyp_t_
only 4 types of nodes returned
Definition: xml_util.h:189
xml_new_node
xml_node_t * xml_new_node(void)
Malloc and init a new xml_node_t struct.
Definition: xml_util.c:206
EMPTY_STRING
#define EMPTY_STRING
empty string used to get const xmlChar * cast
Definition: ncxconst.h:289
xml_strcmp
int xml_strcmp(const xmlChar *s1, const xmlChar *s2)
String compare for xmlChar.
Definition: xml_util.c:1746
xml_check_qname_content
void xml_check_qname_content(xmlTextReaderPtr reader, xml_node_t *node)
Check if the string node content is a likely QName.
Definition: xml_util.c:2307
log.h
NCX System Logging Manager.
ERR_NCX_WRONG_NAMESPACE
@ ERR_NCX_WRONG_NAMESPACE
netconf error extensions start here
Definition: status_enum.h:319
ERR_NCX_WRONG_ELEMENT
@ ERR_NCX_WRONG_ELEMENT
279
Definition: status_enum.h:322
ERR_XML_READER_INTERNAL
@ ERR_XML_READER_INTERNAL
121
Definition: status_enum.h:233
ERR_NCX_UNKNOWN_NS
@ ERR_NCX_UNKNOWN_NS
229
Definition: status_enum.h:268
xml_find_attr
xml_attr_t * xml_find_attr(xml_node_t *node, xmlns_id_t nsid, const xmlChar *attrname)
Find an attribute.
Definition: xml_util.c:1295
xml_node_t_::simfree
xmlChar * simfree
non-NULL if simval is freed
Definition: xml_util.h:232
XML_NT_START
@ XML_NT_START
start-tag of an element
Definition: xml_util.h:192
xpath_pcb_t_
XPath parser control block.
Definition: xpath.h:668
xml_free_reader
void xml_free_reader(xmlTextReaderPtr reader)
Free the previously allocated xmlTextReader.
Definition: xml_util.c:453
xml_move_attrs
void xml_move_attrs(xml_attrs_t *src_attrs, xml_attrs_t *dest_attrs)
Move all the attrs from the src to the dest.
Definition: xml_util.c:1272
xml_attr_t_::attr_name
const xmlChar * attr_name
attribute name without any prefix
Definition: xml_util.h:169
xml_strcmp_nosp2
int xml_strcmp_nosp2(const xmlChar *s1, const xmlChar *s2)
String compare for xmlChar for 2 strings, but completely ignoring whitespace differences.
Definition: xml_util.c:2043
xml_attr_t_::attr_qname
const xmlChar * attr_qname
attribute qname with prefix (if any)
Definition: xml_util.h:166
xml_get_node_name
const char * xml_get_node_name(int nodeval)
get the node type according to the xmlElementType enum list in /usr/include/libxml/libxml/tree....
Definition: xml_util.c:475
xml_attr_t_::attr_dname
xmlChar * attr_dname
malloced attribute name full qualified name if any
Definition: xml_util.h:174
dlq_deque
void * dlq_deque(dlq_hdrT *listP)
remove the first queue node from the queue list
Definition: dlq.c:286
dlq_empty
#define dlq_empty(listP)
check if queue list is empty
Definition: dlq.h:367
xml_add_attr
status_t xml_add_attr(xml_attrs_t *attrs, xmlns_id_t ns_id, const xmlChar *attr_name, const xmlChar *attr_val)
add an attribute to an attribute list
Definition: xml_util.c:820
xml_docdone
boolean xml_docdone(xmlTextReaderPtr reader)
check if the input is completed for a given PDU
Definition: xml_util.c:636
xml_strcpy
uint32 xml_strcpy(xmlChar *copyTo, const xmlChar *copyFrom)
String copy for xmlChar.
Definition: xml_util.c:1486
ERR_XML_READER_START_FAILED
@ ERR_XML_READER_START_FAILED
212
Definition: status_enum.h:251
xml_strcat
xmlChar * xml_strcat(xmlChar *appendTo, const xmlChar *appendFrom)
String concatenate for xmlChar.
Definition: xml_util.c:1597
ERR_XML_READER_EOF
@ ERR_XML_READER_EOF
221
Definition: status_enum.h:260
xml_strcmp_nosp
int xml_strcmp_nosp(const xmlChar *s1, const xmlChar *s2)
String compare for xmlChar for 2 strings, but ignoring whitespace differences.
Definition: xml_util.c:1964
xml_attr_t_
represents one attribute
Definition: xml_util.h:155
dlq_firstEntry
#define dlq_firstEntry(listP)
get the first entry in the queue list
Definition: dlq.h:337
ncx.h
YANG module utility functions.
xml_attrs_t
dlq_hdr_t xml_attrs_t
queue of xml_attr_t
Definition: xml_util.h:151
xml_find_ro_attr
const xml_attr_t * xml_find_ro_attr(const xml_node_t *node, xmlns_id_t nsid, const xmlChar *attrname)
Find a read-only attribute.
Definition: xml_util.c:1367
xml_get_first_attr
xml_attr_t * xml_get_first_attr(const xml_node_t *node)
get the first attribute in the attrs list, from an xml_node_t param
Definition: xml_util.c:1192
xmlns_get_ns_name
const xmlChar * xmlns_get_ns_name(xmlns_id_t ns_id)
Get the name for the specified namespace.
Definition: xmlns.c:690
xml_node_t_::simval
const xmlChar * simval
simple value if this is an XML_NT_STRING node
Definition: xml_util.h:226
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
xmlns_inv_id
xmlns_id_t xmlns_inv_id(void)
Get the INVALID namespace ID.
Definition: xmlns.c:931
SET_ERROR
#define SET_ERROR(E)
macro SET_ERROR
Definition: status_enum.h:103
XML_NT_EMPTY
@ XML_NT_EMPTY
standalone empty node
Definition: xml_util.h:191
xml_init_node
void xml_init_node(xml_node_t *node)
Init an xml_node_t struct.
Definition: xml_util.c:229
ERR_NCX_UNKNOWN_NAMESPACE
@ ERR_NCX_UNKNOWN_NAMESPACE
266
Definition: status_enum.h:307
xmlns_find_ns_by_name
xmlns_id_t xmlns_find_ns_by_name(const xmlChar *name)
Find the NS ID from its name.
Definition: xmlns.c:797
xml_add_qattr
xml_attr_t * xml_add_qattr(xml_attrs_t *attrs, xmlns_id_t ns_id, const xmlChar *attr_qname, uint32 plen, const xmlChar *attr_val, status_t *res)
add a qualified attribute to an attribute list with a prefix
Definition: xml_util.c:872
xml_endnode_match
status_t xml_endnode_match(const xml_node_t *startnode, const xml_node_t *endnode)
check if a specific node is the proper endnode match for a given startnode
Definition: xml_util.c:592
xmlns.h
XML namespace support.
status.h
Global error messages for status code enumerations.
xml_dump_node
void xml_dump_node(const xml_node_t *node, log_debug_t lvl)
Debug function to printf xml_node_t contents.
Definition: xml_util.c:661
xml_attr_t_::attr_xmlns_ns
xmlns_id_t attr_xmlns_ns
if xmlns, then namespace ID getting assigned
Definition: xml_util.h:163
xml_node_match
status_t xml_node_match(const xml_node_t *node, xmlns_id_t nsid, const xmlChar *elname, xml_nodetyp_t nodetyp)
check if a specific node is the proper owner, name, and type
Definition: xml_util.c:545
xml_consume_node
status_t xml_consume_node(xmlTextReaderPtr reader, xml_node_t *xmlnode, boolean nserr, boolean adv)
parse function for YIN input
Definition: xml_util.c:2447
LOGDEBUG3
#define LOGDEBUG3
Check if at least log-level=debug3.
Definition: log.h:297
xml_attr_t_::attr_qhdr
dlq_hdr_t attr_qhdr
queue header
Definition: xml_util.h:157
xml_get_reader_for_session
status_t xml_get_reader_for_session(xmlInputReadCallback readfn, xmlInputCloseCallback closefn, void *context, xmlTextReaderPtr *reader)
Get a new xmlTextReader for parsing the input of a NETCONF session.
Definition: xml_util.c:378