summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2011-09-27 00:48:35 +0000
committerjstebbins <[email protected]>2011-09-27 00:48:35 +0000
commit57f74136121d09a3583e5ed9c838dfab29ab8548 (patch)
treedb28a5c8b21a2d1fa3a1be1ffa2f354a36f531d7
parent6f78c9f7853dc7c31c0e42e5feee0526f7a4dff1 (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
-rw-r--r--libhb/common.c33
-rw-r--r--libhb/internal.h1
2 files changed, 34 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 );
+ }
+}
+
diff --git a/libhb/internal.h b/libhb/internal.h
index 77ead967c..63220f5cb 100644
--- a/libhb/internal.h
+++ b/libhb/internal.h
@@ -18,6 +18,7 @@ typedef enum hb_debug_level_s
void hb_valog( hb_debug_level_t level, const char * prefix, const char * log, va_list args) HB_WPRINTF(3,0);
void hb_deep_log( hb_debug_level_t level, char * log, ... ) HB_WPRINTF(2,3);
void hb_error( char * fmt, ...) HB_WPRINTF(1,2);
+void hb_hexdump( hb_debug_level_t level, const char * label, const uint8_t * data, int len );
int hb_list_bytes( hb_list_t * );
void hb_list_seebytes( hb_list_t * l, uint8_t * dst, int size );