# HG changeset patch # User Mychaela Falconia # Date 1691217157 0 # Node ID cd2d82ec5144e31480670881e9c92086d642fcb3 # Parent b831ee7d512c0e792432bc1e51502f509110a835 libcoding/hexdigits.c: import from fc-sim-tools/libutil diff -r b831ee7d512c -r cd2d82ec5144 libcoding/Makefile --- a/libcoding/Makefile Sat Aug 05 05:45:15 2023 +0000 +++ b/libcoding/Makefile Sat Aug 05 06:32:37 2023 +0000 @@ -1,7 +1,7 @@ CC= gcc CFLAGS= -O2 -OBJS= gsm7_encode.o gsm7_encode_table.o gsm7_pack.o hexout.o number_encode.o \ - timestamp.o ucs2_bigend.o utf8_decode.o utf8_decode2.o +OBJS= gsm7_encode.o gsm7_encode_table.o gsm7_pack.o hexdigits.o hexout.o \ + number_encode.o timestamp.o ucs2_bigend.o utf8_decode.o utf8_decode2.o LIB= libcoding.a all: ${LIB} diff -r b831ee7d512c -r cd2d82ec5144 libcoding/hexdigits.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libcoding/hexdigits.c Sat Aug 05 06:32:37 2023 +0000 @@ -0,0 +1,23 @@ +/* + * This module contains elementary functions for working with hex digits. + */ + +decode_hex_digit(c) +{ + if (c >= '0' && c <= '9') + return(c - '0'); + if (c >= 'A' && c <= 'F') + return(c - 'A' + 10); + if (c >= 'a' && c <= 'f') + return(c - 'a' + 10); + return(-1); +} + +encode_hex_digit(d) + unsigned d; +{ + if (d <= 9) + return(d + '0'); + else + return(d - 10 + 'A'); +}