-/* +------------------------------------+
- * | 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 <danieldg@inspircd.org>
+ * Copyright (C) 2008 Thomas Stagner <aquanight@inspircd.org>
*
- * 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 <http://www.gnu.org/licenses/>.
*/
+
#include "m_regex.h"
#include "inspircd.h"
}
};
-class ModuleRegexGlob : public Module
+class GlobFactory : public RegexFactory
{
-public:
- ModuleRegexGlob() {
- ServerInstance->Modules->PublishInterface("RegularExpression", this);
- }
-
- virtual Version GetVersion()
+ public:
+ Regex* Create(const std::string& expr)
{
- return Version("Regex module using plain wildcard matching.", VF_OPTCOMMON | VF_VENDOR);
+ return new GlobRegex(expr);
}
- virtual ~ModuleRegexGlob()
- {
- ServerInstance->Modules->UnpublishInterface("RegularExpression", this);
+ GlobFactory(Module* m) : RegexFactory(m, "regex/glob") {}
+};
+
+class ModuleRegexGlob : public Module
+{
+ GlobFactory gf;
+public:
+ ModuleRegexGlob() : gf(this) {
+ ServerInstance->Modules->AddService(gf);
}
- void OnRequest(Request& request)
+ Version GetVersion()
{
- if (strcmp("REGEX-NAME", request.id) == 0)
- {
- static_cast<RegexNameRequest&>(request).result = "glob";
- }
- else if (strcmp("REGEX", request.id) == 0)
- {
- RegexFactoryRequest& rfr = (RegexFactoryRequest&)request;
- std::string rx = rfr.GetRegex();
- rfr.result = new GlobRegex(rx);
- }
+ return Version("Regex module using plain wildcard matching.", VF_VENDOR);
}
};