16 long *native = (
long *)*sptr;
22 if(constraints) ct = &constraints->value;
23 else if(td->encoding_constraints.per_constraints)
24 ct = &td->encoding_constraints.per_constraints->value;
29 native = (
long *)(*sptr =
CALLOC(1,
sizeof(*native)));
33 ASN_DEBUG(
"Decoding %s as NativeEnumerated", td->name);
35 if(ct->
flags & APC_EXTENSIBLE) {
44 padding = (8 - (pd->moved % 8)) % 8;
45 ASN_DEBUG(
"For NativeEnumerated %s,offset = %zu Padding bits = %d",
46 td->name, pd->moved, padding);
47 ASN_DEBUG(
"For NativeEnumerated %s, upper bound = %llu",
56 if(value >= (specs->extension
57 ? specs->extension - 1 : specs->map_count))
69 value += specs->extension - 1;
72 if(value >= specs->map_count) {
73 ASN_DEBUG(
"Decoded unknown index value %s = %ld", td->name, value);
75 *native = specs->value2enum[0].nat_value;
80 *native = specs->value2enum[value].nat_value;
81 ASN_DEBUG(
"Decoded %s = %ld", td->name, *native);
94 int inext = 0, range_bits = 1;
101 if(constraints) ct = &constraints->value;
102 else if(td->encoding_constraints.per_constraints)
103 ct = &td->encoding_constraints.per_constraints->value;
106 ASN_DEBUG(
"Encoding %s as NativeEnumerated", td->name);
110 native = *(
const long *)sptr;
113 key.nat_value = native;
114 kf = bsearch(&
key, specs->value2enum, specs->map_count,
117 ASN_DEBUG(
"No element corresponds to %ld", native);
120 value = kf - specs->value2enum;
123 int cmpWith = specs->extension
124 ? specs->extension - 1 : specs->map_count;
128 if(ct->
flags & APC_EXTENSIBLE) {
131 if(inext) range_bits = 0;
142 if(!specs->extension)
148 ASN_DEBUG(
"value = %ld, ext = %d, inext = %d, res = %ld",
149 value, specs->extension, inext,
150 value - (inext ? (specs->extension - 1) : 0));