Hex Code 를 File 로 저장하는 소스코드
CODE2009. 5. 20. 15:40
void UTIL_HexDump(unsigned char* FileName, unsigned char* buf, long len) { FILE *fi = 0; int i = 0; long start = 0; unsigned int TempPort = 0; if( !FileName ) return; if( !buf ) return; fi = fopen( (const char*)FileName, "a+t"); if( len == -1 ) { fprintf( fi, "\n=====%s=====\n", buf); fclose( fi ); return; } if( len == -2 ) { fprintf( fi, "%s", buf); fclose( fi ); return; } while( len > 0L ) { fprintf( fi, "%6.6X:", start ); for( i = 0; i < 8; ++i ) { if( len - i > 0 ) fprintf( fi, " %2.2X", buf[ i ] & 0xFF ); else fprintf( fi, " " ); } fprintf( fi, ":" ); for( i = 8; i < 16; ++i ) { if( len - i > 0 ) fprintf( fi, " %2.2X", buf[ i ] & 0xFF ); else fprintf( fi, " " ); } fprintf( fi, " " ); for( i = 0; i < 16; ++i ) { if( len - i > 0 ) { if( buf[i]>=0x20 && buf[i]<=0x7e ) fprintf( fi, "%c", buf[ i ] ); else fprintf( fi, "%c", '.' ); } else fprintf( fi, "%c", '.' ); } fprintf( fi, "\n" ); len -= 16; start += 16L; buf += 16; } fclose(fi); return; }