+ ASN_DEBUG("Encoding %s->%s:%s", td->name, elm->name, elm->type->name);
+ er = elm->type->op->uper_encoder(
+ elm->type, elm->encoding_constraints.per_constraints, *memb_ptr2,
+ po);
+ if(er.encoded == -1) return er;
+ }
+
+ /* No extensions to encode */
+ if(!n_extensions) ASN__ENCODED_OK(er);
+
+ ASN_DEBUG("Length of extensions %d bit-map", n_extensions);
+ /* #18.8. Write down the presence bit-map length. */
+ if(uper_put_nslength(po, n_extensions))
+ ASN__ENCODE_FAILED;
+
+ ASN_DEBUG("Bit-map of %d elements", n_extensions);
+ /* #18.7. Encoding the extensions presence bit-map. */
+ /* TODO: act upon NOTE in #18.7 for canonical PER */
+ if(SEQUENCE__handle_extensions(td, sptr, po, 0) != n_extensions)
+ ASN__ENCODE_FAILED;
+
+ ASN_DEBUG("Writing %d extensions", n_extensions);
+ /* #18.9. Encode extensions as open type fields. */
+ if(SEQUENCE__handle_extensions(td, sptr, 0, po) != n_extensions)
+ ASN__ENCODE_FAILED;
+
+ ASN__ENCODED_OK(er);
+}
+
+#endif /* ASN_DISABLE_PER_SUPPORT */
+
+int
+SEQUENCE_compare(const asn_TYPE_descriptor_t *td, const void *aptr,
+ const void *bptr) {
+ size_t edx;
+
+ for(edx = 0; edx < td->elements_count; edx++) {
+ asn_TYPE_member_t *elm = &td->elements[edx];
+ const void *amemb;
+ const void *bmemb;
+ int ret;
+
+ if(elm->flags & ATF_POINTER) {
+ amemb =
+ *(const void *const *)((const char *)aptr + elm->memb_offset);
+ bmemb =
+ *(const void *const *)((const char *)bptr + elm->memb_offset);
+ if(!amemb) {
+ if(!bmemb) continue;
+ if(elm->default_value_cmp
+ && elm->default_value_cmp(bmemb) == 0) {
+ /* A is absent, but B is present and equal to DEFAULT */
+ continue;
+ }
+ return -1;
+ } else if(!bmemb) {
+ if(elm->default_value_cmp
+ && elm->default_value_cmp(amemb) == 0) {
+ /* B is absent, but A is present and equal to DEFAULT */
+ continue;
+ }
+ return 1;
+ }
+ } else {
+ amemb = (const void *)((const char *)aptr + elm->memb_offset);
+ bmemb = (const void *)((const char *)bptr + elm->memb_offset);
+ }
+
+ ret = elm->type->op->compare_struct(elm->type, amemb, bmemb);
+ if(ret != 0) return ret;
+ }
+
+ return 0;
+}