diff --git a/src/shared/shell.c b/src/shared/shell.c
index f724c98..69f303b 100644
--- a/src/shared/shell.c
+++ b/src/shared/shell.c
}
}
-void bt_shell_hexdump(const unsigned char *buf, size_t len)
+static void print_string(const char *str, void *user_data)
{
- static const char hexdigits[] = "0123456789abcdef";
- char str[68];
- size_t i;
-
- if (!len)
- return;
-
- str[0] = ' ';
-
- for (i = 0; i < len; i++) {
- str[((i % 16) * 3) + 1] = ' ';
- str[((i % 16) * 3) + 2] = hexdigits[buf[i] >> 4];
- str[((i % 16) * 3) + 3] = hexdigits[buf[i] & 0xf];
- str[(i % 16) + 51] = isprint(buf[i]) ? buf[i] : '.';
-
- if ((i + 1) % 16 == 0) {
- str[49] = ' ';
- str[50] = ' ';
- str[67] = '\0';
- bt_shell_printf("%s\n", str);
- str[0] = ' ';
- }
- }
+ bt_shell_printf("%s\n", str);
+}
- if (i % 16 > 0) {
- size_t j;
- for (j = (i % 16); j < 16; j++) {
- str[(j * 3) + 1] = ' ';
- str[(j * 3) + 2] = ' ';
- str[(j * 3) + 3] = ' ';
- str[j + 51] = ' ';
- }
- str[49] = ' ';
- str[50] = ' ';
- str[67] = '\0';
- bt_shell_printf("%s\n", str);
- }
+void bt_shell_hexdump(const unsigned char *buf, size_t len)
+{
+ util_hexdump(' ', buf, len, print_string, NULL);
}
void bt_shell_prompt_input(const char *label, const char *msg,