mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-22 04:32:37 +01:00
client: update station to use display_table_row
This includes updating diagnostics too, otherwise the output becomes really nasty.
This commit is contained in:
parent
e1d485029b
commit
35dd2c0821
@ -69,12 +69,13 @@ static bool display_bitrate_100kbps(struct l_dbus_message_iter *variant,
|
||||
int name_column_width, int value_column_width)
|
||||
{
|
||||
uint32_t rate;
|
||||
char str[50];
|
||||
|
||||
if (!l_dbus_message_iter_get_variant(variant, "u", &rate))
|
||||
return false;
|
||||
|
||||
display("%s%-*s%-*u Kbit/s\n", margin, name_column_width, key,
|
||||
value_column_width, rate * 100);
|
||||
sprintf(str, "%u Kbit/s", rate * 100);
|
||||
display_table_row(margin, 3, 8, "", name_column_width, key, value_column_width, str);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -110,6 +111,7 @@ void diagnostic_display(struct l_dbus_message_iter *dict,
|
||||
uint32_t u_value;
|
||||
int16_t n_value;
|
||||
uint8_t y_value;
|
||||
int bytes;
|
||||
|
||||
map = find_mapping(key, diagnostic_mapping);
|
||||
if (!map)
|
||||
@ -132,9 +134,7 @@ void diagnostic_display(struct l_dbus_message_iter *dict,
|
||||
&s_value))
|
||||
goto parse_error;
|
||||
|
||||
sprintf(display_text, "%s%-*s%-*s", margin,
|
||||
name_column_width, key,
|
||||
value_column_width, s_value);
|
||||
bytes = sprintf(display_text, "%s", s_value);
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
@ -142,9 +142,7 @@ void diagnostic_display(struct l_dbus_message_iter *dict,
|
||||
&u_value))
|
||||
goto parse_error;
|
||||
|
||||
sprintf(display_text, "%s%-*s%-*u", margin,
|
||||
name_column_width, key,
|
||||
value_column_width, u_value);
|
||||
bytes = sprintf(display_text, "%u", u_value);
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
@ -152,9 +150,7 @@ void diagnostic_display(struct l_dbus_message_iter *dict,
|
||||
&n_value))
|
||||
goto parse_error;
|
||||
|
||||
sprintf(display_text, "%s%-*s%-*i", margin,
|
||||
name_column_width, key,
|
||||
value_column_width, n_value);
|
||||
bytes = sprintf(display_text, "%i", n_value);
|
||||
break;
|
||||
|
||||
case 'y':
|
||||
@ -162,21 +158,19 @@ void diagnostic_display(struct l_dbus_message_iter *dict,
|
||||
&y_value))
|
||||
goto parse_error;
|
||||
|
||||
sprintf(display_text, "%s%-*s%-*u", margin,
|
||||
name_column_width, key,
|
||||
value_column_width, y_value);
|
||||
bytes = sprintf(display_text, "%u", y_value);
|
||||
break;
|
||||
|
||||
default:
|
||||
display("type %c not handled", map->type);
|
||||
display("type %c not handled\n", map->type);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (map->units)
|
||||
display("%s %s\n", display_text,
|
||||
(const char *)map->units);
|
||||
else
|
||||
display("%s\n", display_text);
|
||||
sprintf(display_text + bytes, " %s", map->units);
|
||||
|
||||
display_table_row(margin, 3, 8, "", name_column_width,
|
||||
key, value_column_width, display_text);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -186,8 +186,7 @@ static void display_addresses(const char *device_name)
|
||||
continue;
|
||||
|
||||
have_address = true;
|
||||
display("%s%*s %-*s%-*s\n", MARGIN, 8, "", 20,
|
||||
"IPv4 address", 47, addrstr);
|
||||
display_table_row(MARGIN, 3, 8, "", 20, "IPv4 address", 47, addrstr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,8 +199,7 @@ static void display_addresses(const char *device_name)
|
||||
if (r < 0 || r == 1)
|
||||
return;
|
||||
|
||||
display("%s%*s %-*s%-*s\n", MARGIN, 8, "", 20,
|
||||
"No IP addresses", 47, "Is DHCP client configured?");
|
||||
display_table_row(MARGIN, 3, 8, "", 20, "No IP addresses", 47, "Is DHCP client configured?");
|
||||
}
|
||||
|
||||
|
||||
@ -215,9 +213,9 @@ static void display_station(const char *device_name,
|
||||
l_free(caption);
|
||||
|
||||
if (station->connected_network) {
|
||||
display("%s%*s %-*s%-*s\n", MARGIN, 8, "", 20,
|
||||
"Connected network", 47,
|
||||
network_get_name(station->connected_network));
|
||||
display_table_row(MARGIN, 3, 8, "", 20, "Connected network",
|
||||
47, network_get_name(station->connected_network));
|
||||
|
||||
display_addresses(device_name);
|
||||
|
||||
/*
|
||||
@ -246,10 +244,8 @@ static void display_station_inline(const char *margin, const void *data)
|
||||
if (!identity)
|
||||
return;
|
||||
|
||||
display("%s%-*s%-*s%-*s\n", margin,
|
||||
20, identity,
|
||||
15, station->state ? : "",
|
||||
8, station->scanning ? "scanning" : "");
|
||||
display_table_row(margin, 3, 20, identity, 15, station->state ? : "",
|
||||
8, station->scanning ? "scanning" : "");
|
||||
}
|
||||
|
||||
static enum cmd_status cmd_list(const char *device_name, char **argv, int argc)
|
||||
@ -258,7 +254,8 @@ static enum cmd_status cmd_list(const char *device_name, char **argv, int argc)
|
||||
struct l_queue *match =
|
||||
proxy_interface_find_all(IWD_STATION_INTERFACE, NULL, NULL);
|
||||
|
||||
display_table_header("Devices in Station Mode", MARGIN "%-*s%-*s%-*s",
|
||||
display_table_header("Devices in Station Mode",
|
||||
MARGIN "%-*s %-*s %-*s",
|
||||
20, "Name", 15, "State", 8, "Scanning");
|
||||
|
||||
if (!match) {
|
||||
@ -416,7 +413,7 @@ static void ordered_networks_display(struct l_queue *ordered_networks)
|
||||
char *dbms = NULL;
|
||||
const struct l_queue_entry *entry;
|
||||
|
||||
display_table_header("Available networks", "%s%-*s%-*s%-*s%*s",
|
||||
display_table_header("Available networks", "%s%-*s %-*s %-*s %*s",
|
||||
MARGIN, 2, "", 32, "Network name",
|
||||
18, "Security", 6, "Signal");
|
||||
|
||||
@ -441,11 +438,11 @@ static void ordered_networks_display(struct l_queue *ordered_networks)
|
||||
if (display_signal_as_dbms)
|
||||
dbms = l_strdup_printf("%d", network->signal_strength);
|
||||
|
||||
display("%s%-*s%-*s%-*s%-*s\n", MARGIN, 2,
|
||||
network_is_connected(network_i) ?
|
||||
COLOR_BOLDGRAY "> " COLOR_OFF : "",
|
||||
32, network_name, 18, network_type,
|
||||
6, display_signal_as_dbms ? dbms :
|
||||
display_table_row(MARGIN, 4, 2,
|
||||
network_is_connected(network_i) ?
|
||||
COLOR_BOLDGRAY "> " COLOR_OFF: "",
|
||||
32, network_name, 18, network_type, 6,
|
||||
display_signal_as_dbms ? dbms :
|
||||
dbms_tostars(network->signal_strength));
|
||||
|
||||
if (display_signal_as_dbms) {
|
||||
@ -556,7 +553,7 @@ static void hidden_access_points_display(struct l_queue *access_points)
|
||||
{
|
||||
const struct l_queue_entry *entry;
|
||||
|
||||
display_table_header("Available hidden APs", MARGIN "%-*s%-*s%*s",
|
||||
display_table_header("Available hidden APs", MARGIN "%-*s %-*s %*s",
|
||||
20, "Address", 10, "Security", 6, "Signal");
|
||||
|
||||
if (l_queue_isempty(access_points)) {
|
||||
@ -574,9 +571,8 @@ static void hidden_access_points_display(struct l_queue *access_points)
|
||||
if (display_signal_as_dbms)
|
||||
dbms = l_strdup_printf("%d", ap->signal_strength);
|
||||
|
||||
display(MARGIN "%-*s%-*s%-*s\n",
|
||||
20, ap->address, 10, ap->type,
|
||||
6, dbms ? : dbms_tostars(ap->signal_strength));
|
||||
display_table_row(MARGIN, 3, 20, ap->address, 10, ap->type, 6,
|
||||
dbms ? : dbms_tostars(ap->signal_strength));
|
||||
}
|
||||
|
||||
display_table_footer();
|
||||
@ -676,7 +672,7 @@ static void get_diagnostics_callback(struct l_dbus_message *message,
|
||||
goto done;
|
||||
}
|
||||
|
||||
diagnostic_display(&iter, " ", 20, 20);
|
||||
diagnostic_display(&iter, MARGIN, 20, 47);
|
||||
|
||||
done:
|
||||
/* Finish the table started by cmd_show */
|
||||
|
Loading…
Reference in New Issue
Block a user