diff --git a/client/main.c b/client/main.c index a6217e033..50aa3e7a6 100644 --- a/client/main.c +++ b/client/main.c @@ -221,33 +221,6 @@ done: address, name); } -static void print_uuid(const char *label, const char *uuid) -{ - const char *text; - - text = bt_uuidstr_to_str(uuid); - if (text) { - char str[26]; - unsigned int n; - - str[sizeof(str) - 1] = '\0'; - - n = snprintf(str, sizeof(str), "%s", text); - if (n > sizeof(str) - 1) { - str[sizeof(str) - 2] = '.'; - str[sizeof(str) - 3] = '.'; - if (str[sizeof(str) - 4] == ' ') - str[sizeof(str) - 4] = '.'; - - n = sizeof(str) - 1; - } - - bt_shell_printf("\t%s: %s%*c(%s)\n", label, str, 26 - n, ' ', - uuid); - } else - bt_shell_printf("\t%s: %*c(%s)\n", label, 26, ' ', uuid); -} - static void print_uuids(GDBusProxy *proxy) { DBusMessageIter iter, value; @@ -262,7 +235,7 @@ static void print_uuids(GDBusProxy *proxy) dbus_message_iter_get_basic(&value, &uuid); - print_uuid("UUID", uuid); + print_uuid("\t", "UUID", uuid); dbus_message_iter_next(&value); } @@ -283,7 +256,7 @@ static void print_experimental(GDBusProxy *proxy) dbus_message_iter_get_basic(&value, &uuid); - print_uuid("ExperimentalFeatures", uuid); + print_uuid("\t", "ExperimentalFeatures", uuid); dbus_message_iter_next(&value); } @@ -1376,7 +1349,7 @@ static void cmd_scan_filter_uuids(int argc, char *argv[]) char **uuid; for (uuid = filter.uuids; uuid && *uuid; uuid++) - print_uuid("UUID", *uuid); + print_uuid("\t", "UUID", *uuid); return bt_shell_noninteractive_quit(EXIT_SUCCESS); } diff --git a/client/print.c b/client/print.c index 8d721e21d..39f8567ee 100644 --- a/client/print.c +++ b/client/print.c @@ -116,6 +116,12 @@ void print_iter(const char *label, const char *name, DBusMessageIter *iter) bt_shell_printf("%s%s is invalid\n", label, name); break; case DBUS_TYPE_STRING: + if (!strcasecmp(name, "UUID")) { + dbus_message_iter_get_basic(iter, &valstr); + print_uuid(label, name, valstr); + break; + } + /* fall through */ case DBUS_TYPE_OBJECT_PATH: dbus_message_iter_get_basic(iter, &valstr); bt_shell_printf("%s%s: %s\n", label, name, valstr); @@ -203,3 +209,30 @@ void print_property(GDBusProxy *proxy, const char *name) { print_property_with_label(proxy, name, NULL); } + +void print_uuid(const char *label, const char *name, const char *uuid) +{ + const char *text; + + text = bt_uuidstr_to_str(uuid); + if (text) { + char str[26]; + unsigned int n; + + str[sizeof(str) - 1] = '\0'; + + n = snprintf(str, sizeof(str), "%s", text); + if (n > sizeof(str) - 1) { + str[sizeof(str) - 2] = '.'; + str[sizeof(str) - 3] = '.'; + if (str[sizeof(str) - 4] == ' ') + str[sizeof(str) - 4] = '.'; + + n = sizeof(str) - 1; + } + + bt_shell_printf("%s%s: %s%*c(%s)\n", label, name, str, 26 - n, + ' ', uuid); + } else + bt_shell_printf("%s%s: %*c(%s)\n", label, name, 26, ' ', uuid); +} diff --git a/client/print.h b/client/print.h index c0866d06c..56bcce16a 100644 --- a/client/print.h +++ b/client/print.h @@ -12,3 +12,4 @@ void print_property(GDBusProxy *proxy, const char *name); void print_property_with_label(GDBusProxy *proxy, const char *name, const char *label); void print_iter(const char *label, const char *name, DBusMessageIter *iter); +void print_uuid(const char *label, const char *name, const char *uuid);