Message ID | 20220629192709.38743-1-prestwoj@gmail.com (mailing list archive) |
---|---|
State | Accepted, archived |
Headers | show |
Series | [1/2] client: support multi-line print for long values | expand |
Context | Check | Description |
---|---|---|
tedd_an/pre-ci_am | success | Success |
prestwoj/iwd-alpine-ci-fetch | success | Fetch PR |
prestwoj/iwd-ci-gitlint | success | GitLint |
prestwoj/iwd-ci-fetch | success | Fetch PR |
prestwoj/iwd-ci-makedistcheck | success | Make Distcheck |
prestwoj/iwd-alpine-ci-makedistcheck | success | Make Distcheck |
prestwoj/iwd-ci-build | success | Build - Configure |
prestwoj/iwd-alpine-ci-build | success | Build - Configure |
prestwoj/iwd-ci-clang | success | clang PASS |
prestwoj/iwd-ci-makecheckvalgrind | success | Make Check w/Valgrind |
prestwoj/iwd-ci-makecheck | success | Make Check |
prestwoj/iwd-alpine-ci-makecheckvalgrind | success | Make Check w/Valgrind |
prestwoj/iwd-alpine-ci-makecheck | success | Make Check |
prestwoj/iwd-ci-incremental_build | success | Incremental Build with patches |
prestwoj/iwd-alpine-ci-incremental_build | success | Incremental Build with patches |
prestwoj/iwd-ci-testrunner | success | test-runner PASS |
Hi James, On 6/29/22 14:27, James Prestwood wrote: > The generic proxy property display was limited to a width for names/value > which makes the output look nice and uniform, but will cut off any values > which are longer than this limit. > > This patch adds some logic to detect this, and continue displaying the > value on the next line. > > The width arguments were also updated to be unsigned, which allows checking > the length without a cast. > --- > client/dbus-proxy.c | 21 +++++++++++++++++++-- > client/dbus-proxy.h | 3 ++- > 2 files changed, 21 insertions(+), 3 deletions(-) > Both applied, thanks. Regards, -Denis
diff --git a/client/dbus-proxy.c b/client/dbus-proxy.c index 624ce4aa..9f05c0e7 100644 --- a/client/dbus-proxy.c +++ b/client/dbus-proxy.c @@ -49,7 +49,8 @@ static struct l_queue *proxy_interface_types; void proxy_properties_display(const struct proxy_interface *proxy, const char *caption, const char *margin, - int name_column_width, int value_column_width) + unsigned int name_column_width, + unsigned int value_column_width) { const void *data; const struct proxy_interface_property *properties; @@ -67,14 +68,30 @@ void proxy_properties_display(const struct proxy_interface *proxy, properties = proxy->type->properties; for (i = 0; properties[i].name; i++) { + const char *str; + size_t len; + size_t j; + if (!properties[i].tostr) continue; + str = properties[i].tostr(data); + len = str ? strlen(str) : 0; + display("%s%*s %-*s%-.*s\n", margin, 8, properties[i].is_read_write ? COLOR_BOLDGRAY " *" COLOR_OFF : "", name_column_width, properties[i].name, - value_column_width, properties[i].tostr(data) ? : ""); + value_column_width, str ? : ""); + + if (len <= value_column_width) + continue; + + /* Display remaining data */ + for (j = value_column_width; j < len; j += value_column_width) + display("%s%*s %-*s%-.*s\n", margin, 8, "", + name_column_width, "", value_column_width, + str + j); } } diff --git a/client/dbus-proxy.h b/client/dbus-proxy.h index 1d6af5de..34917e82 100644 --- a/client/dbus-proxy.h +++ b/client/dbus-proxy.h @@ -89,7 +89,8 @@ bool proxy_interface_method_call(const struct proxy_interface *proxy, void proxy_properties_display(const struct proxy_interface *proxy, const char *caption, const char *margin, - int name_column_width, int value_column_width); + unsigned int name_column_width, + unsigned int value_column_width); char *proxy_property_str_completion(const struct proxy_interface_type *type, proxy_property_match_func_t function,