]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_banexception.cpp
Make User:: nick/ident/dhost/fullname and some other things std::string instead of...
[user/henk/code/inspircd.git] / src / modules / m_banexception.cpp
index 4c0e93deabfbe77bd7839e639616053703313059..d90cbff2959eb90782d90784c9f05f3494409514 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
  * See: http://www.inspircd.org/wiki/index.php/Credits
  *
  * This program is free but copyrighted software; see
@@ -32,7 +32,7 @@
 class BanException : public ListModeBase
 {
  public:
-       BanException(InspIRCd* Instance) : ListModeBase(Instance, 'e', "End of Channel Exception List", "348", "349", true) { }
+       BanException(InspIRCd* Instance) : ListModeBase(Instance, 'e', "End of Channel Exception List", 348, 349, true) { }
 };
 
 
@@ -42,19 +42,17 @@ class ModuleBanException : public Module
        
 
 public:
-       ModuleBanException(InspIRCd* Me)
-       : Module(Me)
+       ModuleBanException(InspIRCd* Me) : Module(Me)
        {
                be = new BanException(ServerInstance);
-               if (!ServerInstance->AddMode(be, 'e'))
+               if (!ServerInstance->Modes->AddMode(be))
                        throw ModuleException("Could not add new modes!");
                ServerInstance->Modules->PublishInterface("ChannelBanList", this);
-       }
-       
-       virtual void Implements(char* List)
-       {
-               be->DoImplements(List);
-               List[I_OnRehash] = List[I_OnRequest] = List[I_On005Numeric] = List[I_OnCheckBan] = 1;
+
+               be->DoImplements(this);
+               Implementation list[] = { I_OnRehash, I_OnRequest, I_On005Numeric, I_OnCheckBan };
+               Me->Modules->Attach(list, this, 4);
+
        }
        
        virtual void On005Numeric(std::string &output)
@@ -69,21 +67,21 @@ public:
                        modelist* list;
                        chan->GetExt(be->GetInfoKey(), list);
                        
-                       if (list)
+                       if (!list)
                        {
-                               char mask[MAXBUF];
-                               snprintf(mask, MAXBUF, "%s!%s@%s", user->nick, user->ident, user->GetIPString());
-                               for (modelist::iterator it = list->begin(); it != list->end(); it++)
+                               // No list, proceed normally
+                               return 0;
+                       }
+
+                       std::string mask = std::string(user->nick) + "!" + user->ident + "@" + user->GetIPString();
+                       for (modelist::iterator it = list->begin(); it != list->end(); it++)
+                       {
+                               if (match(user->GetFullRealHost(), it->mask) || match(user->GetFullHost(), it->mask) || (match(mask, it->mask, true)))
                                {
-                                       if (match(user->GetFullRealHost(), it->mask.c_str()) || match(user->GetFullHost(), it->mask.c_str()) || (match(mask, it->mask.c_str(), true)))
-                                       {
-                                               // They match an entry on the list, so let them in.
-                                               return 1;
-                                       }
+                                       // They match an entry on the list, so let them in.
+                                       return 1;
                                }
-                               return 0;
                        }
-                       // or if there wasn't a list, there can't be anyone on it, so we don't need to do anything.
                }
                return 0;       
        }
@@ -108,7 +106,7 @@ public:
                be->DoRehash();
        }
 
-       virtual char* OnRequest(Request* request)
+       virtual const char* OnRequest(Request* request)
        {
                ListModeRequest* LM = (ListModeRequest*)request;
                if (strcmp("LM_CHECKLIST", request->GetId()) == 0)
@@ -117,11 +115,10 @@ public:
                        LM->chan->GetExt(be->GetInfoKey(), list);
                        if (list)
                        {
-                               char mask[MAXBUF];
-                               snprintf(mask, MAXBUF, "%s!%s@%s", LM->user->nick, LM->user->ident, LM->user->GetIPString());
+                               std::string mask = std::string(LM->user->nick) + "!" + LM->user->ident + "@" + LM->user->GetIPString();
                                for (modelist::iterator it = list->begin(); it != list->end(); it++)
                                {
-                                       if (match(LM->user->GetFullRealHost(), it->mask.c_str()) || match(LM->user->GetFullHost(), it->mask.c_str()) || (match(mask, it->mask.c_str(), true)))
+                                       if (match(LM->user->GetFullRealHost(), it->mask) || match(LM->user->GetFullHost(), it->mask) || (match(mask, it->mask, true)))
                                        {
                                                // They match an entry
                                                return (char*)it->mask.c_str();
@@ -135,7 +132,7 @@ public:
 
        virtual Version GetVersion()
        {
-               return Version(1, 1, 0, 3, VF_COMMON | VF_VENDOR, API_VERSION);
+               return Version(1, 2, 0, 3, VF_COMMON | VF_VENDOR, API_VERSION);
        }
        
        virtual ~ModuleBanException()