]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Added charlcat which appends a single char to a char* string (range checked)
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 2 Mar 2006 11:45:38 +0000 (11:45 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 2 Mar 2006 11:45:38 +0000 (11:45 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3416 e03df62e-2008-0410-955e-edbf42e46eb7

include/helperfuncs.h
src/cmd_who.cpp
src/helperfuncs.cpp

index c5939f8ba2d889fc59a02a0f522ee43b77f35217..933aeaca1c03d3d96045444f144c62cc4bc54caa 100644 (file)
@@ -87,4 +87,6 @@ std::string GetFullProgDir(char** argv, int argc);
 int InsertMode(std::string &output, const char* modes, unsigned short section);
 bool IsValidChannelName(const char *);
 
+inline int charlcat(char* x,char y,int z);
+
 #endif
index ecb52ea293c1c1d51a646f63b06e0b9f0457bc8b..624006758e71d8832b329f79ba3aa8cc516f2c6e 100644 (file)
@@ -84,11 +84,11 @@ void cmd_who::Handle (char **parameters, int pcnt, userrec *user)
                                                // Bug Fix #29
                                                *tmp = 0;
                                                if (*i->second->awaymsg) {
-                                                       strlcat(tmp, "G", 9);
+                                                       charlcat(tmp, 'G', 9);
                                                } else {
-                                                       strlcat(tmp, "H", 9);
+                                                       charlcat(tmp, 'H', 9);
                                                }
-                                               if (*i->second->oper) { strlcat(tmp, "*", 9); }
+                                               if (*i->second->oper) { charlcat(tmp, '*', 9); }
                                                WriteServ(user->fd,"352 %s %s %s %s %s %s %s :0 %s",user->nick, Ptr ? Ptr->name : "*", i->second->ident, i->second->dhost, i->second->server, i->second->nick, tmp, i->second->fullname);
                                                if (n_list++ > Config->MaxWhoResults)
                                                {
@@ -121,11 +121,11 @@ void cmd_who::Handle (char **parameters, int pcnt, userrec *user)
                                                // Fix Bug #29 - Part 2..
                                                *tmp = 0;
                                                if (*i->second->awaymsg) {
-                                                       strlcat(tmp, "G", 9);
+                                                       charlcat(tmp, 'G', 9);
                                                } else {
-                                                       strlcat(tmp, "H", 9);
+                                                       charlcat(tmp, 'H', 9);
                                                }
-                                               if (*i->second->oper) { strlcat(tmp, "*", 9); }
+                                               if (*i->second->oper) { charlcat(tmp, '*', 9); }
                                                strlcat(tmp, cmode(i->second, Ptr),5);
                                                WriteServ(user->fd,"352 %s %s %s %s %s %s %s :0 %s",user->nick, Ptr->name, i->second->ident, i->second->dhost, i->second->server, i->second->nick, tmp, i->second->fullname);
                                                 n_list++;
@@ -152,11 +152,11 @@ void cmd_who::Handle (char **parameters, int pcnt, userrec *user)
                                // Bug Fix #29 -- Part 29..
                                *tmp = 0;
                                if (*u->awaymsg) {
-                                       strlcat(tmp, "G" ,9);
+                                       charlcat(tmp, 'G' ,9);
                                } else {
-                                       strlcat(tmp, "H" ,9);
+                                       charlcat(tmp, 'H' ,9);
                                }
-                               if (*u->oper) { strlcat(tmp, "*" ,9); }
+                               if (*u->oper) { charlcat(tmp, '*' ,9); }
                                WriteServ(user->fd,"352 %s %s %s %s %s %s %s :0 %s",user->nick, u->chans.size() && u->chans[0].channel ? u->chans[0].channel->name
                                 : "*", u->ident, u->dhost, u->server, u->nick, tmp, u->fullname);
                        }
@@ -174,9 +174,9 @@ void cmd_who::Handle (char **parameters, int pcnt, userrec *user)
                                userrec* oper = *i;
                                *tmp = 0;
                                if (*oper->awaymsg) {
-                                       strlcat(tmp, "G" ,9);
+                                       charlcat(tmp, 'G' ,9);
                                } else {
-                                       strlcat(tmp, "H" ,9);
+                                       charlcat(tmp, 'H' ,9);
                                }
                                 WriteServ(user->fd,"352 %s %s %s %s %s %s %s* :0 %s", user->nick, oper->chans.size() && oper->chans[0].channel ? oper->chans[0].channel->name 
                                : "*", oper->ident, oper->dhost, oper->server, oper->nick, tmp, oper->fullname);
@@ -187,4 +187,3 @@ void cmd_who::Handle (char **parameters, int pcnt, userrec *user)
        }
 }
 
-
index eed073a35906dde2068e49a28d31d5b54a0aad00..1ea21426404457ef3a058136a381d2471667ac50 100644 (file)
@@ -1175,7 +1175,7 @@ char* chanmodes(chanrec *chan, bool showkey)
                         std::string extparam = chan->GetModeParameter(chan->custom_modes[z]);
                         if (extparam != "")
                         {
-                                strlcat(sparam," ",MAXBUF);
+                                charlcat(sparam,' ',MAXBUF);
                                 strlcat(sparam,extparam.c_str(),MAXBUF);
                         }
                 }
@@ -1213,7 +1213,7 @@ void userlist(userrec *user,chanrec *c)
                 }
                 strlcat(list,cmode(otheruser,c),MAXBUF);
                 strlcat(list,otheruser->nick,MAXBUF);
-                strlcat(list," ",MAXBUF);
+                charlcat(list,' ',MAXBUF);
                 if (strlen(list)>(480-NICKMAX))
                 {
                         /* list overflowed into
@@ -1567,3 +1567,18 @@ bool IsValidChannelName(const char *chname)
 
                return true;
 }
+
+inline int charlcat(char* x,char y,int z)
+{
+        char* x__n = x;
+        int v = 0;
+        while(*x__n++)
+                v++;
+        if (v < z - 1)
+        {
+                *--x__n = y;
+                *++x__n = 0;
+        }
+       return v;
+}
+