]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Added CullList class
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 15 Dec 2005 10:30:25 +0000 (10:30 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 15 Dec 2005 10:30:25 +0000 (10:30 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2458 e03df62e-2008-0410-955e-edbf42e46eb7

include/cull_list.h [new file with mode: 0644]
src/cull_list.cpp [new file with mode: 0644]
src/xline.cpp

diff --git a/include/cull_list.h b/include/cull_list.h
new file mode 100644 (file)
index 0000000..eb76f37
--- /dev/null
@@ -0,0 +1,54 @@
+/*       +------------------------------------+
+ *       | Inspire Internet Relay Chat Daemon |
+ *       +------------------------------------+
+ *
+ *  Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ *                       E-mail:
+ *                <brain@chatspike.net>
+ *                <Craig@chatspike.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ *            the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+#ifndef __CULLLIST_H__
+#define __CULLLIST_H__
+
+// include the common header files
+
+#include <typeinfo>
+#include <iostream>
+#include <string>
+#include <deque>
+#include <sstream>
+#include <vector>
+#include "users.h"
+#include "channels.h"
+
+class CullItem
+{
+ private:
+        userrec* user;
+        std::string reason;
+ public:
+        CullItem(userrec* u, std::string r);
+        userrec* GetUser();
+        std::string GetReason();
+};
+
+
+class CullList
+{
+ private:
+         std::vector<CullItem> list;
+         char exempt[65535];
+ public:
+         CullList();
+         void AddItem(userrec* user, std::string reason);
+         int Apply();
+};
+
+#endif
diff --git a/src/cull_list.cpp b/src/cull_list.cpp
new file mode 100644 (file)
index 0000000..d931b56
--- /dev/null
@@ -0,0 +1,97 @@
+/*       +------------------------------------+
+ *       | Inspire Internet Relay Chat Daemon |
+ *       +------------------------------------+
+ *
+ *  Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ *                       E-mail:
+ *                <brain@chatspike.net>
+ *                <Craig@chatspike.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ *            the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include "inspircd_util.h"
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/errno.h>
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#include <map>
+#include <sstream>
+#include <vector>
+#include <deque>
+#include "users.h"
+#include "ctables.h"
+#include "globals.h"
+#include "modules.h"
+#include "dynamic.h"
+#include "wildcard.h"
+#include "message.h"
+#include "commands.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "typedefs.h"
+#include "cull_list.h"
+
+CullItem::CullItem(userrec* u, std::string r)
+{
+        this->user = u;
+        this->reason = r;
+}
+
+userrec* CullItem::GetUser()
+{
+        return this->user;
+}
+
+std::string CullItem::GetReason()
+{
+        return this->reason;
+}
+
+CullList::CullList()
+{
+       list.clear();
+        memset(exempt,0,65535);
+}
+
+void CullList::AddItem(userrec* user, std::string reason)
+{
+        if ((user->fd > -1) && (exempt[user->fd] == 0))
+        {
+                CullItem item(user,reason);
+                list.push_back(item);
+                exempt[user->fd] = 1;
+        }
+}
+
+int CullList::Apply()
+{
+        int n = 0;
+        while (list.size())
+        {
+               std::vector<CullItem>::iterator a = list.begin();
+               userrec* u = a->GetUser();
+               std::string reason = a->GetReason();
+               kill_link(u,reason.c_str());
+               list.erase(list.begin());
+               n++;
+        }
+        return n;
+}
index c6c4cd8a91d7161ce7a888903766f805c41d642a..93732fa2ad0adafef5754e02f8d99df19844e6d7 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
+ *  Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
  *                       E-mail:
  *                <brain@chatspike.net>
  *               <Craig@chatspike.net>
@@ -47,6 +47,7 @@ using namespace std;
 #include "helperfuncs.h"
 #include "hashcomp.h"
 #include "typedefs.h"
+#include "cull_list.h"
 
 extern ServerConfig *Config;
 
@@ -642,70 +643,10 @@ void expire_lines()
        
 }
 
-class CullItem
-{
- private:
-       userrec* user;
-       std::string reason;
- public:
-       CullItem(userrec* u, std::string r)
-       {
-               this->user = u;
-               this->reason = r;
-       }
-
-       userrec* GetUser()
-       {
-               return this->user;
-       }
-
-       std::string GetReason()
-       {
-               return this->reason;
-       }
-};
-
-
-class CullList
-{
- private:
-        std::vector<CullItem> list;
-        char exempt[65535];
- public:
-        CullList()
-        {
-                memset(exempt,0,65535);
-                line = ltype;
-        }
-        
-        AddItem(userrec* user, std::string reason)
-        {
-                if ((user->fd > -1) && (exempt[user->fd] == 0))
-                {
-                        CullItem item(user,reason);
-                        list.push_back(item);
-                        exempt[user->fd] = 1;
-                }
-        }
-
-        Apply()
-        {
-                while (list.size())
-                {
-                       std::vector<CullItem>::iterator a = list.begin();
-                       userrec* u = a->GetUser();
-                       std::string reason = a->GetReason();
-                       kill_link(u,reason);
-                       list.erase(list.begin());
-                }
-        }
-}
-
 // applies lines, removing clients and changing nicks etc as applicable
 
 void apply_lines(const int What)
 {
-       bool go_again = true;
        char reason[MAXBUF];
        char host[MAXBUF];