static const char *cmdname[MESSAGE_TYPE_COUNT] = {
[MESSAGE_TYPE_PRIVMSG] = "PRIVMSG",
[MESSAGE_TYPE_NOTICE] = "NOTICE",
+ [MESSAGE_TYPE_PART] = "PART",
};
enum filter_state {
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, {me_setfilter, 2}, {mo_setfilter, 2}}
};
-static void
+static int
modinit(void)
{
filter_umode = user_modes['u'] = find_umode_slot();
construct_umodebuf();
filter_chmode = cflag_add('u', chm_simple);
+ return 0;
}
static void
r = hs_alloc_scratch(db, &filter_scratch);
if (r != HS_SUCCESS) {
if (error) *error = "couldn't allocate scratch";
+ hs_free_database(db);
return -1;
}
if (filter_db) {
if (state == FILTER_FILLING) {
int dl;
- unsigned char *d = rb_base64_decode(data, strlen(data), &dl);
+ unsigned char *d = rb_base64_decode((unsigned char *)data, strlen(data), &dl);
if (!d) {
if (error) *error = "invalid data";
return -1;
return 0;
if (!filter_db)
return 0;
+ if (!command)
+ return 0;
snprintf(check_buffer, sizeof check_buffer, "%s:%s!%s@%s#%c %s %s :%s",
prefix,
#if FILTER_NICK
"*",
#endif
source->user && source->user->suser[0] != '\0' ? '1' : '0',
- command, target,
- msg);
+ command, target, msg);
hs_error_t r = hs_scan(filter_db, check_buffer, strlen(check_buffer), 0, filter_scratch, match_callback, &state);
if (r != HS_SUCCESS && r != HS_SCAN_TERMINATED)
return 0;
state = filter_db ? FILTER_LOADED : FILTER_EMPTY;
}
}
-