On Wed, Nov 28, 2012 at 11:17:38AM +0100, Nikola Pajkovsky wrote:
Vitezslav Samel <vitezslav(a)samel.cz> writes:
> There was garbage printed in "IP traffic monitor" when interface
> name was longer than 5 chars. Fix it by making more room for the name
> (shortening the flags field) and caping name length to room left
> on display (at least 7 and maximum IFNAMSIZ characters).
>
> Signed-off-by: Vitezslav Samel <vitezslav(a)samel.cz>
> ---
> src/tcptable.c | 47 ++++++++++++++++++-----------------------------
> src/tcptable.h | 1 +
> 2 files changed, 19 insertions(+), 29 deletions(-)
>
> diff --git a/src/tcptable.c b/src/tcptable.c
> index 3f492dd..956866c 100644
> --- a/src/tcptable.c
> +++ b/src/tcptable.c
> @@ -118,11 +118,16 @@ void init_tcp_table(struct tcptable *table)
> setlabels(table->borderwin, 0); /* initially use mode 0 */
>
> wmove(table->borderwin, 0, 65 * COLS / 80);
> - wprintw(table->borderwin, " Flags ");
> - wmove(table->borderwin, 0, 72 * COLS / 80);
> + wprintw(table->borderwin, " Flag ");
> + wmove(table->borderwin, 0, 70 * COLS / 80);
> wprintw(table->borderwin, " Iface ");
> update_panels();
> doupdate();
> + table->ifnamew = COLS - (70 * COLS / 80) - 3;
> + if (table->ifnamew < 7)
> + table->ifnamew = 7;
> + if (table->ifnamew > IFNAMSIZ)
> + table->ifnamew = IFNAMSIZ;
>
> table->head = table->tail = NULL;
> table->firstvisible = table->lastvisible = NULL;
> @@ -862,39 +867,23 @@ void printentry(struct tcptable *table, struct tcptableent
*tableentry,
> wattrset(table->tcpscreen, normalattr);
>
> if (tableentry->finsent == 1)
> - strcpy(stat, "DONE ");
> + strcpy(stat, "DONE");
> else if (tableentry->finsent == 2)
> - strcpy(stat, "CLOSED");
> + strcpy(stat, "CLOS");
> else if (tableentry->stat & FLAG_RST)
> - strcpy(stat, "RESET ");
> + strcpy(stat, "RSET");
just nitpicking, RST is for me more informative
I just wanted to make it 4-chars wide and don't have preference
to either version.
Vita