+ /** Checks what users match e:lines and sets their ban exempt flag accordingly.
+ */
+ void CheckELines();
+
+ /** Get all lines of a certain type to an XLineLookup (std::map<std::string, XLine*>).
+ * NOTE: When this function runs any expired items are removed from the list before it
+ * is returned to the caller.
+ * @param The type to look up
+ * @return A list of all XLines of the given type.
+ */
+ XLineLookup* GetAll(const std::string &type);
+
+ /** Return all known types of line currently stored by the XLineManager.
+ * @return A vector containing all known line types currently stored in the main list.
+ */
+ std::vector<std::string> GetAllTypes();
+
+ /** Add a new XLine
+ * @param line The line to be added
+ * @param user The user adding the line or NULL for the local server
+ * @return True if the line was added successfully
+ */
+ bool AddLine(XLine* line, User* user);
+
+ /** Delete an XLine
+ * @param hostmask The xline-specific string identifying the line, e.g. "*@foo"
+ * @param type The type of xline
+ * @param user The user removing the line or NULL if its the local server
+ * @param simulate If this is true, don't actually remove the line, just return
+ * @return True if the line was deleted successfully
+ */
+ bool DelLine(const char* hostmask, const std::string &type, User* user, bool simulate = false);
+
+ /** Registers an xline factory.
+ * An xline factory is a class which when given a particular xline type,
+ * will generate a new XLine specialized to that type. For example if you
+ * pass the XLineFactory that handles glines some data it will return a
+ * pointer to a GLine, polymorphically represented as XLine. This is used where
+ * you do not know the full details of the item you wish to create, e.g. in a
+ * server protocol module like m_spanningtree, when you receive xlines from other
+ * servers.
+ * @param xlf XLineFactory pointer to register
+ */
+ bool RegisterFactory(XLineFactory* xlf);
+
+ /** Unregisters an xline factory.
+ * You must do this when your module unloads.
+ * @param xlf XLineFactory pointer to unregister
+ */
+ bool UnregisterFactory(XLineFactory* xlf);
+
+ /** Get the XLineFactory for a specific type.
+ * Returns NULL if there is no known handler for this xline type.
+ * @param type The type of XLine you require the XLineFactory for
+ */
+ XLineFactory* GetFactory(const std::string &type);
+
+ /** Check if a user matches an XLine
+ * @param type The type of line to look up
+ * @param user The user to match against (what is checked is specific to the xline type)
+ * @return The reason for the line if there is a match, or NULL if there is no match
+ */
+ XLine* MatchesLine(const std::string &type, User* user);
+
+ /** Check if a pattern matches an XLine
+ * @param type The type of line to look up
+ * @param pattern A pattern string specific to the xline type
+ * @return The matching XLine if there is a match, or NULL if there is no match
+ */
+ XLine* MatchesLine(const std::string &type, const std::string &pattern);
+
+ /** Expire a line given two iterators which identify it in the main map.
+ * @param container Iterator to the first level of entries the map
+ * @param item Iterator to the second level of entries in the map
+ */
+ void ExpireLine(ContainerIter container, LookupIter item);
+
+ /** Apply any new lines that are pending to be applied.
+ * This will only apply lines in the pending_lines list, to save on
+ * CPU time.
+ */
+ void ApplyLines();
+
+ /** Handle /STATS for a given type.
+ * NOTE: Any items in the list for this particular line type which have expired
+ * will be expired and removed before the list is displayed.
+ * @param numeric The numeric to give to each result line
+ * @param user The username making the query
+ * @param results The string_list to receive the results
+ */
+ void InvokeStats(const std::string &type, int numeric, User* user, string_list &results);
+};
+
+/** An XLineFactory specialized to generate GLine* pointers
+ */
+class CoreExport GLineFactory : public XLineFactory
+{
+ public:
+ GLineFactory(InspIRCd* Instance) : XLineFactory(Instance, "G") { }
+
+ /** Generate a GLine
+ */
+ 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());
+ }
+};
+
+/** An XLineFactory specialized to generate ELine* pointers
+ */
+class CoreExport ELineFactory : public XLineFactory
+{
+ public:
+ ELineFactory(InspIRCd* Instance) : XLineFactory(Instance, "E") { }
+
+ /** Generate an ELine
+ */
+ 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());
+ }
+};
+
+/** An XLineFactory specialized to generate KLine* pointers
+ */
+class CoreExport KLineFactory : public XLineFactory
+{
+ public:
+ KLineFactory(InspIRCd* Instance) : XLineFactory(Instance, "K") { }
+
+ /** Generate a KLine
+ */
+ 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 KLine(ServerInstance, set_time, duration, source, reason, ih.first.c_str(), ih.second.c_str());
+ }
+};
+
+/** An XLineFactory specialized to generate QLine* pointers
+ */
+class CoreExport QLineFactory : public XLineFactory
+{
+ public:
+ QLineFactory(InspIRCd* Instance) : XLineFactory(Instance, "Q") { }
+
+ /** Generate a QLine
+ */
+ XLine* Generate(time_t set_time, long duration, const char* source, const char* reason, const char* xline_specific_mask)
+ {
+ return new QLine(ServerInstance, set_time, duration, source, reason, xline_specific_mask);
+ }
+};
+
+/** An XLineFactory specialized to generate ZLine* pointers
+ */
+class CoreExport ZLineFactory : public XLineFactory
+{
+ public:
+ ZLineFactory(InspIRCd* Instance) : XLineFactory(Instance, "Z") { }
+
+ /** Generate a ZLine
+ */
+ XLine* Generate(time_t set_time, long duration, const char* source, const char* reason, const char* xline_specific_mask)
+ {
+ return new ZLine(ServerInstance, set_time, duration, source, reason, xline_specific_mask);
+ }
+};