summaryrefslogtreecommitdiff
path: root/hacking.h
diff options
context:
space:
mode:
Diffstat (limited to 'hacking.h')
-rw-r--r--hacking.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/hacking.h b/hacking.h
index ef8d2c1..2684b6c 100644
--- a/hacking.h
+++ b/hacking.h
@@ -17,3 +17,28 @@ void *ec_malloc(unsigned int size)
fatal("in ec_malloc() on memory allocation");
return ptr;
}
+
+void dump(const char *data_buffer, const unsigned int length) {
+ unsigned char byte;
+ unsigned int i, j;
+
+ for (int i = 0; i < length; i++) {
+ byte = data_buffer[i];
+ printf("%02x ", data_buffer[i]);
+ if ( ((i%16) == 15) || (i==length-1) ) {
+ for (int j = 0; j < 15 - (i%16); j++) {
+ printf(" ");
+ }
+ printf("| ");
+ for (j=(i-(i%16)); j <= i; j++) {
+ byte = data_buffer[j];
+ if ((byte > 31) && (byte < 127)) {
+ printf("%c", byte);
+ } else {
+ printf(".");
+ }
+ }
+ printf("\n");
+ }
+ }
+}