]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/extra/m_pgsql.cpp
A few more I missed.
[user/henk/code/inspircd.git] / src / modules / extra / m_pgsql.cpp
index b24911bb788542c3f42ff63562c303feb31f798f..5d267fc1acce29f481a414efc7aa3c12ecaa3201 100644 (file)
  * ---------------------------------------------------
  */
 
+#include "inspircd.h"
 #include <cstdlib>
 #include <sstream>
-#include <string>
-#include <deque>
-#include <map>
 #include <libpq-fe.h>
-
 #include "users.h"
 #include "channels.h"
 #include "modules.h"
-#include "inspircd.h"
 #include "configreader.h"
-
 #include "m_sqlv2.h"
 
 /* $ModDesc: PostgreSQL Service Provider module for all other m_sql* modules, uses v2 of the SQL API */
-/* $CompileFlags: -Iexec("pg_config --includedir") eval("my $s = `pg_config --version`;$s =~ /^.*?(\d+)\.(\d+)\.(\d+).*?$/;my $v = hex(sprintf("0x%02x%02x%02x", $1, $2, $3));print "-DPGSQL_HAS_ESCAPECONN" if($v >= 0x080104);") */
+/* $CompileFlags: -Iexec("pg_config --includedir") eval("my $s = `pg_config --version`;$s =~ /^.*?(\d+)\.(\d+)\.(\d+).*?$/;my $v = hex(sprintf("0x%02x%02x%02x", $1, $2, $3));print "-DPGSQL_HAS_ESCAPECONN" if(($v >= 0x080104) || ($v >= 0x07030F && $v < 0x070400) || ($v >= 0x07040D && $v < 0x080000) || ($v >= 0x080008 && $v < 0x080100));") */
 /* $LinkerFlags: -Lexec("pg_config --libdir") -lpq */
 /* $ModDep: m_sqlv2.h */
 
@@ -803,7 +798,6 @@ class ModulePgSQL : public Module
                {
                        SQLhost host;
                        int ipvalid;
-                       insp_inaddr blargle;
 
                        host.id         = conf.ReadValue("database", "id", i);
                        host.host       = conf.ReadValue("database", "hostname", i);
@@ -816,7 +810,18 @@ class ModulePgSQL : public Module
                        if (HasHost(host))
                                continue;
 
-                       ipvalid = insp_aton(host.host.c_str(), &blargle);
+#ifdef IPV6
+                       if (strchr(host.host.c_str(),':'))
+                       {
+                               in6_addr blargle;
+                               ipvalid = inet_pton(AF_INET6, host.host.c_str(), &blargle);
+                       }
+                       else
+#endif
+                       {
+                               in_addr blargle;
+                               ipvalid = inet_aton(host.host.c_str(), &blargle);
+                       }
 
                        if(ipvalid > 0)
                        {
@@ -975,26 +980,5 @@ void SQLConn::DelayReconnect()
        ((ModulePgSQL*)us)->ReconnectConn(this);
 }
 
+MODULE_INIT(ModulePgSQL);
 
-class ModulePgSQLFactory : public ModuleFactory
-{
- public:
-       ModulePgSQLFactory()
-       {
-       }
-
-       ~ModulePgSQLFactory()
-       {
-       }
-
-       virtual Module * CreateModule(InspIRCd* Me)
-       {
-               return new ModulePgSQL(Me);
-       }
-};
-
-
-extern "C" void * init_module( void )
-{
-       return new ModulePgSQLFactory;
-}