*/
#ifndef INCLUDED_channel_h
#define INCLUDED_channel_h
-#ifndef INCLUDED_config_h
-#include "config.h"
-#endif
#ifndef INCLUDED_ircd_defs_h
#include "ircd_defs.h" /* NICKLEN */
#endif
#define MODEBUFLEN 200
#define KEYLEN 23
+#define PASSLEN 23
#define CHANNELLEN 200
-#define MAXBANS 30
-#define MAXBANLENGTH 1024
+
+#define MAXJOINARGS 15 /* number of slots for join buffer */
+#define STARTJOINLEN 10 /* fuzzy numbers */
+#define STARTCREATELEN 20
/*
* Macro's
#define CHFL_BANVALID 0x0800 /* CHFL_BANNED bit is valid */
#define CHFL_BANNED 0x1000 /* Channel member is banned */
#define CHFL_SILENCE_IPMASK 0x2000 /* silence mask is an IP-number mask */
+#define CHFL_BURST_ALREADY_OPPED 0x04000 /* In oob BURST, but was already joined and opped */
+#define CHFL_BURST_ALREADY_VOICED 0x08000 /* In oob BURST, but was already joined and voiced */
+#define CHFL_CHANNEL_MANAGER 0x10000 /* Set when creating channel or using Apass */
+#define CHFL_USER_PARTING 0x20000 /* User is already parting that channel */
#define CHFL_OVERLAP (CHFL_CHANOP | CHFL_VOICE)
#define CHFL_BANVALIDMASK (CHFL_BANVALID | CHFL_BANNED)
#define MODE_KEY 0x0100
#define MODE_BAN 0x0200
#define MODE_LIMIT 0x0400
-#define MODE_SENDTS 0x0800 /* TS was 0 during a local user /join; send
- * temporary TS; can be removed when all 2.10 */
+#define MODE_REGONLY 0x0800 /* Only +r users may join */
#define MODE_LISTED 0x10000
-
+#define MODE_SAVE 0x20000 /* save this mode-with-arg 'til later */
+#define MODE_FREE 0x40000 /* string needs to be passed to MyFree() */
+#define MODE_BURSTADDED 0x80000 /* channel was created by a BURST */
+#define MODE_UPASS 0x100000
+#define MODE_APASS 0x200000
/*
* mode flags which take another parameter (With PARAmeterS)
*/
-#define MODE_WPARAS (MODE_CHANOP|MODE_VOICE|MODE_BAN|MODE_KEY|MODE_LIMIT)
+#define MODE_WPARAS (MODE_CHANOP|MODE_VOICE|MODE_BAN|MODE_KEY|MODE_LIMIT|MODE_APASS|MODE_UPASS)
+
+#define infochanmodes feature_bool(FEAT_OPLEVELS) ? "Abiklmnopstuvr" : "biklmnopstvr"
+#define infochanmodeswithparams feature_bool(FEAT_OPLEVELS) ? "Abklouv" : "bklov"
#define HoldChannel(x) (!(x))
/* name invisible */
/* channel not shown but names are */
#define HiddenChannel(x) ((x) && ((x)->mode.mode & MODE_PRIVATE))
/* channel visible */
-#define ShowChannel(v,c) (PubChannel(c) || find_channel_member((v),(c)))
+#define ShowChannel(v,c) (PubChannel(c) || find_channel_member((v),(c)) || \
+ (IsAnOper(v) && HasPriv(v, PRIV_LIST_CHAN)))
#define PubChannel(x) ((!x) || ((x)->mode.mode & \
(MODE_PRIVATE | MODE_SECRET)) == 0)
#define is_listed(x) ((x)->mode.mode & MODE_LISTED)
#define IsLocalChannel(name) (*(name) == '&')
-#define IsModelessChannel(name) (*(name) == '+')
#define IsChannelName(name) (*(name) == '#' || \
- IsModelessChannel(name) || IsLocalChannel(name))
-
-/*
- * Check if a sptr is an oper, and chptr is a local channel.
- */
-#define IsOperOnLocalChannel(sptr,chname) \
- ((IsAnOper(sptr)) && (IsLocalChannel(chname)))
+ IsLocalChannel(name))
typedef enum ChannelGetType {
CGT_NO_CREATE,
*/
#define MAGIC_REMOTE_JOIN_TS 1270080000
-#ifdef OPER_WALK_THROUGH_LMODES
/*
* used in can_join to determine if an oper forced a join on a channel
*/
#define MAGIC_OPER_OVERRIDE 1000
-#endif
extern const char* const PartFmt1;
struct Membership* next_channel;
struct Membership* prev_channel;
unsigned int status;
+ unsigned short oplevel;
};
+#define MAXOPLEVELDIGITS 3
+#define MAXOPLEVEL 999
+
#define IsZombie(x) ((x)->status & CHFL_ZOMBIE)
#define IsDeopped(x) ((x)->status & CHFL_DEOPPED)
#define IsBanned(x) ((x)->status & CHFL_BANNED)
#define IsBanValid(x) ((x)->status & CHFL_BANVALID)
#define IsChanOp(x) ((x)->status & CHFL_CHANOP)
+#define OpLevel(x) ((x)->oplevel)
#define HasVoice(x) ((x)->status & CHFL_VOICE)
#define IsServOpOk(x) ((x)->status & CHFL_SERVOPOK)
#define IsBurstJoined(x) ((x)->status & CHFL_BURST_JOINED)
#define IsVoicedOrOpped(x) ((x)->status & CHFL_VOICED_OR_OPPED)
+#define IsChannelManager(x) ((x)->status & CHFL_CHANNEL_MANAGER)
+#define IsUserParting(x) ((x)->status & CHFL_USER_PARTING)
#define SetBanned(x) ((x)->status |= CHFL_BANNED)
#define SetBanValid(x) ((x)->status |= CHFL_BANVALID)
#define SetServOpOk(x) ((x)->status |= CHFL_SERVOPOK)
#define SetBurstJoined(x) ((x)->status |= CHFL_BURST_JOINED)
#define SetZombie(x) ((x)->status |= CHFL_ZOMBIE)
+#define SetChannelManager(x) ((x)->status |= CHFL_CHANNEL_MANAGER)
+#define SetOpLevel(x, v) (void)((x)->oplevel = (v))
+#define SetUserParting(x) ((x)->status |= CHFL_USER_PARTING)
#define ClearBanned(x) ((x)->status &= ~CHFL_BANNED)
#define ClearBanValid(x) ((x)->status &= ~CHFL_BANVALID)
unsigned int mode;
unsigned int limit;
char key[KEYLEN + 1];
+ char upass[PASSLEN + 1];
+ char apass[PASSLEN + 1];
};
struct Channel {
struct Channel* next;
struct Channel* prev;
struct Channel* hnext;
+ struct DestructEvent* destruct_event;
time_t creationtime;
time_t topic_time;
unsigned int users;
struct Channel *chptr;
};
+struct ModeBuf {
+ unsigned int mb_add; /* Modes to add */
+ unsigned int mb_rem; /* Modes to remove */
+ struct Client *mb_source; /* Source of MODE changes */
+ struct Client *mb_connect; /* Connection of MODE changes */
+ struct Channel *mb_channel; /* Channel they affect */
+ unsigned int mb_dest; /* Destination of MODE changes */
+ unsigned int mb_count; /* Number of modes w/args */
+ struct {
+ unsigned int mbm_type; /* Type of argument */
+ union {
+ unsigned int mbma_uint; /* A limit */
+ char *mbma_string; /* A string */
+ struct Client *mbma_client; /* A client */
+ } mbm_arg; /* The mode argument */
+ } mb_modeargs[MAXMODEPARAMS];
+ /* A mode w/args */
+};
+
+#define MODEBUF_DEST_CHANNEL 0x00001 /* Mode is flushed to channel */
+#define MODEBUF_DEST_SERVER 0x00002 /* Mode is flushed to server */
+
+#define MODEBUF_DEST_OPMODE 0x00100 /* Send server mode as OPMODE */
+#define MODEBUF_DEST_DEOP 0x00200 /* Deop the offender */
+#define MODEBUF_DEST_BOUNCE 0x00400 /* Bounce the modes */
+#define MODEBUF_DEST_LOG 0x00800 /* Log the mode changes to OPATH */
+
+#define MODEBUF_DEST_HACK2 0x02000 /* Send a HACK(2) notice, reverse */
+#define MODEBUF_DEST_HACK3 0x04000 /* Send a HACK(3) notice, TS == 0 */
+#define MODEBUF_DEST_HACK4 0x08000 /* Send a HACK(4) notice, TS == 0 */
+
+#define MODEBUF_DEST_NOKEY 0x10000 /* Don't send the real key */
+
+#define MB_TYPE(mb, i) ((mb)->mb_modeargs[(i)].mbm_type)
+#define MB_UINT(mb, i) ((mb)->mb_modeargs[(i)].mbm_arg.mbma_uint)
+#define MB_STRING(mb, i) ((mb)->mb_modeargs[(i)].mbm_arg.mbma_string)
+#define MB_CLIENT(mb, i) ((mb)->mb_modeargs[(i)].mbm_arg.mbma_client)
+
+struct JoinBuf {
+ struct Client *jb_source; /* Source of joins (ie, joiner) */
+ struct Client *jb_connect; /* Connection of joiner */
+ unsigned int jb_type; /* Type of join (JOIN or CREATE) */
+ char *jb_comment; /* part comment */
+ time_t jb_create; /* Creation timestamp */
+ unsigned int jb_count; /* Number of channels */
+ unsigned int jb_strlen; /* length so far */
+ struct Channel *jb_channels[MAXJOINARGS];
+ /* channels joined or whatever */
+};
+
+#define JOINBUF_TYPE_JOIN 0 /* send JOINs */
+#define JOINBUF_TYPE_CREATE 1 /* send CREATEs */
+#define JOINBUF_TYPE_PART 2 /* send PARTs */
+#define JOINBUF_TYPE_PARTALL 3 /* send local PARTs, but not remote */
+
extern struct Channel* GlobalChannelList;
extern int LocalChanOperMode;
*/
extern void clean_channelname(char* name);
extern void channel_modes(struct Client *cptr, char *mbuf, char *pbuf,
- struct Channel *chptr);
+ int buflen, struct Channel *chptr,
+ struct Membership *member);
extern int set_mode(struct Client* cptr, struct Client* sptr,
struct Channel* chptr, int parc, char* parv[],
char* mbuf, char* pbuf, char* npbuf, int* badop);
extern struct Membership* find_member_link(struct Channel * chptr,
const struct Client* cptr);
extern int sub1_from_channel(struct Channel* chptr);
+extern int destruct_channel(struct Channel* chptr);
extern int can_join(struct Client *sptr, struct Channel *chptr, char *key);
extern void add_user_to_channel(struct Channel* chptr, struct Client* who,
- unsigned int flags);
+ unsigned int flags, int oplevel);
extern void cancel_mode(struct Client *sptr, struct Channel *chptr, char m,
const char *param, int *count);
extern void add_token_to_sendbuf(char *token, size_t *sblenp, int *firstp,
extern int is_chan_op(struct Client *cptr, struct Channel *chptr);
extern int is_zombie(struct Client *cptr, struct Channel *chptr);
extern int has_voice(struct Client *cptr, struct Channel *chptr);
+/*
+ NOTE: pointer is compared, and not dereferenced, called by
+ add_target with a void*, since targets could be anything,
+ this function can't make any assumptions that it has a channel
+*/
+extern int IsInvited(struct Client* cptr, const void* chptr);
extern void send_channel_modes(struct Client *cptr, struct Channel *chptr);
extern char *pretty_mask(char *mask);
extern void del_invite(struct Client *cptr, struct Channel *chptr);
extern void list_next_channels(struct Client *cptr, int nr);
-extern void send_user_joins(struct Client *cptr, struct Client *user);
-
+extern void list_set_default(void); /* this belongs elsewhere! */
+
+extern void modebuf_init(struct ModeBuf *mbuf, struct Client *source,
+ struct Client *connect, struct Channel *chan,
+ unsigned int dest);
+extern void modebuf_mode(struct ModeBuf *mbuf, unsigned int mode);
+extern void modebuf_mode_uint(struct ModeBuf *mbuf, unsigned int mode,
+ unsigned int uint);
+extern void modebuf_mode_string(struct ModeBuf *mbuf, unsigned int mode,
+ char *string, int free);
+extern void modebuf_mode_client(struct ModeBuf *mbuf, unsigned int mode,
+ struct Client *client);
+extern int modebuf_flush(struct ModeBuf *mbuf);
+extern void modebuf_extract(struct ModeBuf *mbuf, char *buf);
+
+extern void mode_ban_invalidate(struct Channel *chan);
+extern void mode_invite_clear(struct Channel *chan);
+
+extern int mode_parse(struct ModeBuf *mbuf, struct Client *cptr,
+ struct Client *sptr, struct Channel *chptr,
+ int parc, char *parv[], unsigned int flags,
+ struct Membership* member);
+
+#define MODE_PARSE_SET 0x01 /* actually set channel modes */
+#define MODE_PARSE_STRICT 0x02 /* +m +n +t style not supported */
+#define MODE_PARSE_FORCE 0x04 /* force the mode to be applied */
+#define MODE_PARSE_BOUNCE 0x08 /* we will be bouncing the modes */
+#define MODE_PARSE_NOTOPER 0x10 /* send "not chanop" to user */
+#define MODE_PARSE_NOTMEMBER 0x20 /* send "not member" to user */
+#define MODE_PARSE_WIPEOUT 0x40 /* wipe out +k and +l during burst */
+#define MODE_PARSE_BURST 0x80 /* be even more strict w/extra args */
+
+extern void joinbuf_init(struct JoinBuf *jbuf, struct Client *source,
+ struct Client *connect, unsigned int type,
+ char *comment, time_t create);
+extern void joinbuf_join(struct JoinBuf *jbuf, struct Channel *chan,
+ unsigned int flags);
+extern int joinbuf_flush(struct JoinBuf *jbuf);
#endif /* INCLUDED_channel_h */