diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2016-09-08 16:04:47 +0200 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2016-09-08 16:04:47 +0200 |
commit | 49de98994f234e93cc37e2f01d2927a05880a7e7 (patch) | |
tree | 9504916f296ec7b15908cd1d16150dbc59be9928 /misc.cc | |
parent | 7dbbe7fb4c50c62b0e1818c5356aafb97a00ac0f (diff) | |
download | libnitrokey-49de98994f234e93cc37e2f01d2927a05880a7e7.tar.gz libnitrokey-49de98994f234e93cc37e2f01d2927a05880a7e7.tar.bz2 |
Allow disabling hexdump header
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'misc.cc')
-rw-r--r-- | misc.cc | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -6,14 +6,16 @@ namespace nitrokey { namespace misc { -std::string hexdump(const char *p, size_t size) { +std::string hexdump(const char *p, size_t size, bool print_header) { std::stringstream out; char formatbuf[128]; const char *pstart = p; for (const char *pend = p + size; p < pend;) { - snprintf(formatbuf, 128, "%04lx\t", p - pstart); - out << formatbuf; + if (print_header){ + snprintf(formatbuf, 128, "%04lx\t", p - pstart); + out << formatbuf; + } for (const char *le = p + 16; p < le && p < pend; p++) { snprintf(formatbuf, 128, "%02x ", uint8_t(*p)); |