From fef98f43ba40c9c85f013df9f9ee31aded31b237 Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Wed, 18 Jan 2017 17:03:06 +1100 Subject: [PATCH] Separate notion of _FLOOD constant from the flags stored in the Flooding struct This adds a FLOOD_FLAG() macro to convert a _FLOOD constant to the appropriate flag. For now this just casts the argument to unsigned int. Rename Flooding.type to Flooding.flags and change it to unsigned int, to reflect that it's a bitfield of flags for multiple flooding types. --- include/flood.h | 2 ++ include/struct.h | 2 +- source/flood.c | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/flood.h b/include/flood.h index 09ef129..80dc708 100644 --- a/include/flood.h +++ b/include/flood.h @@ -26,6 +26,8 @@ void clean_flood_list(void); #define KICK_FLOOD 0x0800 #define JOIN_FLOOD 0x1000 +#define FLOOD_FLAG(t) ((unsigned)(t)) + #include "hash.h" #define FLOOD_HASHSIZE 31 extern HashEntry no_flood_list[FLOOD_HASHSIZE]; diff --git a/include/struct.h b/include/struct.h index c5de21b..b8c4dfd 100644 --- a/include/struct.h +++ b/include/struct.h @@ -1012,7 +1012,7 @@ typedef struct flood_stru char *name; char *host; char *channel; - int type; + unsigned flags; char flood; unsigned long cnt; struct timeval start; diff --git a/source/flood.c b/source/flood.c index 7c0b86b..a140d7d 100644 --- a/source/flood.c +++ b/source/flood.c @@ -401,15 +401,15 @@ int BX_check_flooding(char *nick, int type, char *line, char *channel) { remove_oldest_flood_hashlist(&flood_list[0]); tmp = add_name_to_floodlist(nick, FromUserHost, channel, flood_list, FLOOD_HASHSIZE); - tmp->type = type; + tmp->flags = FLOOD_FLAG(type); tmp->cnt = 1; get_time(&tmp->start); tmp->flood = 0; return 1; } - if (!(tmp->type & type)) + if (!(tmp->flags & FLOOD_FLAG(type))) { - tmp->type |= type; + tmp->flags |= FLOOD_FLAG(type); return 1; }