summaryrefslogtreecommitdiff
path: root/src/mysql.c
diff options
context:
space:
mode:
authorcertus certus@31f1291d-b8d6-0310-a050-a5561fc1590b <certus certus@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2006-07-04 19:50:00 +0000
committercertus certus@31f1291d-b8d6-0310-a050-a5561fc1590b <certus certus@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2006-07-04 19:50:00 +0000
commit3323816264fc01ccfb455b61bf43cbe8621532cf (patch)
tree340e92d5519851b254900fe997a577b34002ca2e /src/mysql.c
parent7ceb358ec4c7ceb8d202ca18c1572804400b4a31 (diff)
# 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
Diffstat (limited to 'src/mysql.c')
-rw-r--r--src/mysql.c29
1 files changed, 19 insertions, 10 deletions
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)