summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/commands.h2
-rw-r--r--src/commands.cpp37
2 files changed, 27 insertions, 12 deletions
diff --git a/include/commands.h b/include/commands.h
index 1981b1688..ff6365d78 100644
--- a/include/commands.h
+++ b/include/commands.h
@@ -35,7 +35,7 @@ bool host_matches_everyone(const std::string &mask, userrec* user);
bool ip_matches_everyone(const std::string &ip, userrec* user);
bool nick_matches_everyone(const std::string &nick, userrec* user);
int operstrcmp(char* data,char* input);
-void split_chlist(userrec* user, userrec* dest, std::string &cl);
+void split_chlist(userrec* user, userrec* dest, const std::string &cl);
/* XXX Serious WTFness XXX
*
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());
}
}