fixed ssl.c bug when ssl backend returns IO_BLOCKED but IO engine doesn't get informe...
[ircu2.10.12-pk.git] / include / channel.h
index 353aeae6f437462ccf05183dcc50738f937952d6..b3deec89220ee10be89162deb3e3f0f84e1bf62c 100644 (file)
 struct SLink;
 struct Client;
 
+#if defined(_MSC_VER) || defined(__BORLANDC__)
+typedef unsigned __int64 ulong64;
+typedef signed __int64 long64;
+#else
+typedef unsigned long long ulong64;
+typedef signed long long long64;
+#endif
+
 /*
  * General defines
  */
@@ -58,10 +66,12 @@ struct Client;
 #define ChannelExists(n)        (0 != FindChannel(n))
 
 #define CHFL_CHANOP             0x0001  /**< Channel operator */
-#define CHFL_VOICE              0x0002  /**< the power to speak */
-#define CHFL_DEOPPED            0x0004  /**< Is de-opped by a server */
-#define CHFL_SERVOPOK           0x0008  /**< Server op allowed */
-#define CHFL_ZOMBIE             0x0010  /**< Kicked from channel */
+#define CHFL_HALFOP             0x0002  /**< Channel operator */
+#define CHFL_VOICE              0x0004  /**< the power to speak */
+
+#define CHFL_DEOPPED            0x0010  /**< Is de-opped by a server */
+#define CHFL_SERVOPOK           0x0020  /**< Server op allowed */
+#define CHFL_ZOMBIE             0x0040  /**< Kicked from channel */
 #define CHFL_BURST_JOINED       0x0100  /**< Just joined by net.junction */
 #define CHFL_BANVALID           0x0800  /**< CHFL_BANNED bit is valid */
 #define CHFL_BANNED             0x1000  /**< Channel member is banned */
@@ -74,62 +84,70 @@ struct Client;
                                        /**, In oob BURST, but was already 
                                         * joined and voiced 
                                         */
-#define CHFL_CHANNEL_MANAGER   0x10000 /**< Set when creating channel or using 
+#define CHFL_BURST_ALREADY_HALFOPPED   0x10000  
+                                       /**, In oob BURST, but was already 
+                                        * joined and voiced 
+                                        */
+#define CHFL_CHANNEL_MANAGER   0x40000 /**< Set when creating channel or using 
                                         * Apass 
                                         */
-#define CHFL_USER_PARTING       0x20000 /**< User is already parting that 
+#define CHFL_USER_PARTING       0x80000 /**< User is already parting that 
                                         * channel 
                                         */
-#define CHFL_DELAYED            0x40000 /**< User's join message is delayed */
-#define CHFL_INVISIBLE            0x80000 /**< User's join message is delayed */
+#define CHFL_DELAYED            0x100000 /**< User's join message is delayed */
+#define CHFL_INVISIBLE            0x200000 /**< User's join message is delayed */
 
-#define CHFL_OVERLAP         (CHFL_CHANOP | CHFL_VOICE)
+#define CHFL_OVERLAP         (CHFL_CHANOP | CHFL_HALFOP | CHFL_VOICE)
 #define CHFL_BANVALIDMASK    (CHFL_BANVALID | CHFL_BANNED)
-#define CHFL_VOICED_OR_OPPED (CHFL_CHANOP | CHFL_VOICE)
+#define CHFL_VOICED_OR_OPPED (CHFL_CHANOP | CHFL_HALFOP | CHFL_VOICE)
 
 /* Channel Visibility macros */
 
-#define MODE_CHANOP     CHFL_CHANOP    /**< +o Chanop */
-#define MODE_VOICE      CHFL_VOICE     /**< +v Voice */
-#define MODE_PRIVATE    0x0004         /**< +p Private */
-#define MODE_SECRET     0x0008         /**< +s Secret */
-#define MODE_MODERATED  0x0010         /**< +m Moderated */
-#define MODE_TOPICLIMIT 0x0020         /**< +t Topic Limited */
-#define MODE_INVITEONLY 0x0040         /**< +i Invite only */
-#define MODE_NOPRIVMSGS 0x0080         /**< +n No Private Messages */
-#define MODE_KEY        0x0100         /**< +k Keyed */
-#define MODE_BAN        0x0200         /**< +b Ban */
-#define MODE_LIMIT      0x0400         /**< +l Limit */
-#define MODE_REGONLY    0x0800         /**< Only +r users may join */
-#define MODE_DELJOINS   0x1000         /**< New join messages are delayed */
-#define MODE_REGISTERED 0x2000         /**< Channel marked as registered
-                                        * (for future semantic expansion) */
-#define MODE_PERSIST    0x4000      /**< +z persistant channel */
-#define MODE_NOCOLOUR   0x8000      /**< no ANSI color codes */
-#define MODE_NOCTCP    0x10000      /**< no channel CTCPs */
-#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
-#define MODE_WASDELJOINS 0x400000      /**< Not DELJOINS, but some joins 
-                                        * pending */
-#define MODE_EXCEPTION  0x800000    /**< ban exceptions */
-#define MODE_NOAMSGS 0x1000000    /**< No multi target messages */
-#define MODE_NONOTICE 0x2000000    /**< No channel notices */
-#define MODE_QUARANTINE 0x4000000    /**< No channel notices */
-#define MODE_ALTCHAN 0x8000000    /**< Alternative channel */
-#define MODE_ACCESS 0x10000000    /**< ChanServ access */
+#define MODE_NULL           0
+#define MODE_CHANOP         CHFL_CHANOP        /**< +o Chanop */
+#define MODE_HALFOP         CHFL_HALFOP /**< +h Halfop */
+#define MODE_VOICE          CHFL_VOICE /**< +v Voice */
+
+#define MODE_PRIVATE           0x10            /**< +p Private */
+#define MODE_SECRET            0x20            /**< +s Secret */
+#define MODE_MODERATED         0x40            /**< +m Moderated */
+#define MODE_TOPICLIMIT        0x80            /**< +t Topic Limited */
+#define MODE_INVITEONLY       0x100            /**< +i Invite only */
+#define MODE_NOPRIVMSGS       0x200            /**< +n No Private Messages */
+#define MODE_KEY              0x400            /**< +k Keyed */
+#define MODE_BAN              0x800            /**< +b Ban */
+#define MODE_LIMIT           0x1000            /**< +l Limit */
+#define MODE_REGONLY         0x2000            /**< Only +r users may join */
+#define MODE_DELJOINS        0x4000            /**< New join messages are delayed */
+#define MODE_REGISTERED      0x8000            /**< Channel marked as registered (for future semantic expansion) */
+#define MODE_PERSIST        0x10000            /**< +z persistant channel */
+#define MODE_NOCOLOUR       0x20000            /**< no ANSI color codes */
+#define MODE_NOCTCP         0x40000            /**< no channel CTCPs */
+#define MODE_SAVE           0x80000            /**< save this mode-with-arg 'til later */
+#define MODE_FREE          0x100000        /**< string needs to be passed to  MyFree() */
+#define MODE_BURSTADDED    0x200000            /**< channel was created by a BURST */
+#define MODE_UPASS         0x400000
+#define MODE_APASS         0x800000
+#define MODE_WASDELJOINS  0x1000000            /**< Not DELJOINS, but some joins  pending */
+#define MODE_NOAMSGS      0x2000000            /**< No multi target messages */
+#define MODE_NONOTICE     0x4000000            /**< No channel notices */
+#define MODE_QUARANTINE   0x8000000            /**< No channel notices */
+#define MODE_ALTCHAN     0x10000000            /**< Alternative channel */
+#define MODE_DEL         0x20000000
+#define MODE_ADD         0x40000000
+#define MODE_ACCESS     0x100000000LLU /**< ChanServ access */
+#define MODE_AUDITORIUM 0x200000000LLU /**< +u Auditorium */
+#define MODE_NOFLOOD    0x400000000LLU /**< +f NoFlood */
+#define MODE_SSLCHAN    0x800000000LLU /**< +S SSL Channel */
+#define MODE_BANEXCEPTION 0x1000000000LLU /**< +e Ban exception */
 /** mode flags which take another parameter (With PARAmeterS)
  */
-#define MODE_WPARAS     (MODE_CHANOP|MODE_VOICE|MODE_BAN|MODE_KEY|MODE_LIMIT|MODE_APASS|MODE_UPASS|MODE_EXCEPTION|MODE_ALTCHAN|MODE_ACCESS)
+#define MODE_WPARAS     (MODE_CHANOP|MODE_HALFOP|MODE_VOICE|MODE_BAN|MODE_KEY|MODE_LIMIT|MODE_APASS|MODE_UPASS|MODE_ALTCHAN|MODE_ACCESS|MODE_NOFLOOD|MODE_BANEXCEPTION)
 
 /** Available Channel modes */
-#define infochanmodes feature_bool(FEAT_OPLEVELS) ? "AcCbiklmMnNopstUvrDRzQ" : "cCbiklmMnNopstvrDRzQ"
+#define infochanmodes feature_bool(FEAT_OPLEVELS) ? "AcCbehiklmMnNopsStuUvrDRzQu" : "cCbehiklmMnNopsStuvrDRzQu"
 /** Available Channel modes that take parameters */
-#define infochanmodeswithparams feature_bool(FEAT_OPLEVELS) ? "AbkloUvFa" : "bklovFa"
+#define infochanmodeswithparams feature_bool(FEAT_OPLEVELS) ? "AbefhkloUvFa" : "befhklovFa"
 
 #define HoldChannel(x)          (!(x))
 /** name invisible */
@@ -150,12 +168,6 @@ typedef enum ChannelGetType {
   CGT_CREATE
 } ChannelGetType;
 
-/* used in SetMode() in channel.c and m_umode() in s_msg.c */
-
-#define MODE_NULL      0
-#define MODE_ADD       0x40000000
-#define MODE_DEL       0x20000000
-
 /* used in ListingArgs.flags */
 
 #define LISTARG_TOPICLIMITS     0x0001
@@ -203,10 +215,21 @@ struct Membership {
   struct Membership* prev_member;      /**< The previous user on this channel*/
   struct Membership* next_channel;     /**< Next channel this user is on */
   struct Membership* prev_channel;     /**< Previous channel this user is on*/
+  struct MemberFlood* flood;        /**< count's how many times a user sent something (+f floodcontrol) */
   unsigned int       status;           /**< Flags for op'd, voice'd, etc */
   unsigned short     oplevel;          /**< Op level */
 };
 
+#define FLFL_CHANOP  0x01
+#define FLFL_HALFOP   0x02
+#define FLFL_VOICE   0x04
+#define FLFL_NOFLOOD  0x08
+
+struct MemberFlood {
+  struct MemberFlood* next_memberflood;
+  time_t time;
+};
+
 #define MAXOPLEVELDIGITS    3
 #define MAXOPLEVEL          999
 
@@ -216,6 +239,8 @@ struct Membership {
 #define IsBanValid(x)       ((x)->status & CHFL_BANVALID)
 #define IsChanOp(x)         ((x)->status & CHFL_CHANOP)
 #define OpLevel(x)          ((x)->oplevel)
+#define IsHalfOp(x)         ((x)->status & CHFL_HALFOP)
+#define IsChanOpOrHalfOp(x) ((x)->status & (CHFL_CHANOP | CHFL_HALFOP))
 #define HasVoice(x)         ((x)->status & CHFL_VOICE)
 #define IsServOpOk(x)       ((x)->status & CHFL_SERVOPOK)
 #define IsBurstJoined(x)    ((x)->status & CHFL_BURST_JOINED)
@@ -246,9 +271,11 @@ struct Membership {
 
 /** Mode information for a channel */
 struct Mode {
-  unsigned int mode;
+  ulong64 mode;
   unsigned int limit;
   unsigned int access;
+  char noflood[11]; //max [@+]999:9999
+  unsigned int noflood_value; //3bit for @+, 10bit  first field,  14bit second field  = 27bit of 32bit
   char key[KEYLEN + 1];
   char upass[KEYLEN + 1];
   char apass[KEYLEN + 1];
@@ -312,15 +339,15 @@ struct ListingArgs {
 };
 
 struct ModeBuf {
-  unsigned int         mb_add;         /**< Modes to add */
-  unsigned int         mb_rem;         /**< Modes to remove */
+  ulong64      mb_add;         /**< Modes to add */
+  ulong64      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 */
+    ulong64    mbm_type;       /**< Type of argument */
     union {
       unsigned int     mbma_uint;      /**< A limit */
       char            *mbma_string;    /**< A string */
@@ -398,7 +425,7 @@ extern struct Client* find_chasing(struct Client* sptr, const char* user, int* c
 void add_invite(struct Client *cptr, struct Channel *chptr);
 int number_of_zombies(struct Channel *chptr);
 
-extern const char* find_no_nickchange_channel(struct Client* cptr);
+extern const char* find_no_nickchange_channel(struct Client* cptr, const char* new_nick);
 extern struct Membership* find_channel_member(struct Client* cptr, struct Channel* chptr);
 extern int member_can_send_to_channel(struct Membership* member, int reveal);
 extern int client_can_send_to_channel(struct Client *cptr, struct Channel *chptr, int reveal);
@@ -407,6 +434,7 @@ extern void remove_user_from_channel(struct Client *sptr, struct Channel *chptr)
 extern void remove_user_from_all_channels(struct Client* cptr);
 
 extern int is_chan_op(struct Client *cptr, struct Channel *chptr);
+extern int is_halfop(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);
 /*
@@ -423,16 +451,17 @@ extern void list_set_default(void); /* this belongs elsewhere! */
 extern void RevealDelayedJoinIfNeeded(struct Client *sptr, struct Channel *chptr);
 extern void RevealDelayedJoin(struct Membership *member);
 extern void CheckDelayedJoins(struct Channel *chan);
+extern void CheckEnableDelayedJoins(struct Channel *chan);
 
 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,
+extern void modebuf_mode(struct ModeBuf *mbuf, ulong64 mode);
+extern void modebuf_mode_uint(struct ModeBuf *mbuf, ulong64 mode,
                              unsigned int uint);
-extern void modebuf_mode_string(struct ModeBuf *mbuf, unsigned int mode,
+extern void modebuf_mode_string(struct ModeBuf *mbuf, ulong64 mode,
                                char *string, int free);
-extern void modebuf_mode_client(struct ModeBuf *mbuf, unsigned int mode,
+extern void modebuf_mode_client(struct ModeBuf *mbuf, ulong64 mode,
                                struct Client *client, int oplevel);
 extern int modebuf_flush(struct ModeBuf *mbuf);
 extern void modebuf_extract(struct ModeBuf *mbuf, char *buf);
@@ -466,5 +495,6 @@ extern int apply_ban(struct Ban **banlist, struct Ban *newban, int free);
 extern void free_ban(struct Ban *ban);
 extern signed int destruct_nonpers_channel(struct Channel *chptr);
 extern int ext_amsg_block(struct Client *cptr, struct Channel *chptr, const char *msg);
+extern int ext_noflood_block(struct Client *cptr, struct Channel *chptr);
 
 #endif /* INCLUDED_channel_h */