From 7887a482dc7951a88fd0b2a4caa8988f0aef4340 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Wed, 6 Sep 2023 23:23:08 -0400 Subject: add hex.h, refactor main.c --- hex.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 hex.h (limited to 'hex.h') 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 // fprintf() +#include // 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 */ -- cgit v1.2.3