]>
Commit | Line | Data |
---|---|---|
c86edd1d Q |
1 | /* testmod.c */ |
2 | ||
3 | #include <stdio.h> | |
4 | #include "../core/hooks.h" | |
5 | #include "../server/server.h" | |
6 | #include "../nick/nick.h" | |
7 | #include "../core/error.h" | |
8 | #include "../core/schedule.h" | |
9 | #include "../localuser/localuser.h" | |
10 | ||
11 | void spamserverstate(int hook, void *servernum) { | |
12 | switch(hook) { | |
13 | case HOOK_SERVER_NEWSERVER: | |
14 | Error("testmod",ERR_INFO,"New server: %d (%d maxusers)",(int)servernum,serverlist[(int)servernum].maxusernum+1); | |
15 | break; | |
16 | ||
17 | case HOOK_SERVER_LOSTSERVER: | |
18 | Error("testmod",ERR_INFO,"Lost server: %d",(int)servernum); | |
19 | break; | |
20 | } | |
21 | } | |
22 | ||
23 | void printnick(int hook, void *vp) { | |
24 | /* | |
25 | // nick *np=(nick *)vp; | |
26 | ||
27 | // printf("New nick %s: %s!%s@%s (%s)\n",longtonumeric(np->numeric,5),np->nick,np->ident,np->host->name->content,np->realname->name->content); | |
28 | */ | |
29 | } | |
30 | ||
31 | void printstats(int hook, void *arg) { | |
32 | printf("%s\n",(char *)arg); | |
33 | } | |
34 | ||
35 | void requeststats(void *arg) { | |
36 | triggerhook(HOOK_CORE_STATSREQUEST,(void *)20); | |
37 | } | |
38 | ||
39 | void _init() { | |
40 | registerhook(HOOK_SERVER_NEWSERVER,&spamserverstate); | |
41 | registerhook(HOOK_SERVER_LOSTSERVER,&spamserverstate); | |
42 | registerhook(HOOK_NICK_NEWNICK,&printnick); | |
43 | registerhook(HOOK_CORE_STATSREPLY,&printstats); | |
44 | ||
45 | schedulerecurring(time(NULL),0,10,&requeststats,NULL); | |
46 | } | |
47 | ||
48 | void _fini() { | |
49 | deregisterhook(HOOK_SERVER_NEWSERVER,&spamserverstate); | |
50 | deregisterhook(HOOK_SERVER_LOSTSERVER,&spamserverstate); | |
51 | deregisterhook(HOOK_NICK_NEWNICK,&printnick); | |
52 | deregisterhook(HOOK_CORE_STATSREPLY,&printstats); | |
53 | ||
54 | deleteschedule(NULL,&requeststats,NULL); | |
55 | } |