From 938e0759c3b9775d1a7751d0e975a1e1f78df979 Mon Sep 17 00:00:00 2001 From: w00t Date: Fri, 23 Dec 2005 08:45:03 +0000 Subject: Hopefully sped things up here -- I need to check this out on a box that I can run ircd on and test. For now, it compiles. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2642 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_blockcolor.cpp | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_blockcolor.cpp b/src/modules/m_blockcolor.cpp index f63caf6c5..6f612f6b2 100644 --- a/src/modules/m_blockcolor.cpp +++ b/src/modules/m_blockcolor.cpp @@ -63,13 +63,26 @@ class ModuleBlockColor : public Module { chanrec* c = (chanrec*)dest; char ctext[MAXBUF]; + char *ctptr = ctext; snprintf(ctext,MAXBUF,"%s",text.c_str()); + + if (c->IsCustomModeSet('c')) { - if ((strchr(ctext,'\2')) || (strchr(ctext,'\3')) || (strchr(ctext,31))) + /* Instead of using strchr() here, do our own loop. Hopefully faster. --w00t */ + while (ctptr && *ctptr) { - WriteServ(user->fd,"404 %s %s :Can't send colors to channel (+c set)",user->nick, c->name); - return 1; + switch (*ctptr) + { + case 2: + case 3: + case 31: + WriteServ(user->fd,"404 %s %s :Can't send colors to channel (+c set)",user->nick, c->name); + return 1; + break; + } + + *ctptr++; } } } @@ -82,13 +95,26 @@ class ModuleBlockColor : public Module { chanrec* c = (chanrec*)dest; char ctext[MAXBUF]; + char *ctptr = ctext; snprintf(ctext,MAXBUF,"%s",text.c_str()); + + if (c->IsCustomModeSet('c')) { - if ((strchr(ctext,'\2')) || (strchr(ctext,'\3')) || (strchr(ctext,31))) + /* Instead of using strchr() here, do our own loop. Hopefully faster. --w00t */ + while (ctptr && *ctptr) { - WriteServ(user->fd,"404 %s %s :Can't send colors to channel (+c set)",user->nick, c->name); - return 1; + switch (*ctptr) + { + case 2: + case 3: + case 31: + WriteServ(user->fd,"404 %s %s :Can't send colors to channel (+c set)",user->nick, c->name); + return 1; + break; + } + + *ctptr++; } } } -- cgit v1.2.3