chiark / gitweb /
serpent: Ad-hoc debugging facility
[secnet.git] / hexdebug.h
diff --git a/hexdebug.h b/hexdebug.h
new file mode 100644 (file)
index 0000000..4139f72
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef HEXDEBUG_H
+#define HEXDEBUG_H
+
+#include <stdio.h>
+#include <sys/types.h>
+
+static inline void hexdebug(FILE *file, const void *buffer, size_t len)
+{
+    const uint8_t *array=buffer;
+    size_t i;
+    for (i=0; i<len; i++)
+       fprintf(file,"%02x",array[i]);
+}
+
+#endif /*HEXDEBUG_H*/