diff --git a/include/flood.h b/include/flood.h index 80dc708..03d798c 100644 --- a/include/flood.h +++ b/include/flood.h @@ -7,27 +7,29 @@ #ifndef __flood_h_ #define __flood_h_ -int BX_check_flooding(char *, int, char *, char *); -int BX_is_other_flood(ChannelList *, NickList *, int, int *); -int BX_flood_prot(char *nick, char *userhost, int flood_type, int ignoretime, char *channel); -void clean_flood_list(void); - -#define MSG_FLOOD 0x0001 -#define PUBLIC_FLOOD 0x0002 -#define NOTICE_FLOOD 0x0004 -#define WALL_FLOOD 0x0008 -#define WALLOP_FLOOD 0x0010 -#define CTCP_FLOOD 0x0020 -#define INVITE_FLOOD 0x0040 -#define CDCC_FLOOD 0x0080 -#define CTCP_ACTION_FLOOD 0x0100 -#define NICK_FLOOD 0x0200 -#define DEOP_FLOOD 0x0400 -#define KICK_FLOOD 0x0800 -#define JOIN_FLOOD 0x1000 +enum flood_type { + MSG_FLOOD = 0x0001, + PUBLIC_FLOOD = 0x0002, + NOTICE_FLOOD = 0x0004, + WALL_FLOOD = 0x0008, + WALLOP_FLOOD = 0x0010, + CTCP_FLOOD = 0x0020, + INVITE_FLOOD = 0x0040, + CDCC_FLOOD = 0x0080, + CTCP_ACTION_FLOOD = 0x0100, + NICK_FLOOD = 0x0200, + DEOP_FLOOD = 0x0400, + KICK_FLOOD = 0x0800, + JOIN_FLOOD = 0x1000 +}; #define FLOOD_FLAG(t) ((unsigned)(t)) +int BX_check_flooding(char *nick, enum flood_type type, char *line, char *channel); +int BX_is_other_flood(ChannelList *channel, NickList *nick, enum flood_type type, int *t_flood); +int BX_flood_prot(char *nick, char *userhost, enum flood_type flood_type, int ignoretime, char *channel); +void clean_flood_list(void); + #include "hash.h" #define FLOOD_HASHSIZE 31 extern HashEntry no_flood_list[FLOOD_HASHSIZE]; diff --git a/include/modval.h b/include/modval.h index 8444995..5c9dde0 100644 --- a/include/modval.h +++ b/include/modval.h @@ -594,9 +594,9 @@ extern Function_ptr *global; /* flood.c */ -#define is_other_flood (*(int (*)(ChannelList *, NickList *, int, int *))global[IS_OTHER_FLOOD]) -#define check_flooding (*(int (*)(char *, int , char *, char *))global[CHECK_FLOODING]) -#define flood_prot (*(int (*)(char *, char *, int , int , char *))global[FLOOD_PROT]) +#define is_other_flood (*(int (*)(ChannelList *, NickList *, enum flood_type, int *))global[IS_OTHER_FLOOD]) +#define check_flooding (*(int (*)(char *, enum flood_type, char *, char *))global[CHECK_FLOODING]) +#define flood_prot (*(int (*)(char *, char *, enum flood_type, int, char *))global[FLOOD_PROT]) /* expr.c */ #define next_unit (*(char *(*)(char *, const char *, int *, int ))global[NEXT_UNIT]) diff --git a/source/flood.c b/source/flood.c index a140d7d..beef907 100644 --- a/source/flood.c +++ b/source/flood.c @@ -162,7 +162,7 @@ int get_flood_count(int type, ChannelList * channel) } #endif -void get_flood_val(ChannelList *chan, int type, int *flood_count, int *flood_rate) +static void get_flood_val(ChannelList *chan, enum flood_type type, int *flood_count, int *flood_rate) { *flood_count = get_int_var(FLOOD_AFTER_VAR); *flood_rate = get_int_var(FLOOD_RATE_VAR); @@ -212,7 +212,7 @@ void get_flood_val(ChannelList *chan, int type, int *flood_count, int *flood_rat } } -int set_flood(int type, time_t flood_time, int reset, NickList *tmpnick) +static int set_flood(enum flood_type type, time_t flood_time, int reset, NickList *tmpnick) { if (!tmpnick) return 0; @@ -259,7 +259,7 @@ int set_flood(int type, time_t flood_time, int reset, NickList *tmpnick) return 1; } -int BX_is_other_flood(ChannelList *channel, NickList *tmpnick, int type, int *t_flood) +int BX_is_other_flood(ChannelList *channel, NickList *tmpnick, enum flood_type type, int *t_flood) { time_t diff = 0, flood_time = 0; int doit = 0; @@ -387,7 +387,7 @@ static int remove_oldest_flood_hashlist(HashEntry *list) * FLOOD is activated. */ -int BX_check_flooding(char *nick, int type, char *line, char *channel) +int BX_check_flooding(char *nick, enum flood_type type, char *line, char *channel) { Flooding *tmp; int flood_rate; @@ -462,7 +462,7 @@ int BX_check_flooding(char *nick, int type, char *line, char *channel) return 1; } -void check_ctcp_ban_flood(char *channel, char *nick) +static void check_ctcp_ban_flood(char *channel, char *nick) { NickList *Nick = NULL; ChannelList *chan = NULL; @@ -487,7 +487,7 @@ ChannelList *chan = NULL; } } -int BX_flood_prot(char *nick, char *userhost, int flood_type, int ignoretime, char *channel) +int BX_flood_prot(char *nick, char *userhost, enum flood_type flood_type, int ignoretime, char *channel) { ChannelList *chan; NickList *Nick;