diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-07-15 17:06:21 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-07-15 17:06:21 -0500 |
commit | 20f225bd5a557b9751439cb1857020f9ed367a6a (patch) | |
tree | eb317f370c6feabf528c43a6b9b88f0fceb95235 /lib | |
parent | 274a42aacecfcbcbdd80e3845e3b01991b65f925 (diff) | |
download | ulab-20f225bd5a557b9751439cb1857020f9ed367a6a.tar.gz ulab-20f225bd5a557b9751439cb1857020f9ed367a6a.zip |
Fix scope and float array transfers
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libtdekrb/src/tdekrbclientsocket.cpp | 15 | ||||
-rw-r--r-- | lib/libtdekrb/src/tdekrbserversocket.cpp | 15 | ||||
-rw-r--r-- | lib/libtqtrla/src/tqtrla.cpp | 51 |
3 files changed, 63 insertions, 18 deletions
diff --git a/lib/libtdekrb/src/tdekrbclientsocket.cpp b/lib/libtdekrb/src/tdekrbclientsocket.cpp index b49d48d..5a0266e 100644 --- a/lib/libtdekrb/src/tdekrbclientsocket.cpp +++ b/lib/libtdekrb/src/tdekrbclientsocket.cpp @@ -168,7 +168,6 @@ TQIODevice::Offset TDEKerberosClientSocket::at() const { } bool TDEKerberosClientSocket::at(TQIODevice::Offset off, int hidebasehack) { - long i; bool ret; Q_UNUSED(hidebasehack); @@ -339,7 +338,6 @@ void TDEKerberosClientSocket::setServerFQDN(TQString name) { } TQ_LONG TDEKerberosClientSocket::readBlock(char *data, TQ_ULONG maxlen) { - long i; TQ_LONG ret; if (kerberosStatus() == KerberosInUse) { @@ -401,7 +399,6 @@ TQ_LONG TDEKerberosClientSocket::writeBlock(const char *data, TQ_ULONG len) { } TQ_LONG TDEKerberosClientSocket::readLine(char *data, TQ_ULONG maxlen) { - long i; TQ_LONG ret; if (kerberosStatus() == KerberosInUse) { @@ -450,7 +447,6 @@ TQ_LONG TDEKerberosClientSocket::readLine(char *data, TQ_ULONG maxlen) { } TQString TDEKerberosClientSocket::readLine() { - long i; TQString ret; long maxlen; @@ -545,8 +541,9 @@ void TDEKerberosClientSocket::sendSASLDataToNetwork(const char *buffer, unsigned len = strlen(buf); buf[len] = '\n'; buf[len+1] = 0; - if (TQSocket::writeBlock(buf, len+1) < 0) { - printf("[WARNING] Transmitting data in base64 failed due to short write\n\r"); + unsigned int ret = TQSocket::writeBlock(buf, len+1); + if (ret < (len+1)) { + printf("[WARNING] Transmitting data in base64 failed due to short write [wanted: %d wrote: %d]\n\r", len+1, ret); } free(buf); @@ -733,7 +730,6 @@ bool TDEKerberosClientSocket::canReadFrame() { } void TDEKerberosClientSocket::clearFrameTail() { - int i; int eofLoc; if (m_bufferLength > 0) { eofLoc = m_buffer->buffer().find(255, m_bufferReadPointer) + 1; @@ -956,6 +952,11 @@ int TDEKerberosClientSocket::initializeKerberosInterface() { callback->context = NULL; ++callback; + // Clear the buffer from memory + m_buffer->close(); + m_buffer->open(IO_ReadWrite|IO_Truncate); + m_bufferReadPointer = 0; + // Initialize default data structures memset(&secprops, 0L, sizeof(secprops)); secprops.maxbufsize = NET_SEC_BUF_SIZE; diff --git a/lib/libtdekrb/src/tdekrbserversocket.cpp b/lib/libtdekrb/src/tdekrbserversocket.cpp index 1926cb3..a8c2ecf 100644 --- a/lib/libtdekrb/src/tdekrbserversocket.cpp +++ b/lib/libtdekrb/src/tdekrbserversocket.cpp @@ -169,7 +169,6 @@ TQIODevice::Offset TDEKerberosServerSocket::at() const { } bool TDEKerberosServerSocket::at(TQIODevice::Offset off, int hidebasehack) { - long i; bool ret; Q_UNUSED(hidebasehack); @@ -348,7 +347,6 @@ void TDEKerberosServerSocket::setServerFQDN(TQString name) { } TQ_LONG TDEKerberosServerSocket::readBlock(char *data, TQ_ULONG maxlen) { - long i; TQ_LONG ret; if (m_kerberosRequested) { @@ -410,7 +408,6 @@ TQ_LONG TDEKerberosServerSocket::writeBlock(const char *data, TQ_ULONG len) { } TQ_LONG TDEKerberosServerSocket::readLine(char *data, TQ_ULONG maxlen) { - long i; TQ_LONG ret; if (m_kerberosRequested) { @@ -459,7 +456,6 @@ TQ_LONG TDEKerberosServerSocket::readLine(char *data, TQ_ULONG maxlen) { } TQString TDEKerberosServerSocket::readLine() { - long i; TQString ret; long maxlen; @@ -554,8 +550,9 @@ void TDEKerberosServerSocket::sendSASLDataToNetwork(const char *buffer, unsigned len = strlen(buf); buf[len] = '\n'; buf[len+1] = 0; - if (TQSocket::writeBlock(buf, len+1) < (len+1)) { - printf("[WARNING] Transmitting data in base64 failed due to short write\n\r"); + unsigned int ret = TQSocket::writeBlock(buf, len+1); + if (ret < (len+1)) { + printf("[WARNING] Transmitting data in base64 failed due to short write [wanted: %d wrote: %d]\n\r", len+1, ret); } free(buf); @@ -742,7 +739,6 @@ bool TDEKerberosServerSocket::canReadFrame() { } void TDEKerberosServerSocket::clearFrameTail() { - int i; int eofLoc; if (m_bufferLength > 0) { eofLoc = m_buffer->buffer().find(255, m_bufferReadPointer) + 1; @@ -977,6 +973,11 @@ int TDEKerberosServerSocket::initializeKerberosInterface() { callback->context = NULL; ++callback; + // Clear the buffer from memory + m_buffer->close(); + m_buffer->open(IO_ReadWrite|IO_Truncate); + m_bufferReadPointer = 0; + // Initialize default data structures memset(&secprops, 0L, sizeof(secprops)); secprops.maxbufsize = NET_SEC_BUF_SIZE; diff --git a/lib/libtqtrla/src/tqtrla.cpp b/lib/libtqtrla/src/tqtrla.cpp index 3fdea05..b3fc1ec 100644 --- a/lib/libtqtrla/src/tqtrla.cpp +++ b/lib/libtqtrla/src/tqtrla.cpp @@ -21,6 +21,7 @@ #include "tqtrla.h" #include <tqwidget.h> +#include <tqbuffer.h> #include <klocale.h> #include <kmessagebox.h> @@ -325,9 +326,30 @@ TQDataStream &operator<<( TQDataStream &s, const TQFloatArray &data ) { TQ_UINT32 i; TQ_UINT32 count = data.count(); s << count; - for (i=0; i<count; i++) { - s << data[i]; + + TQIODevice* dev = s.device(); + if (dev) { + // This uses the channel efficiently by writing all the data in one large block + TQBuffer ba; + ba.open(IO_ReadWrite); + TQDataStream ds(&ba); + ds.setPrintableData(s.isPrintableData()); + + for (i=0; i<count; i++) { + ds << data[i]; + } + + ba.close(); + TQByteArray buffer = ba.buffer(); + dev->writeBlock(buffer.data(), buffer.size()); + } + else { + // This uses the channel inefficiently by writing the data in byte-sized chunks + for (i=0; i<count; i++) { + s << data[i]; + } } + return s; } @@ -346,9 +368,30 @@ TQDataStream &operator<<( TQDataStream &s, const TQDoubleArray &data ) { TQ_UINT32 i; TQ_UINT32 count = data.count(); s << count; - for (i=0; i<count; i++) { - s << data[i]; + + TQIODevice* dev = s.device(); + if (dev) { + // This uses the channel efficiently by writing all the data in one large block + TQBuffer ba; + ba.open(IO_ReadWrite); + TQDataStream ds(&ba); + ds.setPrintableData(s.isPrintableData()); + + for (i=0; i<count; i++) { + ds << data[i]; + } + + ba.close(); + TQByteArray buffer = ba.buffer(); + dev->writeBlock(buffer.data(), buffer.size()); + } + else { + // This uses the channel inefficiently by writing the data in byte-sized chunks + for (i=0; i<count; i++) { + s << data[i]; + } } + return s; } |