]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/helperfuncs.cpp
GCC doesn't like characters being used in array subscripts
[user/henk/code/inspircd.git] / src / helperfuncs.cpp
index 66a84bbceca06aec9649d2e95e7d1bfacc1316d4..779bc94cc1b48d7340a2a35a10444cd3d896e23b 100644 (file)
@@ -439,3 +439,28 @@ void GenRandomHandler::Call(char *output, size_t max)
        for(unsigned int i=0; i < max; i++)
                output[i] = random();
 }
+
+ModResult OnCheckExemptionHandler::Call(User* user, Channel* chan, const std::string& restriction)
+{
+       unsigned int mypfx = chan->GetPrefixValue(user);
+       char minmode = 0;
+       std::string current;
+
+       irc::spacesepstream defaultstream(ServerInstance->Config->ConfValue("options")->getString("exemptchanops"));
+
+       while (defaultstream.GetToken(current))
+       {
+               std::string::size_type pos = current.find(':');
+               if (pos == std::string::npos)
+                       continue;
+               if (current.substr(0,pos) == restriction)
+                       minmode = current[pos+1];
+       }
+
+       ModeHandler* mh = ServerInstance->Modes->FindMode(minmode, MODETYPE_CHANNEL);
+       if (mh && mypfx >= mh->GetPrefixRank())
+               return MOD_RES_ALLOW;
+       if (mh || minmode == '*')
+               return MOD_RES_DENY;
+       return MOD_RES_PASSTHRU;
+}