/* Simple file "hexadecimal dump" (hd) program. Shows printable text also. ** ** Written 1995/06/07 by Craig Bruce */ #include #include #include typedef unsigned char uchar; typedef unsigned long ulong; typedef int bool; #define TRUE 1 #define FALSE 0 int main( int argc, char *argv[] ); void HexDumpFile( FILE *fin ); void HexPut( char outline[], int linepos, int hexDigits, ulong value ); int GetChunk( FILE *fin, uchar buf[], int len ); /****************************************************************************/ int main(int argc, char *argv[]) { FILE *fin, *fout; int ifile; if (argc < 2) { HexDumpFile( stdin ); } else { for( ifile=1; ifile=0x20 && c<=0x7e) || (c>=0xa0) ) { outline[62+i] = c; } else { outline[62+i] = '.'; } } /* remove excess character values */ outline[62+bytes] = '\0'; /* print */ printf("%s\n", outline); filepos += bytes; } } /****************************************************************************/ void HexPut( char outline[], int linepos, int hexDigits, ulong value ) { char str[20]; char fmt[20]; int i; sprintf(fmt, "%%0%dx", hexDigits); sprintf(str, fmt, value); for (i=0; i