]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/channels.cpp
Fix this up to convert deque to const char* const for w00t
[user/henk/code/inspircd.git] / src / channels.cpp
index 52e8faca9006384fd925f8199bfc614b32f0f81e..6b89883bd11b3b85441825d2c4cb01a8b5c5f294 100644 (file)
@@ -450,6 +450,37 @@ bool Channel::IsBanned(User* user)
        return false;
 }
 
+bool Channel::IsExtBanned(User *user, char type)
+{
+       // XXX. do we need events?
+       char mask[MAXBUF];
+       char *maskptr;
+
+       snprintf(mask, MAXBUF, "%s!%s@%s", user->nick, user->ident, user->GetIPString());
+
+       for (BanList::iterator i = this->bans.begin(); i != this->bans.end(); i++)
+       {
+               if (i->data[0] != type || i->data[1] != ':')
+                       continue;
+
+               // Iterate past char and : to get to the mask without doing a data copy(!)
+               maskptr = i->data;
+               maskptr++; // past the char
+               maskptr++; // past the :
+
+               /* This allows CIDR ban matching
+                * 
+                *        Full masked host                             Full unmasked host                     IP with/without CIDR
+                */
+               if ((match(user->GetFullHost(), maskptr)) || (match(user->GetFullRealHost(), maskptr)) || (match(mask, maskptr, true)))
+               {
+                       return true;
+               }
+       }
+
+       return false;
+}
+
 /* Channel::PartUser
  * remove a channel from a users record, and return the number of users left.
  * Therefore, if this function returns 0 the caller should delete the Channel.
@@ -721,25 +752,9 @@ void Channel::WriteAllExcept(User* user, bool serversource, char status, CUList
 
 void Channel::WriteAllExcept(User* user, bool serversource, char status, CUList &except_list, const std::string &text)
 {
-       CUList *ulist;
+       CUList *ulist = this->GetUsers();
        char tb[MAXBUF];
 
-       switch (status)
-       {
-               case '@':
-                       ulist = this->GetOppedUsers();
-                       break;
-               case '%':
-                       ulist = this->GetHalfoppedUsers();
-                       break;
-               case '+':
-                       ulist = this->GetVoicedUsers();
-                       break;
-               default:
-                       ulist = this->GetUsers();
-                       break;
-       }
-
        snprintf(tb,MAXBUF,":%s %s",user->GetFullHost(),text.c_str());
        std::string out = tb;
 
@@ -747,6 +762,10 @@ void Channel::WriteAllExcept(User* user, bool serversource, char status, CUList
        {
                if ((IS_LOCAL(i->first)) && (except_list.find(i->first) == except_list.end()))
                {
+                       /* User doesnt have the status we're after */
+                       if (status && !strchr(this->GetAllPrefixChars(i->first), status))
+                               continue;
+
                        if (serversource)
                                i->first->WriteServ(text);
                        else