yumapro  24.10-3
YumaPro SDK
Loading...
Searching...
No Matches
xml_wr.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_wr
13#define _H_xml_wr
14
15/* FILE: xml_wr.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
33date init comment
34----------------------------------------------------------------------
3512-feb-07 abb Begun; split out from xml_wr_util.c
36
37*/
38
39#include <stdio.h>
40#include <xmlstring.h>
41
42#ifndef _H_cfg
43#include "cfg.h"
44#endif
45
46#ifndef _H_dlq
47#include "dlq.h"
48#endif
49
50#ifndef _H_getcb
51#include "getcb.h"
52#endif
53
54#ifndef _H_ncxtypes
55#include "ncxtypes.h"
56#endif
57
58#ifndef _H_ses
59#include "ses.h"
60#endif
61
62#ifndef _H_status
63#include "status.h"
64#endif
65
66#ifndef _H_val
67#include "val.h"
68#endif
69
70#ifndef _H_val_util
71#include "val_util.h"
72#endif
73
74#ifndef _H_xml_msg
75#include "xml_msg.h"
76#endif
77
78#ifdef __cplusplus
79extern "C" {
80#endif
81
82/********************************************************************
83* *
84* C O N S T A N T S *
85* *
86*********************************************************************/
87
88/* isattrq labels */
89#define ATTRQ TRUE
90#define METAQ FALSE
91
92/* empty labels */
93#define START FALSE
94#define EMPTY TRUE
95
96/* docmode labels */
97#define XMLMODE FALSE
98#define DOCMODE TRUE
99
100/* xmlhdr labels */
101#define NOHDR FALSE
102#define WITHHDR TRUE
103
104/* buffer size used in begin_elem_val function
105 * this is sort of a hack -- a hard limit in the code:
106 * this limits the number of different namespace IDs
107 * that can be present in a single XPath expression
108 * and the xmlns attributes will be corrected generated
109 * in element start tags for the XPath expression
110 */
111#define XML_WR_MAX_NAMESPACES 512
112
113
114/********************************************************************
115* *
116* T Y P E S *
117* *
118*********************************************************************/
119
120
131typedef struct walker_cookie_t_ {
134
137
139 int32 indent;
140
143
146
148 boolean maxmode;
150
151
152/********************************************************************
153* *
154* F U N C T I O N S *
155* *
156*********************************************************************/
157
158
169extern void
170 xml_wr_buff (ses_cb_t *scb,
171 const xmlChar *buff,
172 uint32 bufflen);
173
174
195extern void
197 xml_msg_hdr_t *msg,
198 xmlns_id_t parent_nsid,
199 xmlns_id_t nsid,
200 const xmlChar *elname,
201 const dlq_hdr_t *attrQ,
202 boolean isattrq,
203 int32 indent,
204 boolean empty);
205
206
221extern void
223 xml_msg_hdr_t *msg,
224 xmlns_id_t parent_nsid,
225 xmlns_id_t nsid,
226 const xmlChar *elname,
227 int32 indent);
228
229
244extern void
246 xml_msg_hdr_t *msg,
247 xmlns_id_t parent_nsid,
248 xmlns_id_t nsid,
249 const xmlChar *elname,
250 int32 indent);
251
252
267extern void
269 xml_msg_hdr_t *msg,
270 xmlns_id_t nsid,
271 const xmlChar *elname,
272 int32 indent);
273
274
297extern void
299 xml_msg_hdr_t *msg,
300 const xmlChar *str,
301 xmlns_id_t parent_nsid,
302 xmlns_id_t nsid,
303 const xmlChar *elname,
304 const dlq_hdr_t *attrQ,
305 boolean isattrq,
306 int32 indent);
307
308
309
332extern void
334 xml_msg_hdr_t *msg,
335 uint32 num,
336 xmlns_id_t parent_nsid,
337 xmlns_id_t nsid,
338 const xmlChar *elname,
339 const dlq_hdr_t *attrQ,
340 boolean isattrq,
341 int32 indent);
342
343
368extern void
370 xml_msg_hdr_t *msg,
371 xmlns_id_t val_nsid,
372 const xmlChar *str,
373 xmlns_id_t parent_nsid,
374 xmlns_id_t nsid,
375 const xmlChar *elname,
376 const dlq_hdr_t *attrQ,
377 boolean isattrq,
378 int32 indent,
379 boolean isdefault);
380
381
406extern void
408 xml_msg_hdr_t *msg,
409 val_value_t *val,
410 int32 indent,
411 val_nodetest_fn_t testfn);
412
413
426extern void
427 xml_wr_val (ses_cb_t *scb,
428 xml_msg_hdr_t *msg,
429 val_value_t *val,
430 int32 indent);
431
432
446extern void
448 xml_msg_hdr_t *msg,
449 val_value_t *val,
450 int32 indent,
451 val_nodetest_fn_t testfn,
452 boolean force_xmlns);
453
454
470extern void
472 xml_msg_hdr_t *msg,
473 val_value_t *val,
474 int32 indent,
475 val_nodetest_fn_t testfn,
476 boolean force_xmlns,
477 xmlns_id_t force_nsid,
478 const xmlChar *force_name);
479
480
495extern void
497 xml_msg_hdr_t *msg,
498 val_value_t *val,
499 int32 indent,
500 val_nodetest_fn_t testfn,
501 boolean expand_varexpr);
502
503
520extern void
522 xml_msg_hdr_t *msg,
523 val_value_t *val,
524 int32 indent,
525 val_nodetest_fn_t testfn,
526 boolean force_xmlns,
527 boolean expand_varexpr,
528 xmlns_id_t parent_nsid);
529
530
548extern void
550 xml_msg_hdr_t *msg,
551 val_value_t *val,
552 int32 indent,
553 val_nodetest_fn_t testfn,
554 boolean expand_varexpr,
555 boolean file_write);
556
557
568extern void
570 xml_msg_hdr_t *msg,
571 val_value_t *val,
572 int32 indent);
573
574
586extern void
588 xml_msg_hdr_t *msg,
589 val_value_t *val,
590 int32 indent);
591
592
615extern status_t
616 xml_wr_check_open_file (FILE *fp,
617 val_value_t *val,
618 xml_attrs_t *attrs,
619 boolean docmode,
620 boolean xmlhdr,
621 boolean withns,
622 boolean expand_varexpr,
623 boolean with_owners,
624 int32 startindent,
625 int32 indent,
626 val_nodetest_fn_t testfn);
627
628
629
655extern status_t
657 val_value_t *val,
658 xml_attrs_t *attrs,
659 boolean docmode,
660 boolean xmlhdr,
661 boolean withns,
662 boolean expand_varexpr,
663 boolean with_owners,
664 boolean top_meta,
665 int32 startindent,
666 int32 indent,
667 val_nodetest_fn_t testfn);
668
669
693extern status_t
694 xml_wr_check_file (const xmlChar *filespec,
695 val_value_t *val,
696 xml_attrs_t *attrs,
697 boolean docmode,
698 boolean xmlhdr,
699 boolean withns,
700 boolean expand_varexpr,
701 boolean with_owners,
702 int32 startindent,
703 int32 indent,
704 val_nodetest_fn_t testfn);
705
706
728extern status_t
729 xml_wr_file (const xmlChar *filespec,
730 val_value_t *val,
731 xml_attrs_t *attrs,
732 boolean docmode,
733 boolean xmlhdr,
734 boolean withns,
735 boolean expand_varexpr,
736 boolean with_owners,
737 int32 startindent,
738 int32 indent);
739
740
755extern void
757 xml_msg_hdr_t *msg,
758 val_value_t *val,
759 obj_template_t *objnode,
760 int32 indent,
761 val_nodetest_fn_t testfn);
762
763
777extern void
779 xml_msg_hdr_t *msg,
780 getcb_get2_t *parent_get2cb,
781 obj_template_t *objnode,
782 int32 indent,
783 val_nodetest_fn_t testfn);
784
785
789#ifdef __cplusplus
790} /* end extern 'C' */
791#endif
792
793#endif /* _H_xml_wr */
@ brief NCX configuration database manager
dlq provides general double-linked list and queue support:
GET1 and GET2 Callback Support.
boolean(* val_nodetest_fn_t)(xml_msg_hdr_t *mhdr, ncx_withdefaults_t withdef, boolean realtest, val_value_t *node)
user function callback template to test output of a specified node.
Definition: val_util.h:132
status_t
global error return code
Definition: status_enum.h:210
uint16 xmlns_id_t
integer handle for registered namespaces
Definition: xmlns.h:89
dlq_hdr_t xml_attrs_t
queue of xml_attr_t
Definition: xml_util.h:155
void xml_wr_end_elem(ses_cb_t *scb, xml_msg_hdr_t *msg, xmlns_id_t nsid, const xmlChar *elname, int32 indent)
Write an end tag to the specified session.
Definition: xml_wr.c:3096
status_t xml_wr_file(const xmlChar *filespec, val_value_t *val, xml_attrs_t *attrs, boolean docmode, boolean xmlhdr, boolean withns, boolean expand_varexpr, boolean with_owners, int32 startindent, int32 indent)
Write the specified value to a FILE in XML format.
Definition: xml_wr.c:4120
void xml_wr_check_child_obj_ex(ses_cb_t *scb, xml_msg_hdr_t *msg, getcb_get2_t *parent_get2cb, obj_template_t *objnode, int32 indent, val_nodetest_fn_t testfn)
Write an entire <get2> val_value_t out from the obj_template_t callback.
Definition: xml_wr.c:4217
void xml_wr_check_val(ses_cb_t *scb, xml_msg_hdr_t *msg, val_value_t *val, int32 indent, val_nodetest_fn_t testfn)
Write an NCX value in XML encoding while checking nodes for suppression of output with the supplied t...
Definition: xml_wr.c:3381
void xml_wr_empty_elem(ses_cb_t *scb, xml_msg_hdr_t *msg, xmlns_id_t parent_nsid, xmlns_id_t nsid, const xmlChar *elname, int32 indent)
Write an empty XML tag to the specified session without attributes.
Definition: xml_wr.c:3058
void xml_wr_check_child_obj(ses_cb_t *scb, xml_msg_hdr_t *msg, val_value_t *val, obj_template_t *objnode, int32 indent, val_nodetest_fn_t testfn)
Generate entire val_value_t *w/filter) for GET2.
Definition: xml_wr.c:4156
void xml_wr_string_elem(ses_cb_t *scb, xml_msg_hdr_t *msg, const xmlChar *str, xmlns_id_t parent_nsid, xmlns_id_t nsid, const xmlChar *elname, const dlq_hdr_t *attrQ, boolean isattrq, int32 indent)
Write a start tag, simple string content, and an end tag to the specified session.
Definition: xml_wr.c:3217
void xml_wr_max_check_val(ses_cb_t *scb, xml_msg_hdr_t *msg, val_value_t *val, int32 indent, val_nodetest_fn_t testfn, boolean force_xmlns)
Generate entire val_value_t *w/filter)
Definition: xml_wr.c:3450
void xml_wr_buff(ses_cb_t *scb, const xmlChar *buff, uint32 bufflen)
Write some xmlChars to the specified session.
Definition: xml_wr.c:2942
void xml_wr_val(ses_cb_t *scb, xml_msg_hdr_t *msg, val_value_t *val, int32 indent)
Output val_value_t node contents only.
Definition: xml_wr.c:3421
status_t xml_wr_check_open_file(FILE *fp, val_value_t *val, xml_attrs_t *attrs, boolean docmode, boolean xmlhdr, boolean withns, boolean expand_varexpr, boolean with_owners, int32 startindent, int32 indent, val_nodetest_fn_t testfn)
Write the specified value to an open FILE in XML format.
Definition: xml_wr.c:3758
void xml_wr_max_check_val_force(ses_cb_t *scb, xml_msg_hdr_t *msg, val_value_t *val, int32 indent, val_nodetest_fn_t testfn, boolean force_xmlns, xmlns_id_t force_nsid, const xmlChar *force_name)
Generate entire val_value_t *w/filter)
Definition: xml_wr.c:3495
void xml_wr_begin_elem_ex(ses_cb_t *scb, xml_msg_hdr_t *msg, xmlns_id_t parent_nsid, xmlns_id_t nsid, const xmlChar *elname, const dlq_hdr_t *attrQ, boolean isattrq, int32 indent, boolean empty)
Write a start or empty XML tag to the specified session.
Definition: xml_wr.c:2983
void xml_wr_file_write_check_val(ses_cb_t *scb, xml_msg_hdr_t *msg, val_value_t *val, int32 indent, val_nodetest_fn_t testfn, boolean expand_varexpr, boolean file_write)
Generate entire val_value_t *w/filter)
Definition: xml_wr.c:3636
void xml_wr_full_val(ses_cb_t *scb, xml_msg_hdr_t *msg, val_value_t *val, int32 indent)
Generate entire val_value_t.
Definition: xml_wr.c:3677
void xml_wr_qname_elem(ses_cb_t *scb, xml_msg_hdr_t *msg, xmlns_id_t val_nsid, const xmlChar *str, xmlns_id_t parent_nsid, xmlns_id_t nsid, const xmlChar *elname, const dlq_hdr_t *attrQ, boolean isattrq, int32 indent, boolean isdefault)
Write a start tag, QName string content, and an end tag to the specified session.
Definition: xml_wr.c:3314
status_t xml_wr_check_open_file_ex(FILE *fp, val_value_t *val, xml_attrs_t *attrs, boolean docmode, boolean xmlhdr, boolean withns, boolean expand_varexpr, boolean with_owners, boolean top_meta, int32 startindent, int32 indent, val_nodetest_fn_t testfn)
Write the specified value to an open FILE in XML format Extended.
Definition: xml_wr.c:3812
void xml_wr_uint32_elem(ses_cb_t *scb, xml_msg_hdr_t *msg, uint32 num, xmlns_id_t parent_nsid, xmlns_id_t nsid, const xmlChar *elname, const dlq_hdr_t *attrQ, boolean isattrq, int32 indent)
Write a start tag, simple uint32 content, and an end tag to the specified session.
Definition: xml_wr.c:3163
void xml_wr_begin_elem(ses_cb_t *scb, xml_msg_hdr_t *msg, xmlns_id_t parent_nsid, xmlns_id_t nsid, const xmlChar *elname, int32 indent)
Write a start XML tag to the specified session without attributes.
Definition: xml_wr.c:3022
void xml_wr_full_check_val2(ses_cb_t *scb, xml_msg_hdr_t *msg, val_value_t *val, int32 indent, val_nodetest_fn_t testfn, boolean force_xmlns, boolean expand_varexpr, xmlns_id_t parent_nsid)
Generate entire val_value_t *w/filter)
Definition: xml_wr.c:3588
void xml_wr_full_val_origin(ses_cb_t *scb, xml_msg_hdr_t *msg, val_value_t *val, int32 indent)
Generate entire val_value_t with NMDA origin.
Definition: xml_wr.c:3704
void xml_wr_full_check_val(ses_cb_t *scb, xml_msg_hdr_t *msg, val_value_t *val, int32 indent, val_nodetest_fn_t testfn, boolean expand_varexpr)
Generate entire val_value_t *w/filter)
Definition: xml_wr.c:3544
status_t xml_wr_check_file(const xmlChar *filespec, val_value_t *val, xml_attrs_t *attrs, boolean docmode, boolean xmlhdr, boolean withns, boolean expand_varexpr, boolean with_owners, int32 startindent, int32 indent, val_nodetest_fn_t testfn)
Write the specified value to a FILE in XML format.
Definition: xml_wr.c:4063
YANG module data structures Many internal representations of YANG module constructs.
NETCONF Session Common definitions module.
Global error messages for status code enumerations.
GET2 control block.
Definition: getcb.h:357
One YANG data-def-stmt.
Definition: obj.h:1229
Session Control Block.
Definition: ses.h:573
one value to match one type
Definition: val.h:912
Common Encoding Message Header No longer XML specific!! Used by JSON and CBOR parsing as well!...
Definition: xml_msg.h:404
Value Node Basic Support.
Value Node Utilities.
XML and JSON Message send and receive support.