[PATCH 1/2] osmocon: extend hexdump to show all printable characters

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/baseband-devel@lists.osmocom.org/.

Jan Luebbe jluebbe at debian.org
Sun May 16 15:31:21 UTC 2010


---
 src/host/osmocon/osmocon.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/host/osmocon/osmocon.c b/src/host/osmocon/osmocon.c
index b823b5b..4ad48e2 100644
--- a/src/host/osmocon/osmocon.c
+++ b/src/host/osmocon/osmocon.c
@@ -22,6 +22,7 @@
  *
  */
 
+#include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -418,11 +419,16 @@ int read_file(const char *filename)
 
 static void hexdump(const uint8_t *data, unsigned int len)
 {
-	const uint8_t *bufptr = data;
 	int n;
 
-	for (n=0; n < len; n++, bufptr++)
-		printf("%02x ", *bufptr);
+	for (n=0; n < len; n++)
+		printf("%02x ", data[n]);
+	printf(" ");
+	for (n=0; n < len; n++)
+		if (isprint(data[n]))
+			putchar(data[n]);
+		else
+			putchar('.');
 	printf("\n");
 }
 
-- 
1.7.1





More information about the baseband-devel mailing list