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(text, this->regex_string);
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 Version GetVersion()
49 return Version("$Id$", VF_COMMON | VF_VENDOR | VF_SERVICEPROVIDER, API_VERSION);
52 virtual ~ModuleRegexGlob()
54 ServerInstance->Modules->UnpublishInterface("RegularExpression", this);
57 virtual const char* OnRequest(Request* request)
59 if (strcmp("REGEX-NAME", request->GetId()) == 0)
63 else if (strcmp("REGEX", request->GetId()) == 0)
65 RegexFactoryRequest* rfr = (RegexFactoryRequest*)request;
66 std::string rx = rfr->GetRegex();
67 rfr->result = (Regex*)new GlobRegex(rx, ServerInstance);
74 MODULE_INIT(ModuleRegexGlob)