changeset 161:884b93362449

libutil: nibbles_to_ascii() function implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 26 Feb 2021 21:10:26 +0000
parents b86b3f8890ba
children 274bfd8bccd0
files libutil/Makefile libutil/nibbles2asc.c
diffstat 2 files changed, 22 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libutil/Makefile	Fri Feb 26 21:04:11 2021 +0000
+++ b/libutil/Makefile	Fri Feb 26 21:10:26 2021 +0000
@@ -2,8 +2,9 @@
 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 hexdigits.o hexread.o hexstr.o number_decode.o \
-	number_encode.o pinentry.o plmncodes.o revnibbles.o shorthand.o
+	gsm7_unpack.o hexdigits.o hexread.o hexstr.o nibbles2asc.o \
+	number_decode.o number_encode.o pinentry.o plmncodes.o revnibbles.o \
+	shorthand.o
 LIB=	libutil.a
 
 all:	${LIB}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libutil/nibbles2asc.c	Fri Feb 26 21:10:26 2021 +0000
@@ -0,0 +1,19 @@
+/*
+ * This module implements a function for turning a nibble array
+ * into printable ASCII.
+ */
+
+#include <sys/types.h>
+
+void
+nibbles_to_ascii(nib, len, out)
+	u_char *nib;
+	unsigned len;
+	char *out;
+{
+	unsigned n;
+
+	for (n = 0; n < len; n++)
+		*out++ = encode_hex_digit(*nib++);
+	*out = '\0';
+}