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());
}
}
WriteServ(user->fd,"311 %s %s %s %s * :%s",user->nick, dest->nick, dest->ident, dest->dhost, dest->fullname);
if ((user == dest) || (*user->oper))
{
- WriteServ(user->fd,"378 %s %s :is connecting from *@%s %s",user->nick, dest->nick, dest->host, (char*)inet_ntoa(dest->ip4));
+ WriteServ(user->fd,"378 %s %s :is connecting from *@%s %s",user->nick, dest->nick, dest->host, inet_ntoa(dest->ip4));
}
std::string cl = chlist(dest,user);
if (cl.length())
WriteServ(user->fd,"319 %s %s :%s",user->nick, dest->nick, cl.c_str());
}
}
- if (*Config->HideWhoisServer)
+ if (*Config->HideWhoisServer && !(*user->oper))
{
- WriteServ(user->fd,"312 %s %s %s :%s",user->nick, dest->nick, *user->oper ? dest->server : Config->HideWhoisServer, *user->oper ? GetServerDescription(dest->server).c_str() : Config->Network);
+ WriteServ(user->fd,"312 %s %s %s :%s",user->nick, dest->nick, Config->HideWhoisServer, Config->Network);
}
else
{
{
char n_field[MAXBUF];
long total = 0;
- const char* str_end = str + strlen(str);
n_field[0] = 0;
if ((!strchr(str,'s')) && (!strchr(str,'m')) && (!strchr(str,'h')) && (!strchr(str,'d')) && (!strchr(str,'w')) && (!strchr(str,'y')))
{
std::string n = str;
- n = n + "s";
+ n += 's';
return duration(n.c_str());
}
- for (char* i = (char*)str; i < str_end; i++)
+ for (char* i = (char*)str; *i; i++)
{
// if we have digits, build up a string for the value in n_field,
// up to 10 digits in size.