X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/5d1d4279f234803bf7ece3b2e75b6c497faff9d1..fe50e8140a2dbb3ba357a0ab777f34e07d568c23:/ldisc.c diff --git a/ldisc.c b/ldisc.c index 4f1b913a..10576d29 100644 --- a/ldisc.c +++ b/ldisc.c @@ -1,4 +1,11 @@ #include +#ifndef AUTO_WINSOCK +#ifdef WINSOCK_TWO +#include +#else +#include +#endif +#endif #include #include @@ -9,13 +16,11 @@ */ static void c_write (char *buf, int len) { - while (len--) { - int new_head = (inbuf_head + 1) & INBUF_MASK; - if (new_head != inbuf_reap) { - inbuf[inbuf_head] = *buf++; - inbuf_head = new_head; - } - } + from_backend(0, buf, len); +} + +static void c_write1 (char c) { + c_write(&c, 1); } static char *term_buf = NULL; @@ -34,8 +39,7 @@ static int plen(unsigned char c) { static void pwrite(unsigned char c) { if ((c >= 32 && c <= 126) || (c >= 160)) { - char cc = (char)c; - c_write(&cc, 1); + c_write1(c); } else if (c < 128) { char cc[2]; cc[1] = (c == 127 ? '?' : c + 0x40); @@ -98,6 +102,7 @@ static void term_send(char *buf, int len) { bsb(plen(term_buf[term_buflen-1])); term_buflen--; } + back->special (TS_EL); if( c == CTRL('C') ) back->special (TS_IP); if( c == CTRL('Z') ) back->special (TS_SUSP); if( c == CTRL('\\') ) back->special (TS_ABORT); @@ -122,8 +127,12 @@ static void term_send(char *buf, int len) { } break; case CTRL('M'): /* send with newline */ - back->send(term_buf, term_buflen); - back->send("\r\n", 2); + if (term_buflen > 0) + back->send(term_buf, term_buflen); + if (cfg.protocol == PROT_RAW) + back->send("\r\n", 2); + else + back->send("\r", 1); c_write("\r\n", 2); term_buflen = 0; break; @@ -149,7 +158,8 @@ static void simple_send(char *buf, int len) { term_buflen--; } } - back->send(buf, len); + if (len > 0) + back->send(buf, len); } Ldisc ldisc_term = { term_send };