From de7922c77175f625744926f5c34e7d5367d5ca12 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 15 Oct 2007 14:18:32 +0000 Subject: Minor changes, ProtcolTelnet now intellegently converts lone CR characters in the outgoing stream into CRLF sequences. Eventually there should be an option to convert these to CR NUL sequences as well (lone CRs are not allowed). --- src/protocoltelnet.cpp | 35 ++++++++++++++++++++++++++++++----- src/protocoltelnet.h | 2 +- 2 files changed, 31 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/protocoltelnet.cpp b/src/protocoltelnet.cpp index e4fc926..5361a61 100644 --- a/src/protocoltelnet.cpp +++ b/src/protocoltelnet.cpp @@ -268,17 +268,42 @@ bool Bu::ProtocolTelnet::isCanonical() void Bu::ProtocolTelnet::write( const Bu::FString &sData ) { - pClient->write( sData ); + write( sData.getStr(), sData.getSize() ); } - -void Bu::ProtocolTelnet::write( char *pData, int iSize ) +#include "bu/logger.h" +void Bu::ProtocolTelnet::write( const char *pData, int iSize ) { - pClient->write( pData, iSize ); + int iLast = 0, j; + for( j = iLast; j < iSize; j++ ) + { + if( pData[j] == '\n' ) + { + if( j+1 >= iSize || + (pData[j+1] != '\r' && pData[j+1] != '\0') ) + { + logHexDump( 1, pData+iLast, j-iLast, "bo" ); + pClient->write( pData+iLast, j-iLast ); + logHexDump( 1, "\n\r", 2, "ba" ); + pClient->write( "\n\r", 2 ); + iLast = j+1; + } + else + { + j++; + } + } + } + if( j > iLast ) + { + logHexDump( 1, pData+iLast, iSize-iLast, "bl" ); + pClient->write( pData+iLast, iSize-iLast ); + } + //pClient->write( pData, iSize ); } void Bu::ProtocolTelnet::write( char cData ) { - pClient->write( &cData, 1 ); + write( &cData, 1 ); } void Bu::ProtocolTelnet::onWill( char cCode ) diff --git a/src/protocoltelnet.h b/src/protocoltelnet.h index f773f1e..82d6398 100644 --- a/src/protocoltelnet.h +++ b/src/protocoltelnet.h @@ -110,7 +110,7 @@ namespace Bu bool isCanonical(); void write( const Bu::FString &sData ); - void write( char *pData, int iSize ); + void write( const char *pData, int iSize ); void write( char cData ); public: -- cgit v1.2.3