From 061430973e82995368d27ff9081391f9475da3c7 Mon Sep 17 00:00:00 2001 From: James McKenzie Date: Mon, 3 Aug 2015 10:34:07 +0100 Subject: fish --- host/hexdump.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 host/hexdump.c (limited to 'host/hexdump.c') diff --git a/host/hexdump.c b/host/hexdump.c new file mode 100644 index 0000000..127faab --- /dev/null +++ b/host/hexdump.c @@ -0,0 +1,60 @@ +/* + * hexdump.c + * + * Copyright (c) 2011 Citrix Sysmtes Inc., + * All rights reserved. + * + */ + +#include "project.h" + +void +hexdump (char *prefix, void *_d, int len) +{ + uint8_t *d = (uint8_t *) _d; + int i, j, k; + int e; + + printf ("%s %d bytes from %p\n", prefix, len, d); + + if (!d || len < 0) + return; + + e = len + 15; + e &= ~15; + + for (i = 0; i < e; i += 16) + { + printf ("%s %05x:", prefix, i); + for (j = 0; j < 16; ++j) + { + k = i + j; + + if (k < len) + printf (" %02x", d[k]); + else + printf (" "); + + if (j == 7) + printf (" "); + } + + printf (" "); + for (j = 0; j < 16; ++j) + { + k = i + j; + if (k < len) + { + uint8_t c = d[k]; + if (c < 33) + c = '.'; + if (c > 126) + c = '.'; + printf ("%c", c); + } + if (j == 7) + printf (" "); + } + printf ("\n"); + } +} -- cgit v1.2.3