diff options
author | jstebbins <[email protected]> | 2011-09-27 00:48:35 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2011-09-27 00:48:35 +0000 |
commit | 57f74136121d09a3583e5ed9c838dfab29ab8548 (patch) | |
tree | db28a5c8b21a2d1fa3a1be1ffa2f354a36f531d7 /libhb/common.c | |
parent | 6f78c9f7853dc7c31c0e42e5feee0526f7a4dff1 (diff) |
add utility function for doing hexdumps to log
I find myself re-writing a quick and dirty hexdump function far too
often when debugging. This will save some time in the future.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4259 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/common.c')
-rw-r--r-- | libhb/common.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/libhb/common.c b/libhb/common.c index ce0f1a7f6..51a5139fe 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -1634,3 +1634,36 @@ const char * hb_subsource_name( int source ) } } +void hb_hexdump( hb_debug_level_t level, const char * label, const uint8_t * data, int len ) +{ + int ii; + char line[80], *p; + + p = line; + if( label ) + hb_deep_log(level, "++++ %s ++++", label); + else + hb_deep_log(level, "++++++++++++"); + for( ii = 0; ii < len; ii++ ) + { + if( ( ii & 0x0f ) == 0x0f ) + { + p += sprintf( p, "%02x", data[ii] ); + hb_deep_log( level, " %s", line ); + p = line; + } + else if( ( ii & 0x07 ) == 0x07 ) + { + p += sprintf( p, "%02x ", data[ii] ); + } + else + { + p += sprintf( p, "%02x ", data[ii] ); + } + } + if( p != line ) + { + hb_deep_log( level, " %s", line ); + } +} + |