/src/open5gs/lib/asn1c/common/constr_SEQUENCE_print.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>. |
3 | | * All rights reserved. |
4 | | * Redistribution and modifications are permitted subject to BSD license. |
5 | | */ |
6 | | #include <asn_internal.h> |
7 | | #include <constr_SEQUENCE.h> |
8 | | #include <OPEN_TYPE.h> |
9 | | |
10 | | int |
11 | | SEQUENCE_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, |
12 | 0 | asn_app_consume_bytes_f *cb, void *app_key) { |
13 | 0 | size_t edx; |
14 | 0 | int ret; |
15 | |
|
16 | 0 | if(!sptr) return (cb("<absent>", 8, app_key) < 0) ? -1 : 0; |
17 | | |
18 | | /* Dump preamble */ |
19 | 0 | if(cb(td->name, strlen(td->name), app_key) < 0 |
20 | 0 | || cb(" ::= {", 6, app_key) < 0) |
21 | 0 | return -1; |
22 | | |
23 | 0 | for(edx = 0; edx < td->elements_count; edx++) { |
24 | 0 | asn_TYPE_member_t *elm = &td->elements[edx]; |
25 | 0 | const void *memb_ptr; |
26 | |
|
27 | 0 | if(elm->flags & ATF_POINTER) { |
28 | 0 | memb_ptr = *(const void * const *)((const char *)sptr + elm->memb_offset); |
29 | 0 | if(!memb_ptr) { |
30 | 0 | if(elm->optional) continue; |
31 | | /* Print <absent> line */ |
32 | | /* Fall through */ |
33 | 0 | } |
34 | 0 | } else { |
35 | 0 | memb_ptr = (const void *)((const char *)sptr + elm->memb_offset); |
36 | 0 | } |
37 | | |
38 | | /* Indentation */ |
39 | 0 | _i_INDENT(1); |
40 | | |
41 | | /* Print the member's name and stuff */ |
42 | 0 | if(cb(elm->name, strlen(elm->name), app_key) < 0 |
43 | 0 | || cb(": ", 2, app_key) < 0) |
44 | 0 | return -1; |
45 | | |
46 | | /* Print the member itself */ |
47 | 0 | if(elm->flags & ATF_OPEN_TYPE) { |
48 | 0 | ret = OPEN_TYPE_print_member(td, sptr, elm, ilevel + 1, cb, app_key); |
49 | 0 | } else { |
50 | 0 | ret = elm->type->op->print_struct(elm->type, memb_ptr, ilevel + 1, |
51 | 0 | cb, app_key); |
52 | 0 | } |
53 | 0 | if(ret) return ret; |
54 | 0 | } |
55 | | |
56 | 0 | ilevel--; |
57 | 0 | _i_INDENT(1); |
58 | | |
59 | 0 | return (cb("}", 1, app_key) < 0) ? -1 : 0; |
60 | 0 | } |