summaryrefslogtreecommitdiff
path: root/src/modules/m_regex_glob.cpp
diff options
context:
space:
mode:
authoraquanight <aquanight@e03df62e-2008-0410-955e-edbf42e46eb7>2008-09-20 23:01:53 +0000
committeraquanight <aquanight@e03df62e-2008-0410-955e-edbf42e46eb7>2008-09-20 23:01:53 +0000
commitb3cbd1a15354f593b1c891b870bf7f2f276f74d7 (patch)
treeb21dc145751245465b604563bdf3d336bbc06de0 /src/modules/m_regex_glob.cpp
parentdf91e30723c9cfb91ff0c7f6506fe67ef4909b89 (diff)
Move m_regex.h and m_regex_glob.cpp to main modules directory, as these have no requirements.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10571 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_regex_glob.cpp')
-rw-r--r--src/modules/m_regex_glob.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/modules/m_regex_glob.cpp b/src/modules/m_regex_glob.cpp
new file mode 100644
index 000000000..7977c77f1
--- /dev/null
+++ b/src/modules/m_regex_glob.cpp
@@ -0,0 +1,67 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * InspIRCd: (C) 2002-2008 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
+ *
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+#include "m_regex.h"
+#include "inspircd.h"
+
+/* $ModDesc: Regex module using plain wildcard matching. */
+/* $ModDep: m_regex.h */
+
+class GlobRegex : public Regex
+{
+public:
+ GlobRegex(const std::string& rx, InspIRCd* Me) : Regex(rx, Me)
+ {
+ }
+
+ virtual ~GlobRegex()
+ {
+ }
+
+ virtual bool Matches(const std::string& text)
+ {
+ return InspIRCd::Match(this->regex_string, text);
+ }
+};
+
+class ModuleRegexGlob : public Module
+{
+public:
+ ModuleRegexGlob(InspIRCd* Me) : Module(Me)
+ {
+ Me->Modules->PublishInterface("RegularExpression", this);
+ Implementation eventlist[] = { I_OnRequest };
+ Me->Modules->Attach(eventlist, this, 1);
+ }
+
+ virtual ~ModuleRegexGlob()
+ {
+ ServerInstance->Modules->UnpublishInterface("RegularExpression", this);
+ }
+
+ virtual const char* OnRequest(Request* request)
+ {
+ 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 = (Regex*)new GlobRegex(rx, ServerInstance);
+ return "OK";
+ }
+ return NULL;
+ }
+};