]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_regex_glob.cpp
Update wiki links to use HTTPS and point to the correct pages.
[user/henk/code/inspircd.git] / src / modules / m_regex_glob.cpp
index a3923205f9321771683372beb739d9282dc79759..44d1a5898c7987091d72fd239b26248c1e02cf12 100644 (file)
@@ -1,16 +1,23 @@
-/*       +------------------------------------+
- *       | Inspire Internet Relay Chat Daemon |
- *       +------------------------------------+
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
  *
- *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
- * See: http://wiki.inspircd.org/Credits
+ *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
+ *   Copyright (C) 2008 Thomas Stagner <aquanight@inspircd.org>
  *
- * This program is free but copyrighted software; see
- *          the file COPYING for details.
+ * This file is part of InspIRCd.  InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
  *
- * ---------------------------------------------------
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+
 #include "m_regex.h"
 #include "inspircd.h"
 
@@ -33,35 +40,28 @@ public:
        }
 };
 
-class ModuleRegexGlob : public Module
+class GlobFactory : public RegexFactory
 {
-public:
-       ModuleRegexGlob()       {
-               ServerInstance->Modules->PublishInterface("RegularExpression", this);
-       }
-
-       virtual Version GetVersion()
+ public:
+       Regex* Create(const std::string& expr)
        {
-               return Version("Regex module using plain wildcard matching.", VF_OPTCOMMON | VF_VENDOR | VF_SERVICEPROVIDER);
+               return new GlobRegex(expr);
        }
 
-       virtual ~ModuleRegexGlob()
-       {
-               ServerInstance->Modules->UnpublishInterface("RegularExpression", this);
+       GlobFactory(Module* m) : RegexFactory(m, "regex/glob") {}
+};
+
+class ModuleRegexGlob : public Module
+{
+       GlobFactory gf;
+public:
+       ModuleRegexGlob() : gf(this) {
+               ServerInstance->Modules->AddService(gf);
        }
 
-       void OnRequest(Request& request)
+       Version GetVersion()
        {
-               if (strcmp("REGEX-NAME", request.id) == 0)
-               {
-                       static_cast<RegexNameRequest&>(request).result = "glob";
-               }
-               else if (strcmp("REGEX", request.id) == 0)
-               {
-                       RegexFactoryRequest& rfr = (RegexFactoryRequest&)request;
-                       std::string rx = rfr.GetRegex();
-                       rfr.result = new GlobRegex(rx);
-               }
+               return Version("Regex module using plain wildcard matching.", VF_VENDOR);
        }
 };