Commit 81cc4e47 authored by v0-e's avatar v0-e

INTEGER to (u)int64_t

parent ce10a57a
......@@ -414,6 +414,33 @@ asn_ulong2INTEGER(INTEGER_t *st, unsigned long value) {
return asn_imax2INTEGER(st, value);
}
int asn_INTEGER2int64(const INTEGER_t *st, int64_t *value) {
intmax_t v;
if(asn_INTEGER2imax(st, &v) == 0) {
if(v < INT64_MIN || v > INT64_MAX) {
errno = ERANGE;
return -1;
}
*value = v;
return 0;
} else {
return -1;
}
}
int asn_INTEGER2uint64(const INTEGER_t *st, uint64_t *value) {
uintmax_t v;
if(asn_INTEGER2umax(st, &v) == 0) {
if(v > UINT64_MAX) {
errno = ERANGE;
return -1;
}
*value = v;
return 0;
} else {
return -1;
}
}
int
asn_uint642INTEGER(INTEGER_t *st, uint64_t value) {
......
......@@ -108,6 +108,8 @@ int asn_INTEGER2long(const INTEGER_t *i, long *l);
int asn_INTEGER2ulong(const INTEGER_t *i, unsigned long *l);
int asn_long2INTEGER(INTEGER_t *i, long l);
int asn_ulong2INTEGER(INTEGER_t *i, unsigned long l);
int asn_INTEGER2int64(const INTEGER_t *i, int64_t *l);
int asn_INTEGER2uint64(const INTEGER_t *i, uint64_t *l);
int asn_int642INTEGER(INTEGER_t *i, int64_t l);
int asn_uint642INTEGER(INTEGER_t *i, uint64_t l);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment