diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-03-07 12:05:34 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-03-07 12:05:34 +0000 |
commit | 34b0ca01b6da7fc039ecdf4d0bc8bbb5bb3f64bf (patch) | |
tree | 4ac31611f90a8b5660a942fc44aee4d9305f807d /src/helperfuncs.cpp | |
parent | 5dd6b4e97d9c63172fac90a5b2b7167214b4ba64 (diff) |
Improved userlist to avoid strlen
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3514 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/helperfuncs.cpp')
-rw-r--r-- | src/helperfuncs.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index 9cf45889f..9080cc6a5 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -1229,9 +1229,11 @@ void userlist(userrec *user,chanrec *c) return; } - snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name); + size_t dlen = snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name); + size_t initial = dlen; std::map<char*,char*> *ulist= c->GetUsers(); + for (std::map<char*,char*>::iterator i = ulist->begin(); i != ulist->end(); i++) { char* o = i->second; @@ -1242,19 +1244,20 @@ void userlist(userrec *user,chanrec *c) * nick in NAMES list */ continue; } - strlcat(list,cmode(otheruser,c),MAXBUF); - strlcat(list,otheruser->nick,MAXBUF); + dlen += strlcat(list,cmode(otheruser,c),MAXBUF); + dlen += strlcat(list,otheruser->nick,MAXBUF); charlcat(list,' ',MAXBUF); - if (strlen(list)>(480-NICKMAX)) + dlen++; + if (dlen > (480-NICKMAX)) { /* list overflowed into * multiple numerics */ WriteServ_NoFormat(user->fd,list); - snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name); + dlen = snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name); } } /* if whats left in the list isnt empty, send it */ - if (list[strlen(list)-1] != ':') + if (dlen != initial) { WriteServ_NoFormat(user->fd,list); } |