# HG changeset patch # User Mychaela Falconia # Date 1614372091 0 # Node ID 3698c8192d2d4026d45ba4f52fb0ae292bb37672 # Parent f064dbcc5f41a0938fb530a3ac2998e5467f305a libutil: hex digit functions factored out diff -r f064dbcc5f41 -r 3698c8192d2d libutil/Makefile --- a/libutil/Makefile Fri Feb 26 20:19:58 2021 +0000 +++ b/libutil/Makefile Fri Feb 26 20:41:31 2021 +0000 @@ -2,8 +2,8 @@ CFLAGS= -O2 OBJS= alpha_decode.o alpha_fromfile.o alpha_valid.o decimal_str.o \ filesearch.o gsm7_decode.o gsm7_encode.o gsm7_encode_table.o \ - gsm7_unpack.o hexread.o hexstr.o number_decode.o number_encode.o \ - pinentry.o plmncodes.o revnibbles.o + gsm7_unpack.o hexdigits.o hexread.o hexstr.o number_decode.o \ + number_encode.o pinentry.o plmncodes.o revnibbles.o LIB= libutil.a all: ${LIB} diff -r f064dbcc5f41 -r 3698c8192d2d libutil/hexdigits.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libutil/hexdigits.c Fri Feb 26 20:41:31 2021 +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'); +} diff -r f064dbcc5f41 -r 3698c8192d2d libutil/hexstr.c --- a/libutil/hexstr.c Fri Feb 26 20:19:58 2021 +0000 +++ b/libutil/hexstr.c Fri Feb 26 20:41:31 2021 +0000 @@ -4,21 +4,7 @@ #include #include -#include -#include #include -#include - -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); -} decode_hex_data_from_string(arg, databuf, minlen, maxlen) char *arg; diff -r f064dbcc5f41 -r 3698c8192d2d libutil/revnibbles.c --- a/libutil/revnibbles.c Fri Feb 26 20:19:58 2021 +0000 +++ b/libutil/revnibbles.c Fri Feb 26 20:41:31 2021 +0000 @@ -4,15 +4,6 @@ #include -encode_hex_digit(d) - unsigned d; -{ - if (d <= 9) - return(d + '0'); - else - return(d - 10 + 'A'); -} - decode_reversed_nibbles(bytes, nbytes, dest) u_char *bytes; unsigned nbytes;