mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 21:33:47 -07:00
Merge pull request #2514 from douniwan5788/hexdump
refactor: Optimize Dbhexdump
This commit is contained in:
commit
c9b1cc1d95
1 changed files with 12 additions and 11 deletions
|
@ -75,26 +75,27 @@ void Dbprintf(const char *fmt, ...) {
|
||||||
// prints HEX & ASCII
|
// prints HEX & ASCII
|
||||||
void Dbhexdump(int len, const uint8_t *d, bool bAsci) {
|
void Dbhexdump(int len, const uint8_t *d, bool bAsci) {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
char ascii[17];
|
|
||||||
|
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
|
|
||||||
int l = (len > 16) ? 16 : len;
|
int l = (len > 16) ? 16 : len;
|
||||||
|
|
||||||
memcpy(ascii, d, l);
|
if (bAsci) {
|
||||||
ascii[l] = 0;
|
char ascii[17];
|
||||||
|
|
||||||
// filter safe ascii
|
memcpy(ascii, d, l);
|
||||||
for (int i = 0; i < l; i++) {
|
ascii[l] = 0;
|
||||||
if (ascii[i] < 32 || ascii[i] > 126) {
|
|
||||||
ascii[i] = '.';
|
// filter safe ascii
|
||||||
|
for (int i = 0; i < l; i++) {
|
||||||
|
if (ascii[i] < 32 || ascii[i] > 126) {
|
||||||
|
ascii[i] = '.';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (bAsci)
|
|
||||||
Dbprintf("%-8s %*D", ascii, l, d, " ");
|
Dbprintf("%-8s %*D", ascii, l, d, " ");
|
||||||
else
|
} else {
|
||||||
Dbprintf("%*D", l, d, " ");
|
Dbprintf("%*D", l, d, " ");
|
||||||
|
}
|
||||||
|
|
||||||
len -= 16;
|
len -= 16;
|
||||||
d += 16;
|
d += 16;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue