diff options
| author | Ian C <ianc@noddybox.co.uk> | 2007-03-04 18:35:36 +0000 |
|---|---|---|
| committer | Ian C <ianc@noddybox.co.uk> | 2007-03-04 18:35:36 +0000 |
| commit | 954af9179665457b40453a0417ddf5b3949a0449 (patch) | |
| tree | e3772817de5c79e29b602ebe47fe0129793f1470 /hex.c | |
| parent | 892e6e107dbf2386831bd00e7f1c2a0bbe8b2cbb (diff) | |
This commit was generated by cvs2svn to compensate for changes in r2,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'hex.c')
| -rw-r--r-- | hex.c | 62 |
1 files changed, 62 insertions, 0 deletions
@@ -0,0 +1,62 @@ +#include <stdlib.h> +#include <stdio.h> +#include <ctype.h> + +int main(int argc,char *argv[]) + +{ + void Dump(char *fn,FILE *fp); + FILE *fp; + int f; + + if (argc==1) + Dump("stdin",stdin); + else + for(f=1;f<argc;f++) + if ((fp=fopen(argv[f],"r"))) + { + Dump(argv[f],fp); + fclose(fp); + } + else + fprintf(stderr,"Couldn't open %s\n",argv[f]); +} + + +void Dump(char *fn,FILE *fp) +{ + char s[17]; + int p; + int f; + int b; + + printf("File:%s\n",fn); + + b=!EOF; + p=0; + + while(b!=EOF) + { + strcpy(s," "); + + printf("%6.6x: ",p); + p+=16; + + for(f=0;f<16;f++) + { + if((b!=EOF)&&((b=getc(fp))!=EOF)) + { + printf("%2.2x ",(unsigned char)b); + + if (isprint(b)) + s[f]=b; + else + s[f]='.'; + } + else + printf("** "); + } + + printf(" %s\n",s); + } +} |
