aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-10-15 14:18:32 +0000
committerMike Buland <eichlan@xagasoft.com>2007-10-15 14:18:32 +0000
commitde7922c77175f625744926f5c34e7d5367d5ca12 (patch)
tree689b1cf17ca96c3f18da426418c817fbf518918c
parente72d6077b475bc6142afc3b5967db113922c76f5 (diff)
downloadlibbu++-de7922c77175f625744926f5c34e7d5367d5ca12.tar.gz
libbu++-de7922c77175f625744926f5c34e7d5367d5ca12.tar.bz2
libbu++-de7922c77175f625744926f5c34e7d5367d5ca12.tar.xz
libbu++-de7922c77175f625744926f5c34e7d5367d5ca12.zip
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).
-rw-r--r--src/protocoltelnet.cpp35
-rw-r--r--src/protocoltelnet.h2
2 files changed, 31 insertions, 6 deletions
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()
268 268
269void Bu::ProtocolTelnet::write( const Bu::FString &sData ) 269void Bu::ProtocolTelnet::write( const Bu::FString &sData )
270{ 270{
271 pClient->write( sData ); 271 write( sData.getStr(), sData.getSize() );
272} 272}
273 273#include "bu/logger.h"
274void Bu::ProtocolTelnet::write( char *pData, int iSize ) 274void Bu::ProtocolTelnet::write( const char *pData, int iSize )
275{ 275{
276 pClient->write( pData, iSize ); 276 int iLast = 0, j;
277 for( j = iLast; j < iSize; j++ )
278 {
279 if( pData[j] == '\n' )
280 {
281 if( j+1 >= iSize ||
282 (pData[j+1] != '\r' && pData[j+1] != '\0') )
283 {
284 logHexDump( 1, pData+iLast, j-iLast, "bo" );
285 pClient->write( pData+iLast, j-iLast );
286 logHexDump( 1, "\n\r", 2, "ba" );
287 pClient->write( "\n\r", 2 );
288 iLast = j+1;
289 }
290 else
291 {
292 j++;
293 }
294 }
295 }
296 if( j > iLast )
297 {
298 logHexDump( 1, pData+iLast, iSize-iLast, "bl" );
299 pClient->write( pData+iLast, iSize-iLast );
300 }
301 //pClient->write( pData, iSize );
277} 302}
278 303
279void Bu::ProtocolTelnet::write( char cData ) 304void Bu::ProtocolTelnet::write( char cData )
280{ 305{
281 pClient->write( &cData, 1 ); 306 write( &cData, 1 );
282} 307}
283 308
284void Bu::ProtocolTelnet::onWill( char cCode ) 309void 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
110 bool isCanonical(); 110 bool isCanonical();
111 111
112 void write( const Bu::FString &sData ); 112 void write( const Bu::FString &sData );
113 void write( char *pData, int iSize ); 113 void write( const char *pData, int iSize );
114 void write( char cData ); 114 void write( char cData );
115 115
116 public: 116 public: