diff options
author | Sadie Powell <sadie@witchery.services> | 2024-01-24 12:01:50 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2024-01-24 12:22:51 +0000 |
commit | 7ac1fe58478d58e2480b6919c4abf3a82929169c (patch) | |
tree | 198ad9a6e23d4c189dce57fd95306b6b22d8c23f /modules/extra/m_regex_posix.cpp | |
parent | 72acef4e159df5dcdb93b3c13b2f9d2e5e4c21a9 (diff) |
Rename several modules to remove the m_ prefix.
Diffstat (limited to 'modules/extra/m_regex_posix.cpp')
-rw-r--r-- | modules/extra/m_regex_posix.cpp | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/modules/extra/m_regex_posix.cpp b/modules/extra/m_regex_posix.cpp deleted file mode 100644 index cef4486f9..000000000 --- a/modules/extra/m_regex_posix.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * - * (C) 2012-2024 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - */ - -#include "module.h" -#include <sys/types.h> -#include <regex.h> - -class POSIXRegex final - : public Regex -{ - regex_t regbuf; - -public: - POSIXRegex(const Anope::string &expr) : Regex(expr) - { - int err = regcomp(&this->regbuf, expr.c_str(), REG_EXTENDED | REG_NOSUB | REG_ICASE); - if (err) - { - char buf[BUFSIZE]; - regerror(err, &this->regbuf, buf, sizeof(buf)); - regfree(&this->regbuf); - throw RegexException("Error in regex " + expr + ": " + buf); - } - } - - ~POSIXRegex() - { - regfree(&this->regbuf); - } - - bool Matches(const Anope::string &str) - { - return regexec(&this->regbuf, str.c_str(), 0, NULL, 0) == 0; - } -}; - -class POSIXRegexProvider final - : public RegexProvider -{ -public: - POSIXRegexProvider(Module *creator) : RegexProvider(creator, "regex/posix") { } - - Regex *Compile(const Anope::string &expression) override - { - return new POSIXRegex(expression); - } -}; - -class ModuleRegexPOSIX final - : public Module -{ - POSIXRegexProvider posix_regex_provider; - -public: - ModuleRegexPOSIX(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), - posix_regex_provider(this) - { - this->SetPermanent(true); - } - - ~ModuleRegexPOSIX() - { - for (auto *xlm : XLineManager::XLineManagers) - { - for (auto *x : xlm->GetList()) - { - if (x->regex && dynamic_cast<POSIXRegex *>(x->regex)) - { - delete x->regex; - x->regex = NULL; - } - } - } - } -}; - -MODULE_INIT(ModuleRegexPOSIX) |