35 if(size <= 0)
return -1;
37 for(bptr = buf, toGo = size; toGo;) {
39 ASN_DEBUG(
"Prepending length %d to %s and allowing to save %d",
40 (
int)size, td->
name, (
int)maySave);
41 if(maySave < 0)
break;
43 bptr = (
char *)bptr + maySave;
50 ASN_DEBUG(
"Open type put %s of length %ld + overhead (1byte?)",
51 td->
name, (
long)size);
78 if(bufLen + chunk_bytes > bufSize) {
80 bufSize = chunk_bytes + (bufSize << 2);
92 bufLen += chunk_bytes;
95 ASN_DEBUG(
"Getting open type %s encoded in %ld bytes", td->
name,
98 memset(&spd, 0,
sizeof(spd));
100 spd.
nbits = bufLen << 3;
103 rv = td->
uper_decoder(ctx, td, constraints, sptr, &spd);
119 ASN_DEBUG(
"Too large padding %d in open type", (
int)padding);
158 #define UPDRESTOREPD do { \ 160 pd->nbits = arg.oldpd.nbits - (pd->moved - arg.ot_moved); \ 161 pd->moved = arg.oldpd.moved + (pd->moved - arg.ot_moved); \ 162 pd->refill = arg.oldpd.refill; \ 163 pd->refill_key = arg.oldpd.refill_key; \ 171 ASN_DEBUG(
"OpenType %s pd%s old%s unclaimed=%d, repeat=%d", td->
name,
176 padding = pd->
moved % 8;
180 ASN_DEBUG(
"Too large padding %d in open type",
186 padding = 8 - padding;
187 ASN_DEBUG(
"Getting padding of %d bits", (
int)padding);
196 ASN_DEBUG(
"Non-blank padding (%d bits 0x%02x)",
197 (
int)padding, (
int)pvalue);
228 ASN_DEBUG(
"Non-blank unconsumed padding");
235 ASN_DEBUG(
"Not consumed the whole thing");
256 s_td.
name =
"<unknown extension>";
291 ssize_t next_chunk_bytes, next_chunk_bits;
296 ASN_DEBUG(
"REFILLING pd->moved=%ld, oldpd->moved=%ld",
310 if(oldpd->
nboff == 0) {
317 ASN_DEBUG(
"UNCLAIMED <- return from (pd->moved=%ld)",
323 ASN_DEBUG(
"Want more but refill doesn't have it");
328 ASN_DEBUG(
"Open type LENGTH %ld bytes at off %ld, repeat %ld",
329 (
long)next_chunk_bytes, (
long)oldpd->
moved, (
long)arg->
repeat);
330 if(next_chunk_bytes < 0)
return -1;
331 if(next_chunk_bytes == 0) {
335 next_chunk_bits = next_chunk_bytes << 3;
337 if(avail >= next_chunk_bits) {
340 ASN_DEBUG(
"!+Parent frame %ld bits, alloting %ld [%ld..%ld] (%ld)",
341 (
long)next_chunk_bits, (
long)oldpd->
moved,
346 arg->
unclaimed = next_chunk_bits - avail;
347 ASN_DEBUG(
"!-Parent frame %ld, require %ld, will claim %ld",
348 (
long)avail, (
long)next_chunk_bits,
360 int hasNonZeroBits = 0;
361 while(skip_nbits > 0) {
374 default: hasNonZeroBits = 1;
continue;
377 return hasNonZeroBits;
int uper_open_type_skip(asn_codec_ctx_t *ctx, asn_per_data_t *pd)
static int uper_ugot_refill(asn_per_data_t *pd)
struct uper_ugot_key uper_ugot_key
int per_put_many_bits(asn_per_outp_t *po, const uint8_t *src, int put_nbits)
asn_dec_rval_t uper_open_type_get(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd)
#define _ASN_DECODE_STARVED
int uper_open_type_put(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po)
static asn_dec_rval_t GCC_NOTUSED uper_open_type_get_complex(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd)
#define REALLOC(oldptr, size)
ssize_t uper_put_length(asn_per_outp_t *po, size_t whole_length)
static int _ASN_STACK_OVERFLOW_CHECK(asn_codec_ctx_t *ctx)
static asn_dec_rval_t uper_open_type_get_simple(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd)
int per_get_many_bits(asn_per_data_t *pd, uint8_t *dst, int right_align, int get_nbits)
int32_t per_get_few_bits(asn_per_data_t *per_data, int get_nbits)
static int per_skip_bits(asn_per_data_t *pd, int skip_nbits)
ssize_t uper_get_length(asn_per_data_t *pd, int effective_bound_bits, int *repeat)
enum asn_dec_rval_code_e code
int(* refill)(struct asn_per_data_s *)
#define ASN_DEBUG_INDENT_ADD(i)
static void ASN_DEBUG(const char *fmt,...)
per_type_decoder_f * uper_decoder
char * per_data_string(asn_per_data_t *pd)
static asn_dec_rval_t uper_sot_suck(asn_codec_ctx_t *, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd)
#define _ASN_DECODE_FAILED
ssize_t uper_encode_to_new_buffer(struct asn_TYPE_descriptor_s *type_descriptor, asn_per_constraints_t *constraints, void *struct_ptr, void **buffer_r)