Move docs around.

This commit is contained in:
barant committed 2020-06-11 18:54:51 -07:00
1 parent 63943e02dd
commit 3fee297136
2154 files changed
+19543 -41261

No files matched your search

+35 -17
View File
@@ -16,10 +16,9 @@ namespace core {
}
void TCPSession::protocol(std::string data = "") {
if(data.length() > 0) {
if(!server.commands.processRequest(data, this, out))
server.sessionErrorHandler("Invalid data received.", out);
}
if(!server.commands.processRequest(data, this, out))
if(data != "")
server.sessionErrorHandler("Invalid data received.", out);
}
void TCPSession::onRegistered() {
@@ -38,24 +37,43 @@ namespace core {
memcpy(lineBuffer + lineBufferSize, data, len);
lineBufferSize += len;
while(lineBufferSize > 0) {
int lineLength = strcspn(lineBuffer, "\r\n");
if(lineLength == lineBufferSize)
break;
onLineReceived(std::string(lineBuffer, lineLength));
if(lineBuffer[lineLength] == '\r')
++lineLength;
if(lineBuffer[lineLength] == '\n')
++lineLength;
lineBufferSize -= lineLength;
if(lineBufferSize > 0)
memmove(lineBuffer, lineBuffer + lineLength, lineBufferSize);
lineBuffer = (char *)realloc(lineBuffer, lineBufferSize);
}
switch(mode) {
case LINE:
int lineLength = strcspn(lineBuffer, "\r\n");
if(lineLength == lineBufferSize)
break;
onLineReceived(std::string(lineBuffer, lineLength));
if(lineBuffer[lineLength] == '\r')
++lineLength;
if(lineBuffer[lineLength] == '\n')
++lineLength;
lineBufferSize -= lineLength;
if(lineBufferSize > 0)
memmove(lineBuffer, lineBuffer + lineLength, lineBufferSize);
lineBuffer = (char *)realloc(lineBuffer, lineBufferSize);
break;
case BLOCK:
if(lineBufferSize >= blockLength) {
onBlockReceived(std::string(lineBuffer, blockLength));
lineBufferSize -= blockLength;
if(lineBufferSize > 0)
memmove(lineBuffer, lineBuffer + blockLength, lineBufferSize);
lineBuffer = (char *)realloc(lineBuffer, lineBufferSize);
}
break;
}
}
}
}
void setMode(Mode mode, int blockSize = 0) {
this->mode = mode;
this->blockSize = blockSize;
}
void TCPSession::onLineReceived(std::string line) {
coreutils::Log(coreutils::LOG_DEBUG_3) << "[" << line << "]";
protocol(line);
send();
if(term)