]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/inspircd.cpp
More stuff for allowing hostnames in <bind> and <link> again - note there is a FIXME...
[user/henk/code/inspircd.git] / src / inspircd.cpp
index fd164000a3eff82ddc601d4c4d07bf7e65fec033..77c2c72b380b682b5519db2ad62c3e8e656bfd5e 100644 (file)
@@ -1,27 +1,40 @@
-/*       +------------------------------------+
- *       | Inspire Internet Relay Chat Daemon |
- *       +------------------------------------+
+/* ---------------------------------------------------------------------
+ * 
+ *              +------------------------------------+
+ *              | Inspire Internet Relay Chat Daemon |
+ *              +------------------------------------+
  *
- *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
- *                       E-mail:
- *                <brain@chatspike.net>
- *               <Craig@chatspike.net>
+ *         InspIRCd is copyright (C) 2002-2006 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.
+ *  Written by Craig Edwards, Craig McLure, and others.
+ *  This program is free but copyrighted software; you can redistribute
+ *  it and/or modify it under the terms of the GNU General Public
+ *  License as published by the Free Software Foundation, version 2
+ *  (two) ONLY.
  *
- * ---------------------------------------------------
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * ---------------------------------------------------------------------
  */
 
-/* Now with added unF! ;) */
-
+#include <algorithm>
 #include "inspircd_config.h"
 #include "inspircd.h"
 #include "configreader.h"
 #include <fcntl.h>
 #include <sys/errno.h>
 #include <sys/ioctl.h>
+#include <signal.h>
 #include <time.h>
 #include <string>
 #include <exception>
@@ -60,8 +73,8 @@ InspIRCd* ServerInstance;
 int WHOWAS_STALE = 48; // default WHOWAS Entries last 2 days before they go 'stale'
 int WHOWAS_MAX = 100;  // default 100 people maximum in the WHOWAS list
 
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
+extern ModuleList modules;
+extern FactoryList factory;
 
 std::vector<InspSocket*> module_sockets;
 std::vector<userrec*> local_users;
@@ -94,36 +107,30 @@ chan_hash chanlist;
 servernamelist servernames;
 char lowermap[255];
 
-void AddServerName(std::string servername)
+void AddServerName(const std::string &servername)
 {
        log(DEBUG,"Adding server name: %s",servername.c_str());
-       for (servernamelist::iterator a = servernames.begin(); a < servernames.end(); a++)
-       {
-               if (*a == servername)
-                       return;
-       }
-       servernames.push_back(servername);
+       
+       if(find(servernames.begin(), servernames.end(), servername) == servernames.end())
+               servernames.push_back(servername); /* Wasn't already there. */
 }
 
-const char* FindServerNamePtr(std::string servername)
+const char* FindServerNamePtr(const std::string &servername)
 {
-       for (servernamelist::iterator a = servernames.begin(); a < servernames.end(); a++)
-       {
-               if (*a == servername)
-                       return a->c_str();
+       servernamelist::iterator iter = find(servernames.begin(), servernames.end(), servername);
+       
+       if(iter == servernames.end())
+       {               
+               AddServerName(servername);
+               iter = --servernames.end();
        }
-       AddServerName(servername);
-       return FindServerNamePtr(servername);
+
+       return iter->c_str();
 }
 
-bool FindServerName(std::string servername)
+bool FindServerName(const std::string &servername)
 {
-       for (servernamelist::iterator a = servernames.begin(); a < servernames.end(); a++)
-       {
-               if (*a == servername)
-                       return true;
-       }
-       return false;
+       return (find(servernames.begin(), servernames.end(), servername) != servernames.end());
 }
 
 void Exit(int status)
@@ -376,7 +383,7 @@ void InspIRCd::erase_module(int j)
        {
                if (v1 == j)
                {
-                       delete *m;
+                       DELETE(*m);
                        modules.erase(m);
                        modules.push_back(NULL);
                        break;
@@ -821,7 +828,7 @@ void InspIRCd::DoOneIteration(bool process_module_sockets)
                                                }
                                        }
                                        s->Close();
-                                       delete s;
+                                       DELETE(s);
                                }
                                else if (!s)
                                {
@@ -951,7 +958,7 @@ int main(int argc, char** argv)
        {
                ServerInstance = new InspIRCd(argc, argv);
                ServerInstance->Run();
-               delete ServerInstance;
+               DELETE(ServerInstance);
        }
        catch (std::bad_alloc)
        {