yumapro  23.10T-6
YumaPro SDK
Loading...
Searching...
No Matches
cbor_wr.h
Go to the documentation of this file.
1#ifdef WITH_YANG_CBOR
2/*
3 * Copyright (c) 2008 - 2012, Andy Bierman, All Rights Reserved.
4 * Copyright (c) 2012 - 2021, YumaWorks, Inc., All Rights Reserved.
5 *
6 * Unless required by applicable law or agreed to in writing,
7 * software distributed under the License is distributed on an
8 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
9 * KIND, either express or implied. See the License for the
10 * specific language governing permissions and limitations
11 * under the License.
12 */
13#ifndef _H_cbor_wr
14#define _H_cbor_wr
15
16/* FILE: cbor_wr.h
17*********************************************************************
18* *
19* P U R P O S E *
20* *
21*********************************************************************/
22
28/*********************************************************************
29* *
30* C H A N G E H I S T O R Y *
31* *
32*********************************************************************
33
34date init comment
35----------------------------------------------------------------------
3611-dec-21 abb Begun; copied from cbor_wr.c
37
38*/
39
40#include <stdio.h>
41
42/* used for xmlChar type */
43#include <xmlstring.h>
44
45
46#ifndef _H_getcb
47#include "getcb.h"
48#endif
49
50#ifndef _H_ncxtypes
51#include "ncxtypes.h"
52#endif
53
54#ifndef _H_ses
55#include "ses.h"
56#endif
57
58#ifndef _H_status
59#include "status.h"
60#endif
61
62#ifndef _H_val
63#include "val.h"
64#endif
65
66#ifndef _H_val_util
67#include "val_util.h"
68#endif
69
70#ifndef _H_xml_msg
71#include "xml_msg.h"
72#endif
73
74#ifdef __cplusplus
75extern "C" {
76#endif
77
78/********************************************************************
79* *
80* C O N S T A N T S *
81* *
82*********************************************************************/
83
84#define CBOR_WR_TESTFN(T) (T)->testfn
85#define CBOR_WR_EXPAND_VAREXPR(T) (T)->expand_varexpr
86#define CBOR_WR_PARENT_NSID(T) (T)->parent_nsid
87#define CBOR_WR_PARENT_SID(T) (T)->parent_sid
88#define CBOR_WR_FORCE_PARENT_SID(T) (T)->force_parent_sid
89#define CBOR_WR_IS_EMPTY(T) (T)->is_empty
90#define CBOR_WR_CONTENT_ONLY(T) (T)->content_only
91#define CBOR_WR_ACM_CHECK(T) (T)->acm_check
92#define CBOR_WR_FORCE_NAMES(T) (T)->force_names
93
94
95/********************************************************************
96* *
97* T Y P E S *
98* *
99*********************************************************************/
100
101
112typedef struct cbor_wr_parms_t_ {
115
121
124
127
133
135 boolean file_write;
136
138 boolean with_origin;
139
141 boolean with_owners;
142
145
148
150 boolean maxmode;
151
154
158 boolean is_empty;
159
163 boolean acm_check;
164
168 boolean force_names;
169
171
172
173
175typedef struct cbor_walker_cookie_t_ {
180
185
190
192
193
194/********************************************************************
195* *
196* F U N C T I O N S *
197* *
198*********************************************************************/
199
200
213extern void
215 xml_msg_hdr_t *msg,
216 obj_template_t *obj,
217 cbor_wr_parms_t *parms);
218
219
220
221
232extern void
234 xml_msg_hdr_t *msg);
235
236
237
238#define cbor_wr_end_list cbor_wr_end_elem
239
240
248extern void
250 xml_msg_hdr_t *msg,
251 obj_template_t *obj);
252
253
254
269extern void
271 xml_msg_hdr_t *msg,
272 const xmlChar *strval,
273 obj_template_t *obj,
274 cbor_wr_parms_t *parms);
275
276
291extern void
293 xml_msg_hdr_t *msg,
294 uint64 val,
295 obj_template_t *obj,
296 cbor_wr_parms_t *parms);
297
298
299
312extern void
313 cbor_wr_val (ses_cb_t *scb,
314 xml_msg_hdr_t *msg,
315 val_value_t *val,
316 cbor_wr_parms_t *parms);
317
318
332extern void
334 xml_msg_hdr_t *msg,
335 getcb_get2_t *parent_get2cb,
336 obj_template_t *objnode,
337 cbor_wr_parms_t *parms);
338
339
340
352extern void
354
355
356
368extern status_t
369 cbor_wr_file (const xmlChar *filespec,
370 xml_msg_hdr_t *hdr,
371 val_value_t *val,
372 cbor_wr_parms_t *parms);
373
374
386extern status_t
387 cbor_wr_open_file (FILE *fp,
388 xml_msg_hdr_t *hdr,
389 val_value_t *val,
390 cbor_wr_parms_t *parms);
391
392
393/*
394* @brief Initialize a cbor_wr_parms_t struct
395*
396* @param parms parameter block to initialize
397*/
398extern void
399 cbor_wr_init_parms (cbor_wr_parms_t *parms);
400
401/*
402* @brief Clean a cbor_wr_parms_t struct
403*
404* The parms will be left in initialized state so no
405* need to call cbor_wr_init_parms after this function
406*
407* @param parms parameter block to clean
408*/
409extern void
410 cbor_wr_clean_parms (cbor_wr_parms_t *parms);
411
412
416#ifdef __cplusplus
417} /* end extern 'C' */
418#endif
419
420#endif /* _H_cbor_wr */
421#endif // WITH_YANG_CBOR
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 cbor_wr_open_file(FILE *fp, xml_msg_hdr_t *hdr, val_value_t *val, cbor_wr_parms_t *parms)
Write the specified value to an open FILE in CBOR format.
Definition: cbor_wr.c:2968
void cbor_wr_start_msg(ses_cb_t *scb)
Write the CBOR start message byte.
Definition: cbor_wr.c:2910
void cbor_wr_child_obj(ses_cb_t *scb, xml_msg_hdr_t *msg, getcb_get2_t *parent_get2cb, obj_template_t *objnode, cbor_wr_parms_t *parms)
Write an entire <get2> val_value_t out from the obj_template_t callback.
Definition: cbor_wr.c:2858
void cbor_wr_string_elem(ses_cb_t *scb, xml_msg_hdr_t *msg, const xmlChar *strval, obj_template_t *obj, cbor_wr_parms_t *parms)
Write a string CBOR node to the specified session.
Definition: cbor_wr.c:2734
void cbor_wr_begin_list(ses_cb_t *scb, xml_msg_hdr_t *msg)
Write a start CBOR list entry.
Definition: cbor_wr.c:2671
void cbor_wr_uint_elem(ses_cb_t *scb, xml_msg_hdr_t *msg, uint64 val, obj_template_t *obj, cbor_wr_parms_t *parms)
Write a UINT CBOR node to the specified session.
Definition: cbor_wr.c:2776
void cbor_wr_end_elem(ses_cb_t *scb, xml_msg_hdr_t *msg, obj_template_t *obj)
Write an end container: indef (break) to the specified session.
Definition: cbor_wr.c:2695
void cbor_wr_val(ses_cb_t *scb, xml_msg_hdr_t *msg, val_value_t *val, cbor_wr_parms_t *parms)
Output val_value_t node contents only.
Definition: cbor_wr.c:2817
status_t cbor_wr_file(const xmlChar *filespec, xml_msg_hdr_t *hdr, val_value_t *val, cbor_wr_parms_t *parms)
Write the specified value to a FILE in CBOR format.
Definition: cbor_wr.c:2930
void cbor_wr_begin_elem(ses_cb_t *scb, xml_msg_hdr_t *msg, obj_template_t *obj, cbor_wr_parms_t *parms)
Write a start CBOR node to the specified session.
Definition: cbor_wr.c:2635
status_t
global error return code
Definition: status_enum.h:210
uint16 xmlns_id_t
integer handle for registered namespaces
Definition: xmlns.h:89
uint64 ncx_sid_t
Standard YANG SID is a 63-bit integer defined as uint64.
Definition: ncxtypes.h:744
ncx_nmda_origin_t
internal enumerations for standard NMDA origins
Definition: ncxtypes.h:1628
YANG module data structures Many internal representations of YANG module constructs.
NETCONF Session Common definitions module.
Global error messages for status code enumerations.
Parameter Request Block used instead of passing lots of leafs.
Definition: cbor_wr.h:112
boolean force_names
TRUE if inside an anyxml or anydata so names are forced instead of possibly using internal SIDs.
Definition: cbor_wr.h:168
ncx_nmda_origin_t origin
TBD: current origin enum.
Definition: cbor_wr.h:147
ncx_sid_t parent_sid
parent SID
Definition: cbor_wr.h:126
boolean acm_check
TRUE if an acmcheck should be done FALSE if skip acmcheck (use this for notifications!
Definition: cbor_wr.h:163
xmlns_id_t parent_nsid
parent namespace ID
Definition: cbor_wr.h:123
val_nodetest_fn_t testfn
testfn callback function to use, NULL if not used
Definition: cbor_wr.h:114
boolean with_owners
TBD: TRUE if owner attributes needed.
Definition: cbor_wr.h:141
boolean file_write
TBD: TRUE if writing to a file instead of a session.
Definition: cbor_wr.h:135
boolean maxmode
TRUE if max depth already reached.
Definition: cbor_wr.h:150
boolean content_only
TRUE if only requesting val contents not full val.
Definition: cbor_wr.h:153
boolean expand_varexpr
expand var expressions; used in yangcli mostly TRUE if expanding variable expressions FALSE if not ex...
Definition: cbor_wr.h:120
boolean is_empty
TRUE if calling cbor_wr_begin_elem and really want an empty leaf instead.
Definition: cbor_wr.h:158
ncx_nmda_origin_t parent_origin
TBD: parent node origin enum.
Definition: cbor_wr.h:144
boolean with_origin
TBD: TRUE if origin attributes needed.
Definition: cbor_wr.h:138
boolean force_parent_sid
force parent SID: allows nested object to be written as if it were the top node.
Definition: cbor_wr.h:132
GET2 control block.
Definition: getcb.h:355
One YANG data-def-stmt.
Definition: obj.h:1184
Session Control Block.
Definition: ses.h:573
one value to match one type
Definition: val.h:911
Common Encoding Message Header No longer XML specific!! Used by JSON and CBOR parsing as well!...
Definition: xml_msg.h:389
Value Node Basic Support.
Value Node Utilities.
XML and JSON Message send and receive support.