]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_regex_glob.cpp
Specify regex engine in m_filter/m_rline CAPAB line instead of marking m_regex_*...
[user/henk/code/inspircd.git] / src / modules / m_regex_glob.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2010 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/Credits
7  *
8  * This program is free but copyrighted software; see
9  *          the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "m_regex.h"
15 #include "inspircd.h"
16
17 /* $ModDesc: Regex module using plain wildcard matching. */
18
19 class GlobRegex : public Regex
20 {
21 public:
22         GlobRegex(const std::string& rx) : Regex(rx)
23         {
24         }
25
26         virtual ~GlobRegex()
27         {
28         }
29
30         virtual bool Matches(const std::string& text)
31         {
32                 return InspIRCd::Match(text, this->regex_string);
33         }
34 };
35
36 class GlobFactory : public RegexFactory
37 {
38  public:
39         Regex* Create(const std::string& expr)
40         {
41                 return new GlobRegex(expr);
42         }
43
44         GlobFactory(Module* m) : RegexFactory(m, "regex/glob") {}
45 };
46
47 class ModuleRegexGlob : public Module
48 {
49         GlobFactory gf;
50 public:
51         ModuleRegexGlob() : gf(this) {
52                 ServerInstance->Modules->AddService(gf);
53         }
54
55         Version GetVersion()
56         {
57                 return Version("Regex module using plain wildcard matching.", VF_VENDOR);
58         }
59 };
60
61 MODULE_INIT(ModuleRegexGlob)