COMMON: Switch hexdump() to debugN instead of printf
Rational: hexdump() is used for debug output. An even better alternative might be to change it to return a string, instead of printing anything. This way, it could be used inside e.g. GUI debug consoles. This is left as an exercise to the interested developer :). svn-id: r54010
This commit is contained in:
parent
f77b8aee75
commit
459ef85068
1 changed files with 14 additions and 14 deletions
|
@ -38,20 +38,20 @@ void hexdump(const byte *data, int len, int bytesPerLine, int startOffset) {
|
||||||
byte c;
|
byte c;
|
||||||
int offset = startOffset;
|
int offset = startOffset;
|
||||||
while (len >= bytesPerLine) {
|
while (len >= bytesPerLine) {
|
||||||
printf("%06x: ", offset);
|
debugN("%06x: ", offset);
|
||||||
for (i = 0; i < bytesPerLine; i++) {
|
for (i = 0; i < bytesPerLine; i++) {
|
||||||
printf("%02x ", data[i]);
|
debugN("%02x ", data[i]);
|
||||||
if (i % 4 == 3)
|
if (i % 4 == 3)
|
||||||
printf(" ");
|
debugN(" ");
|
||||||
}
|
}
|
||||||
printf(" |");
|
debugN(" |");
|
||||||
for (i = 0; i < bytesPerLine; i++) {
|
for (i = 0; i < bytesPerLine; i++) {
|
||||||
c = data[i];
|
c = data[i];
|
||||||
if (c < 32 || c >= 127)
|
if (c < 32 || c >= 127)
|
||||||
c = '.';
|
c = '.';
|
||||||
printf("%c", c);
|
debugN("%c", c);
|
||||||
}
|
}
|
||||||
printf("|\n");
|
debugN("|\n");
|
||||||
data += bytesPerLine;
|
data += bytesPerLine;
|
||||||
len -= bytesPerLine;
|
len -= bytesPerLine;
|
||||||
offset += bytesPerLine;
|
offset += bytesPerLine;
|
||||||
|
@ -60,25 +60,25 @@ void hexdump(const byte *data, int len, int bytesPerLine, int startOffset) {
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
printf("%06x: ", offset);
|
debugN("%06x: ", offset);
|
||||||
for (i = 0; i < bytesPerLine; i++) {
|
for (i = 0; i < bytesPerLine; i++) {
|
||||||
if (i < len)
|
if (i < len)
|
||||||
printf("%02x ", data[i]);
|
debugN("%02x ", data[i]);
|
||||||
else
|
else
|
||||||
printf(" ");
|
debugN(" ");
|
||||||
if (i % 4 == 3)
|
if (i % 4 == 3)
|
||||||
printf(" ");
|
debugN(" ");
|
||||||
}
|
}
|
||||||
printf(" |");
|
debugN(" |");
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
c = data[i];
|
c = data[i];
|
||||||
if (c < 32 || c >= 127)
|
if (c < 32 || c >= 127)
|
||||||
c = '.';
|
c = '.';
|
||||||
printf("%c", c);
|
debugN("%c", c);
|
||||||
}
|
}
|
||||||
for (; i < bytesPerLine; i++)
|
for (; i < bytesPerLine; i++)
|
||||||
printf(" ");
|
debugN(" ");
|
||||||
printf("|\n");
|
debugN("|\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue