Browse Source

Compilation fix

pull/827/head
Luca Deri 3 years ago
parent
commit
00159d0d01
  1. 70
      src/hexdump.c

70
src/hexdump.c

@ -5,39 +5,41 @@
#include "hexdump.h"
void fhexdump(unsigned int display_addr, void *in, int size, FILE *stream) {
uint8_t *p = in;
while(size>0) {
fprintf(stream, "%03x: ", display_addr);
for (int i = 0; i < 16; i++) {
if (i < size) {
fprintf(stream, "%02x", p[i]);
} else {
fprintf(stream, " ");
}
if (i==7) {
fprintf(stream, " ");
} else {
fprintf(stream, " ");
}
}
fprintf(stream, " |");
for (int i = 0; i < 16; i++) {
if (i < size) {
char ch = p[i];
if (ch>=0x20 && ch<=0x7e) {
fprintf(stream, "%c", ch);
} else {
fprintf(stream, " ");
}
}
}
fprintf(stream, "|\n");
size -= 16;
display_addr += 16;
p += 16;
uint8_t *p = in;
while(size>0) {
int i;
fprintf(stream, "%03x: ", display_addr);
for (i = 0; i < 16; i++) {
if (i < size) {
fprintf(stream, "%02x", p[i]);
} else {
fprintf(stream, " ");
}
if (i==7) {
fprintf(stream, " ");
} else {
fprintf(stream, " ");
}
}
fprintf(stream, " |");
for (i = 0; i < 16; i++) {
if (i < size) {
char ch = p[i];
if (ch>=0x20 && ch<=0x7e) {
fprintf(stream, "%c", ch);
} else {
fprintf(stream, " ");
}
}
}
fprintf(stream, "|\n");
size -= 16;
display_addr += 16;
p += 16;
}
}

Loading…
Cancel
Save