From 4e76adb0e1aed7b8a094d26adcef793b51ce252b Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 22 Nov 2012 14:26:41 +0100 Subject: lib/ttyutils: create .c file Well, now all tty stuff are incline functions in include/ttyutils.h. It's seems more elegant to create regular lib/ttyutils.c for libcommon and write test program. Signed-off-by: Karel Zak --- include/ttyutils.h | 35 +++-------------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) (limited to 'include/ttyutils.h') diff --git a/include/ttyutils.h b/include/ttyutils.h index 3c40d72a4..0bcae1493 100644 --- a/include/ttyutils.h +++ b/include/ttyutils.h @@ -8,6 +8,9 @@ #include #endif +extern int get_terminal_width(void); + + #define UL_TTY_KEEPCFLAGS (1 << 1) #define UL_TTY_UTF8 (1 << 2) @@ -79,38 +82,6 @@ static inline void reset_virtual_console(struct termios *tp, int flags) tp->c_cc[VEOL2] = _POSIX_VDISABLE; } -static inline int get_terminal_width(void) -{ -#ifdef TIOCGSIZE - struct ttysize t_win; -#endif -#ifdef TIOCGWINSZ - struct winsize w_win; -#endif - const char *cp; - -#ifdef TIOCGSIZE - if (ioctl (0, TIOCGSIZE, &t_win) == 0) - return t_win.ts_cols; -#endif -#ifdef TIOCGWINSZ - if (ioctl (0, TIOCGWINSZ, &w_win) == 0) - return w_win.ws_col; -#endif - cp = getenv("COLUMNS"); - if (cp) { - char *end = NULL; - long c; - - errno = 0; - c = strtol(cp, &end, 10); - - if (errno == 0 && end && *end == '\0' && end > cp && - c > 0 && c <= INT_MAX) - return c; - } - return 0; -} #endif /* UTIL_LINUX_TTYUTILS_H */ -- cgit v1.2.3-55-g7522