SIM-115: update simulator to use latest E2SM KPM version 3
[sim/e2-interface.git] / e2sim / asn1c / constr_SET_OF_print.c
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_SET_OF.h>
8
9 int
10 SET_OF_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
11              asn_app_consume_bytes_f *cb, void *app_key) {
12     asn_TYPE_member_t *elm = td->elements;
13     const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr);
14     int ret;
15     int i;
16
17     if(!sptr) return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
18
19     /* Dump preamble */
20     if(cb(td->name, strlen(td->name), app_key) < 0
21     || cb(" ::= {", 6, app_key) < 0)
22         return -1;
23
24     for(i = 0; i < list->count; i++) {
25         const void *memb_ptr = list->array[i];
26         if(!memb_ptr) continue;
27
28         _i_INDENT(1);
29
30         ret = elm->type->op->print_struct(elm->type, memb_ptr,
31                                           ilevel + 1, cb, app_key);
32         if(ret) return ret;
33     }
34
35     ilevel--;
36     _i_INDENT(1);
37
38     return (cb("}", 1, app_key) < 0) ? -1 : 0;
39 }