]> jfr.im git - irc/freenode/ircd-seven.git/commitdiff
Add sendto_channel_local_with_capability().
authorWilliam Pitcock <redacted>
Thu, 16 Dec 2010 06:19:24 +0000 (00:19 -0600)
committerWilliam Pitcock <redacted>
Thu, 16 Dec 2010 06:19:24 +0000 (00:19 -0600)
include/send.h
src/send.c

index f9fbd38fa6877a61980a669a04d5d662302734d3..668eb8ca37eab166cf9fec4691072c3a54d93035 100644 (file)
@@ -63,6 +63,9 @@ extern void sendto_channel_opmod(struct Client *one, struct Client *source_p,
 
 extern void sendto_channel_local(int type, struct Channel *, const char *, ...) AFP(3, 4);
 extern void sendto_channel_local_butone(struct Client *, int type, struct Channel *, const char *, ...) AFP(4, 5);
+
+extern void sendto_channel_local_with_capability(int type, int caps, int negcaps, struct Channel *, const char *, ...) AFP(5, 6);
+
 extern void sendto_common_channels_local(struct Client *, int cap, const char *, ...) AFP(3, 4);
 extern void sendto_common_channels_local_butone(struct Client *, int cap, const char *, ...) AFP(3, 4);
 
index a009976218526fa724132b7cd42e6499f7b75dbb..7b69b407184c7f987dfb51d441dd9feebed506d4 100644 (file)
@@ -655,6 +655,47 @@ sendto_channel_local(int type, struct Channel *chptr, const char *pattern, ...)
        rb_linebuf_donebuf(&linebuf);
 }
 
+/* sendto_channel_local_with_capability()
+ *
+ * inputs      - flags to send to, caps, negate caps, channel to send to, va_args
+ * outputs     - message to local channel members
+ * side effects -
+ */
+void
+sendto_channel_local_with_capability(int type, int caps, int negcaps, struct Channel *chptr, const char *pattern, ...)
+{
+       va_list args;
+       buf_head_t linebuf;
+       struct membership *msptr;
+       struct Client *target_p;
+       rb_dlink_node *ptr;
+       rb_dlink_node *next_ptr;
+       
+       rb_linebuf_newbuf(&linebuf); 
+       
+       va_start(args, pattern);
+       rb_linebuf_putmsg(&linebuf, pattern, &args, NULL);
+       va_end(args);
+
+       RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->locmembers.head)
+       {
+               msptr = ptr->data;
+               target_p = msptr->client_p;
+
+               if(IsIOError(target_p) ||
+                  !IsCapable(target_p, caps) ||
+                  IsCapable(target_p, negcaps))
+                       continue;
+
+               if(type && ((msptr->flags & type) == 0))
+                       continue;
+
+               _send_linebuf(target_p, &linebuf);
+       }
+
+       rb_linebuf_donebuf(&linebuf);
+}
+
 /* sendto_channel_local_butone()
  *
  * inputs      - flags to send to, channel to send to, va_args