2 * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>.
4 * Redistribution and modifications are permitted subject to BSD license.
6 #include <asn_internal.h>
7 #include <constr_SEQUENCE.h>
9 asn_TYPE_operation_t asn_OP_SEQUENCE = {
11 #if !defined(ASN_DISABLE_PRINT_SUPPORT)
15 #endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
17 #if !defined(ASN_DISABLE_BER_SUPPORT)
23 #endif /* !defined(ASN_DISABLE_BER_SUPPORT) */
24 #if !defined(ASN_DISABLE_XER_SUPPORT)
30 #endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
31 #if !defined(ASN_DISABLE_JER_SUPPORT)
35 #endif /* !defined(ASN_DISABLE_JER_SUPPORT) */
36 #if !defined(ASN_DISABLE_OER_SUPPORT)
42 #endif /* !defined(ASN_DISABLE_OER_SUPPORT) */
43 #if !defined(ASN_DISABLE_UPER_SUPPORT)
49 #endif /* !defined(ASN_DISABLE_UPER_SUPPORT) */
50 #if !defined(ASN_DISABLE_APER_SUPPORT)
56 #endif /* !defined(ASN_DISABLE_APER_SUPPORT) */
57 #if !defined(ASN_DISABLE_RFILL_SUPPORT)
61 #endif /* !defined(ASN_DISABLE_RFILL_SUPPORT) */
62 0 /* Use generic outmost tag fetcher */
66 SEQUENCE_free(const asn_TYPE_descriptor_t *td, void *sptr,
67 enum asn_struct_free_method method) {
69 const asn_SEQUENCE_specifics_t *specs =
70 (const asn_SEQUENCE_specifics_t *)td->specifics;
71 asn_struct_ctx_t *ctx; /* Decoder context */
76 ASN_DEBUG("Freeing %s as SEQUENCE", td->name);
78 for(edx = 0; edx < td->elements_count; edx++) {
79 asn_TYPE_member_t *elm = &td->elements[edx];
81 if(elm->flags & ATF_POINTER) {
82 memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
84 ASN_STRUCT_FREE(*elm->type, memb_ptr);
86 memb_ptr = (void *)((char *)sptr + elm->memb_offset);
87 ASN_STRUCT_FREE_CONTENTS_ONLY(*elm->type, memb_ptr);
91 /* Clean parsing context */
92 ctx = (asn_struct_ctx_t *)((char *)sptr + specs->ctx_offset);
96 case ASFM_FREE_EVERYTHING:
99 case ASFM_FREE_UNDERLYING:
101 case ASFM_FREE_UNDERLYING_AND_RESET:
104 ((const asn_SEQUENCE_specifics_t *)(td->specifics))->struct_size);
110 SEQUENCE_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
111 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
115 ASN__CTFAIL(app_key, td, sptr,
116 "%s: value not given (%s:%d)",
117 td->name, __FILE__, __LINE__);
122 * Iterate over structure members and check their validity.
124 for(edx = 0; edx < td->elements_count; edx++) {
125 asn_TYPE_member_t *elm = &td->elements[edx];
126 const void *memb_ptr;
127 asn_constr_check_f *constr;
130 if(elm->flags & ATF_POINTER) {
131 memb_ptr = *(const void * const *)((const char *)sptr + elm->memb_offset);
135 ASN__CTFAIL(app_key, td, sptr,
136 "%s: mandatory element %s absent (%s:%d)",
137 td->name, elm->name, __FILE__, __LINE__);
141 memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
144 constr = elm->encoding_constraints.general_constraints;
146 constr = elm->type->encoding_constraints.general_constraints;
148 ret = constr(elm->type, memb_ptr, ctfailcb, app_key);
156 SEQUENCE_compare(const asn_TYPE_descriptor_t *td, const void *aptr,
160 for(edx = 0; edx < td->elements_count; edx++) {
161 asn_TYPE_member_t *elm = &td->elements[edx];
166 if(elm->flags & ATF_POINTER) {
168 *(const void *const *)((const char *)aptr + elm->memb_offset);
170 *(const void *const *)((const char *)bptr + elm->memb_offset);
173 if(elm->default_value_cmp
174 && elm->default_value_cmp(bmemb) == 0) {
175 /* A is absent, but B is present and equal to DEFAULT */
180 if(elm->default_value_cmp
181 && elm->default_value_cmp(amemb) == 0) {
182 /* B is absent, but A is present and equal to DEFAULT */
188 amemb = (const void *)((const char *)aptr + elm->memb_offset);
189 bmemb = (const void *)((const char *)bptr + elm->memb_offset);
192 ret = elm->type->op->compare_struct(elm->type, amemb, bmemb);
193 if(ret != 0) return ret;