From 8ab514fabc53bf8270d3567d48f41b53de02239f Mon Sep 17 00:00:00 2001 From: "Sergio R. Caprile" Date: Mon, 28 Apr 2025 12:33:31 -0300 Subject: [PATCH] make hexdump send CRLF --- mongoose.c | 5 +++-- src/log.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mongoose.c b/mongoose.c index 3fde7a2b..b94797fb 100644 --- a/mongoose.c +++ b/mongoose.c @@ -3104,7 +3104,8 @@ void mg_hexdump(const void *buf, size_t len) { for (i = 0; i < len; i++) { if ((i % 16) == 0) { // Print buffered ascii chars - if (i > 0) logs(" ", 2), logs((char *) ascii, 16), logc('\n'), alen = 0; + if (i > 0) + logs(" ", 2), logs((char *) ascii, 16), logs("\r\n", 2), alen = 0; // Print hex address, then \t logc(nibble((i >> 12) & 15)), logc(nibble((i >> 8) & 15)), logc(nibble((i >> 4) & 15)), logc('0'), logs(" ", 3); @@ -3114,7 +3115,7 @@ void mg_hexdump(const void *buf, size_t len) { ascii[alen++] = ISPRINT(p[i]) ? p[i] : '.'; // Add to the ascii buf } while (alen < 16) logs(" ", 3), ascii[alen++] = ' '; - logs(" ", 2), logs((char *) ascii, 16), logc('\n'); + logs(" ", 2), logs((char *) ascii, 16), logs("\r\n", 2); } #ifdef MG_ENABLE_LINES diff --git a/src/log.c b/src/log.c index e5d3eeba..8e046a26 100644 --- a/src/log.c +++ b/src/log.c @@ -57,7 +57,8 @@ void mg_hexdump(const void *buf, size_t len) { for (i = 0; i < len; i++) { if ((i % 16) == 0) { // Print buffered ascii chars - if (i > 0) logs(" ", 2), logs((char *) ascii, 16), logc('\n'), alen = 0; + if (i > 0) + logs(" ", 2), logs((char *) ascii, 16), logs("\r\n", 2), alen = 0; // Print hex address, then \t logc(nibble((i >> 12) & 15)), logc(nibble((i >> 8) & 15)), logc(nibble((i >> 4) & 15)), logc('0'), logs(" ", 3); @@ -67,5 +68,5 @@ void mg_hexdump(const void *buf, size_t len) { ascii[alen++] = ISPRINT(p[i]) ? p[i] : '.'; // Add to the ascii buf } while (alen < 16) logs(" ", 3), ascii[alen++] = ' '; - logs(" ", 2), logs((char *) ascii, 16), logc('\n'); + logs(" ", 2), logs((char *) ascii, 16), logs("\r\n", 2); }