diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2004-04-14 18:58:25 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2004-04-14 18:58:25 +0000 |
commit | 8be0c0008766de9003c7e8dd2ae74bf7c9dcd525 (patch) | |
tree | 25034a9d41c26eba067bacd9a72fd47c17914e7a /src/connection.cpp | |
parent | 84d9f0dc9aa9eff59ec606882821e82bf9194752 (diff) |
More fixes to connection buffer handling
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@579 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/connection.cpp')
-rw-r--r-- | src/connection.cpp | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/connection.cpp b/src/connection.cpp index 513ac69db..19424afc4 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -256,20 +256,40 @@ bool connection::SendPacket(char *message, char* host) // receives a packet from any where there is data waiting, first come, first served // fills the message and host values with the host where the data came from. -bool connection::RecvPacket(char *message, char* host) +bool connection::RecvPacket(string_list &messages, char* host) { + char data[32767]; for (int i = 0; i < this->connectors.size(); i++) { // returns false if the packet could not be sent (e.g. target host down) int rcvsize = 0; - if (rcvsize = recv(this->connectors[i].GetDescriptor(),message,MAXBUF,0)) + if (rcvsize = recv(this->connectors[i].GetDescriptor(),data,32767,0)) { if (rcvsize > 0) { - // something new on this socket, fill the return values and bail - strncpy(host,this->connectors[i].GetServerName().c_str(),160); - message[rcvsize-1] = 0; - log(DEBUG,"main: Connection::RecvPacket() got '%s' from %s",message,host); + char* l = strtok(data,"\n"); + while (l) + { + char sanitized[32767]; + memset(sanitized, 0, 32767); + int ptt = 0; + for (int pt = 0; pt < strlen(l); pt++) + { + if (l[pt] != '\r') + { + sanitized[ptt++] = l[pt]; + } + } + sanitized[ptt] = '\0'; + if (strlen(sanitized)) + { + messages.push_back(sanitized); + strncpy(host,this->connectors[i].GetServerName().c_str(),160); + log(DEBUG,"main: Connection::RecvPacket() got '%s' from %s",sanitized,host); + + } + l = strtok(NULL,"\n"); + } return true; } } |