]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_filter.cpp
kick_channel -> chanrec::KickUser(), server_kick_channel -> chanrec::ServerKickUser()
[user/henk/code/inspircd.git] / src / modules / m_filter.cpp
index f1254e3fb748211bc2c3e8a7a2723cb4e1350d7c..1fd3bde927dfcb496a9429bf34bf9bfdb36003b0 100644 (file)
@@ -29,8 +29,9 @@ using namespace std;
 
 /* $ModDesc: An enhanced version of the unreal m_filter.so used by chatspike.net */
 
-class Filter
+class Filter : public classbase
 {
+ public:
        std::string reason;
        std::string action;
 };
@@ -40,7 +41,7 @@ typedef std::map<std::string,Filter*> filter_t;
 class FilterException : public ModuleException
 {
  public:
-       virtual char* GetReason()
+       virtual const char* GetReason()
        {
                return "Could not find <filter file=\"\"> definition in your config file!";
        }
@@ -49,8 +50,7 @@ class FilterException : public ModuleException
 class ModuleFilter : public Module
 {
  Server *Srv;
- ConfigReader *Conf, *MyConf;
- filter_t* filters;
+ filter_t filters;
  
  public:
        ModuleFilter(Server* Me)
@@ -63,13 +63,10 @@ class ModuleFilter : public Module
                // of using a seperate config file is provided.
                Srv = Me;
                OnRehash("");
-               Srv->Log(DEFAULT,std::string("m_filter: read configuration from ")+filterfile);
        }
        
        virtual ~ModuleFilter()
        {
-               delete MyConf;
-               delete Conf;
        }
 
        void Implements(char* List)
@@ -91,7 +88,7 @@ class ModuleFilter : public Module
                {
                        if ((Srv->MatchText(text2,index->first)) || (Srv->MatchText(text,index->first)))
                        {
-                               Filter* f = (Filter*)*x->second;
+                               Filter* f = (Filter*)index->second;
                                std::string target = "";
 
                                if (target_type == TYPE_USER)
@@ -127,14 +124,14 @@ class ModuleFilter : public Module
                return 0;
        }
        
-       virtual void OnRehash(std::string parameter)
+       virtual void OnRehash(const std::string &parameter)
        {
                // reload our config file on rehash - we must destroy and re-allocate the classes
                // to call the constructor again and re-read our data.
-               Conf = new ConfigReader;
+               ConfigReader* Conf = new ConfigReader;
                std::string filterfile = Conf->ReadValue("filter","file",0);
                // this automatically re-reads the configuration file into the class
-               MyConf = new ConfigReader(filterfile);
+               ConfigReader* MyConf = new ConfigReader(filterfile);
                if ((filterfile == "") || (!MyConf->Verify()))
                {
                        // bail if the user forgot to create a config file
@@ -143,7 +140,7 @@ class ModuleFilter : public Module
                }
                for (filter_t::iterator n = filters.begin(); n != filters.end(); n++)
                {
-                       delete n->second;
+                       DELETE(n->second);
                }
                filters.clear();
                for (int index = 0; index < MyConf->Enumerate("keyword"); index++)
@@ -159,8 +156,8 @@ class ModuleFilter : public Module
                        filters[pattern] = x;
                }
                Srv->Log(DEFAULT,std::string("m_filter: read configuration from ")+filterfile);
-               delete Conf;
-               delete MyConf;
+               DELETE(Conf);
+               DELETE(MyConf);
        }
        
        virtual Version GetVersion()