]> jfr.im git - solanum.git/blobdiff - include/channel.h
refuse opers setting an invalidly long k-line reason
[solanum.git] / include / channel.h
index a9c0752995bbd800eb80a170f7b4007865c4d3eb..19ca532fe8fcd828a2aeb037386b12f1f5eda898 100644 (file)
@@ -32,6 +32,7 @@
 #define MAXMODEPARAMSSERV 10
 
 #include <setup.h>
+#include "hook.h"
 
 struct Client;
 
@@ -121,14 +122,24 @@ struct ChModeChange
        int mems;
 };
 
-typedef void (*ChannelModeFunc)(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);
+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
+{
+       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
 {
-       ChannelModeFunc set_func;
+       ChannelModeFunc *set_func;
        long mode_type;
+       enum chm_flags flags;
 };
 
 typedef int (*ExtbanFunc)(const char *data, struct Client *client_p,
@@ -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))
@@ -200,6 +212,30 @@ typedef int (*ExtbanFunc)(const char *data, struct Client *client_p,
 #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);
 
@@ -213,7 +249,7 @@ extern void destroy_channel(struct Channel *);
 
 extern int can_send(struct Channel *chptr, struct Client *who,
                    struct membership *);
-extern bool flood_attack_channel(int p_or_n, struct Client *source_p,
+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,