]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/extra/m_geoip.cpp
m_ssl_openssl Remove bogus errno assignment from CloseSession()
[user/henk/code/inspircd.git] / src / modules / extra / m_geoip.cpp
index cf87de51e252a2ea17339845eb1221747c8ad5e1..a36c39bc83cd3e6d078d311b4a11313df543a44f 100644 (file)
@@ -23,7 +23,7 @@
 
 #include <GeoIP.h>
 
-#ifdef WINDOWS
+#ifdef _WIN32
 # pragma comment(lib, "GeoIP.lib")
 #endif
 
@@ -35,7 +35,7 @@ class ModuleGeoIP : public Module
        LocalStringExt ext;
        GeoIP* gi;
 
-       void SetExt(LocalUser* user)
+       std::string* SetExt(LocalUser* user)
        {
                const char* c = GeoIP_country_code_by_addr(gi, user->GetIPString());
                if (!c)
@@ -43,6 +43,7 @@ class ModuleGeoIP : public Module
 
                std::string* cc = new std::string(c);
                ext.set(user, cc);
+               return cc;
        }
 
  public:
@@ -58,9 +59,9 @@ class ModuleGeoIP : public Module
 
                ServerInstance->Modules->AddService(ext);
                Implementation eventlist[] = { I_OnSetConnectClass, I_OnStats };
-               ServerInstance->Modules->Attach(eventlist, this, 2);
+               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
 
-               for (std::vector<LocalUser*>::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); ++i)
+               for (LocalUserList::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); ++i)
                {
                        LocalUser* user = *i;
                        if ((user->registered == REG_ALL) && (!ext.get(user)))
@@ -85,7 +86,7 @@ class ModuleGeoIP : public Module
        {
                std::string* cc = ext.get(user);
                if (!cc)
-                       SetExt(user);
+                       cc = SetExt(user);
 
                std::string geoip = myclass->config->getString("geoip");
                if (geoip.empty())
@@ -105,7 +106,7 @@ class ModuleGeoIP : public Module
 
                unsigned int unknown = 0;
                std::map<std::string, unsigned int> results;
-               for (std::vector<LocalUser*>::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); ++i)
+               for (LocalUserList::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); ++i)
                {
                        std::string* cc = ext.get(*i);
                        if (cc)