From 01cb925740f158ccd6ce7f48302080867a09a0ac Mon Sep 17 00:00:00 2001 From: piaip Date: Fri, 18 Jan 2008 16:02:22 +0000 Subject: - improve input system logic git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3842 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/io.c | 14 ++++++++++++++ mbbsd/telnet.c | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/mbbsd/io.c b/mbbsd/io.c index 71b153c1..3d6a36c5 100644 --- a/mbbsd/io.c +++ b/mbbsd/io.c @@ -165,6 +165,8 @@ add_io(int fd, int timeout) int num_in_buf(void) { + if (ibufsize <= icurrchar) + return 0; return ibufsize - icurrchar; } @@ -267,6 +269,15 @@ dogetch(void) currutmp->lastact = now; lastact = now; } + + // CR LF are treated as one. + if (inbuf[icurrchar] == Ctrl('M')) + { + if (++icurrchar < ibufsize && + inbuf[icurrchar] == Ctrl('J')) + icurrchar ++; + return Ctrl('M'); + } return (unsigned char)inbuf[icurrchar++]; } @@ -626,6 +637,8 @@ igetch(void) } return ch; + // try to do this in getch() level. +#if 0 case Ctrl('J'): /* Ptt §â \n ®³±¼ */ #ifdef PLAY_ANGEL /* Seams some telnet client still send CR LF when changing lines. @@ -633,6 +646,7 @@ igetch(void) */ #endif continue; +#endif default: return ch; diff --git a/mbbsd/telnet.c b/mbbsd/telnet.c index 4f4bba0b..332b3f3a 100644 --- a/mbbsd/telnet.c +++ b/mbbsd/telnet.c @@ -164,7 +164,9 @@ telnet_handler(unsigned char c) iac_state = IAC_NONE; /* by default we restore state. */ switch(c) { case IAC: - return 0; + // return 0; + // we don't want to allow IACs as input. + return 1; /* we don't want to process these. or maybe in future. */ case BREAK: /* break */ -- cgit v1.2.3