diff options
Diffstat (limited to 'src/utils.c')
-rw-r--r-- | src/utils.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/utils.c b/src/utils.c index a6c2d6d2..21558857 100644 --- a/src/utils.c +++ b/src/utils.c @@ -78,7 +78,7 @@ int hexparse(const char *str, uint8_t *b, int max_len) static char hexd_buff[4096]; -char *hexdump(const unsigned char *buf, int len) +static char *_hexdump(const unsigned char *buf, int len, char *delim) { int i; char *cur = hexd_buff; @@ -86,7 +86,7 @@ char *hexdump(const unsigned char *buf, int len) hexd_buff[0] = 0; for (i = 0; i < len; i++) { int len_remain = sizeof(hexd_buff) - (cur - hexd_buff); - int rc = snprintf(cur, len_remain, "%02x ", buf[i]); + int rc = snprintf(cur, len_remain, "%02x%s", buf[i], delim); if (rc <= 0) break; cur += rc; @@ -94,3 +94,13 @@ char *hexdump(const unsigned char *buf, int len) hexd_buff[sizeof(hexd_buff)-1] = 0; return hexd_buff; } + +char *hexdump(const unsigned char *buf, int len) +{ + return _hexdump(buf, len, " "); +} + +char *hexdump_nospc(const unsigned char *buf, int len) +{ + return _hexdump(buf, len, ""); +} |