/* * change kernel terminal size. */ static void change_term_size (int fd, int x, int y) { #ifdef TIOCGSIZE struct ttysize win; #elif defined(TIOCGWINSZ) struct winsize win; #endif #ifdef TIOCGSIZE if (ioctl (fd, TIOCGSIZE, &win)) return; if (y && y>24) win.ts_lines = y; else win.ts_lines = 24; if (x && x>80) win.ts_cols = x; else win.ts_cols = 80; ioctl (fd, TIOCSSIZE, &win); #elif defined TIOCGWINSZ if (ioctl (fd, TIOCGWINSZ, &win)) return; if (y && y >24) win.ws_row = y; else win.ws_row = 24; if (x && x>80) win.ws_col = x; else win.ws_col = 80; ioctl (fd, TIOCSWINSZ, &win); #endif } /* * inquire actual terminal size (this it what the * kernel thinks - not was the user on the over end * of the phone line has really). */ static int get_term_size (int fd, int *x, int *y) { #ifdef TIOCGSIZE struct ttysize win; #elif defined(TIOCGWINSZ) struct winsize win; #endif #ifdef TIOCGSIZE if (ioctl (fd, TIOCGSIZE, &win)) return 0; if (y) *y=win.ts_lines; if (x) *x=win.ts_cols; #elif defined TIOCGWINSZ if (ioctl (fd, TIOCGWINSZ, &win)) return 0; if (y) *y=win.ws_row; if (x) *x=win.ws_col; #else { const char *s; s=getenv("LINES"); if (s) *y=strtol(s,NULL,10); else *y=25; s=getenv("COLUMNS"); if (s) *x=strtol(s,NULL,10); else *x=80; } #endif return 1; }