From 31eaefa6a6244bc1226bacf9b3d9e527f49f035f Mon Sep 17 00:00:00 2001 From: brain Date: Wed, 31 Oct 2007 19:26:26 +0000 Subject: Add factories for eline and gline as tests git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8438 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/xline.h | 46 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) (limited to 'include/xline.h') 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 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 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 line_factory; + GLineFactory* GFact; + ELineFactory* EFact; + public: std::map > 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 -- cgit v1.2.3