]> jfr.im git - solanum.git/blobdiff - include/channel.h
refuse opers setting an invalidly long k-line reason
[solanum.git] / include / channel.h
index 236f49cf93b45fc22fa2e01d3b3122ae6478ceec..19ca532fe8fcd828a2aeb037386b12f1f5eda898 100644 (file)
@@ -20,8 +20,6 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
- *
- *  $Id: channel.h 3580 2007-11-07 23:45:14Z jilles $
  */
 
 #ifndef INCLUDED_channel_h
@@ -33,6 +31,9 @@
 #define MAXMODEPARAMS   4
 #define MAXMODEPARAMSSERV 10
 
+#include <setup.h>
+#include "hook.h"
+
 struct Client;
 
 /* mode structure for channels */
@@ -51,6 +52,7 @@ struct Channel
 {
        rb_dlink_node node;
        struct Mode mode;
+       char *mode_lock;
        char *topic;
        char *topic_info;
        time_t topic_time;
@@ -72,9 +74,14 @@ struct Channel
        unsigned int join_count;  /* joins within delta */
        unsigned int join_delta;  /* last ts of join */
 
-       unsigned long bants;
+       time_t bants;
        time_t channelts;
        char *chname;
+
+       struct Client *last_checked_client;
+       time_t last_checked_ts;
+       unsigned int last_checked_type;
+       int last_checked_result;
 };
 
 struct membership
@@ -87,7 +94,7 @@ struct membership
        struct Client *client_p;
        unsigned int flags;
 
-       unsigned long bants;
+       time_t bants;
 };
 
 #define BANLEN 195
@@ -96,6 +103,7 @@ struct Ban
        char *banstr;
        char *who;
        time_t when;
+       char *forward;
        rb_dlink_node node;
 };
 
@@ -111,25 +119,27 @@ struct ChModeChange
        const char *arg;
        const char *id;
        int dir;
-       int caps;
-       int nocaps;
        int mems;
-       struct Client *client;
 };
 
-struct ChCapCombo
+typedef void ChannelModeFunc(struct Client *source_p, struct Channel *chptr,
+               int alevel, const char *arg, int *errors, int dir, char c, long mode_type);
+
+enum chm_flags
 {
-       int count;
-       int cap_yes;
-       int cap_no;
+       CHM_CAN_QUERY  = 1 << 0,
+       CHM_OPS_QUERY  = 1 << 1,
+       CHM_ARG_SET    = 1 << 2,
+       CHM_ARG_DEL    = 1 << 3,
+       CHM_ARGS       = CHM_ARG_SET | CHM_ARG_DEL,
+       CHM_QUERYABLE  = CHM_ARGS | CHM_CAN_QUERY,
 };
 
 struct ChannelMode
 {
-       void (*set_func) (struct Client * source_p, struct Channel * chptr,
-                     int alevel, int parc, int *parn,
-                     const char **parv, int *errors, int dir, char c, long mode_type);
+       ChannelModeFunc *set_func;
        long mode_type;
+       enum chm_flags flags;
 };
 
 typedef int (*ExtbanFunc)(const char *data, struct Client *client_p,
@@ -142,11 +152,13 @@ typedef int (*ExtbanFunc)(const char *data, struct Client *client_p,
 
 /* channel status flags */
 #define CHFL_PEON              0x0000  /* normal member of channel */
-#define CHFL_CHANOP            0x0001  /* Channel operator */
-#define CHFL_VOICE             0x0002  /* the power to speak */
+#define CHFL_VOICE             0x0001  /* the power to speak */
+#define CHFL_CHANOP            0x0002  /* Channel operator */
+
 #define CHFL_BANNED            0x0008  /* cached as banned */
 #define CHFL_QUIETED           0x0010  /* cached as being +q victim */
 #define ONLY_SERVERS           0x0020
+#define ONLY_OPERS             0x0040
 #define ALL_MEMBERS            CHFL_PEON
 #define ONLY_CHANOPS           CHFL_CHANOP
 #define ONLY_CHANOPSVOICED     (CHFL_CHANOP|CHFL_VOICE)
@@ -164,7 +176,6 @@ typedef int (*ExtbanFunc)(const char *data, struct Client *client_p,
 #define MODE_INVITEONLY 0x0010
 #define MODE_NOPRIVMSGS 0x0020
 #define MODE_REGONLY   0x0040
-#define MODE_NOCOLOR   0x0080
 #define MODE_EXLIMIT   0x0100  /* exempt from list limits, +b/+e/+I/+q */
 #define MODE_PERMANENT  0x0200  /* permanant channel, +P */
 #define MODE_OPMODERATE 0x0400  /* send rejected messages to ops */
@@ -181,6 +192,7 @@ typedef int (*ExtbanFunc)(const char *data, struct Client *client_p,
 #define MODE_QUERY     0
 #define MODE_ADD       1
 #define MODE_DEL       -1
+#define MODE_OP_QUERY  2
 
 #define SecretChannel(x)        ((x) && ((x)->mode.mode & MODE_SECRET))
 #define HiddenChannel(x)        ((x) && ((x)->mode.mode & MODE_PRIVATE))
@@ -193,31 +205,60 @@ typedef int (*ExtbanFunc)(const char *data, struct Client *client_p,
 #define IsMember(who, chan) ((who && who->user && \
                 find_channel_membership(chan, who)) ? 1 : 0)
 
-#define IsChannelName(name) ((name) && (*(name) == '#' || *(name) == '&'))
+#define IsChannelName(name) ((name) && (IsChanPrefix(*(name))))
 
 /* extban function results */
 #define EXTBAN_INVALID -1  /* invalid mask, false even if negated */
 #define EXTBAN_NOMATCH  0  /* valid mask, no match */
 #define EXTBAN_MATCH    1  /* matches */
 
+int iter_comm_channels_step(rb_dlink_node *pos1, rb_dlink_node *pos2,
+               struct membership **ms1, struct membership **ms2,
+               struct Channel **chptr);
+
+
+/* Iterate two sorted linked lists of channels, with heads headN, in lockstep.
+   At each iteration, chptr will be a channel in at least one of the lists,
+   and each msN will be non-null iff the channel is in its corresponding list.
+
+   head1 and head2 must be linked list heads.
+   pos1, pos2, ms1, ms2 must be names of modifiable variables, and should not
+   be modified during iteration. It is safe to break or continue at any point
+   without any special cleanup.
+
+   rb_dlink_node_t *pos1, *pos2, *head1, *head2;
+   struct membership *ms1, *ms2;
+   struct Channel *chptr;
+*/
+#define ITER_COMM_CHANNELS(pos1, pos2, head1, head2, ms1, ms2, chptr) \
+               for ((pos1) = (head1), (pos2) = (head2); \
+                       iter_comm_channels_step((pos1), (pos2), &(ms1), &(ms2), &(chptr)); \
+                       (ms1) && ((pos1) = (pos1)->next), (ms2) && ((pos2) = (pos2)->next))
+
+
 extern rb_dlink_list global_channel_list;
 void init_channels(void);
 
 struct Channel *allocate_channel(const char *chname);
 void free_channel(struct Channel *chptr);
-struct Ban *allocate_ban(const char *, const char *);
+struct Ban *allocate_ban(const char *, const char *, const char *);
 void free_ban(struct Ban *bptr);
 
 
 extern void destroy_channel(struct Channel *);
 
-extern int can_send(struct Channel *chptr, struct Client *who, 
+extern int can_send(struct Channel *chptr, struct Client *who,
                    struct membership *);
+extern bool flood_attack_channel(enum message_type msgtype, struct Client *source_p,
+                               struct Channel *chptr, char *chname);
+struct matchset;
 extern int is_banned(struct Channel *chptr, struct Client *who,
-                    struct membership *msptr, const char *, const char *);
+                     struct membership *msptr, const struct matchset *ms,
+                     const char **);
 extern int is_quieted(struct Channel *chptr, struct Client *who,
-                    struct membership *msptr, const char *, const char *);
-extern int can_join(struct Client *source_p, struct Channel *chptr, char *key);
+                    struct membership *msptr, const struct matchset *ms);
+extern int can_join(struct Client *source_p, struct Channel *chptr,
+                   const char *key, const char **forward);
 
 extern struct membership *find_channel_membership(struct Channel *, struct Client *);
 extern const char *find_channel_status(struct membership *msptr, int combine);
@@ -228,7 +269,7 @@ extern void invalidate_bancache_user(struct Client *);
 
 extern void free_channel_list(rb_dlink_list *);
 
-extern int check_channel_name(const char *name);
+extern bool check_channel_name(const char *name);
 
 extern void channel_member_names(struct Channel *chptr, struct Client *,
                                 int show_eon);
@@ -252,17 +293,20 @@ extern void unset_chcap_usage_counts(struct Client *serv_p);
 extern void send_cap_mode_changes(struct Client *client_p, struct Client *source_p,
                                  struct Channel *chptr, struct ChModeChange foo[], int);
 
+void resv_chan_forcepart(const char *name, const char *reason, int temp_time);
+
 extern void set_channel_mode(struct Client *client_p, struct Client *source_p,
                struct Channel *chptr, struct membership *msptr, int parc, const char *parv[]);
-
-extern int chmode_flags[256];
+extern void set_channel_mlock(struct Client *client_p, struct Client *source_p,
+               struct Channel *chptr, const char *newmlock, bool propagate);
 
 extern struct ChannelMode chmode_table[256];
 
-extern int add_id(struct Client *source_p, struct Channel *chptr, const char *banid,
-       rb_dlink_list * list, long mode_type);
+extern bool add_id(struct Client *source_p, struct Channel *chptr, const char *banid,
+       const char *forward, rb_dlink_list * list, long mode_type);
 
-extern int del_id(struct Channel *chptr, const char *banid, rb_dlink_list * list, long mode_type);
+extern struct Ban * del_id(struct Channel *chptr, const char *banid, rb_dlink_list * list,
+       long mode_type);
 
 extern ExtbanFunc extban_table[256];
 
@@ -270,5 +314,8 @@ extern int match_extban(const char *banstr, struct Client *client_p, struct Chan
 extern int valid_extban(const char *banstr, struct Client *client_p, struct Channel *chptr, long mode_type);
 const char * get_extban_string(void);
 
+extern int get_channel_access(struct Client *source_p, struct Channel *chptr, struct membership *msptr, int dir, const char *modestr);
+
+extern void send_channel_join(struct Channel *chptr, struct Client *client_p);
 
 #endif /* INCLUDED_channel_h */