From 3323816264fc01ccfb455b61bf43cbe8621532cf Mon Sep 17 00:00:00 2001 From: "certus certus@31f1291d-b8d6-0310-a050-a5561fc1590b" Date: Tue, 4 Jul 2006 19:50:00 +0000 Subject: # BUILD : 1.7.14 (1080) # BUGS : 491? # NOTES : rewrote exception system due to a bug we couldn't track down. git-svn-id: svn://svn.anope.org/anope/trunk@1080 31f1291d-b8d6-0310-a050-a5561fc1590b git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@804 5417fbe8-f217-4b02-8779-1006273d7864 --- src/mysql.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'src/mysql.c') diff --git a/src/mysql.c b/src/mysql.c index af319d5b6..889dcd40d 100644 --- a/src/mysql.c +++ b/src/mysql.c @@ -983,10 +983,13 @@ void db_mysql_load_news(void) mysql_free_result(mysql_res); } +#define HASH(host) (((host)[0]&31)<<5 | ((host)[1]&31)) + void db_mysql_load_exceptions(void) { char sqlcmd[MAX_SQL_BUF]; - int j; + Exception *exception; + int index; if (!do_mysql) return; @@ -1000,20 +1003,26 @@ void db_mysql_load_exceptions(void) } mysql_res = mysql_store_result(mysql); nexceptions = mysql_num_rows(mysql_res); - exceptions = scalloc(sizeof(Exception) * nexceptions, 1); - j = 0; + exception = scalloc(sizeof(Exception), 1); while ((mysql_row = mysql_fetch_row(mysql_res))) { - exceptions[j].mask = sstrdup(mysql_row[0]); - exceptions[j].limit = atoi(mysql_row[1]); - snprintf(exceptions[j].who, NICKMAX, "%s", mysql_row[2]); - exceptions[j].reason = sstrdup(mysql_row[3]); - exceptions[j].time = atoi(mysql_row[4]); - exceptions[j].expires = atoi(mysql_row[5]); - j++; + exception->mask = sstrdup(mysql_row[0]); + exception->limit = atoi(mysql_row[1]); + snprintf(exception->who, NICKMAX, "%s", mysql_row[2]); + exception->reason = sstrdup(mysql_row[3]); + exception->time = atoi(mysql_row[4]); + exception->expires = atoi(mysql_row[5]); + index = HASH(exception->mask); + exception->prev = NULL; + exception->next = exceptionlist[index]; + if (exception->next) + exception->next->prev = exception; + exceptionlist[index] = exception; } mysql_free_result(mysql_res); } +#undef HASH + #define HASH(host) ((tolower((host)[0])&31)<<5 | (tolower((host)[1])&31)) void db_mysql_load_os_dbase(void) -- cgit