summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2011-09-29 18:18:13 +0000
committerjstebbins <[email protected]>2011-09-29 18:18:13 +0000
commit6778323dcdcfac399be811e4e6c45072f7aa4526 (patch)
treedadb843abb70a932655f85b30ea20b1f58259ef1 /libhb
parent320e87db93bfcd1cad18d9ed75f0c12b9fa57d0a (diff)
log printable ascii with hexdumps
Provides similar output to 'hexdump -C' *nix command. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4262 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r--libhb/common.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/libhb/common.c b/libhb/common.c
index 01884f02b..5abc9b950 100644
--- a/libhb/common.c
+++ b/libhb/common.c
@@ -6,6 +6,7 @@
#include <stdarg.h>
#include <time.h>
+#include <ctype.h>
#include <sys/time.h>
#include "common.h"
@@ -1643,8 +1644,12 @@ 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;
+ char line[80], ascii[19], *p;
+ ascii[18] = 0;
+ ascii[0] = '|';
+ ascii[17] = '|';
+ memset(&ascii[1], '.', 16);
p = line;
if( label )
hb_deep_log(level, "++++ %s ++++", label);
@@ -1655,7 +1660,8 @@ void hb_hexdump( hb_debug_level_t level, const char * label, const uint8_t * dat
if( ( ii & 0x0f ) == 0x0f )
{
p += sprintf( p, "%02x", data[ii] );
- hb_deep_log( level, " %s", line );
+ hb_deep_log( level, " %-50s%20s", line, ascii );
+ memset(&ascii[1], '.', 16);
p = line;
}
else if( ( ii & 0x07 ) == 0x07 )
@@ -1666,10 +1672,15 @@ void hb_hexdump( hb_debug_level_t level, const char * label, const uint8_t * dat
{
p += sprintf( p, "%02x ", data[ii] );
}
+ if( isgraph( data[ii] ) )
+ ascii[(ii & 0x0f) + 1] = data[ii];
+ else
+ ascii[(ii & 0x0f) + 1] = '.';
}
+ ascii[ii] = 0;
if( p != line )
{
- hb_deep_log( level, " %s", line );
+ hb_deep_log( level, " %-50s%20s", line, ascii );
}
}