summaryrefslogtreecommitdiffstats
path: root/mbbsd/term.c
diff options
context:
space:
mode:
authorscw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-06-29 22:17:59 +0800
committerscw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-06-29 22:17:59 +0800
commitc0a22dee78c1470d62d658e1b2beacb84ffb5cc5 (patch)
tree463fbd38518dffa479767dfc59a8cc69225da29e /mbbsd/term.c
parent3cbefc4792908b0b0f7433f6565958032e01b241 (diff)
downloadpttbbs-c0a22dee78c1470d62d658e1b2beacb84ffb5cc5.tar
pttbbs-c0a22dee78c1470d62d658e1b2beacb84ffb5cc5.tar.gz
pttbbs-c0a22dee78c1470d62d658e1b2beacb84ffb5cc5.tar.bz2
pttbbs-c0a22dee78c1470d62d658e1b2beacb84ffb5cc5.tar.lz
pttbbs-c0a22dee78c1470d62d658e1b2beacb84ffb5cc5.tar.xz
pttbbs-c0a22dee78c1470d62d658e1b2beacb84ffb5cc5.tar.zst
pttbbs-c0a22dee78c1470d62d658e1b2beacb84ffb5cc5.zip
Reverting revision 2098 and 2100. These make kernel panic due to out of swap.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2101 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/term.c')
-rw-r--r--mbbsd/term.c57
1 files changed, 17 insertions, 40 deletions
diff --git a/mbbsd/term.c b/mbbsd/term.c
index 3d9fd793..555840d1 100644
--- a/mbbsd/term.c
+++ b/mbbsd/term.c
@@ -52,16 +52,22 @@ outcf(int ch)
}
#endif
-static inline void
-term_resize(int row, int col){
+static void
+term_resize(int sig)
+{
+ struct winsize newsize;
screenline_t *new_picture;
+ signal(SIGWINCH, SIG_IGN); /* Don't bother me! */
+ ioctl(0, TIOCGWINSZ, &newsize);
+
/* make sure reasonable size */
- row = MAX(24, MIN(100, row));
- col = MAX(80, MIN(200, col));
+ newsize.ws_row = MAX(24, MIN(100, newsize.ws_row));
+ newsize.ws_col = MAX(80, MIN(200, newsize.ws_col));
- if (big_picture != NULL && row > t_lines) {
- new_picture = (screenline_t *) calloc(row, sizeof(screenline_t));
+ if (newsize.ws_row > t_lines) {
+ new_picture = (screenline_t *) calloc(newsize.ws_row,
+ sizeof(screenline_t));
if (new_picture == NULL) {
syslog(LOG_ERR, "calloc(): %m");
return;
@@ -70,48 +76,19 @@ term_resize(int row, int col){
free(big_picture);
big_picture = new_picture;
}
- t_lines = row;
- t_columns = col;
+ t_lines = newsize.ws_row;
+ t_columns = newsize.ws_col;
+ scr_lns = t_lines; /* XXX: scr_lns 跟 t_lines 有什麼不同, 為何分成兩個 */
b_lines = t_lines - 1;
p_lines = t_lines - 4;
-}
-static void
-term_resize_catch(int sig)
-{
- struct winsize newsize;
-
- signal(SIGWINCH, SIG_IGN); /* Don't bother me! */
- ioctl(0, TIOCGWINSZ, &newsize);
-
- term_resize(newsize.ws_row, newsize.ws_col);
-
- signal(SIGWINCH, term_resize_catch);
+ signal(SIGWINCH, term_resize);
}
-#ifndef SKIP_TELNET_CONTROL_SIGNAL
-void
-telnet_parse_size(const unsigned char* msg){
- /* msg[0] == IAC, msg[1] == SB, msg[2] = TELOPT_NAWS */
- int i = 4, row, col;
-
- col = msg[3] << 8;
- if(msg[i] == 0xff)
- ++i; /* avoid escaped 0xff */
- col |= msg[i++];
-
- row = msg[i++] << 8;
- if(msg[i] == 0xff)
- ++i;
- row |= msg[i];
- term_resize(row, col);
-}
-#endif
-
int
term_init()
{
- signal(SIGWINCH, term_resize_catch);
+ signal(SIGWINCH, term_resize);
return YEA;
}