summaryrefslogtreecommitdiff
path: root/src/modules/extra
diff options
context:
space:
mode:
authorpeavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7>2007-01-02 04:33:37 +0000
committerpeavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7>2007-01-02 04:33:37 +0000
commit62dc4e40b6fdd75e950ef69ae658ced3a96b5a7a (patch)
tree7f1f2daeeeaee0e1be0c25637432d9dec87fc1db /src/modules/extra
parentbb0e1ee1eb5cba9e9f11419c5d142159516c84cc (diff)
Also use SQLhost for host config.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6213 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/extra')
-rw-r--r--src/modules/extra/m_mysql.cpp39
1 files changed, 19 insertions, 20 deletions
diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp
index dd298bd1a..ea49de5ac 100644
--- a/src/modules/extra/m_mysql.cpp
+++ b/src/modules/extra/m_mysql.cpp
@@ -393,13 +393,9 @@ class SQLConnection : public classbase
MYSQL connection;
MYSQL_RES *res;
MYSQL_ROW row;
- std::string host;
- std::string user;
- std::string pass;
- std::string db;
+ SQLhost host;
std::map<std::string,std::string> thisrow;
bool Enabled;
- std::string id;
public:
@@ -407,7 +403,7 @@ class SQLConnection : public classbase
ResultQueue rq;
// This constructor creates an SQLConnection object with the given credentials, but does not connect yet.
- SQLConnection(const std::string &thishost, const std::string &thisuser, const std::string &thispass, const std::string &thisdb, const std::string &myid) : host(thishost), user(thisuser), pass(thispass), db(thisdb), Enabled(true), id(myid)
+ SQLConnection(const SQLhost &hi) : host(hi), Enabled(true)
{
}
@@ -423,7 +419,7 @@ class SQLConnection : public classbase
unsigned int timeout = 1;
mysql_init(&connection);
mysql_options(&connection,MYSQL_OPT_CONNECT_TIMEOUT,(char*)&timeout);
- return mysql_real_connect(&connection, host.c_str(), user.c_str(), pass.c_str(), db.c_str(), 0, NULL, 0);
+ return mysql_real_connect(&connection, host.host.c_str(), host.user.c_str(), host.pass.c_str(), host.name.c_str(), host.port, NULL, 0);
}
void DoLeadingQuery()
@@ -561,12 +557,12 @@ class SQLConnection : public classbase
const std::string& GetID()
{
- return id;
+ return host.id;
}
std::string GetHost()
{
- return host;
+ return host.host;
}
void SetEnable(bool Enable)
@@ -614,20 +610,23 @@ void ClearDatabases()
}
}
-void LoadDatabases(ConfigReader* ThisConf, InspIRCd* ServerInstance)
+void LoadDatabases(ConfigReader* conf, InspIRCd* ServerInstance)
{
ClearDatabases();
- for (int j =0; j < ThisConf->Enumerate("database"); j++)
- {
- std::string db = ThisConf->ReadValue("database","name",j);
- std::string user = ThisConf->ReadValue("database","username",j);
- std::string pass = ThisConf->ReadValue("database","password",j);
- std::string host = ThisConf->ReadValue("database","hostname",j);
- std::string id = ThisConf->ReadValue("database","id",j);
- if ((db != "") && (host != "") && (user != "") && (id != "") && (pass != ""))
+ for (int j =0; j < conf->Enumerate("database"); j++)
+ {
+ SQLhost host;
+ host.id = conf->ReadValue("database", "id", j);
+ host.host = conf->ReadValue("database", "hostname", j);
+ host.port = conf->ReadInteger("database", "port", j, true);
+ host.name = conf->ReadValue("database", "name", j);
+ host.user = conf->ReadValue("database", "username", j);
+ host.pass = conf->ReadValue("database", "password", j);
+
+ if (!host.id.empty() && !host.host.empty() && !host.name.empty() && !host.user.empty() && !host.pass.empty())
{
- SQLConnection* ThisSQL = new SQLConnection(host,user,pass,db,id);
- Connections[id] = ThisSQL;
+ SQLConnection* ThisSQL = new SQLConnection(host);
+ Connections[host.id] = ThisSQL;
}
}
ConnectDatabases(ServerInstance);