blob: ef0c2e4a8161938ea3911562b38a8b100931db47 [file] [log] [blame]
Václav Kubernát8cd61562021-12-08 13:27:31 +01001From 90271bd69a7488714a51173dcec3f349459761c9 Mon Sep 17 00:00:00 2001
Tomáš Peckaae301762021-10-13 10:50:37 +02002From: Tomas Pecka <peckato1@users.noreply.github.com>
3Date: Thu, 7 Oct 2021 14:16:53 +0200
4Subject: [PATCH 6/9] networkctl: lldp table now ellpsizes via table functions
5
6Tables can now ellipize on their own so there is no need to manually
7call ellpsize on the table data.
8
9To achieve compatibility with previous versions the table columns are
10set to have the exact same size as before, therefore the minimum and
11maximum widths for the columns in the output.
12---
13 src/network/networkctl.c | 32 +++++++-------------------------
14 1 file changed, 7 insertions(+), 25 deletions(-)
15
16diff --git a/src/network/networkctl.c b/src/network/networkctl.c
Václav Kubernát8cd61562021-12-08 13:27:31 +010017index 30cd75eec0..46c08b5549 100644
Tomáš Peckaae301762021-10-13 10:50:37 +020018--- a/src/network/networkctl.c
19+++ b/src/network/networkctl.c
Václav Kubernát8cd61562021-12-08 13:27:31 +010020@@ -2513,21 +2513,27 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
Tomáš Peckaae301762021-10-13 10:50:37 +020021
22 assert_se(cell = table_get_cell(table, 0, 0));
23 table_set_minimum_width(table, cell, 16);
24+ table_set_maximum_width(table, cell, 16);
25
26 assert_se(cell = table_get_cell(table, 0, 1));
27 table_set_minimum_width(table, cell, 17);
28+ table_set_maximum_width(table, cell, 17);
29
30 assert_se(cell = table_get_cell(table, 0, 2));
31 table_set_minimum_width(table, cell, 16);
32+ table_set_maximum_width(table, cell, 16);
33
34 assert_se(cell = table_get_cell(table, 0, 3));
35 table_set_minimum_width(table, cell, 11);
36+ table_set_maximum_width(table, cell, 11);
37
38 assert_se(cell = table_get_cell(table, 0, 4));
39 table_set_minimum_width(table, cell, 17);
40+ table_set_maximum_width(table, cell, 17);
41
42 assert_se(cell = table_get_cell(table, 0, 5));
43 table_set_minimum_width(table, cell, 16);
44+ table_set_maximum_width(table, cell, 16);
45
46 if (table_set_empty_string(table, "n/a") < 0)
47 return log_oom();
Václav Kubernát8cd61562021-12-08 13:27:31 +010048@@ -2544,7 +2550,7 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
Tomáš Peckaae301762021-10-13 10:50:37 +020049 }
50
51 for (;;) {
52- _cleanup_free_ char *cid = NULL, *pid = NULL, *sname = NULL, *pdesc = NULL, *capabilities = NULL;
53+ _cleanup_free_ char *capabilities = NULL;
54 const char *chassis_id = NULL, *port_id = NULL, *system_name = NULL, *port_description = NULL;
55 _cleanup_(sd_lldp_neighbor_unrefp) sd_lldp_neighbor *n = NULL;
56 uint16_t cc;
Václav Kubernát8cd61562021-12-08 13:27:31 +010057@@ -2562,30 +2568,6 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
Tomáš Peckaae301762021-10-13 10:50:37 +020058 (void) sd_lldp_neighbor_get_system_name(n, &system_name);
59 (void) sd_lldp_neighbor_get_port_description(n, &port_description);
60
61- if (chassis_id) {
62- cid = ellipsize(chassis_id, 17, 100);
63- if (cid)
64- chassis_id = cid;
65- }
66-
67- if (port_id) {
68- pid = ellipsize(port_id, 17, 100);
69- if (pid)
70- port_id = pid;
71- }
72-
73- if (system_name) {
74- sname = ellipsize(system_name, 16, 100);
75- if (sname)
76- system_name = sname;
77- }
78-
79- if (port_description) {
80- pdesc = ellipsize(port_description, 16, 100);
81- if (pdesc)
82- port_description = pdesc;
83- }
84-
85 if (sd_lldp_neighbor_get_enabled_capabilities(n, &cc) >= 0) {
86 capabilities = lldp_capabilities_to_string(cc);
87 all |= cc;
88--
Václav Kubernát8cd61562021-12-08 13:27:31 +0100892.34.1
Tomáš Peckaae301762021-10-13 10:50:37 +020090