From b3cbd1a15354f593b1c891b870bf7f2f276f74d7 Mon Sep 17 00:00:00 2001 From: aquanight Date: Sat, 20 Sep 2008 23:01:53 +0000 Subject: 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 --- src/modules/extra/m_regex.h | 76 -------------------------------------- src/modules/extra/m_regex_glob.cpp | 67 --------------------------------- src/modules/m_regex.h | 76 ++++++++++++++++++++++++++++++++++++++ src/modules/m_regex_glob.cpp | 67 +++++++++++++++++++++++++++++++++ 4 files changed, 143 insertions(+), 143 deletions(-) delete mode 100644 src/modules/extra/m_regex.h delete mode 100644 src/modules/extra/m_regex_glob.cpp create mode 100644 src/modules/m_regex.h create mode 100644 src/modules/m_regex_glob.cpp diff --git a/src/modules/extra/m_regex.h b/src/modules/extra/m_regex.h deleted file mode 100644 index 50e7a4845..000000000 --- a/src/modules/extra/m_regex.h +++ /dev/null @@ -1,76 +0,0 @@ -/* +------------------------------------+ - * | 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. - * - * --------------------------------------------------- - */ - -#ifndef _M_REGEX_H -#define _M_REGEX_H - -#include "inspircd.h" - -class Regex : public classbase -{ -protected: - std::string regex_string; // The raw uncompiled regex string. - InspIRCd* ServerInstance; - - // Constructor may as well be protected, as this class is abstract. - Regex(const std::string& rx, InspIRCd* Me) : regex_string(rx), ServerInstance(Me) - { - } - -public: - - virtual ~Regex() - { - } - - virtual bool Matches(const std::string& text) = 0; - - const std::string& GetRegexString() const - { - return regex_string; - } -}; - -class RegexFactoryRequest : public Request -{ -private: - std::string regex; - -public: - Regex* result; - - RegexFactoryRequest(Module* Me, Module* Target, const std::string& rx) : Request(Me, Target, "REGEX"), regex(rx), result(NULL) - { - } - - const std::string& GetRegex() const - { - return regex; - } - - Regex* Create() - { - Send(); - return this->result; - } -}; - -class RegexNameRequest : public Request -{ -public: - RegexNameRequest(Module* Me, Module* Target) : Request(Me, Target, "REGEX-NAME") - { - } -}; - -#endif diff --git a/src/modules/extra/m_regex_glob.cpp b/src/modules/extra/m_regex_glob.cpp deleted file mode 100644 index 7977c77f1..000000000 --- a/src/modules/extra/m_regex_glob.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* +------------------------------------+ - * | 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; - } -}; diff --git a/src/modules/m_regex.h b/src/modules/m_regex.h new file mode 100644 index 000000000..50e7a4845 --- /dev/null +++ b/src/modules/m_regex.h @@ -0,0 +1,76 @@ +/* +------------------------------------+ + * | 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. + * + * --------------------------------------------------- + */ + +#ifndef _M_REGEX_H +#define _M_REGEX_H + +#include "inspircd.h" + +class Regex : public classbase +{ +protected: + std::string regex_string; // The raw uncompiled regex string. + InspIRCd* ServerInstance; + + // Constructor may as well be protected, as this class is abstract. + Regex(const std::string& rx, InspIRCd* Me) : regex_string(rx), ServerInstance(Me) + { + } + +public: + + virtual ~Regex() + { + } + + virtual bool Matches(const std::string& text) = 0; + + const std::string& GetRegexString() const + { + return regex_string; + } +}; + +class RegexFactoryRequest : public Request +{ +private: + std::string regex; + +public: + Regex* result; + + RegexFactoryRequest(Module* Me, Module* Target, const std::string& rx) : Request(Me, Target, "REGEX"), regex(rx), result(NULL) + { + } + + const std::string& GetRegex() const + { + return regex; + } + + Regex* Create() + { + Send(); + return this->result; + } +}; + +class RegexNameRequest : public Request +{ +public: + RegexNameRequest(Module* Me, Module* Target) : Request(Me, Target, "REGEX-NAME") + { + } +}; + +#endif 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; + } +}; -- cgit v1.2.3