diff options
author | David Ahern <dsahern@gmail.com> | 2013-01-14 10:48:01 -0700 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-01-24 16:40:34 -0300 |
commit | 2c803e5248d038988ec7c52e8fd7c83130dd3c13 (patch) | |
tree | 7be870a45610585b34258b6a5da0551f5613e301 /tools/perf/util/util.c | |
parent | b7c14a0b6a4e3add92e1527a31cb1826f4799248 (diff) | |
download | linux-2c803e5248d038988ec7c52e8fd7c83130dd3c13.tar.gz linux-2c803e5248d038988ec7c52e8fd7c83130dd3c13.tar.bz2 linux-2c803e5248d038988ec7c52e8fd7c83130dd3c13.zip |
perf tools: Move get_term_dimensions from top to util.c
It is used by util/help.c so it should be a lib function and included in
libperf.a. Code move only.
Signed-off-by: David Ahern <dsahern@gmail.com>
Link: http://lkml.kernel.org/r/1358185681-90926-1-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/util.c')
-rw-r--r-- | tools/perf/util/util.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 252b889ac8c2..805d1f52c5b4 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -220,3 +220,25 @@ void dump_stack(void) #else void dump_stack(void) {} #endif + +void get_term_dimensions(struct winsize *ws) +{ + char *s = getenv("LINES"); + + if (s != NULL) { + ws->ws_row = atoi(s); + s = getenv("COLUMNS"); + if (s != NULL) { + ws->ws_col = atoi(s); + if (ws->ws_row && ws->ws_col) + return; + } + } +#ifdef TIOCGWINSZ + if (ioctl(1, TIOCGWINSZ, ws) == 0 && + ws->ws_row && ws->ws_col) + return; +#endif + ws->ws_row = 25; + ws->ws_col = 80; +} |