#include "../core/hooks.h"
#include "../core/error.h"
#include "../nick/nick.h"
+#include "../chanindex/chanindex.h"
+#include "../bans/bans.h"
#include <time.h>
#include <stdlib.h>
#define CHANMODE_DELJOINS 0x0800
#define CHANMODE_NOQUITMSG 0x1000
#define CHANMODE_NONOTICE 0x2000
+#define CHANMODE_MODNOAUTH 0x4000
+#define CHANMODE_SINGLETARG 0x8000
-#define CHANMODE_ALL 0x3FFF
-
-#define CHANBAN_NICKEXACT 0x0001 /* Ban includes an exact nick (no wildcards) */
-#define CHANBAN_NICKMASK 0x0002 /* Ban includes a nick mask with wildcards */
-#define CHANBAN_NICKANY 0x0004 /* Ban is *!.. */
-#define CHANBAN_NICKNULL 0x0008 /* Ban has no nick */
-#define CHANBAN_USEREXACT 0x0010 /* Ban includes an exact user (no wildcards) */
-#define CHANBAN_USERMASK 0x0020 /* Ban includes a user mask with wildcards */
-#define CHANBAN_USERANY 0x0040 /* Ban is ..!*@.. */
-#define CHANBAN_USERNULL 0x0080 /* Ban has no user */
-#define CHANBAN_HOSTEXACT 0x0100 /* Ban includes an exact host */
-#define CHANBAN_HOSTMASK 0x0200 /* Ban includes a host mask */
-#define CHANBAN_HOSTANY 0x0400 /* Ban is ..@* */
-#define CHANBAN_HOSTNULL 0x0800 /* Ban has no host */
-#define CHANBAN_IP 0x1000 /* Ban could match against IP address */
-#define CHANBAN_CIDR 0x2000 /* Ban includes a CIDR mask (e.g. 192.168.0.0/16 ) */
-#define CHANBAN_INVALID 0x4000 /* Ban is nonsensical, i.e. has at least one really NULL component*/
-#define CHANBAN_HIDDENHOST 0x8000 /* Ban could possibly match hidden host */
+#define CHANMODE_ALL 0xFFFF
+#define CHANMODE_DEFAULT 0x2203 /* +ntCN */
#define IsNoExtMsg(x) ((x)->flags & CHANMODE_NOEXTMSG)
#define IsTopicLimit(x) ((x)->flags & CHANMODE_TOPICLIMIT)
#define IsDelJoins(x) ((x)->flags & CHANMODE_DELJOINS)
#define IsNoQuitMsg(x) ((x)->flags & CHANMODE_NOQUITMSG)
#define IsNoNotice(x) ((x)->flags & CHANMODE_NONOTICE)
+#define IsModNoAuth(x) ((x)->flags & CHANMODE_MODNOAUTH)
+#define IsSingleTarg(x) ((x)->flags & CHANMODE_SINGLETARG)
#define SetNoExtMsg(x) ((x)->flags |= CHANMODE_NOEXTMSG)
#define SetTopicLimit(x) ((x)->flags |= CHANMODE_TOPICLIMIT)
#define SetDelJoins(x) ((x)->flags |= CHANMODE_DELJOINS)
#define SetNoQuitMsg(x) ((x)->flags |= CHANMODE_NOQUITMSG)
#define SetNoNotice(x) ((x)->flags |= CHANMODE_NONOTICE)
+#define SetModNoAuth(x) ((x)->flags |= CHANMODE_MODNOAUTH)
+#define SetSingleTarg(x) ((x)->flags |= CHANMODE_SINGLETARG)
#define ClearNoExtMsg(x) ((x)->flags &= ~CHANMODE_NOEXTMSG)
#define ClearTopicLimit(x) ((x)->flags &= ~CHANMODE_TOPICLIMIT)
#define ClearDelJoins(x) ((x)->flags &= ~CHANMODE_DELJOINS)
#define ClearNoQuitMsg(x) ((x)->flags &= ~CHANMODE_NOQUITMSG)
#define ClearNoNotice(x) ((x)->flags &= ~CHANMODE_NONOTICE)
+#define ClearModNoAuth(x) ((x)->flags &= ~CHANMODE_MODNOAUTH)
+#define ClearSingleTarg(x) ((x)->flags &= ~CHANMODE_SINGLETARG)
#define CUMODE_OP 0x80000000
#define CUMODE_VOICE 0x40000000
#define MAGIC_REMOTE_JOIN_TS 1270080000
-#define CHANNELHASHSIZE 60000
-#define MAXCHANNELEXTS 7
-
#define MODECHANGE_MODES 0x00000001
#define MODECHANGE_USERS 0x00000002
#define MODECHANGE_BANS 0x00000004
-struct channel;
-
-typedef struct chanindex {
- sstring *name;
- struct channel *channel;
- struct chanindex *next;
- unsigned int marker;
- void *exts[MAXCHANNELEXTS];
-} chanindex;
-
-typedef struct chanban {
- flag_t flags;
- sstring *nick;
- sstring *user;
- sstring *host;
- time_t timeset;
- struct chanban *next;
-} chanban;
-
typedef struct chanuserhash {
unsigned short hashsize;
unsigned short totalusers;
extern unsigned long nouser;
extern const flag cmodeflags[];
-extern chanindex *chantable[CHANNELHASHSIZE];
/* functions from channel.c */
int addnicktochannel(channel *cp, long numeric);
void addordelnick(int hooknum, void *arg);
void onconnect(int hooknum, void *arg);
unsigned int countuniquehosts(channel *cp);
+void clean_key(char *s);
/* functions from channelhandlers.c */
int handleburstmsg(void *source, int cargc, char **cargv);
void freechan(channel *cp);
chanuserhash *newchanuserhash(int numbuckets);
void freechanuserhash(chanuserhash *cuhp);
-chanban *getchanban();
-void freechanban(chanban *cbp);
-chanindex *getchanindex();
-void freechanindex(chanindex *cip);
/* functions from channelbans.c */
-chanban *makeban(const char *mask);
-int banoverlap(const chanban *bana, const chanban *banb);
-int banequal(chanban *bana, chanban *banb);
-char *bantostring(chanban *bp);
-char *bantostringdebug(chanban *bp);
-void setban(channel *cp, const char *ban);
+int setban(channel *cp, const char *ban);
int clearban(channel *cp, const char *ban, int optional);
void clearallbans(channel *cp);
-int nickmatchban(nick *np, chanban *bp);
-int nickbanned(nick *np, channel *cp);
+int nickmatchban(nick *np, chanban *bp, int visibleonly);
+int nickbanned(nick *np, channel *cp, int visibleonly);
/* functions from channelindex.c */
void initchannelindex();