* hexdump output is easily parseable

* Add hexparse.c
This commit is contained in:
pancake@dazo committed 2010-06-14 00:45:16 +02:00
1 parent 5a5595ced6
commit 4d81079a14
3 files changed
+25 -5

No files matched your search

+1
View File
@@ -3,3 +3,4 @@
* getcurblock can manage its own memory.. all those free's can be removed
* Find a way to return original value if str2ut64 fails (2nd arg..)
* Add math support to '?' command
* w<- should write from stdin
+20
View File
@@ -0,0 +1,20 @@
#include <unistd.h>
int main() {
char next=0, ch, och=0;
while (read (0, &ch, 1)==1) {
if (next) {
if (ch==next)
next = 0;
continue;
}
if (och == ' ' && ch==' ')
next = '\n';
if (och == '0' && ch=='x')
next = ':';
if (!next && ch!=' ')
write (1, &ch, 1);
och = ch;
}
return 0;
}
+4 -5
View File
@@ -10,7 +10,7 @@ static inline char *skipspaces(char *arg) {
static inline void hexdump(const ut8 *buf, unsigned int len, int w) {
unsigned int i, j;
for(i=0;i<len;i+=w) {
printf("0x%08"LLF"x ", curseek+i);
printf("0x%08"LLF"x: ", curseek+i);
for(j=i;j<i+w;j++) {
if(j>=len) {
printf(j%2?" ":" ");
@@ -18,10 +18,9 @@ static inline void hexdump(const ut8 *buf, unsigned int len, int w) {
}
printf(j%2?"%02x ":"%02x", buf[j]);
}
for(j=i;j<i+w;j++) {
if(j>=len) printf(" ");
else printf("%c", isprint(buf[j])?buf[j]:'.');
}
printf(" ");
for(j=i;j<i+w;j++)
printf("%c", isprint(buf[j])?buf[j]:'.');
printf("\n");
}
}