29#if defined(INFIX_DEBUG_ENABLED) && INFIX_DEBUG_ENABLED
32#if defined(DBLTAP_ENABLE) && defined(DBLTAP_IMPLEMENTATION)
40 printf("# " __VA_ARGS__); \
62void infix_dump_hex(
const void * data,
size_t size,
const char * title) {
63 const uint8_t *
byte = (
const uint8_t *)data;
68 note(
"%s (size: %llu bytes at %p)", title, (
unsigned long long)size, data);
69 for (
size_t i = 0; i < size; i += 16) {
71 remaining_len =
sizeof(line_buf);
73 written = snprintf(buf_ptr, remaining_len,
"0x%04llx: ", (
unsigned long long)i);
74 if (written < 0 || (
size_t)written >= remaining_len)
77 remaining_len -= written;
79 for (
size_t j = 0; j < 16; ++j) {
81 written = snprintf(buf_ptr, remaining_len,
"%02x ",
byte[i + j]);
83 written = snprintf(buf_ptr, remaining_len,
" ");
84 if (written < 0 || (
size_t)written >= remaining_len)
87 remaining_len -= written;
89 written = snprintf(buf_ptr, remaining_len,
" ");
90 if (written < 0 || (
size_t)written >= remaining_len)
93 remaining_len -= written;
96 written = snprintf(buf_ptr, remaining_len,
"| ");
97 if (written < 0 || (
size_t)written >= remaining_len)
100 remaining_len -= written;
102 for (
size_t j = 0; j < 16; ++j) {
104 if (
byte[i + j] >= 32 &&
byte[i + j] <= 126)
105 written = snprintf(buf_ptr, remaining_len,
"%c",
byte[i + j]);
107 written = snprintf(buf_ptr, remaining_len,
".");
108 if (written < 0 || (
size_t)written >= remaining_len)
111 remaining_len -= written;
115 note(
" %s", line_buf);
117 note(
"End of %s", title);
A lightweight, single-header TAP (Test Anything Protocol) library.
#define note(...)
Definition double_tap.h:172
A header for conditionally compiled debugging utilities.
static void infix_dump_hex(c23_maybe_unused const void *data, c23_maybe_unused size_t size, c23_maybe_unused const char *title)
Definition utility.h:115