aboutsummaryrefslogtreecommitdiff
path: root/src/gatsstream.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2010-11-01 23:15:11 +0000
committerMike Buland <eichlan@xagasoft.com>2010-11-01 23:15:11 +0000
commit2cd1a89109651a19138aec9988d765208d7709e5 (patch)
tree66ea6d6e379c82f17993f9e398999b820d9f2251 /src/gatsstream.cpp
parent1035f576164ceb50f85b787459ad760e0ac7b2b9 (diff)
downloadlibgats-2cd1a89109651a19138aec9988d765208d7709e5.tar.gz
libgats-2cd1a89109651a19138aec9988d765208d7709e5.tar.bz2
libgats-2cd1a89109651a19138aec9988d765208d7709e5.tar.xz
libgats-2cd1a89109651a19138aec9988d765208d7709e5.zip
Minor changes to the float that may circumvent some stupidness in the mingwrt
snprintf code. I really need to write my own number parser/writer.
Diffstat (limited to 'src/gatsstream.cpp')
-rw-r--r--src/gatsstream.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/gatsstream.cpp b/src/gatsstream.cpp
index 3e9b211..71372db 100644
--- a/src/gatsstream.cpp
+++ b/src/gatsstream.cpp
@@ -7,9 +7,9 @@
7#include <arpa/inet.h> 7#include <arpa/inet.h>
8#endif 8#endif
9 9
10// #include <bu/sio.h> 10#include <bu/sio.h>
11#include <bu/nullstream.h> 11#include <bu/nullstream.h>
12// using namespace Bu; 12using namespace Bu;
13 13
14Gats::GatsStream::GatsStream( Bu::Stream &rStream ) : 14Gats::GatsStream::GatsStream( Bu::Stream &rStream ) :
15 rStream( rStream ) 15 rStream( rStream )
@@ -40,40 +40,40 @@ Gats::Object *Gats::GatsStream::readObject()
40 40
41 uint8_t uVer; 41 uint8_t uVer;
42 qbRead.peek( &uVer, 1 ); 42 qbRead.peek( &uVer, 1 );
43 // sio << "Gats::GatsStream::readObject(): Packet version: " << (int)uVer << sio.nl; 43 sio << "Gats::GatsStream::readObject(): Packet version: " << (int)uVer << sio.nl;
44 44
45 int32_t iSize; 45 int32_t iSize;
46 qbRead.peek( &iSize, 4, 1 ); 46 qbRead.peek( &iSize, 4, 1 );
47 iSize = ntohl( iSize ); 47 iSize = ntohl( iSize );
48 // sio << "Gats::GatsStream::readObject(): Header read, looking for " << iSize << "b, we have " << qbRead.getSize() << "b." << sio.nl; 48 sio << "Gats::GatsStream::readObject(): Header read, looking for " << iSize << "b, we have " << qbRead.getSize() << "b." << sio.nl;
49 while( qbRead.getSize() < iSize ) 49 while( qbRead.getSize() < iSize )
50 { 50 {
51 int32_t iRead = iSize - qbRead.getSize(); 51 int32_t iRead = iSize - qbRead.getSize();
52 if( iRead > 1500 ) 52 if( iRead > 1500 )
53 iRead = 1500; 53 iRead = 1500;
54 // sio << "Gats::GatsStream::readObject(): Attempting to read " << iRead << "b." << sio.nl; 54 sio << "Gats::GatsStream::readObject(): Attempting to read " << iRead << "b." << sio.nl;
55 int32_t iReal = rStream.read( buf, iRead ); 55 int32_t iReal = rStream.read( buf, iRead );
56 // sio << "Gats::GatsStream::readObject(): Read " << iReal << "b." << sio.nl; 56 sio << "Gats::GatsStream::readObject(): Read " << iReal << "b." << sio.nl;
57 qbRead.write( buf, iReal ); 57 qbRead.write( buf, iReal );
58 if( iReal < iRead ) 58 if( iReal < iRead )
59 { 59 {
60 // sio << "Gats::GatsStream::readObject(): Insufficient data read in block, bailing on read." << sio.nl; 60 sio << "Gats::GatsStream::readObject(): Insufficient data read in block, bailing on read." << sio.nl;
61 return NULL; 61 return NULL;
62 } 62 }
63 } 63 }
64 64
65 if( qbRead.getSize() < iSize ) 65 if( qbRead.getSize() < iSize )
66 { 66 {
67 // sio << "Gats::GatsStream::readObject(): Somehow, we still don't have enough data, bailing." << sio.nl; 67 sio << "Gats::GatsStream::readObject(): Somehow, we still don't have enough data, bailing." << sio.nl;
68 return NULL; 68 return NULL;
69 } 69 }
70 70
71 // sio << "Gats::GatsStream::readObject(): We have " << qbRead.getSize() << "b of " << iSize << "b, time to read the object." << sio.nl; 71 sio << "Gats::GatsStream::readObject(): We have " << qbRead.getSize() << "b of " << iSize << "b, time to read the object." << sio.nl;
72 72
73 qbRead.seek( 5 ); 73 qbRead.seek( 5 );
74 Gats::Object *pObj = Gats::Object::read( qbRead ); 74 Gats::Object *pObj = Gats::Object::read( qbRead );
75 75
76 // sio << "Gats::GatsStream::readObject(): Read completed, there are " << qbRead.getSize() << "b left in the buffer." << sio.nl; 76 sio << "Gats::GatsStream::readObject(): Read completed, there are " << qbRead.getSize() << "b left in the buffer." << sio.nl;
77 return pObj; 77 return pObj;
78} 78}
79 79