summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-03-09 13:54:13 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-03-09 13:54:13 +0000
commitd4d14b2a9cdbb7984c1ff73557493b96f9bcb31c (patch)
tree7e8b1ba29bfadb2dc3dfd7227c356f792bb19dc8
parentc330b24501fc56516fef098428889a0a526e706a (diff)
(Needs test) Improved userlist()
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3589 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/helperfuncs.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index effffd6e9..a02d19702 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -55,7 +55,6 @@ extern ServerConfig *Config;
extern InspIRCd* ServerInstance;
extern time_t TIME;
extern char lowermap[255];
-static char list[MAXBUF];
extern userrec* fd_ref_table[MAX_DESCRIPTORS];
static char already_sent[MAX_DESCRIPTORS];
extern std::vector<userrec*> all_opers;
@@ -1323,8 +1322,10 @@ void userlist(userrec *user,chanrec *c)
return;
}
+ char list[MAXBUF];
size_t dlen = snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name);
- size_t initial = dlen;
+ int n = 0;
+ char* ptr = list + dlen;
CUList *ulist= c->GetUsers();
@@ -1344,21 +1345,28 @@ void userlist(userrec *user,chanrec *c)
continue;
}
- dlen += strlcat(list,cmode(i->second,c),MAXBUF);
- dlen += strlcat(list,i->second->nick,MAXBUF);
- charlcat(list,' ',MAXBUF);
- dlen++;
+ const char* n = cmode(i->second,c);
+ if (*n)
+ *ptr++ = *n;
+ for (char* t = i->second->nick; *t; t++)
+ *ptr++ = *t;
+ *ptr++ = ' ';
+ n++;
- if (dlen > (480-NICKMAX))
+ if ((ptr - list) > (480-NICKMAX))
{
/* list overflowed into multiple numerics */
+ *--ptr = 0;
WriteServ_NoFormat(user->fd,list);
dlen = snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name);
+ ptr = list + dlen;
+ n = 0;
}
}
+ *--ptr = 0;
/* if whats left in the list isnt empty, send it */
- if (dlen != initial)
+ if (n)
{
WriteServ_NoFormat(user->fd,list);
}