diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-10-31 19:26:26 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-10-31 19:26:26 +0000 |
commit | 31eaefa6a6244bc1226bacf9b3d9e527f49f035f (patch) | |
tree | b26a353635e60b820c0b8ce57bd7bbcf1fb1d048 | |
parent | dcd26f6b564ade8fa51f1adb972c4e1fb5f234c7 (diff) |
Add factories for eline and gline as tests
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8438 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | include/xline.h | 46 | ||||
-rw-r--r-- | src/xline.cpp | 14 |
2 files changed, 54 insertions, 6 deletions
diff --git a/include/xline.h b/include/xline.h index a94161738..edde8d91a 100644 --- a/include/xline.h +++ b/include/xline.h @@ -343,16 +343,21 @@ class CoreExport QLine : public XLine char* nick; }; -class XLineFactory +/** Contains an ident and host split into two strings + */ +typedef std::pair<std::string, std::string> IdentHostPair; + + +class CoreExport XLineFactory { protected: - const char type; InspIRCd* ServerInstance; + const char type; public: - XLineFactory(const char t) : type(t) { } + XLineFactory(InspIRCd* Instance, const char t) : ServerInstance(Instance), type(t) { } virtual const char GetType() { return type; } @@ -366,9 +371,8 @@ class XLineFactory class ServerConfig; class InspIRCd; -/** Contains an ident and host split into two strings - */ -typedef std::pair<std::string, std::string> IdentHostPair; +class GLineFactory; +class ELineFactory; /** XLineManager is a class used to manage glines, klines, elines, zlines and qlines. */ @@ -391,6 +395,9 @@ class CoreExport XLineManager std::map<char, XLineFactory*> line_factory; + GLineFactory* GFact; + ELineFactory* EFact; + public: std::map<char, std::map<std::string, XLine *> > lookup_lines; @@ -400,6 +407,8 @@ class CoreExport XLineManager */ XLineManager(InspIRCd* Instance); + ~XLineManager(); + /** Split an ident and host into two seperate strings. * This allows for faster matching. */ @@ -540,5 +549,30 @@ class CoreExport XLineManager void eline_set_creation_time(const char* host, time_t create_time); }; +class CoreExport GLineFactory : public XLineFactory +{ + public: + GLineFactory(InspIRCd* Instance) : XLineFactory(Instance, 'G') { } + + XLine* Generate(time_t set_time, long duration, const char* source, const char* reason, const char* xline_specific_mask) + { + IdentHostPair ih = ServerInstance->XLines->IdentSplit(xline_specific_mask); + return new GLine(ServerInstance, set_time, duration, source, reason, ih.first.c_str(), ih.second.c_str()); + } +}; + +class CoreExport ELineFactory : public XLineFactory +{ + public: + ELineFactory(InspIRCd* Instance) : XLineFactory(Instance, 'E') { } + + XLine* Generate(time_t set_time, long duration, const char* source, const char* reason, const char* xline_specific_mask) + { + IdentHostPair ih = ServerInstance->XLines->IdentSplit(xline_specific_mask); + return new ELine(ServerInstance, set_time, duration, source, reason, ih.first.c_str(), ih.second.c_str()); + } +}; + + #endif diff --git a/src/xline.cpp b/src/xline.cpp index b970ad9e7..a853eb35f 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -422,6 +422,20 @@ void XLineManager::stats_e(User* user, string_list &results) XLineManager::XLineManager(InspIRCd* Instance) : ServerInstance(Instance) { + GFact = new GLineFactory(Instance); + EFact = new ELineFactory(Instance); + + RegisterFactory(GFact); + RegisterFactory(EFact); +} + +XLineManager::~XLineManager() +{ + UnregisterFactory(GFact); + UnregisterFactory(EFact); + + delete GFact; + delete EFact; } void XLine::Apply(User* u) |