]> jfr.im git - solanum.git/blobdiff - src/send.c
newconf: fix a warning
[solanum.git] / src / send.c
index 4c04daf32ea776d943d8d7259696a437aa5ce048..17af7b4702ecf8bd14b49cc81ea5c5b00bc66f23 100644 (file)
@@ -85,10 +85,7 @@ _send_linebuf(struct Client *to, buf_head_t *linebuf)
                             get_sendq(to));
                }
 
-               if(IsClient(to))
-                       to->flags |= FLAGS_SENDQEX;
-
-               dead_link(to);
+               dead_link(to, 1);
                return -1;
        }
        else
@@ -200,7 +197,7 @@ send_queued(struct Client *to)
 
                if(retlen == 0 || (retlen < 0 && !rb_ignore_errno(errno)))
                {
-                       dead_link(to);
+                       dead_link(to, 0);
                        return;
                }
        }
@@ -658,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) ||
+                  !NotCapable(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
@@ -705,6 +743,7 @@ sendto_channel_local_butone(struct Client *one, int type, struct Channel *chptr,
  * sendto_common_channels_local()
  *
  * inputs      - pointer to client
+ *              - capability mask
  *             - pattern to send
  * output      - NONE
  * side effects        - Sends a message to all people on local server who are
@@ -712,7 +751,7 @@ sendto_channel_local_butone(struct Client *one, int type, struct Channel *chptr,
  *               used by m_nick.c and exit_one_client.
  */
 void
-sendto_common_channels_local(struct Client *user, const char *pattern, ...)
+sendto_common_channels_local(struct Client *user, int cap, const char *pattern, ...)
 {
        va_list args;
        rb_dlink_node *ptr;
@@ -743,7 +782,8 @@ sendto_common_channels_local(struct Client *user, const char *pattern, ...)
                        target_p = msptr->client_p;
 
                        if(IsIOError(target_p) ||
-                          target_p->serial == current_serial)
+                          target_p->serial == current_serial ||
+                          !IsCapable(target_p, cap))
                                continue;
 
                        target_p->serial = current_serial;
@@ -764,13 +804,14 @@ sendto_common_channels_local(struct Client *user, const char *pattern, ...)
  * sendto_common_channels_local_butone()
  *
  * inputs      - pointer to client
+ *              - capability mask
  *             - pattern to send
  * output      - NONE
  * side effects        - Sends a message to all people on local server who are
  *               in same channel with user, except for user itself.
  */
 void
-sendto_common_channels_local_butone(struct Client *user, const char *pattern, ...)
+sendto_common_channels_local_butone(struct Client *user, int cap, const char *pattern, ...)
 {
        va_list args;
        rb_dlink_node *ptr;
@@ -803,7 +844,8 @@ sendto_common_channels_local_butone(struct Client *user, const char *pattern, ..
                        target_p = msptr->client_p;
 
                        if(IsIOError(target_p) ||
-                          target_p->serial == current_serial)
+                          target_p->serial == current_serial ||
+                          !IsCapable(target_p, cap))
                                continue;
 
                        target_p->serial = current_serial;