3 #include "../core/hooks.h"
4 #include "../core/schedule.h"
5 #include "../control/control.h"
6 #include "../irc/irc.h"
7 #include "../lib/irc_string.h"
8 #include "../lib/version.h"
9 #include "../core/config.h"
14 rbl_instance
*rbl_instances
= NULL
;
16 int registerrbl(const char *name
, const rbl_ops
*ops
, void *udata
) {
17 rbl_instance
*instance
;
19 instance
= malloc(sizeof(*instance
));
24 instance
->name
= getsstring(name
, 255);
26 instance
->udata
= udata
;
28 instance
->next
= rbl_instances
;
29 rbl_instances
= instance
;
31 RBL_REFRESH(instance
);
36 void deregisterrblbyops(const rbl_ops
*ops
) {
37 rbl_instance
**pnext
, *rbl
;
39 for (pnext
= &rbl_instances
; *pnext
; pnext
= &((*pnext
)->next
)) {
42 if (rbl
->ops
== ops
) {
45 freesstring(rbl
->name
);
54 static void rbl_sched_refresh(void *uarg
) {
57 for (rbl
= rbl_instances
; rbl
; rbl
= rbl
->next
)
61 static void rbl_whois_cb(int hooknum
, void *arg
) {
63 nick
*np
= (nick
*)arg
;
65 for (rbl
= rbl_instances
; rbl
; rbl
= rbl
->next
) {
66 char reason
[255], message
[255];
67 if (RBL_LOOKUP(rbl
, &np
->ipaddress
, reason
, sizeof(reason
)) <= 0)
70 snprintf(message
, sizeof(message
), "RBL : %s (%s)", rbl
->name
->content
, reason
);
71 triggerhook(HOOK_CONTROL_WHOISREPLY
, message
);
76 schedulerecurring(time(NULL
)+300, 0, 300, rbl_sched_refresh
, NULL
);
77 registerhook(HOOK_CONTROL_WHOISREQUEST
, &rbl_whois_cb
);
81 deleteallschedules(rbl_sched_refresh
);
82 deregisterhook(HOOK_CONTROL_WHOISREQUEST
, &rbl_whois_cb
);