1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/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, InspIRCd* Me) : Regex(rx, Me)
31 virtual bool Matches(const std::string& text)
33 return InspIRCd::Match(this->regex_string, text);
37 class ModuleRegexGlob : public Module
40 ModuleRegexGlob(InspIRCd* Me) : Module(Me)
42 Me->Modules->PublishInterface("RegularExpression", this);
43 Implementation eventlist[] = { I_OnRequest };
44 Me->Modules->Attach(eventlist, this, 1);
47 virtual ~ModuleRegexGlob()
49 ServerInstance->Modules->UnpublishInterface("RegularExpression", this);
52 virtual const char* OnRequest(Request* request)
54 if (strcmp("REGEX-NAME", request->GetId()) == 0)
58 else if (strcmp("REGEX", request->GetId()) == 0)
60 RegexFactoryRequest* rfr = (RegexFactoryRequest*)request;
61 std::string rx = rfr->GetRegex();
62 Regex* rxo = (Regex*)new GlobRegex(rx, ServerInstance); // Cast to base class first, since theoretically the pointer could change by that.
63 return (const char*)(rxo);