Movied ansi parser out of channel code and put it in a filter

This commit is contained in:
manojampalam 2016-03-09 20:32:02 -08:00
parent 1c9731059d
commit 41f53d605c
3 changed files with 26 additions and 1 deletions

View File

@ -2479,7 +2479,7 @@ channel_input_data(int type, u_int32_t seq, void *ctxt)
if (c->datagram) if (c->datagram)
buffer_put_string(&c->output, data, data_len); buffer_put_string(&c->output, data, data_len);
else { else {
#ifndef WIN32_FIXME #if(1)//ndef WIN32_FIXME
buffer_append(&c->output, data, data_len); buffer_append(&c->output, data, data_len);
#else #else
if ( c->client_tty ) if ( c->client_tty )

View File

@ -1520,6 +1520,24 @@ client_simple_escape_filter(Channel *c, char *buf, int len)
buf, len); buf, len);
} }
#ifdef WIN32_FIXME
u_char * client_ansi_parser_filter(Channel *c, u_char **buf, u_int *len) {
if (c->isatty) {
telProcessNetwork(buffer_ptr(&c->output), buffer_len(&c->output));
buffer_clear(&c->output);
buffer_append(&c->output, " \b", 2);
*buf = buffer_ptr(&c->output);
*len = buffer_len(&c->output);
return *buf;
}
else {
*buf = buffer_ptr(&c->output);
*len = buffer_len(&c->output);
return *buf;
}
}
#endif
static void static void
client_channel_closed(int id, void *arg) client_channel_closed(int id, void *arg)
{ {
@ -1606,7 +1624,11 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
if (session_ident != -1) { if (session_ident != -1) {
if (escape_char_arg != SSH_ESCAPECHAR_NONE) { if (escape_char_arg != SSH_ESCAPECHAR_NONE) {
channel_register_filter(session_ident, channel_register_filter(session_ident,
#ifdef WIN32_FIXME
client_simple_escape_filter, client_ansi_parser_filter,
#else
client_simple_escape_filter, NULL, client_simple_escape_filter, NULL,
#endif
client_filter_cleanup, client_filter_cleanup,
client_new_escape_filter_ctx( client_new_escape_filter_ctx(
escape_char_arg)); escape_char_arg));

View File

@ -60,6 +60,9 @@ size_t telProcessNetwork ( char *buf, size_t len )
size_t Result; size_t Result;
unsigned char* pszNewHead; unsigned char* pszNewHead;
if ((len == 1) && (buf[0] == 13))
buf[0] = 10;
if (1) if (1)
{ {
Result = len ; Result = len ;