diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-09-29 01:59:20 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-09-29 01:59:20 +0800 |
commit | c78d877d45496115e90c3584b063fd2bc72303b9 (patch) | |
tree | 2e855c83f3d3e4b3637644d0a60a2431e071b17e /mbbsd/io.c | |
parent | c0dd6835cc9f376ad6f195bad2daacff12b5efd9 (diff) | |
download | pttbbs-c78d877d45496115e90c3584b063fd2bc72303b9.tar pttbbs-c78d877d45496115e90c3584b063fd2bc72303b9.tar.gz pttbbs-c78d877d45496115e90c3584b063fd2bc72303b9.tar.bz2 pttbbs-c78d877d45496115e90c3584b063fd2bc72303b9.tar.lz pttbbs-c78d877d45496115e90c3584b063fd2bc72303b9.tar.xz pttbbs-c78d877d45496115e90c3584b063fd2bc72303b9.tar.zst pttbbs-c78d877d45496115e90c3584b063fd2bc72303b9.zip |
* refine kbd stack and move to common/bbs
* rename visio to vtuikit
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4888 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/io.c')
-rw-r--r-- | mbbsd/io.c | 61 |
1 files changed, 35 insertions, 26 deletions
@@ -158,7 +158,7 @@ static int i_newfd = 0; static struct timeval i_to, *i_top = NULL; static int (*flushf) () = NULL; -void +inline void add_io(int fd, int timeout) { i_newfd = fd; @@ -171,7 +171,7 @@ add_io(int fd, int timeout) i_top = NULL; } -int +inline int num_in_buf(void) { if (ibufsize <= icurrchar) @@ -179,12 +179,42 @@ num_in_buf(void) return ibufsize - icurrchar; } -int +inline int input_isfull(void) { return ibufsize >= IBUFSIZE; } +inline static ssize_t +wrapped_tty_read(unsigned char *buf, size_t max) +{ + /* tty_read will handle abort_bbs. + * len <= 0: read more */ + ssize_t len = tty_read(buf, max); + if (len <= 0) + return len; + + // apply additional converts +#ifdef DBCSAWARE + if (ISDBCSAWARE() && HasUserFlag(UF_DBCS_DROP_REPEAT)) + len = vtkbd_ignore_dbcs_evil_repeats(buf, len); +#endif +#ifdef CONVERT + len = input_wrapper(inbuf, len); +#endif +#ifdef DBG_OUTRPT + { + static char xbuf[128]; + sprintf(xbuf, ESC_STR "[s" ESC_STR "[2;1H [%ld] " + ESC_STR "[u", len); + write(1, xbuf, strlen(xbuf)); + fsync(1); + } +#endif // DBG_OUTRPT + return len; +} + + /* * dogetch() is not reentrant-safe. SIGUSR[12] might happen at any time, and * dogetch() might be called again, and then ibufsize/icurrchar/inbuf might @@ -246,24 +276,7 @@ dogetch(void) STATINC(STAT_SYSREADSOCKET); do { - len = tty_read(inbuf, IBUFSIZE); - /* tty_read will handle abort_bbs. - * len <= 0: read more */ -#ifdef CONVERT - if(len > 0) - len = input_wrapper(inbuf, len); -#endif -#ifdef DBG_OUTRPT - // if (0) - { - static char xbuf[128]; - sprintf(xbuf, ESC_STR "[s" ESC_STR "[2;1H [%ld] " - ESC_STR "[u", len); - write(1, xbuf, strlen(xbuf)); - fsync(1); - } -#endif // DBG_OUTRPT - + len = wrapped_tty_read(inbuf, IBUFSIZE); } while (len <= 0); ibufsize = len; @@ -677,11 +690,7 @@ peek_input(float f, int c) if (wait_input(f, 1) && (IBUFSIZE > ibufsize)) { - int len = tty_read(inbuf + ibufsize, IBUFSIZE - ibufsize); -#ifdef CONVERT - if(len > 0) - len = input_wrapper(inbuf+ibufsize, len); -#endif + int len = wrapped_tty_read(inbuf + ibufsize, IBUFSIZE - ibufsize); if (len > 0) ibufsize += len; } |