Package: nethogs Version: 0.7.0-3 Severity: normal Tags: patch User: ubuntu-de...@lists.ubuntu.com Usertags: origin-ubuntu oneiric ubuntu-patch
In Ubuntu, the attached patch was applied to achieve the following: * Apply patch from Shock to support dynamic terminal sizes (instead of a hard-coded 80). This patch has already been applied upstream. (LP: #627626) Thanks for considering the patch. -- System Information: Debian Release: wheezy/sid APT prefers oneiric-updates APT policy: (500, 'oneiric-updates'), (500, 'oneiric-security'), (500, 'oneiric-proposed'), (500, 'oneiric') Architecture: amd64 (x86_64) Kernel: Linux 3.0.0-7-generic (SMP w/4 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash
--- nethogs-0.7.0.orig/debian/patches/04_support_more_than_80_columns.diff +++ nethogs-0.7.0/debian/patches/04_support_more_than_80_columns.diff @@ -0,0 +1,148 @@ +Description: Fix assumption of hard-coded 80 columns in terminal +Forwarded: https://bugs.launchpad.net/ubuntu/+source/nethogs/+bug/627626/comments/2 +Applied-Upstream: https://bugs.launchpad.net/ubuntu/+source/nethogs/+bug/627626/comments/2 +Author: Shock +Reviewed-By: Daniel T Chen <crim...@ubuntu.com> +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/nethogs/+bug/627626 +Last-Update: 2011-07-29 + +diff -Nur -x '*.orig' -x '*~' nethogs-0.7.0//cui.cpp nethogs-0.7.0.new//cui.cpp +--- nethogs-0.7.0//cui.cpp 2009-03-12 17:28:14.000000000 -0400 ++++ nethogs-0.7.0.new//cui.cpp 2011-07-29 18:13:52.000000000 -0400 +@@ -46,7 +46,7 @@ + assert (m_pid >= 0); + } + +- void show (int row); ++ void show (int row, unsigned int proglen); + + double sent_value; + double recv_value; +@@ -74,7 +74,7 @@ + } + + +-void Line::show (int row) ++void Line::show (int row, unsigned int proglen) + { + assert (m_pid >= 0); + assert (m_pid <= 100000); +@@ -89,10 +89,10 @@ + char * username = uid2username(m_uid); + mvprintw (3+row, 6, "%s", username); + free (username); +- if (strlen (m_name) > PROGNAME_WIDTH) { ++ if (strlen (m_name) > proglen) { + // truncate oversized names + char * tmp = strdup(m_name); +- char * start = tmp + strlen (m_name) - PROGNAME_WIDTH; ++ char * start = tmp + strlen (m_name) - proglen; + start[0] = '.'; + start[1] = '.'; + mvprintw (3+row, 6 + 9, "%s", start); +@@ -100,24 +100,24 @@ + } else { + mvprintw (3+row, 6 + 9, "%s", m_name); + } +- mvprintw (3+row, 6 + 9 + PROGNAME_WIDTH + 2, "%s", devicename); +- mvprintw (3+row, 6 + 9 + PROGNAME_WIDTH + 2 + 6, "%10.3f", sent_value); +- mvprintw (3+row, 6 + 9 + PROGNAME_WIDTH + 2 + 6 + 9 + 3, "%10.3f", recv_value); ++ mvprintw (3+row, 6 + 9 + proglen + 2, "%s", devicename); ++ mvprintw (3+row, 6 + 9 + proglen + 2 + 6, "%10.3f", sent_value); ++ mvprintw (3+row, 6 + 9 + proglen + 2 + 6 + 9 + 3, "%10.3f", recv_value); + if (viewMode == VIEWMODE_KBPS) + { +- mvprintw (3+row, 6 + 9 + PROGNAME_WIDTH + 2 + 6 + 9 + 3 + 11, "KB/sec"); ++ mvprintw (3+row, 6 + 9 + proglen + 2 + 6 + 9 + 3 + 11, "KB/sec"); + } + else if (viewMode == VIEWMODE_TOTAL_MB) + { +- mvprintw (3+row, 6 + 9 + PROGNAME_WIDTH + 2 + 6 + 9 + 3 + 11, "MB "); ++ mvprintw (3+row, 6 + 9 + proglen + 2 + 6 + 9 + 3 + 11, "MB "); + } + else if (viewMode == VIEWMODE_TOTAL_KB) + { +- mvprintw (3+row, 6 + 9 + PROGNAME_WIDTH + 2 + 6 + 9 + 3 + 11, "KB "); ++ mvprintw (3+row, 6 + 9 + proglen + 2 + 6 + 9 + 3 + 11, "KB "); + } + else if (viewMode == VIEWMODE_TOTAL_B) + { +- mvprintw (3+row, 6 + 9 + PROGNAME_WIDTH + 2 + 6 + 9 + 3 + 11, "B "); ++ mvprintw (3+row, 6 + 9 + proglen + 2 + 6 + 9 + 3 + 11, "B "); + } + } + +@@ -302,6 +302,21 @@ + // Display all processes and relevant network traffic using show function + void do_refresh() + { ++ int row; // number of terminal rows ++ int col; // number of terminal columns ++ unsigned int proglen; // max length of the "PROGRAM" column ++ ++ getmaxyx(stdscr, row, col); /* find the boundaries of the screeen */ ++ if (col < 60) { ++ clear(); ++ mvprintw(0,0, "The terminal is too narrow! Please make it wider.\nI'll wait..."); ++ return; ++ } ++ ++ if (col > PROGNAME_WIDTH) col = PROGNAME_WIDTH; ++ ++ proglen = col - 53; ++ + refreshconninode(); + if (DEBUG || tracemode) + { +@@ -312,7 +327,7 @@ + clear(); + mvprintw (0, 0, "%s", caption->c_str()); + attron(A_REVERSE); +- mvprintw (2, 0, " PID USER PROGRAM DEV SENT RECEIVED "); ++ mvprintw (2, 0, " PID USER %-*.*s DEV SENT RECEIVED ", proglen, proglen, "PROGRAM"); + attroff(A_REVERSE); + } + ProcList * curproc = processes; +@@ -424,7 +439,7 @@ + /* print them */ + for (i=0; i<nproc; i++) + { +- lines[i]->show(i); ++ lines[i]->show(i, proglen); + recv_global += lines[i]->recv_value; + sent_global += lines[i]->sent_value; + delete lines[i]; +@@ -442,16 +457,16 @@ + + if ((!tracemode) && (!DEBUG)){ + attron(A_REVERSE); +- mvprintw (3+1+i, 0, " TOTAL %10.3f %10.3f ", sent_global, recv_global); ++ mvprintw (3+1+i, 0, " TOTAL %-*.*s %10.3f %10.3f ", proglen, proglen, " ", sent_global, recv_global); + if (viewMode == VIEWMODE_KBPS) + { +- mvprintw (3+1+i, 73, "KB/sec "); ++ mvprintw (3+1+i, col - 7, "KB/sec "); + } else if (viewMode == VIEWMODE_TOTAL_B) { +- mvprintw (3+1+i, 73, "B "); ++ mvprintw (3+1+i, col - 7, "B "); + } else if (viewMode == VIEWMODE_TOTAL_KB) { +- mvprintw (3+1+i, 73, "KB "); ++ mvprintw (3+1+i, col - 7, "KB "); + } else if (viewMode == VIEWMODE_TOTAL_MB) { +- mvprintw (3+1+i, 73, "MB "); ++ mvprintw (3+1+i, col - 7, "MB "); + } + attroff(A_REVERSE); + mvprintw (4+1+i, 0, ""); +diff -Nur -x '*.orig' -x '*~' nethogs-0.7.0//nethogs.h nethogs-0.7.0.new//nethogs.h +--- nethogs-0.7.0//nethogs.h 2009-03-12 17:28:14.000000000 -0400 ++++ nethogs-0.7.0.new//nethogs.h 2011-07-29 18:13:52.000000000 -0400 +@@ -39,7 +39,7 @@ + // -> 2*45+1=91. we make it 92, for the null. + #define HASHKEYSIZE 92 + +-#define PROGNAME_WIDTH 27 ++#define PROGNAME_WIDTH 512 + + void forceExit(const char *msg, ...); +