diff --git a/pvattest/src/exchange_format.c b/pvattest/src/exchange_format.c index 293872cf..2f94c4bf 100644 --- a/pvattest/src/exchange_format.c +++ b/pvattest/src/exchange_format.c @@ -455,7 +455,7 @@ static void print_entry(const char *name, GBytes *data, const gboolean print_dat fprintf(stream, _("%s (%#lx bytes)"), name, g_bytes_get_size(data)); if (print_data) { fprintf(stream, ":\n"); - pvattest_hexdump(stream, data, 16, " "); + pvattest_hexdump(stream, data, 16, " ", TRUE); } fprintf(stream, "\n"); } diff --git a/pvattest/src/log.c b/pvattest/src/log.c index 61703fa4..65df2b5e 100644 --- a/pvattest/src/log.c +++ b/pvattest/src/log.c @@ -159,7 +159,8 @@ void pvattest_log_bytes(const void *data, size_t size, size_t width, const char g_log(PVATTEST_BYTES_LOG_DOMAIN, log_lvl, "\n"); } -void pvattest_hexdump(FILE *stream, GBytes *bytes, const size_t width, const char *prefix) +void pvattest_hexdump(FILE *stream, GBytes *bytes, const size_t width, const char *prefix, + const gboolean beautify) { const uint8_t *data; size_t size; @@ -170,19 +171,25 @@ void pvattest_hexdump(FILE *stream, GBytes *bytes, const size_t width, const cha data = g_bytes_get_data(bytes, &size); pv_wrapped_g_assert(data); - fprintf(stream, "%s0x0000 ", prefix); + if (beautify) + fprintf(stream, "%s0x0000 ", prefix); + else + fprintf(stream, "%s", prefix); for (size_t i = 0; i < size; i++) { fprintf(stream, "%02x", data[i]); - if (i % 2 == 1) + if (i % 2 == 1 && beautify) fprintf(stream, " "); if (i == size - 1) break; if (width == 0) continue; - if (i % width == width - 1) - fprintf(stream, "\n%s0x%04lx ", prefix, i + 1); + if (i % width == width - 1) { + if (beautify) + fprintf(stream, "\n%s0x%04lx ", prefix, i + 1); + else + fprintf(stream, "\n%s", prefix); + } } - fprintf(stream, "\n"); } void pvattest_log_GError(const char *info, GError *error) diff --git a/pvattest/src/log.h b/pvattest/src/log.h index 0d15c4cf..ce520b5d 100644 --- a/pvattest/src/log.h +++ b/pvattest/src/log.h @@ -60,8 +60,8 @@ void pvattest_log_plain_logger(const char *log_domain, GLogLevelFlags level, con } void pvattest_log_bytes(const void *data, size_t size, size_t width, const char *prefix, gboolean beautify, GLogLevelFlags log_lvl) PV_NONNULL(1); -void pvattest_hexdump(FILE *stream, GBytes *bytes, const size_t width, const char *prefix) - PV_NONNULL(1, 2); +void pvattest_hexdump(FILE *stream, GBytes *bytes, const size_t width, const char *prefix, + const gboolean beautify) PV_NONNULL(1, 2); void pvattest_log_GError(const char *info, GError *error) PV_NONNULL(1); #endif /* PVATTEST_LOG_H */