From 646b2c1da92538d0c60997c91105c07bdcea0eb1 Mon Sep 17 00:00:00 2001 From: brain Date: Tue, 8 May 2007 18:44:46 +0000 Subject: Add comments to describe wtf we are doing git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6913 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_xmlsocket.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/modules/m_xmlsocket.cpp') diff --git a/src/modules/m_xmlsocket.cpp b/src/modules/m_xmlsocket.cpp index 8fcd72a52..5dc13c7f9 100644 --- a/src/modules/m_xmlsocket.cpp +++ b/src/modules/m_xmlsocket.cpp @@ -141,6 +141,12 @@ class ModuleXMLSocket : public Module else if (result < 1) return 0; + /* XXX: The core is more than happy to split lines purely on an \n + * rather than a \r\n. This is good for us as it means that the size + * of data we are receiving is exactly the same as the size of data + * we asked for, and we dont need to re-implement our own socket + * buffering (See below) + */ for (int n = 0; n < result; n++) if (buffer[n] == 0) buffer[n] = '\n'; @@ -156,9 +162,16 @@ class ModuleXMLSocket : public Module if (user == NULL) return -1; + /* We want to alter the buffer, so we have to make a copy */ char tmpbuffer[count+1]; memcpy(&tmpbuffer, &buffer, count); + /* XXX: This will actually generate lines "looking\0\0like\0\0this" + * rather than lines "looking\0like\0this". This shouldnt be a problem + * to the client, but it saves us a TON of processing and the need + * to re-implement socket buffering, as the data we are sending is + * exactly the same length as the data we are receiving. + */ for (int n = 0; n < count; n++) if ((tmpbuffer[n] == '\r') || (tmpbuffer[n] == '\n')) tmpbuffer[n] = 0; -- cgit v1.2.3