diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-11 08:21:54 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-11 08:21:54 +0000 |
commit | 0b29e01eb5169f5e547b87c32de8e452ba3eff17 (patch) | |
tree | c6486be0eb375ff34edb806472c75b9e00a2fc57 /src | |
parent | fa784b557d4d6862e9a105be60b5efedfb03c271 (diff) |
Somehow, i'd cp'd all these and was making local changes :/
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4868 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/extra/m_mysql.cpp | 32 | ||||
-rw-r--r-- | src/modules/extra/m_pgsql.cpp | 27 | ||||
-rw-r--r-- | src/modules/extra/m_sqlutils.cpp | 4 | ||||
-rw-r--r-- | src/modules/extra/m_ssl_gnutls.cpp | 10 | ||||
-rw-r--r-- | src/modules/extra/m_ssl_openssl.cpp | 10 | ||||
-rw-r--r-- | src/modules/extra/m_testclient.cpp | 4 |
6 files changed, 44 insertions, 43 deletions
diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index f7738d5cf..b539f6327 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -71,7 +71,7 @@ using namespace std; class SQLConnection; class Notifier; -extern InspIRCd* ServerInstance; + typedef std::map<std::string, SQLConnection*> ConnMap; bool giveup = false; static Module* SQLModule = NULL; @@ -596,7 +596,7 @@ class SQLConnection : public classbase ConnMap Connections; -void ConnectDatabases(Server* Srv) +void ConnectDatabases(InspIRCd* ServerInstance) { for (ConnMap::iterator i = Connections.begin(); i != Connections.end(); i++) { @@ -614,7 +614,7 @@ void ConnectDatabases(Server* Srv) } -void LoadDatabases(ConfigReader* ThisConf, Server* Srv) +void LoadDatabases(ConfigReader* ThisConf, InspIRCd* ServerInstance) { log(DEFAULT,"SQL: Loading database settings"); Connections.clear(); @@ -635,7 +635,7 @@ void LoadDatabases(ConfigReader* ThisConf, Server* Srv) log(DEBUG,"Pushed back connection"); } } - ConnectDatabases(Srv); + ConnectDatabases(ServerInstance); } void NotifyMainThread(SQLConnection* connection_with_new_result) @@ -663,15 +663,15 @@ class Notifier : public InspSocket { insp_sockaddr sock_us; socklen_t uslen; - Server* Srv; + public: /* Create a socket on a random port. Let the tcp stack allocate us an available port */ #ifdef IPV6 - Notifier(InspIRCd* SI, Server* S) : InspSocket(SI, "::1", 0, true, 3000), Srv(S) + Notifier(InspIRCd* SI) : InspSocket(SI, "::1", 0, true, 3000) #else - Notifier(InspIRCd* SI, Server* S) : InspSocket(SI, "127.0.0.1", 0, true, 3000), Srv(S) + Notifier(InspIRCd* SI) : InspSocket(SI, "127.0.0.1", 0, true, 3000) #endif { uslen = sizeof(sock_us); @@ -681,7 +681,7 @@ class Notifier : public InspSocket } } - Notifier(InspIRCd* SI, int newfd, char* ip, Server* S) : InspSocket(SI, newfd, ip), Srv(S) + Notifier(InspIRCd* SI, int newfd, char* ip) : InspSocket(SI, newfd, ip) { log(DEBUG,"Constructor of new socket"); } @@ -699,8 +699,8 @@ class Notifier : public InspSocket virtual int OnIncomingConnection(int newsock, char* ip) { log(DEBUG,"Inbound connection on fd %d!",newsock); - Notifier* n = new Notifier(this->Instance, newsock, ip, Srv); - Srv->AddSocket(n); + Notifier* n = new Notifier(this->Instance, newsock, ip); + this->Instance->AddSocket(n); return true; } @@ -735,8 +735,9 @@ class Notifier : public InspSocket class ModuleSQL : public Module { public: - Server *Srv; + ConfigReader *Conf; + InspIRCd* PublicServerInstance; pthread_t Dispatcher; int currid; @@ -793,12 +794,13 @@ class ModuleSQL : public Module : Module::Module(Me) { - Conf = new ConfigReader(); + Conf = new ConfigReader(ServerInstance); + PublicServerInstance = ServerInstance; currid = 0; SQLModule = this; - MessagePipe = new Notifier(ServerInstance, Srv); - Srv->AddSocket(MessagePipe); + MessagePipe = new Notifier(ServerInstance); + ServerInstance->AddSocket(MessagePipe); log(DEBUG,"Bound notifier to 127.0.0.1:%d",MessagePipe->GetPort()); pthread_attr_t attribs; @@ -837,7 +839,7 @@ void* DispatcherThread(void* arg) { log(DEBUG,"Starting Dispatcher thread, mysql version %d",mysql_get_client_version()); ModuleSQL* thismodule = (ModuleSQL*)arg; - LoadDatabases(thismodule->Conf, thismodule->Srv); + LoadDatabases(thismodule->Conf, thismodule->PublicServerInstance); /* Connect back to the Notifier */ diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp index 41582fefb..d30e826e5 100644 --- a/src/modules/extra/m_pgsql.cpp +++ b/src/modules/extra/m_pgsql.cpp @@ -43,7 +43,7 @@ * reimplementing them I need this so * I can access the socket engine :\ */ -extern InspIRCd* ServerInstance; + extern time_t TIME; /* Forward declare, so we can have the typedef neatly at the top */ @@ -95,8 +95,8 @@ class SQLresolver : public Resolver SQLhost host; ModulePgSQL* mod; public: - SQLresolver(ModulePgSQL* m, Server* srv, const SQLhost& hi) - : Resolver(ServerInstance, hi.host, DNS_QUERY_FORWARD), host(hi), mod(m) + SQLresolver(ModulePgSQL* m, InspIRCd* Instance, const SQLhost& hi) + : Resolver(Instance, hi.host, DNS_QUERY_FORWARD), host(hi), mod(m) { } @@ -456,7 +456,6 @@ class SQLConn : public InspSocket { private: ModulePgSQL* us; /* Pointer to the SQL provider itself */ - Server* Srv; /* Server* for..uhm..something, maybe */ std::string dbhost; /* Database server hostname */ unsigned int dbport; /* Database server port */ std::string dbname; /* Database name */ @@ -473,7 +472,7 @@ public: /* This class should only ever be created inside this module, using this constructor, so we don't have to worry about the default ones */ - SQLConn(InspIRCd* SI, ModulePgSQL* self, Server* srv, const SQLhost& hostinfo); + SQLConn(InspIRCd* SI, ModulePgSQL* self, const SQLhost& hostinfo); ~SQLConn(); @@ -513,7 +512,7 @@ public: class ModulePgSQL : public Module { private: - Server* Srv; + ConnMap connections; unsigned long currid; char* sqlsuccess; @@ -538,7 +537,7 @@ public: virtual void OnRehash(const std::string ¶meter) { - ConfigReader conf; + ConfigReader conf(ServerInstance); /* Delete all the SQLConn objects in the connection lists, * this will call their destructors where they can handle @@ -578,9 +577,9 @@ public: /* Conversion failed, assume it's a host */ SQLresolver* resolver; - resolver = new SQLresolver(this, Srv, host); + resolver = new SQLresolver(this, ServerInstance, host); - Srv->AddResolver(resolver); + ServerInstance->AddResolver(resolver); } else { @@ -595,7 +594,7 @@ public: SQLConn* newconn; /* The conversion succeeded, we were given an IP and we can give it straight to SQLConn */ - newconn = new SQLConn(ServerInstance, this, Srv, hi); + newconn = new SQLConn(ServerInstance, this, hi); connections.insert(std::make_pair(hi.id, newconn)); } @@ -662,8 +661,8 @@ public: } }; -SQLConn::SQLConn(InspIRCd* SI, ModulePgSQL* self, Server* srv, const SQLhost& hi) -: InspSocket::InspSocket(SI), us(self), Srv(srv), dbhost(hi.host), dbport(hi.port), dbname(hi.name), dbuser(hi.user), dbpass(hi.pass), ssl(hi.ssl), sql(NULL), status(CWRITE), qinprog(false) +SQLConn::SQLConn(InspIRCd* SI, ModulePgSQL* self, const SQLhost& hi) +: InspSocket::InspSocket(SI), us(self), dbhost(hi.host), dbport(hi.port), dbname(hi.name), dbuser(hi.user), dbpass(hi.pass), ssl(hi.ssl), sql(NULL), status(CWRITE), qinprog(false) { log(DEBUG, "Creating new PgSQL connection to database %s on %s:%u (%s/%s)", dbname.c_str(), dbhost.c_str(), dbport, dbuser.c_str(), dbpass.c_str()); @@ -734,13 +733,13 @@ bool SQLConn::DoConnect() } this->state = I_CONNECTING; - if (!ServerInstance->SE->AddFd(this->fd,false,X_ESTAB_MODULE)) + if (!this->Instance->SE->AddFd(this->fd,false,X_ESTAB_MODULE)) { log(DEBUG, "A PQsocket cant be added to the socket engine!"); Close(); return false; } - Instance->socket_ref[this->fd] = this; + this->Instance->socket_ref[this->fd] = this; /* Socket all hooked into the engine, now to tell PgSQL to start connecting */ diff --git a/src/modules/extra/m_sqlutils.cpp b/src/modules/extra/m_sqlutils.cpp index 6ce57db45..ee9ebf8b4 100644 --- a/src/modules/extra/m_sqlutils.cpp +++ b/src/modules/extra/m_sqlutils.cpp @@ -31,7 +31,7 @@ /* $ModDesc: Provides some utilities to SQL client modules, such as mapping queries to users and channels */ -extern InspIRCd* ServerInstance; + typedef std::map<unsigned long, userrec*> IdUserMap; typedef std::map<unsigned long, chanrec*> IdChanMap; @@ -40,7 +40,7 @@ typedef std::list<unsigned long> AssocIdList; class ModuleSQLutils : public Module { private: - Server* Srv; + IdUserMap iduser; IdChanMap idchan; diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index 0ebd6f982..fd18f51f1 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -17,7 +17,7 @@ /* $CompileFlags: `libgnutls-config --cflags` */ /* $LinkerFlags: `libgnutls-config --libs` `perl ../gnutls_rpath.pl` */ -extern InspIRCd* ServerInstance; + enum issl_status { ISSL_NONE, ISSL_HANDSHAKING_READ, ISSL_HANDSHAKING_WRITE, ISSL_HANDSHAKEN, ISSL_CLOSING, ISSL_CLOSED }; @@ -43,7 +43,7 @@ public: class ModuleSSLGnuTLS : public Module { - Server* Srv; + ConfigReader* Conf; char* dummy; @@ -97,7 +97,7 @@ class ModuleSSLGnuTLS : public Module if(param != "ssl") return; - Conf = new ConfigReader; + Conf = new ConfigReader(ServerInstance); for(unsigned int i = 0; i < listenports.size(); i++) { @@ -534,7 +534,7 @@ class ModuleSSLGnuTLS : public Module log(DEBUG, "m_ssl_gnutls.so: Handshake completed"); // This will do for setting the ssl flag...it could be done earlier if it's needed. But this seems neater. - userrec* extendme = Srv->FindDescriptor(session->fd); + userrec* extendme = ServerInstance->FindDescriptor(session->fd); if (extendme) { if (!extendme->GetExt("ssl", dummy)) @@ -563,7 +563,7 @@ class ModuleSSLGnuTLS : public Module metadata->push_back("ssl"); // The metadata id metadata->push_back("ON"); // The value to send Event* event = new Event((char*)metadata,(Module*)this,"send_metadata"); - event->Send(); // Trigger the event. We don't care what module picks it up. + event->Send(ServerInstance); // Trigger the event. We don't care what module picks it up. DELETE(event); DELETE(metadata); } diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp index 3819d835c..a019d84ab 100644 --- a/src/modules/extra/m_ssl_openssl.cpp +++ b/src/modules/extra/m_ssl_openssl.cpp @@ -18,7 +18,7 @@ /* $CompileFlags: -I/usr/include -I/usr/local/include */ /* $LinkerFlags: -L/usr/local/lib -Wl,--rpath -Wl,/usr/local/lib -L/usr/lib -Wl,--rpath -Wl,/usr/lib -lssl */ -extern InspIRCd* ServerInstance; + enum issl_status { ISSL_NONE, ISSL_HANDSHAKING, ISSL_OPEN }; enum issl_io_status { ISSL_WRITE, ISSL_READ }; @@ -59,7 +59,7 @@ public: class ModuleSSLOpenSSL : public Module { - Server* Srv; + ConfigReader* Conf; CullList* culllist; @@ -107,7 +107,7 @@ class ModuleSSLOpenSSL : public Module if(param != "ssl") return; - Conf = new ConfigReader; + Conf = new ConfigReader(ServerInstance); for(unsigned int i = 0; i < listenports.size(); i++) { @@ -601,7 +601,7 @@ class ModuleSSLOpenSSL : public Module log(DEBUG, "m_ssl_openssl.so: Handshake completed"); // This will do for setting the ssl flag...it could be done earlier if it's needed. But this seems neater. - userrec* u = Srv->FindDescriptor(session->fd); + userrec* u = ServerInstance->FindDescriptor(session->fd); if (u) { if (!u->GetExt("ssl", dummy)) @@ -628,7 +628,7 @@ class ModuleSSLOpenSSL : public Module metadata->push_back("ssl"); // The metadata id metadata->push_back("ON"); // The value to send Event* event = new Event((char*)metadata,(Module*)this,"send_metadata"); - event->Send(); // Trigger the event. We don't care what module picks it up. + event->Send(ServerInstance); // Trigger the event. We don't care what module picks it up. DELETE(event); DELETE(metadata); } diff --git a/src/modules/extra/m_testclient.cpp b/src/modules/extra/m_testclient.cpp index 5a140500a..10229dd99 100644 --- a/src/modules/extra/m_testclient.cpp +++ b/src/modules/extra/m_testclient.cpp @@ -8,12 +8,12 @@ #include "configreader.h" #include "m_sqlv2.h" -extern InspIRCd* ServerInstance; + class ModuleTestClient : public Module { private: - Server* Srv; + public: ModuleTestClient(InspIRCd* Me) |