]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Modified chlist() and whois to allow output of multi line channel membership list (!)
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 13 Dec 2005 17:18:27 +0000 (17:18 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 13 Dec 2005 17:18:27 +0000 (17:18 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2373 e03df62e-2008-0410-955e-edbf42e46eb7

include/message.h
src/commands.cpp
src/message.cpp

index d00cae30e5fc5d1543361dc10c97c6eed99160f1..b990b15ecf12230ee14b0d6dca2b6ba9c6fbac95 100644 (file)
@@ -44,7 +44,7 @@ char* cmode(userrec *user, chanrec *chan);
 int cstatus(userrec *user, chanrec *chan);
 int has_channel(userrec *u, chanrec *c);
 void TidyBan(char *ban);
-char* chlist(userrec *user, userrec* source);
+std::string chlist(userrec *user, userrec* source);
 void send_network_quit(const char* nick, const char* reason);
 
 #endif
index 7cdc534a24b46c9ebe835f29ad89e2a0b52271c7..dbcd3f4f9fa0a389f1bd1efb2e58406b5786ec70 100644 (file)
@@ -823,6 +823,23 @@ void handle_whois(char **parameters, int pcnt, userrec *user)
        }
 }
 
+void split_chlist(userrec* user, userrec* dest, std::string &cl)
+{
+       std::stringstream channels(cl);
+       std::string line = "";
+       std::string cname = "";
+       while (!channels.eof())
+       {
+               channels >> cname;
+               line = line + cname + " ";
+               if (line.length() > 400)
+               {
+                       WriteServ(user->fd,"319 %s %s :%s",user->nick, dest->nick, line.c_str());
+                       line = "";
+               }
+       }
+}
+
 void do_whois(userrec* user, userrec* dest,unsigned long signon, unsigned long idle, char* nick)
 {
        // bug found by phidjit - were able to whois an incomplete connection if it had sent a NICK or USER
@@ -833,10 +850,17 @@ void do_whois(userrec* user, userrec* dest,unsigned long signon, unsigned long i
                {
                        WriteServ(user->fd,"378 %s %s :is connecting from *@%s %s",user->nick, dest->nick, dest->host, dest->ip);
                }
-               char* cl = chlist(dest,user);
-               if (*cl)
+               std::string cl = chlist(dest,user);
+               if (cl.length())
                {
-                       WriteServ(user->fd,"319 %s %s :%s",user->nick, dest->nick, cl);
+                       if (cl.length() > 400)
+                       {
+                               split_chlist(user,dest,cl);
+                       }
+                       else
+                       {
+                               WriteServ(user->fd,"319 %s %s :%s",user->nick, dest->nick, cl.c_str());
+                       }
                }
                WriteServ(user->fd,"312 %s %s %s :%s",user->nick, dest->nick, dest->server, GetServerDescription(dest->server).c_str());
                if (*dest->awaymsg)
index 79ea41f19afca78d7660278ef13c34f81dd6516c..f55df0ee39910231de4e0ace300a12be42a42618 100644 (file)
@@ -427,11 +427,11 @@ void TidyBan(char *ban)
 
 char lst[MAXBUF];
 
-char* chlist(userrec *user,userrec* source)
+std::string chlist(userrec *user,userrec* source)
 {
-       char cmp[MAXBUF];
+       std::string cmp = "";
+       std::string lst = "";
         log(DEBUG,"chlist: %s",user->nick);
-       strcpy(lst,"");
        if (!user)
        {
                return lst;
@@ -442,27 +442,18 @@ char* chlist(userrec *user,userrec* source)
                {
                        if (user->chans[i].channel->name)
                        {
-                               strlcpy(cmp,user->chans[i].channel->name,MAXBUF);
-                               strlcat(cmp," ",MAXBUF);
-                               if (!strstr(lst,cmp))
+                               cmp = std::string(user->chans[i].channel->name) + " ";
+                               if (!strstr(lst.c_str(),cmp.c_str()))
                                {
                                        // if the channel is NOT private/secret, OR the source user is on the channel
                                        if (((!(user->chans[i].channel->binarymodes & CM_PRIVATE)) && (!(user->chans[i].channel->binarymodes & CM_SECRET))) || (has_channel(source,user->chans[i].channel)))
                                        {
-                                               strlcat(lst,cmode(user,user->chans[i].channel),MAXBUF);
-                                               strlcat(lst,user->chans[i].channel->name,MAXBUF);
-                                               strlcat(lst," ",MAXBUF);
+                                               lst = lst + std::string(cmode(user,user->chans[i].channel)) + std::string(user->chans[i].channel->name) + " ";
                                        }
                                }
                        }
                }
        }
-       if (strlen(lst))
-       {
-               lst[strlen(lst)-1] = '\0'; // chop trailing space
-       }
        return lst;
 }
 
-
-