summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorom <om@e03df62e-2008-0410-955e-edbf42e46eb7>2006-04-03 10:22:03 +0000
committerom <om@e03df62e-2008-0410-955e-edbf42e46eb7>2006-04-03 10:22:03 +0000
commite8ad4c8cb0d34aaeafd8ef5223b1dccdc752cc51 (patch)
tree2e925d66baa992594ae900378bb151044a155626 /src
parente3ebbb9292c6ea0b84b90611b78108a085caed63 (diff)
split_clist will never send lines over 512 chars, also should be faster
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3804 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/commands.cpp37
1 files changed, 26 insertions, 11 deletions
diff --git a/src/commands.cpp b/src/commands.cpp
index aea43482f..1715a9ace 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -89,24 +89,39 @@ extern std::vector<userrec*> local_users;
extern userrec* fd_ref_table[MAX_DESCRIPTORS];
-void split_chlist(userrec* user, userrec* dest, std::string &cl)
+void split_chlist(userrec* user, userrec* dest, const std::string &cl)
{
- std::stringstream channels(cl);
- std::string line = "";
- std::string cname = "";
- while (!channels.eof())
+ std::string line;
+ std::ostringstream prefix;
+ std::string::size_type start, pos, length;
+
+ prefix << ":" << Config->ServerName << " 319 " << user->nick << " " << dest->nick << " :";
+ line = prefix.str();
+
+ for (start = 0; pos = cl.find(' ', start); start = pos+1)
{
- channels >> cname;
- line = line + cname + " ";
- if (line.length() > 400)
+ length = (pos == std::string::npos) ? cl.length() : pos;
+
+ if (line.length() + length - start > 510)
+ {
+ Write_NoFormat(user->fd, line.c_str());
+ line = prefix.str();
+ }
+
+ if(pos == std::string::npos)
{
- WriteServ(user->fd,"319 %s %s :%s",user->nick, dest->nick, line.c_str());
- line = "";
+ line += cl.substr(start, length - start);
+ break;
+ }
+ else
+ {
+ line += cl.substr(start, length - start + 1);
}
}
+
if (line.length())
{
- WriteServ(user->fd,"319 %s %s :%s",user->nick, dest->nick, line.c_str());
+ Write_NoFormat(user->fd, line.c_str());
}
}