summaryrefslogtreecommitdiffstats
path: root/src/utils.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2010-07-30 11:43:30 +0200
committerHarald Welte <laforge@gnumonks.org>2010-07-30 11:47:50 +0200
commitdee47cd14dc426c45253f576edaae9fe9c4e028a (patch)
treee8f45b47bf1ac3914184b10c6abba314822b6b28 /src/utils.c
parent40481e895453c53d71f2f254b931b77c830c9e0a (diff)
add new hexdump_nospc() function
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c14
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, "");
+}