diff options
Diffstat (limited to 'lib/libtdekrb/src')
-rw-r--r-- | lib/libtdekrb/src/tdekrbclientsocket.cpp | 47 | ||||
-rw-r--r-- | lib/libtdekrb/src/tdekrbclientsocket.h | 5 | ||||
-rw-r--r-- | lib/libtdekrb/src/tdekrbserversocket.cpp | 49 | ||||
-rw-r--r-- | lib/libtdekrb/src/tdekrbserversocket.h | 5 |
4 files changed, 103 insertions, 3 deletions
diff --git a/lib/libtdekrb/src/tdekrbclientsocket.cpp b/lib/libtdekrb/src/tdekrbclientsocket.cpp index 02bee4d..9e9a27a 100644 --- a/lib/libtdekrb/src/tdekrbclientsocket.cpp +++ b/lib/libtdekrb/src/tdekrbclientsocket.cpp @@ -204,7 +204,7 @@ bool TDEKerberosClientSocket::atEnd() const { bool ret; if (kerberosStatus() == KerberosInUse) { - ret = TQSocket::atEnd(); + ret = ((m_bufferLength < 1) && TQSocket::atEnd()); } else { ret = TQSocket::atEnd(); @@ -710,6 +710,51 @@ bool TDEKerberosClientSocket::canReadData() { return (TQSocket::canReadLine() || (m_bufferLength > 0)); } +void TDEKerberosClientSocket::clearIncomingData() { + char data[64]; + processPendingData(); + while (canReadData()) { + readBlock(data, 64); + } +} + +int TDEKerberosClientSocket::writeEndOfFrame() { + char data[1]; + data[0] = 255; + return writeBlock(data, 1); +} + +bool TDEKerberosClientSocket::canReadFrame() { + processPendingData(); + if (m_buffer->buffer().contains(255) > 0) { + return true; + } + else { + return false; + } +} + +void TDEKerberosClientSocket::clearFrameTail() { + int i; + int eofLoc; + if (m_bufferLength > 0) { + eofLoc = m_buffer->buffer().find(255, 0) + 1; + if ((eofLoc > 0) && (eofLoc <= m_bufferLength)) { + // Remove the remaining frame bytes (including the End of Frame marker) from the buffer + m_bufferLength = m_bufferLength-eofLoc; + TQByteArray ba = m_buffer->buffer(); + for (i=0; i<m_bufferLength;i++) { + ba[i] = ba[i+eofLoc]; + } + if (m_bufferLength < 1) { + // Clear the buffer from memory + m_buffer->close(); + m_buffer->open(IO_ReadWrite|IO_Truncate); + } + } + } +} + void TDEKerberosClientSocket::setStatusMessage(TQString message) { if (message != m_prevStatusMessage) { emit(statusMessageUpdated(message)); diff --git a/lib/libtdekrb/src/tdekrbclientsocket.h b/lib/libtdekrb/src/tdekrbclientsocket.h index 8fa2b25..a9034f0 100644 --- a/lib/libtdekrb/src/tdekrbclientsocket.h +++ b/lib/libtdekrb/src/tdekrbclientsocket.h @@ -71,6 +71,11 @@ class TDEKerberosClientSocket : public TQSocket KerberosStatus kerberosStatus() const; bool canReadData(); + void clearIncomingData(); + + int writeEndOfFrame(); + bool canReadFrame(); + void clearFrameTail(); public slots: int processPendingData(); diff --git a/lib/libtdekrb/src/tdekrbserversocket.cpp b/lib/libtdekrb/src/tdekrbserversocket.cpp index 86c4212..f715af8 100644 --- a/lib/libtdekrb/src/tdekrbserversocket.cpp +++ b/lib/libtdekrb/src/tdekrbserversocket.cpp @@ -204,8 +204,8 @@ bool TDEKerberosServerSocket::at(TQIODevice::Offset off, int hidebasehack) { bool TDEKerberosServerSocket::atEnd() const { bool ret; - if (m_kerberosRequested) { - ret = TQSocket::atEnd(); + if (kerberosStatus() == KerberosInUse) { + ret = ((m_bufferLength < 1) && TQSocket::atEnd()); } else { ret = TQSocket::atEnd(); @@ -719,6 +719,51 @@ bool TDEKerberosServerSocket::canReadData() { return (TQSocket::canReadLine() || (m_bufferLength > 0)); } +void TDEKerberosServerSocket::clearIncomingData() { + char data[64]; + processPendingData(); + while (canReadData()) { + readBlock(data, 64); + } +} + +int TDEKerberosServerSocket::writeEndOfFrame() { + char data[1]; + data[0] = 255; + return writeBlock(data, 1); +} + +bool TDEKerberosServerSocket::canReadFrame() { + processPendingData(); + if (m_buffer->buffer().contains(255) > 0) { + return true; + } + else { + return false; + } +} + +void TDEKerberosServerSocket::clearFrameTail() { + int i; + int eofLoc; + if (m_bufferLength > 0) { + eofLoc = m_buffer->buffer().find(255, 0) + 1; + if ((eofLoc > 0) && (eofLoc <= m_bufferLength)) { + // Remove the remaining frame bytes (including the End of Frame marker) from the buffer + m_bufferLength = m_bufferLength-eofLoc; + TQByteArray ba = m_buffer->buffer(); + for (i=0; i<m_bufferLength;i++) { + ba[i] = ba[i+eofLoc]; + } + if (m_bufferLength < 1) { + // Clear the buffer from memory + m_buffer->close(); + m_buffer->open(IO_ReadWrite|IO_Truncate); + } + } + } +} + void TDEKerberosServerSocket::setStatusMessage(TQString message) { if (message != m_prevStatusMessage) { emit(statusMessageUpdated(message)); diff --git a/lib/libtdekrb/src/tdekrbserversocket.h b/lib/libtdekrb/src/tdekrbserversocket.h index 0394b49..1f4b4ff 100644 --- a/lib/libtdekrb/src/tdekrbserversocket.h +++ b/lib/libtdekrb/src/tdekrbserversocket.h @@ -71,6 +71,11 @@ class TDEKerberosServerSocket : public TQSocket KerberosStatus kerberosStatus() const; bool canReadData(); + void clearIncomingData(); + + int writeEndOfFrame(); + bool canReadFrame(); + void clearFrameTail(); public slots: int processPendingData(); |