added optional formatting to csp_hex_dump
@@ -22,8 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include <stdio.h>
-void csp_hex_dump(const char *desc, void *addr, int len)
-{
+void csp_hex_dump_format(const char *desc, void *addr, int len, int format) {
int i;
unsigned char buff[17];
unsigned char *pc = (unsigned char*)addr;
@@ -45,7 +44,11 @@ void csp_hex_dump(const char *desc, void *addr, int len)
printf (" %s\n", buff);
// Output the offset.
+ if (format & 0x1) {
printf(" %p ", ((uint8_t*)addr) + i);
+ } else {
+ printf(" ");
+ }
}
// Now the hex code for the specific character.
@@ -68,3 +71,7 @@ void csp_hex_dump(const char *desc, void *addr, int len)
// And print the final ASCII bit.
printf (" %s\n", buff);
}
+
+void csp_hex_dump(const char *desc, void *addr, int len) {
+ csp_hex_dump_format(desc, addr, len, 0);
+}
