Commit 16207b15 authored by Raphael Riebl's avatar Raphael Riebl

per_support: add drop-in replacements of per_long_range_{rebase,unrebase}

parent 2a9e2a3c
......@@ -268,6 +268,14 @@ per_imax_range_rebase(intmax_t v, intmax_t lb, intmax_t ub, uintmax_t *output) {
}
}
int
per_long_range_rebase(long v, intmax_t lb, intmax_t ub, unsigned long *output) {
uintmax_t tmp = *output;
int rc = per_imax_range_rebase((intmax_t)v, lb, ub, &tmp);
*output = tmp;
return rc;
}
int
per_imax_range_unrebase(uintmax_t inp, intmax_t lb, intmax_t ub, intmax_t *outp) {
uintmax_t range;
......@@ -294,6 +302,14 @@ per_imax_range_unrebase(uintmax_t inp, intmax_t lb, intmax_t ub, intmax_t *outp)
return 0;
}
int
per_long_range_unrebase(unsigned long inp, intmax_t lb, intmax_t ub, long *outp) {
intmax_t tmp = *outp;
int rc = per_imax_range_unrebase((uintmax_t)inp, lb, ub, &tmp);
*outp = tmp;
return rc;
}
int32_t
aper_get_align(asn_per_data_t *pd) {
......
......@@ -81,8 +81,10 @@ typedef struct asn_bit_outp_s asn_per_outp_t;
* -1: Conversion failed due to range problems.
* 0: Conversion was successful.
*/
int per_long_range_rebase(long, intmax_t lb, intmax_t ub, unsigned long *output);
int per_imax_range_rebase(intmax_t v, intmax_t lb, intmax_t ub, uintmax_t *output);
/* The inverse operation: restores the value by the offset and its bounds. */
int per_long_range_unrebase(unsigned long inp, intmax_t lb, intmax_t ub, long *outp);
int per_imax_range_unrebase(uintmax_t inp, intmax_t lb, intmax_t ub, intmax_t *outp);
/* X.691-2008/11, #11.5 */
......
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