From bedc03e69281508ffdb374085225b5ea516c4b13 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 24 Jun 2013 23:04:44 +0200 Subject: ifpps, flowtop: Move ncurses init and end to common module ncurses (de-)initialization is duplicated across flowtop and ifpps, so move it to an own module and use it from both tools. Signed-off-by: Tobias Klauser --- ifpps.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) (limited to 'ifpps.c') diff --git a/ifpps.c b/ifpps.c index e5988e6..0ae77cb 100644 --- a/ifpps.c +++ b/ifpps.c @@ -28,6 +28,7 @@ #include "promisc.h" #include "cpus.h" #include "built_in.h" +#include "screen.h" struct wifi_stat { uint32_t bitrate; @@ -635,21 +636,6 @@ static void stats_top(const struct ifstat *rel, const struct ifstat *abs, } } -static void screen_init(WINDOW **screen) -{ - (*screen) = initscr(); - - raw(); - noecho(); - cbreak(); - nodelay((*screen), TRUE); - - keypad(stdscr, TRUE); - - refresh(); - wrefresh((*screen)); -} - static void screen_header(WINDOW *screen, const char *ifname, int *voff, uint64_t ms_interval, unsigned int top_cpus) { @@ -931,17 +917,12 @@ static void screen_update(WINDOW *screen, const char *ifname, const struct ifsta refresh(); } -static void screen_end(void) -{ - endwin(); -} - static int screen_main(const char *ifname, uint64_t ms_interval, unsigned int top_cpus) { int first = 1, key; - screen_init(&stats_screen); + stats_screen = screen_init(true); while (!sigint) { key = getch(); -- cgit v1.2.3-54-g00ecf