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 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'src/protocoltelnet.cpp') 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 ) -- cgit v1.2.3