X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fextra%2Fm_regex_posix.cpp;h=4cb1a03d57d5f8ae6f52a8cf92e11637f15f994d;hb=553a8da754c8cd308bad2008018849714e70f9b7;hp=ba653247a48dd262231a727f3b5ed6f8ec1c3b78;hpb=b6dbd6caab62bc2c0d11ce5a45d511611eb9c2ef;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/extra/m_regex_posix.cpp b/src/modules/extra/m_regex_posix.cpp index ba653247a..4cb1a03d5 100644 --- a/src/modules/extra/m_regex_posix.cpp +++ b/src/modules/extra/m_regex_posix.cpp @@ -1,16 +1,23 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ +/* + * InspIRCd -- Internet Relay Chat Daemon * - * InspIRCd: (C) 2002-2009 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits + * Copyright (C) 2009 Daniel De Graaf + * Copyright (C) 2008 Thomas Stagner * - * This program is free but copyrighted software; see - * the file COPYING for details. + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. * - * --------------------------------------------------- + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + #include "inspircd.h" #include "m_regex.h" #include @@ -34,7 +41,7 @@ private: regex_t regbuf; public: - POSIXRegex(const std::string& rx, InspIRCd* Me, bool extended) : Regex(rx, Me) + POSIXRegex(const std::string& rx, bool extended) : Regex(rx) { int flags = (extended ? REG_EXTENDED : 0) | REG_NOSUB; int errcode; @@ -71,49 +78,37 @@ public: } }; -class ModuleRegexPOSIX : public Module +class PosixFactory : public RegexFactory { -private: + public: bool extended; -public: - ModuleRegexPOSIX(InspIRCd* Me) : Module(Me) + PosixFactory(Module* m) : RegexFactory(m, "regex/posix") {} + Regex* Create(const std::string& expr) { - Me->Modules->PublishInterface("RegularExpression", this); - Implementation eventlist[] = { I_OnRequest, I_OnRehash }; - Me->Modules->Attach(eventlist, this, 2); - OnRehash(NULL, ""); - } - - virtual Version GetVersion() - { - return Version("$Id$", VF_COMMON | VF_VENDOR | VF_SERVICEPROVIDER, API_VERSION); + return new POSIXRegex(expr, extended); } +}; - virtual ~ModuleRegexPOSIX() - { - ServerInstance->Modules->UnpublishInterface("RegularExpression", this); +class ModuleRegexPOSIX : public Module +{ + PosixFactory ref; +public: + ModuleRegexPOSIX() : ref(this) { + ServerInstance->Modules->AddService(ref); + Implementation eventlist[] = { I_OnRehash }; + ServerInstance->Modules->Attach(eventlist, this, 1); + OnRehash(NULL); } - virtual void OnRehash(User* u, const std::string& parameter) + Version GetVersion() { - ConfigReader Conf(ServerInstance); - extended = Conf.ReadFlag("posix", "extended", 0); + return Version("Regex Provider Module for POSIX Regular Expressions", VF_VENDOR); } - virtual const char* OnRequest(Request* request) + void OnRehash(User* u) { - if (strcmp("REGEX-NAME", request->GetId()) == 0) - { - return "posix"; - } - else if (strcmp("REGEX", request->GetId()) == 0) - { - RegexFactoryRequest* rfr = (RegexFactoryRequest*)request; - std::string rx = rfr->GetRegex(); - rfr->result = new POSIXRegex(rx, ServerInstance, extended); - return "OK"; - } - return NULL; + ConfigReader Conf; + ref.extended = Conf.ReadFlag("posix", "extended", 0); } };