This repository has been archived by the owner on Jul 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
cdefs.h
455 lines (396 loc) · 9.49 KB
/
cdefs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
/*
* Copyright (c) 2018-2019 Robin Jarry
* SPDX-License-Identifier: MIT
*/
struct ly_ctx;
#define LY_CTX_ALLIMPLEMENTED ...
#define LY_CTX_TRUSTED ...
#define LY_CTX_NOYANGLIBRARY ...
#define LY_CTX_DISABLE_SEARCHDIRS ...
#define LY_CTX_DISABLE_SEARCHDIR_CWD ...
#define LY_CTX_PREFER_SEARCHDIRS ...
struct ly_ctx *ly_ctx_new(const char *, int);
int ly_ctx_set_searchdir(struct ly_ctx *, const char *);
void ly_ctx_destroy(struct ly_ctx *, void *);
typedef enum {
LY_SUCCESS,
...
} LY_ERR;
typedef enum {
LYVE_SUCCESS,
LYVE_PATH_EXISTS,
...
} LY_VECODE;
typedef enum {
LY_LLERR,
LY_LLWRN,
LY_LLVRB,
LY_LLDBG,
...
} LY_LOG_LEVEL;
struct ly_err_item {
char *msg;
char *path;
char *apptag;
struct ly_err_item *next;
...;
};
#define LY_LOLOG ...
#define LY_LOSTORE ...
#define LY_LOSTORE_LAST ...
int ly_log_options(int);
LY_LOG_LEVEL ly_verb(LY_LOG_LEVEL);
extern "Python" void lypy_log_cb(LY_LOG_LEVEL, const char *, const char *);
void ly_set_log_clb(void (*)(LY_LOG_LEVEL, const char *, const char *), int);
struct ly_err_item *ly_err_first(const struct ly_ctx *);
void ly_err_clean(struct ly_ctx *, struct ly_err_item *);
LY_VECODE ly_vecode(const struct ly_ctx *);
struct lys_module {
const char *name;
const char *prefix;
const char *dsc;
const char *filepath;
uint8_t rev_size;
uint8_t features_size;
struct lys_revision *rev;
struct lys_feature *features;
...;
};
#define LY_REV_SIZE 11
struct lys_revision {
char date[LY_REV_SIZE];
uint8_t ext_size;
struct lys_ext_instance **ext;
const char *dsc;
const char *ref;
};
#define LYS_FENABLED ...
struct lys_feature {
const char *name;
const char *dsc;
const char *ref;
uint16_t flags;
uint8_t iffeature_size;
struct lys_iffeature *iffeature;
struct lys_module *module;
...;
};
#define LYS_IFF_NOT ...
#define LYS_IFF_AND ...
#define LYS_IFF_OR ...
#define LYS_IFF_F ...
struct lys_iffeature {
uint8_t *expr;
struct lys_feature **features;
...;
};
int lys_features_enable(const struct lys_module *, const char *);
int lys_features_disable(const struct lys_module *, const char *);
int lys_features_state(const struct lys_module *, const char *);
struct lys_ext {
const char *name;
struct lys_module *module;
...;
};
struct lys_ext_instance {
struct lys_ext *def;
const char *arg_value;
...;
};
struct lys_restr {
const char *expr;
...;
};
typedef enum {
LY_TYPE_DER,
LY_TYPE_BINARY,
LY_TYPE_BITS,
LY_TYPE_BOOL,
LY_TYPE_DEC64,
LY_TYPE_EMPTY,
LY_TYPE_ENUM,
LY_TYPE_IDENT,
LY_TYPE_INST,
LY_TYPE_LEAFREF,
LY_TYPE_STRING,
LY_TYPE_UNION,
LY_TYPE_INT8,
LY_TYPE_UINT8,
LY_TYPE_INT16,
LY_TYPE_UINT16,
LY_TYPE_INT32,
LY_TYPE_UINT32,
LY_TYPE_INT64,
LY_TYPE_UINT64,
LY_TYPE_UNKNOWN,
...
} LY_DATA_TYPE;
struct lys_type_info_binary {
struct lys_restr *length;
};
struct lys_type_bit {
const char *name;
const char *dsc;
uint32_t pos;
...;
};
struct lys_type_info_bits {
struct lys_type_bit *bit;
unsigned int count;
};
struct lys_type_info_dec64 {
struct lys_restr *range;
...;
};
struct lys_type_enum {
const char *name;
const char *dsc;
...;
};
struct lys_type_info_enums {
struct lys_type_enum *enm;
unsigned int count;
};
struct lys_type_info_num {
struct lys_restr *range;
};
struct lys_type_info_lref {
const char *path;
struct lys_node_leaf* target;
int8_t req;
};
struct lys_type_info_str {
struct lys_restr *length;
struct lys_restr *patterns;
unsigned int pat_count;
...;
};
struct lys_type_info_union {
struct lys_type *types;
unsigned int count;
int has_ptr_type;
};
union lys_type_info {
struct lys_type_info_binary binary;
struct lys_type_info_bits bits;
struct lys_type_info_dec64 dec64;
struct lys_type_info_enums enums;
struct lys_type_info_num num;
struct lys_type_info_lref lref;
struct lys_type_info_str str;
struct lys_type_info_union uni;
...;
};
struct lys_type {
LY_DATA_TYPE base;
uint8_t value_flags;
uint8_t ext_size;
struct lys_ext_instance **ext;
struct lys_tpdf *der;
struct lys_tpdf *parent;
union lys_type_info info;
...;
};
struct lys_tpdf {
const char *name;
const char *dsc;
uint8_t ext_size;
struct lys_ext_instance **ext;
const char *units;
struct lys_type type;
const char *dflt;
...;
};
typedef enum lys_nodetype {
LYS_UNKNOWN,
LYS_CONTAINER,
LYS_CHOICE,
LYS_LEAF,
LYS_LEAFLIST,
LYS_LIST,
LYS_ANYXML,
LYS_CASE,
LYS_NOTIF,
LYS_RPC,
LYS_INPUT,
LYS_OUTPUT,
LYS_GROUPING,
LYS_USES,
LYS_AUGMENT,
LYS_ACTION,
LYS_ANYDATA,
LYS_EXT,
...
} LYS_NODE;
#define LYS_CONFIG_W ...
#define LYS_CONFIG_R ...
#define LYS_CONFIG_SET ...
#define LYS_USERORDERED ...
#define LYS_MAND_TRUE ...
#define LYS_STATUS_DEPRC ...
#define LYS_STATUS_OBSLT ...
struct lys_node {
const char *name;
const char *dsc;
uint16_t flags;
uint8_t ext_size;
uint8_t iffeature_size;
struct lys_ext_instance **ext;
struct lys_iffeature *iffeature;
LYS_NODE nodetype;
...;
};
struct lys_node_container {
uint8_t must_size;
struct lys_restr *must;
const char *presence;
...;
};
struct lys_node_leaf {
uint8_t must_size;
struct lys_restr *must;
struct lys_type type;
const char *units;
const char *dflt;
...;
};
struct lys_node_leaflist {
uint8_t must_size;
struct lys_restr *must;
struct lys_type type;
const char *units;
uint32_t min;
uint32_t max;
uint8_t dflt_size;
const char **dflt;
...;
};
struct lys_node_list {
uint8_t must_size;
struct lys_restr *must;
uint8_t keys_size;
struct lys_node_leaf **keys;
uint32_t min;
uint32_t max;
...;
};
union ly_set_set {
struct lys_node **s;
...;
};
struct ly_set {
unsigned int size;
unsigned int number;
union ly_set_set set;
};
const struct lys_module *ly_ctx_load_module(struct ly_ctx *, const char *, const char *);
const struct lys_module *ly_ctx_get_module_iter(const struct ly_ctx *, uint32_t *);
const struct lys_module *ly_ctx_get_module(const struct ly_ctx *, const char *, const char *, int);
struct ly_set *ly_ctx_find_path(struct ly_ctx *, const char *);
void ly_set_free(struct ly_set *set);
const struct lys_node_list *lys_is_key(const struct lys_node_leaf *, uint8_t *);
#define LYS_GETNEXT_WITHCHOICE ...
#define LYS_GETNEXT_WITHCASE ...
#define LYS_GETNEXT_WITHGROUPING ...
#define LYS_GETNEXT_WITHINOUT ...
#define LYS_GETNEXT_WITHUSES ...
#define LYS_GETNEXT_INTOUSES ...
#define LYS_GETNEXT_INTONPCONT ...
#define LYS_GETNEXT_PARENTUSES ...
#define LYS_GETNEXT_NOSTATECHECK ...
const struct lys_node *lys_getnext(const struct lys_node *, const struct lys_node *, const struct lys_module *, int);
char *lys_data_path(const struct lys_node *);
char *lys_path(const struct lys_node *, int);
struct lys_module *lys_node_module(const struct lys_node *);
struct lys_module *lys_main_module(const struct lys_module *);
struct lys_node *lys_parent(const struct lys_node *);
typedef enum {
LYS_IN_UNKNOWN,
LYS_IN_YANG,
LYS_IN_YIN,
...
} LYS_INFORMAT;
const struct lys_module *lys_parse_mem(struct ly_ctx *, const char *, LYS_INFORMAT);
const struct lys_module *lys_parse_fd(struct ly_ctx *, int, LYS_INFORMAT);
typedef enum {
LYS_OUT_UNKNOWN,
LYS_OUT_YANG,
LYS_OUT_YIN,
LYS_OUT_TREE,
LYS_OUT_INFO,
LYS_OUT_JSON,
...
} LYS_OUTFORMAT;
int lys_print_mem(char **, const struct lys_module *, LYS_OUTFORMAT, const char *, int, int);
int lys_print_fd(int, const struct lys_module *, LYS_OUTFORMAT, const char *, int, int);
typedef enum {
LYD_XML,
LYD_JSON,
LYD_LYB,
...
} LYD_FORMAT;
typedef enum {
...
} LYD_ANYDATA_VALUETYPE;
#define LYP_WITHSIBLINGS ...
#define LYP_FORMAT ...
#define LYP_WD_TRIM ...
#define LYP_WD_ALL ...
#define LYP_KEEPEMPTYCONT ...
#define LYD_ANYDATA_CONSTSTRING ...
#define LYD_PATH_OPT_UPDATE ...
#define LYD_PATH_OPT_NOPARENTRET ...
#define LYD_PATH_OPT_OUTPUT ...
#define LYD_OPT_DATA ...
#define LYD_OPT_CONFIG ...
#define LYD_OPT_STRICT ...
#define LYD_OPT_TRUSTED ...
#define LYD_OPT_DATA_NO_YANGLIB ...
#define LYD_OPT_RPC ...
typedef union lyd_value_u {
int8_t bln;
struct lyd_node *leafref;
...;
} lyd_val;
struct lyd_node {
struct lys_node *schema;
struct lyd_node *next;
struct lyd_node *child;
struct lyd_node *parent;
...;
};
struct lyd_node_leaf_list {
struct lys_node *schema;
struct lyd_node *next;
struct lyd_node *parent;
const char *value_str;
lyd_val value;
LY_DATA_TYPE value_type;
...;
};
struct ly_set *lyd_find_instance(const struct lyd_node *, const struct lys_node *);
struct ly_set *lyd_find_path(const struct lyd_node *, const char *);
struct lyd_node *lyd_new_path(struct lyd_node *, const struct ly_ctx *, const char *, void *, LYD_ANYDATA_VALUETYPE, int);
struct lyd_node *lyd_first_sibling(struct lyd_node *);
char *lyd_path(const struct lyd_node *);
struct lys_module *lyd_node_module(struct lyd_node *);
struct lyd_node *lyd_parse_mem(struct ly_ctx *, const char *, LYD_FORMAT, int, ...);
struct lyd_node *lyd_parse_fd(struct ly_ctx *, int, LYD_FORMAT, int, ...);
int lyd_print_fd(int, const struct lyd_node *, LYD_FORMAT, int);
int lyd_print_mem(char **, const struct lyd_node *, LYD_FORMAT, int);
double lyd_dec64_to_double(const struct lyd_node *);
void lyd_free(struct lyd_node *);
void lyd_free_withsiblings(struct lyd_node *);
int lyd_validate(struct lyd_node **, int, void *);
/* from libc, needed to free allocated strings */
void free(void *);
/* extra functions */
const struct lys_ext_instance *lypy_find_ext(
const struct lys_ext_instance **, uint8_t,
const char *, const char *, const char *);
char *lypy_data_path_pattern(const struct lys_node *);
char *lypy_node_fullname(const struct lys_node *);
int lyd_toprint(const struct lyd_node *node, int options);
uint8_t lypy_module_implemented(const struct lys_module *);
LY_ERR lypy_get_errno(void);
void lypy_set_errno(LY_ERR);