X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_regex_glob.cpp;h=57f15f731e9bf39cd8cf0f526dded98de00270dc;hb=f5c631ef8641db6455bed23c02e5a39f63f7d6d0;hp=ef843cc767e07e0ff30150b2fda9c56d852196be;hpb=6d03943426dcce76ba66567a9b18425a5ebb4c0c;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_regex_glob.cpp b/src/modules/m_regex_glob.cpp index ef843cc76..57f15f731 100644 --- a/src/modules/m_regex_glob.cpp +++ b/src/modules/m_regex_glob.cpp @@ -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 @@ -15,7 +15,6 @@ #include "inspircd.h" /* $ModDesc: Regex module using plain wildcard matching. */ -/* $ModDep: m_regex.h */ class GlobRegex : public Regex { @@ -34,39 +33,28 @@ public: } }; -class ModuleRegexGlob : public Module +class GlobFactory : public RegexFactory { -public: - ModuleRegexGlob() { - ServerInstance->Modules->PublishInterface("RegularExpression", this); - Implementation eventlist[] = { I_OnRequest }; - ServerInstance->Modules->Attach(eventlist, this, 1); - } - - virtual Version GetVersion() + public: + Regex* Create(const std::string& expr) { - return Version("Regex module using plain wildcard matching.", VF_COMMON | VF_VENDOR | VF_SERVICEPROVIDER, API_VERSION); + 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); } - 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 = new GlobRegex(rx); - return "OK"; - } - return NULL; + return Version("Regex module using plain wildcard matching.", VF_VENDOR); } };