#include "../core/hooks.h"
#include "trusts.h"
+static void __counthandler(int hooknum, void *arg);
+
static void __newnick(int hooknum, void *arg) {
nick *sender = arg;
uint32_t host;
setnextbytrust(sender, th->users);
th->users = sender;
+ /* sucks we have to do this, at least until we get priority hooks */
+ __counthandler(HOOK_TRUSTS_NEWNICK, sender);
triggerhook(HOOK_TRUSTS_NEWNICK, sender);
}
if(!th)
return;
+ __counthandler(HOOK_TRUSTS_LOSTNICK, sender);
triggerhook(HOOK_TRUSTS_LOSTNICK, sender);
/*
registerhook(HOOK_NICK_NEWNICK, __newnick);
registerhook(HOOK_NICK_LOSTNICK, __lostnick);
- registerhook(HOOK_TRUSTS_NEWNICK, __counthandler);
+/* registerhook(HOOK_TRUSTS_NEWNICK, __counthandler);
registerhook(HOOK_TRUSTS_LOSTNICK, __counthandler);
+*/
/* we could do it by host, but hosts and ips are not bijective :( */
for(i=0;i<NICKHASHSIZE;i++)
deregisterhook(HOOK_NICK_NEWNICK, __newnick);
deregisterhook(HOOK_NICK_LOSTNICK, __lostnick);
+/*
deregisterhook(HOOK_TRUSTS_NEWNICK, __counthandler);
deregisterhook(HOOK_TRUSTS_LOSTNICK, __counthandler);
+*/
}
deregisterhook(HOOK_TRUSTS_DB_LOADED, __dbloaded);
static void statusfn(int, void *);
-static int loaded;
+static int loaded, unloaded;
int trusts_thext, trusts_nextuserext;
trusts_registerevents();
}
-void _fini(void) {
+void trusts_unload(void) {
+ if(unloaded)
+ return;
+
+ unloaded = 1;
+
if(trusts_thext != -1) {
releasenickext(trusts_thext);
releasenickext(trusts_nextuserext);
trusts_closedb();
}
+void _fini(void) {
+ trusts_unload();
+}
+
static void statusfn(int hooknum, void *arg) {
if((long)arg > 10) {
char message[100];
struct trustgroup *next;
} trustgroup;
-/* trusts.c */
-extern int trusts_thext, trusts_nextuserext;
-
#define nextbytrust(x) (nick *)((x)->exts[trusts_nextuserext])
#define gettrusthost(x) (trusthost *)((x)->exts[trusts_thext])
#define setnextbytrust(x, y) (x)->exts[trusts_nextuserext] = (y)
#define settrusthost(x, y) (x)->exts[trusts_thext] = (y)
+/* trusts.c */
+extern int trusts_thext, trusts_nextuserext;
+void trusts_unload(void);
+
/* db.c */
extern int trustsdbloaded;
void trusts_reloaddb(void);
return;
if(!errcode) {
- controlreply(np, "Migration complete, you must reload the module.");
+ controlreply(np, "Migration complete.");
+
+ /* stops flush destroying the database */
+ trusts_freeall();
+
+ trusts_unload();
+ controlreply(np, "All functionality disabled, database unloaded -- please reload the module.");
} else {
controlreply(np, "Error %d occured during migration, commands reregistered.", errcode);
registercommands();