version 1.8, 2014/07/20 06:24:19 |
version 1.9, 2014/07/20 07:35:04 |
|
|
|
|
#include "telnet_locl.h" |
#include "telnet_locl.h" |
|
|
|
#include <unistd.h> |
|
|
Ring ttyoring, ttyiring; |
Ring ttyoring, ttyiring; |
unsigned char ttyobuf[2*BUFSIZ], ttyibuf[BUFSIZ]; |
unsigned char ttyobuf[2*BUFSIZ], ttyibuf[BUFSIZ]; |
|
|
|
|
void |
void |
init_terminal() |
init_terminal() |
{ |
{ |
|
struct termios tc; |
|
|
ring_init(&ttyoring, ttyobuf, sizeof ttyobuf); |
ring_init(&ttyoring, ttyobuf, sizeof ttyobuf); |
ring_init(&ttyiring, ttyibuf, sizeof ttyibuf); |
ring_init(&ttyiring, ttyibuf, sizeof ttyibuf); |
autoflush = TerminalAutoFlush(); |
|
|
tcgetattr(0, &tc); |
|
autoflush = (tc.c_lflag & NOFLSH) == 0; |
} |
} |
|
|
|
|
|
|
n0 = ring_full_count(&ttyoring); |
n0 = ring_full_count(&ttyoring); |
if ((n1 = n = ring_full_consecutive(&ttyoring)) > 0) { |
if ((n1 = n = ring_full_consecutive(&ttyoring)) > 0) { |
if (drop) { |
if (drop) { |
TerminalFlushOutput(); |
tcflush(fileno(stdout), TCOFLUSH); |
/* we leave 'n' alone! */ |
/* we leave 'n' alone! */ |
} else { |
} else { |
n = TerminalWrite((char *)ttyoring.consume, n); |
n = write(tout, ttyoring.consume, n); |
} |
} |
} |
} |
if (n > 0) { |
if (n > 0) { |
|
|
if (n1 == n && n0 > n) { |
if (n1 == n && n0 > n) { |
n1 = n0 - n; |
n1 = n0 - n; |
if (!drop) |
if (!drop) |
n1 = TerminalWrite(ttyoring.bottom, n1); |
n1 = write(tout, ttyoring.bottom, n1); |
if (n1 > 0) |
if (n1 > 0) |
n += n1; |
n += n1; |
} |
} |