summaryrefslogtreecommitdiff
path: root/src/helperfuncs.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-03-02 11:45:38 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-03-02 11:45:38 +0000
commit99f6009b2d0d1bc4b7ddc09f164fc19b78e6b431 (patch)
tree0e730986a55816e53ff990d1af443e5883982fec /src/helperfuncs.cpp
parent21a1aec26cfa93e468912080c60d92c4d43b0f0c (diff)
Added charlcat which appends a single char to a char* string (range checked)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3416 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/helperfuncs.cpp')
-rw-r--r--src/helperfuncs.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index eed073a35..1ea214264 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -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;
+}
+