From 631d11d6a81e8c5f63a19fc279606a61ab1a0563 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 10 May 2010 17:55:23 -0400 Subject: Store a plaintext version of mode names in the mode structures, removes alot of unneeded code from db_plain/db_mysql. --- src/modules/mysql/db_mysql_execute.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/modules/mysql/db_mysql_execute.cpp') diff --git a/src/modules/mysql/db_mysql_execute.cpp b/src/modules/mysql/db_mysql_execute.cpp index 0c7c4de65..3933d54d1 100644 --- a/src/modules/mysql/db_mysql_execute.cpp +++ b/src/modules/mysql/db_mysql_execute.cpp @@ -37,7 +37,7 @@ class FakeUser : public User this->realname = sstrdup("Fake SQL User"); this->hostip = sstrdup("255.255.255.255"); this->vhost = NULL; - this->server = serv_uplink; // XXX Need a good way to set this to ourself + this->server = Me; if (this->prev) this->prev->next = this->next; @@ -50,8 +50,6 @@ class FakeUser : public User ~FakeUser() { - this->server = serv_uplink; // XXX Need a good way to set this to ourself - User **list = &userlist[HASH(this->nick.c_str())]; this->next = *list; if (*list) @@ -73,16 +71,16 @@ class FakeUser : public User class SQLTimer : public Timer { public: - SQLTimer() : Timer(Me->Delay, time(NULL), true) + SQLTimer() : Timer(me->Delay, time(NULL), true) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "TRUNCATE TABLE `anope_commands`"; ExecuteQuery(query); } void Tick(time_t) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); mysqlpp::StoreQueryResult qres; query << "SELECT * FROM `anope_commands`"; -- cgit From f049124905bd9f53439293e873003cb027a17b91 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 14 May 2010 20:35:38 -0400 Subject: Rewrote the hashing system to use std::tr1::unordered_map --- src/modules/mysql/db_mysql_execute.cpp | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'src/modules/mysql/db_mysql_execute.cpp') diff --git a/src/modules/mysql/db_mysql_execute.cpp b/src/modules/mysql/db_mysql_execute.cpp index 3933d54d1..356f7c0f2 100644 --- a/src/modules/mysql/db_mysql_execute.cpp +++ b/src/modules/mysql/db_mysql_execute.cpp @@ -8,17 +8,12 @@ class FakeNickCore : public NickCore public: FakeNickCore() : NickCore("-SQLUser") { - if (this->next) - this->next->prev = this->prev; - if (this->prev) - this->prev->next = this->next; - else - nclists[HASH(this->display)] = this->next; + NickCoreList.erase(this->display); } ~FakeNickCore() { - insert_core(this); + NickCoreList[this->display] = this; Users.clear(); } @@ -39,23 +34,15 @@ class FakeUser : public User this->vhost = NULL; this->server = Me; - if (this->prev) - this->prev->next = this->next; - else - userlist[HASH(this->nick.c_str())] = this->next; - if (this->next) - this->next->prev = this->prev; + UserListByNick.erase("-SQLUser"); --usercnt; } ~FakeUser() { - User **list = &userlist[HASH(this->nick.c_str())]; - this->next = *list; - if (*list) - (*list)->prev = this; - *list = this; + UserListByNick["-SQLUser"] = this; ++usercnt; + nc = NULL; } @@ -145,7 +132,7 @@ class SQLTimer : public Timer // XXX this whole strtok thing needs to die char *cmdbuf = sstrdup(qres[i]["command"].c_str()); char *cmd = strtok(cmdbuf, " "); - mod_run_cmd(bi->nick, u, bi->cmdTable, cmd); + mod_run_cmd(bi, u, cmd); delete [] cmdbuf; if (logout) -- cgit From 1394c96173cec02d148dfece563bb186cf2f33b6 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 26 May 2010 02:53:08 -0500 Subject: Removed a lot of unnecessary .c_str() calls in the find* functions --- src/modules/mysql/db_mysql_execute.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/modules/mysql/db_mysql_execute.cpp') diff --git a/src/modules/mysql/db_mysql_execute.cpp b/src/modules/mysql/db_mysql_execute.cpp index 356f7c0f2..4e4e859cb 100644 --- a/src/modules/mysql/db_mysql_execute.cpp +++ b/src/modules/mysql/db_mysql_execute.cpp @@ -1,7 +1,6 @@ /* RequiredLibraries: mysqlpp */ #include "db_mysql.h" -#define HASH(nick) (((nick)[0]&31)<<5 | ((nick)[1]&31)) class FakeNickCore : public NickCore { -- cgit From 435c9116e9997634eb7215e998c8f01a5e46fb2c Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 28 May 2010 18:27:22 -0400 Subject: Added an arg to User::IsRecognized to check for NI_SECURE --- src/modules/mysql/db_mysql_execute.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/modules/mysql/db_mysql_execute.cpp') diff --git a/src/modules/mysql/db_mysql_execute.cpp b/src/modules/mysql/db_mysql_execute.cpp index 4e4e859cb..572dd2917 100644 --- a/src/modules/mysql/db_mysql_execute.cpp +++ b/src/modules/mysql/db_mysql_execute.cpp @@ -52,6 +52,7 @@ class FakeUser : public User NickCore *Account() const { return nc; } const bool IsIdentified(bool) const { return nc ? true : false; } + const bool IsRecognized(bool) const { return true; } } SQLUser; class SQLTimer : public Timer @@ -155,7 +156,7 @@ class DBMySQLExecute : public DBMySQL ~DBMySQLExecute() { - TimerManager::DelTimer(_SQLTimer); + delete _SQLTimer; } }; -- cgit From b8f9116b19eb511c4f5e6a683725f50bf732a7dd Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 29 May 2010 20:44:31 -0400 Subject: Rewrote all of the command handling to get rid of all the nasty strtoks() everywhere, and added a bot map by uid --- src/modules/mysql/db_mysql_execute.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/modules/mysql/db_mysql_execute.cpp') diff --git a/src/modules/mysql/db_mysql_execute.cpp b/src/modules/mysql/db_mysql_execute.cpp index 572dd2917..2313edd37 100644 --- a/src/modules/mysql/db_mysql_execute.cpp +++ b/src/modules/mysql/db_mysql_execute.cpp @@ -129,11 +129,7 @@ class SQLTimer : public Timer continue; } - // XXX this whole strtok thing needs to die - char *cmdbuf = sstrdup(qres[i]["command"].c_str()); - char *cmd = strtok(cmdbuf, " "); - mod_run_cmd(bi, u, cmd); - delete [] cmdbuf; + mod_run_cmd(bi, u, qres[i]["command"].c_str()); if (logout) u->Logout(); -- cgit