git.stg.codes
/
stg.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Build and test in both Debug and Release mode.
[stg.git]
/
libs
/
smux
/
NativeEnumerated.c
diff --git
a/libs/smux/NativeEnumerated.c
b/libs/smux/NativeEnumerated.c
index 3486cec17c7f1008c3e0a6135cf2a6e6da272df1..78366af31840ca12b53d0d54ca4d3c80bf6ff928 100644
(file)
--- a/
libs/smux/NativeEnumerated.c
+++ b/
libs/smux/NativeEnumerated.c
@@
-1,5
+1,5
@@
/*-
/*-
- * Copyright (c) 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2004
, 2007
Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
/*
* Redistribution and modifications are permitted subject to BSD license.
*/
/*
@@
-15,7
+15,7
@@
/*
* NativeEnumerated basic type description.
*/
/*
* NativeEnumerated basic type description.
*/
-static ber_tlv_tag_t asn_DEF_NativeEnumerated_tags[] = {
+static
const
ber_tlv_tag_t asn_DEF_NativeEnumerated_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (10 << 2))
};
asn_TYPE_descriptor_t asn_DEF_NativeEnumerated = {
(ASN_TAG_CLASS_UNIVERSAL | (10 << 2))
};
asn_TYPE_descriptor_t asn_DEF_NativeEnumerated = {
@@
-52,7
+52,7
@@
NativeEnumerated_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
(void)ilevel;
(void)flags;
(void)ilevel;
(void)flags;
- if(!native)
_ASN
_ENCODE_FAILED;
+ if(!native)
ASN_
_ENCODE_FAILED;
el = INTEGER_map_value2enum(specs, *native);
if(el) {
el = INTEGER_map_value2enum(specs, *native);
if(el) {
@@
-61,12
+61,12
@@
NativeEnumerated_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
er.encoded = snprintf(src, srcsize, "<%s/>", el->enum_name);
assert(er.encoded > 0 && (size_t)er.encoded < srcsize);
er.encoded = snprintf(src, srcsize, "<%s/>", el->enum_name);
assert(er.encoded > 0 && (size_t)er.encoded < srcsize);
- if(cb(src, er.encoded, app_key) < 0)
_ASN
_ENCODE_FAILED;
-
_ASN
_ENCODED_OK(er);
+ if(cb(src, er.encoded, app_key) < 0)
ASN_
_ENCODE_FAILED;
+
ASN_
_ENCODED_OK(er);
} else {
ASN_DEBUG("ASN.1 forbids dealing with "
"unknown value of ENUMERATED type");
} else {
ASN_DEBUG("ASN.1 forbids dealing with "
"unknown value of ENUMERATED type");
-
_ASN
_ENCODE_FAILED;
+
ASN_
_ENCODE_FAILED;
}
}
}
}
@@
-84,39
+84,39
@@
NativeEnumerated_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
if(constraints) ct = &constraints->value;
else if(td->per_constraints) ct = &td->per_constraints->value;
if(constraints) ct = &constraints->value;
else if(td->per_constraints) ct = &td->per_constraints->value;
- else
_ASN
_DECODE_FAILED; /* Mandatory! */
- if(!specs)
_ASN
_DECODE_FAILED;
+ else
ASN_
_DECODE_FAILED; /* Mandatory! */
+ if(!specs)
ASN_
_DECODE_FAILED;
if(!native) {
native = (long *)(*sptr = CALLOC(1, sizeof(*native)));
if(!native) {
native = (long *)(*sptr = CALLOC(1, sizeof(*native)));
- if(!native)
_ASN
_DECODE_FAILED;
+ if(!native)
ASN_
_DECODE_FAILED;
}
ASN_DEBUG("Decoding %s as NativeEnumerated", td->name);
if(ct->flags & APC_EXTENSIBLE) {
int inext = per_get_few_bits(pd, 1);
}
ASN_DEBUG("Decoding %s as NativeEnumerated", td->name);
if(ct->flags & APC_EXTENSIBLE) {
int inext = per_get_few_bits(pd, 1);
- if(inext < 0)
_ASN
_DECODE_STARVED;
+ if(inext < 0)
ASN_
_DECODE_STARVED;
if(inext) ct = 0;
}
if(ct && ct->range_bits >= 0) {
value = per_get_few_bits(pd, ct->range_bits);
if(inext) ct = 0;
}
if(ct && ct->range_bits >= 0) {
value = per_get_few_bits(pd, ct->range_bits);
- if(value < 0)
_ASN
_DECODE_STARVED;
+ if(value < 0)
ASN_
_DECODE_STARVED;
if(value >= (specs->extension
? specs->extension - 1 : specs->map_count))
if(value >= (specs->extension
? specs->extension - 1 : specs->map_count))
-
_ASN
_DECODE_FAILED;
+
ASN_
_DECODE_FAILED;
} else {
if(!specs->extension)
} else {
if(!specs->extension)
-
_ASN
_DECODE_FAILED;
+
ASN_
_DECODE_FAILED;
/*
* X.691, #10.6: normally small non-negative whole number;
*/
value = uper_get_nsnnwn(pd);
/*
* X.691, #10.6: normally small non-negative whole number;
*/
value = uper_get_nsnnwn(pd);
- if(value < 0)
_ASN
_DECODE_STARVED;
+ if(value < 0)
ASN_
_DECODE_STARVED;
value += specs->extension - 1;
if(value >= specs->map_count)
value += specs->extension - 1;
if(value >= specs->map_count)
-
_ASN
_DECODE_FAILED;
+
ASN_
_DECODE_FAILED;
}
*native = specs->value2enum[value].nat_value;
}
*native = specs->value2enum[value].nat_value;
@@
-142,63
+142,66
@@
NativeEnumerated_encode_uper(asn_TYPE_descriptor_t *td,
asn_INTEGER_specifics_t *specs = (asn_INTEGER_specifics_t *)td->specifics;
asn_enc_rval_t er;
long native, value;
asn_INTEGER_specifics_t *specs = (asn_INTEGER_specifics_t *)td->specifics;
asn_enc_rval_t er;
long native, value;
- asn_per_constraint_t *ct
= NULL
;
+ asn_per_constraint_t *ct;
int inext = 0;
asn_INTEGER_enum_map_t key;
int inext = 0;
asn_INTEGER_enum_map_t key;
- asn_INTEGER_enum_map_t *kf;
+
const
asn_INTEGER_enum_map_t *kf;
- if(!sptr)
_ASN
_ENCODE_FAILED;
- if(!specs)
_ASN
_ENCODE_FAILED;
+ if(!sptr)
ASN_
_ENCODE_FAILED;
+ if(!specs)
ASN_
_ENCODE_FAILED;
if(constraints) ct = &constraints->value;
else if(td->per_constraints) ct = &td->per_constraints->value;
if(constraints) ct = &constraints->value;
else if(td->per_constraints) ct = &td->per_constraints->value;
- else
_ASN
_ENCODE_FAILED; /* Mandatory! */
+ else
ASN_
_ENCODE_FAILED; /* Mandatory! */
ASN_DEBUG("Encoding %s as NativeEnumerated", td->name);
er.encoded = 0;
native = *(long *)sptr;
ASN_DEBUG("Encoding %s as NativeEnumerated", td->name);
er.encoded = 0;
native = *(long *)sptr;
- if(native < 0)
_ASN
_ENCODE_FAILED;
+ if(native < 0)
ASN_
_ENCODE_FAILED;
key.nat_value = native;
kf = bsearch(&key, specs->value2enum, specs->map_count,
sizeof(key), NativeEnumerated__compar_value2enum);
if(!kf) {
ASN_DEBUG("No element corresponds to %ld", native);
key.nat_value = native;
kf = bsearch(&key, specs->value2enum, specs->map_count,
sizeof(key), NativeEnumerated__compar_value2enum);
if(!kf) {
ASN_DEBUG("No element corresponds to %ld", native);
-
_ASN
_ENCODE_FAILED;
+
ASN_
_ENCODE_FAILED;
}
value = kf - specs->value2enum;
}
value = kf - specs->value2enum;
- if(ct
&& ct
->range_bits >= 0) {
+ if(ct->range_bits >= 0) {
int cmpWith = specs->extension
? specs->extension - 1 : specs->map_count;
if(value >= cmpWith)
inext = 1;
}
int cmpWith = specs->extension
? specs->extension - 1 : specs->map_count;
if(value >= cmpWith)
inext = 1;
}
- if(ct
&& ct
->flags & APC_EXTENSIBLE) {
- if(per_put_few_bits(po, inext,
0
))
-
_ASN
_ENCODE_FAILED;
- ct = 0;
+ if(ct->flags & APC_EXTENSIBLE) {
+ if(per_put_few_bits(po, inext,
1
))
+
ASN_
_ENCODE_FAILED;
+
if(inext)
ct = 0;
} else if(inext) {
} else if(inext) {
-
_ASN
_ENCODE_FAILED;
+
ASN_
_ENCODE_FAILED;
}
if(ct && ct->range_bits >= 0) {
if(per_put_few_bits(po, value, ct->range_bits))
}
if(ct && ct->range_bits >= 0) {
if(per_put_few_bits(po, value, ct->range_bits))
-
_ASN
_ENCODE_FAILED;
-
_ASN
_ENCODED_OK(er);
+
ASN_
_ENCODE_FAILED;
+
ASN_
_ENCODED_OK(er);
}
if(!specs->extension)
}
if(!specs->extension)
-
_ASN
_ENCODE_FAILED;
+
ASN_
_ENCODE_FAILED;
/*
* X.691, #10.6: normally small non-negative whole number;
*/
/*
* X.691, #10.6: normally small non-negative whole number;
*/
- if(uper_put_nsnnwn(po, value - (specs->extension - 1)))
- _ASN_ENCODE_FAILED;
+ ASN_DEBUG("value = %ld, ext = %d, inext = %d, res = %ld",
+ value, specs->extension, inext,
+ value - (inext ? (specs->extension - 1) : 0));
+ if(uper_put_nsnnwn(po, value - (inext ? (specs->extension - 1) : 0)))
+ ASN__ENCODE_FAILED;
-
_ASN
_ENCODED_OK(er);
+
ASN_
_ENCODED_OK(er);
}
}