32 lines
645 B
C
32 lines
645 B
C
#include "common.h"
|
|
#include <stdarg.h>
|
|
|
|
verbosity_t verbosity = VERBOSITY_NORMAL;
|
|
|
|
void printfv(verbosity_t level, const char* format, ...)
|
|
{
|
|
va_list args;
|
|
va_start(args, format);
|
|
|
|
if (verbosity >= level) {
|
|
vprintf(format, args);
|
|
}
|
|
|
|
va_end(args);
|
|
}
|
|
|
|
void hexdump(const void* data, size_t length)
|
|
{
|
|
for (size_t read = 0; read < length; read += 16) {
|
|
printf("%08zx", read);
|
|
|
|
size_t to_read = length - read > 16 ? 16 : length - read;
|
|
for (size_t byte = 0; byte < to_read; byte++) {
|
|
printf(" %02X", ((unsigned char*)data)[read + byte]);
|
|
}
|
|
|
|
printf("\n");
|
|
}
|
|
}
|
|
|