1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
17 /* $ModDesc: Regex module using plain wildcard matching. */
18 /* $ModDep: m_regex.h */
20 class GlobRegex : public Regex
23 GlobRegex(const std::string& rx) : Regex(rx)
31 virtual bool Matches(const std::string& text)
33 return InspIRCd::Match(text, this->regex_string);
37 class ModuleRegexGlob : public Module
41 ServerInstance->Modules->PublishInterface("RegularExpression", this);
42 Implementation eventlist[] = { I_OnRequest };
43 ServerInstance->Modules->Attach(eventlist, this, 1);
46 virtual Version GetVersion()
48 return Version("Regex module using plain wildcard matching.", VF_COMMON | VF_VENDOR | VF_SERVICEPROVIDER, API_VERSION);
51 virtual ~ModuleRegexGlob()
53 ServerInstance->Modules->UnpublishInterface("RegularExpression", this);
56 virtual const char* OnRequest(Request* request)
58 if (strcmp("REGEX-NAME", request->GetId()) == 0)
62 else if (strcmp("REGEX", request->GetId()) == 0)
64 RegexFactoryRequest* rfr = (RegexFactoryRequest*)request;
65 std::string rx = rfr->GetRegex();
66 rfr->result = new GlobRegex(rx);
73 MODULE_INIT(ModuleRegexGlob)