]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_regex_glob.cpp
Merge commit 'refs/merge-requests/5' of git://gitorious.org/inspircd/inspircd into...
[user/henk/code/inspircd.git] / src / modules / m_regex_glob.cpp
index 8d7eaafc3b2cda9ab2c05f5401efe9d015891dfa..57f15f731e9bf39cd8cf0f526dded98de00270dc 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2010 InspIRCd Development Team
  * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
 #include "inspircd.h"
 
 /* $ModDesc: Regex module using plain wildcard matching. */
-/* $ModDep: m_regex.h */
 
 class GlobRegex : public Regex
 {
 public:
-       GlobRegex(const std::string& rx, InspIRCd* Me) : Regex(rx, Me)
+       GlobRegex(const std::string& rx) : Regex(rx)
        {
        }
 
@@ -34,40 +33,28 @@ public:
        }
 };
 
-class ModuleRegexGlob : public Module
+class GlobFactory : public RegexFactory
 {
-public:
-       ModuleRegexGlob(InspIRCd* Me) : Module(Me)
+ public:
+       Regex* Create(const std::string& expr)
        {
-               Me->Modules->PublishInterface("RegularExpression", this);
-               Implementation eventlist[] = { I_OnRequest };
-               Me->Modules->Attach(eventlist, this, 1);
+               return new GlobRegex(expr);
        }
 
-       virtual Version GetVersion()
-       {
-               return Version("Regex module using plain wildcard matching.", VF_COMMON | VF_VENDOR | VF_SERVICEPROVIDER, API_VERSION);
-       }
+       GlobFactory(Module* m) : RegexFactory(m, "regex/glob") {}
+};
 
-       virtual ~ModuleRegexGlob()
-       {
-               ServerInstance->Modules->UnpublishInterface("RegularExpression", this);
+class ModuleRegexGlob : public Module
+{
+       GlobFactory gf;
+public:
+       ModuleRegexGlob() : gf(this) {
+               ServerInstance->Modules->AddService(gf);
        }
 
-       virtual const char* OnRequest(Request* request)
+       Version GetVersion()
        {
-               if (strcmp("REGEX-NAME", request->GetId()) == 0)
-               {
-                       return "glob";
-               }
-               else if (strcmp("REGEX", request->GetId()) == 0)
-               {
-                       RegexFactoryRequest* rfr = (RegexFactoryRequest*)request;
-                       std::string rx = rfr->GetRegex();
-                       rfr->result = (Regex*)new GlobRegex(rx, ServerInstance);
-                       return "OK";
-               }
-               return NULL;
+               return Version("Regex module using plain wildcard matching.", VF_VENDOR);
        }
 };