summaryrefslogtreecommitdiff
path: root/hex.h
diff options
context:
space:
mode:
Diffstat (limited to 'hex.h')
-rw-r--r--hex.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/hex.h b/hex.h
new file mode 100644
index 0000000..246aeed
--- /dev/null
+++ b/hex.h
@@ -0,0 +1,15 @@
+#ifndef HEX_H
+#define HEX_H
+
+#include <stdio.h> // fprintf()
+#include <stdint.h> // uint8_t
+
+// print hex-encoded buffer to given file handle.
+// (used by top-level main.c)
+static void hex_write(FILE *fh, const uint8_t * const buf, const size_t len) {
+ for (size_t i = 0; i < len; i++) {
+ fprintf(fh, "%02x", buf[i]);
+ }
+}
+
+#endif /* HEX_H */