]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - src/send.c
dlink -> rb_dlink
[irc/rqf/shadowircd.git] / src / send.c
index e32e7fb032977d1f29e7d5dbb1c362a52b0c8f54..b55a2ef298cffbf22bd4b9b093cca7ac178a343d 100644 (file)
@@ -21,7 +21,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *  $Id: send.c 3161 2007-01-25 07:23:01Z nenolod $
+ *  $Id: send.c 3520 2007-06-30 22:15:35Z jilles $
  */
 
 #include "stdinc.h"
@@ -43,6 +43,7 @@
 #include "s_log.h"
 #include "memory.h"
 #include "hook.h"
+#include "monitor.h"
 
 #define LOG_BUFSIZE 2048
 
@@ -107,7 +108,7 @@ _send_linebuf(struct Client *to, buf_head_t *linebuf)
        to->localClient->sendM += 1;
        me.localClient->sendM += 1;
        if(linebuf_len(&to->localClient->buf_sendq) > 0)
-               send_queued_write(to->localClient->fd, to);
+               send_queued_write(to->localClient->F->fd, to);
        return 0;
 }
 
@@ -123,30 +124,7 @@ send_linebuf_remote(struct Client *to, struct Client *from, buf_head_t *linebuf)
        if(to->from)
                to = to->from;
 
-       /* test for fake direction */
-       if(!MyClient(from) && IsPerson(to) && (to == from->from))
-       {
-               if(IsServer(from))
-               {
-                       sendto_realops_snomask(SNO_GENERAL, L_ALL,
-                                            "Send message to %s[%s] dropped from %s(Fake Dir)",
-                                            to->name, to->from->name, from->name);
-                       return;
-               }
-
-               sendto_realops_snomask(SNO_GENERAL, L_ALL,
-                                    "Ghosted: %s[%s@%s] from %s[%s@%s] (%s)",
-                                    to->name, to->username, to->host,
-                                    from->name, from->username, from->host, to->from->name);
-               kill_client_serv_butone(NULL, to, "%s (%s[%s@%s] Ghosted %s)",
-                                       me.name, to->name, to->username,
-                                       to->host, to->from->name);
-
-               to->flags |= FLAGS_KILLED;
-
-               exit_client(NULL, to, &me, "Ghosted client");
-               return;
-       }
+       /* we assume the caller has already tested for fake direction */
 
        _send_linebuf(to, linebuf);
        return;
@@ -167,6 +145,10 @@ send_queued_write(int fd, void *data)
 #ifdef USE_IODEBUG_HOOKS
        hook_data_int hd;
 #endif
+       fde_t *F = rb_locate_fd(to->localClient->F->fd);
+       if (!F)
+               return;
+
        /* cant write anything to a dead socket. */
        if(IsIOError(to))
                return;
@@ -181,7 +163,7 @@ send_queued_write(int fd, void *data)
        if(linebuf_len(&to->localClient->buf_sendq))
        {
                while ((retlen =
-                       linebuf_flush(to->localClient->fd, &to->localClient->buf_sendq)) > 0)
+                       linebuf_flush(F, &to->localClient->buf_sendq)) > 0)
                {
                        /* We have some data written .. update counters */
 #ifdef USE_IODEBUG_HOOKS
@@ -220,7 +202,7 @@ send_queued_write(int fd, void *data)
        else
                flags = COMM_SELECT_WRITE;
        if(linebuf_len(&to->localClient->buf_sendq))
-       comm_setselect(fd, FDLIST_IDLECLIENT, flags,
+       rb_setselect(fd, FDLIST_IDLECLIENT, flags,
                               send_queued_write, to, 0);
 }
 
@@ -283,7 +265,7 @@ send_queued_slink_write(int fd, void *data)
 
        /* if we have any more data, reschedule a write */
        if(to->localClient->slinkq_len)
-               comm_setselect(to->localClient->ctrlfd, FDLIST_IDLECLIENT,
+               rb_setselect(to->localClient->ctrlfd, FDLIST_IDLECLIENT,
                               COMM_SELECT_WRITE|COMM_SELECT_RETRY, send_queued_slink_write, to, 0);
 }
 
@@ -464,12 +446,12 @@ sendto_server(struct Client *one, struct Channel *chptr, unsigned long caps,
 {
        va_list args;
        struct Client *target_p;
-       dlink_node *ptr;
-       dlink_node *next_ptr;
+       rb_dlink_node *ptr;
+       rb_dlink_node *next_ptr;
        buf_head_t linebuf;
 
        /* noone to send to.. */
-       if(dlink_list_length(&serv_list) == 0)
+       if(rb_dlink_list_length(&serv_list) == 0)
                return;
 
        if(chptr != NULL && *chptr->chname != '#')
@@ -520,8 +502,8 @@ sendto_channel_flags(struct Client *one, int type, struct Client *source_p,
        buf_head_t linebuf_id;
        struct Client *target_p;
        struct membership *msptr;
-       dlink_node *ptr;
-       dlink_node *next_ptr;
+       rb_dlink_node *ptr;
+       rb_dlink_node *next_ptr;
 
        linebuf_newbuf(&linebuf_local);
        linebuf_newbuf(&linebuf_name);
@@ -600,8 +582,8 @@ sendto_channel_local(int type, struct Channel *chptr, const char *pattern, ...)
        buf_head_t linebuf;
        struct membership *msptr;
        struct Client *target_p;
-       dlink_node *ptr;
-       dlink_node *next_ptr;
+       rb_dlink_node *ptr;
+       rb_dlink_node *next_ptr;
        
        linebuf_newbuf(&linebuf); 
        
@@ -640,8 +622,8 @@ sendto_channel_local_butone(struct Client *one, int type, struct Channel *chptr,
        buf_head_t linebuf;
        struct membership *msptr;
        struct Client *target_p;
-       dlink_node *ptr;
-       dlink_node *next_ptr;
+       rb_dlink_node *ptr;
+       rb_dlink_node *next_ptr;
        
        linebuf_newbuf(&linebuf); 
        
@@ -683,10 +665,10 @@ void
 sendto_common_channels_local(struct Client *user, const char *pattern, ...)
 {
        va_list args;
-       dlink_node *ptr;
-       dlink_node *next_ptr;
-       dlink_node *uptr;
-       dlink_node *next_uptr;
+       rb_dlink_node *ptr;
+       rb_dlink_node *next_ptr;
+       rb_dlink_node *uptr;
+       rb_dlink_node *next_uptr;
        struct Channel *chptr;
        struct Client *target_p;
        struct membership *msptr;
@@ -741,10 +723,10 @@ void
 sendto_common_channels_local_butone(struct Client *user, const char *pattern, ...)
 {
        va_list args;
-       dlink_node *ptr;
-       dlink_node *next_ptr;
-       dlink_node *uptr;
-       dlink_node *next_uptr;
+       rb_dlink_node *ptr;
+       rb_dlink_node *next_ptr;
+       rb_dlink_node *uptr;
+       rb_dlink_node *next_uptr;
        struct Channel *chptr;
        struct Client *target_p;
        struct membership *msptr;
@@ -795,8 +777,8 @@ sendto_match_butone(struct Client *one, struct Client *source_p,
        static char buf[BUFSIZE];
        va_list args;
        struct Client *target_p;
-       dlink_node *ptr;
-       dlink_node *next_ptr;
+       rb_dlink_node *ptr;
+       rb_dlink_node *next_ptr;
        buf_head_t linebuf_local;
        buf_head_t linebuf_name;
        buf_head_t linebuf_id;
@@ -871,7 +853,7 @@ sendto_match_servs(struct Client *source_p, const char *mask, int cap,
 {
        static char buf[BUFSIZE];
        va_list args;
-       dlink_node *ptr;
+       rb_dlink_node *ptr;
        struct Client *target_p;
        buf_head_t linebuf_id;
        buf_head_t linebuf_name;
@@ -928,6 +910,40 @@ sendto_match_servs(struct Client *source_p, const char *mask, int cap,
        linebuf_donebuf(&linebuf_name);
 }
 
+/* sendto_monitor()
+ *
+ * inputs      - monitor nick to send to, format, va_args
+ * outputs     - message to local users monitoring the given nick
+ * side effects -
+ */
+void
+sendto_monitor(struct monitor *monptr, const char *pattern, ...)
+{
+       va_list args;
+       buf_head_t linebuf;
+       struct Client *target_p;
+       rb_dlink_node *ptr;
+       rb_dlink_node *next_ptr;
+       
+       linebuf_newbuf(&linebuf); 
+       
+       va_start(args, pattern);
+       linebuf_putmsg(&linebuf, pattern, &args, NULL);
+       va_end(args);
+
+       DLINK_FOREACH_SAFE(ptr, next_ptr, monptr->users.head)
+       {
+               target_p = ptr->data;
+
+               if(IsIOError(target_p))
+                       continue;
+
+               _send_linebuf(target_p, &linebuf);
+       }
+
+       linebuf_donebuf(&linebuf);
+}
+
 /* sendto_anywhere()
  *
  * inputs      - target, source, va_args
@@ -982,8 +998,8 @@ void
 sendto_realops_flags(int flags, int level, const char *pattern, ...)
 {
        struct Client *client_p;
-       dlink_node *ptr;
-       dlink_node *next_ptr;
+       rb_dlink_node *ptr;
+       rb_dlink_node *next_ptr;
        va_list args;
        buf_head_t linebuf;
 
@@ -1024,8 +1040,8 @@ sendto_realops_snomask(int flags, int level, const char *pattern, ...)
        static char buf[BUFSIZE];
        char *snobuf;
        struct Client *client_p;
-       dlink_node *ptr;
-       dlink_node *next_ptr;
+       rb_dlink_node *ptr;
+       rb_dlink_node *next_ptr;
        va_list args;
        buf_head_t linebuf;
 
@@ -1089,8 +1105,8 @@ sendto_realops_snomask_from(int flags, int level, struct Client *source_p,
                const char *pattern, ...)
 {
        struct Client *client_p;
-       dlink_node *ptr;
-       dlink_node *next_ptr;
+       rb_dlink_node *ptr;
+       rb_dlink_node *next_ptr;
        va_list args;
        buf_head_t linebuf;
 
@@ -1132,8 +1148,8 @@ void
 sendto_wallops_flags(int flags, struct Client *source_p, const char *pattern, ...)
 {
        struct Client *client_p;
-       dlink_node *ptr;
-       dlink_node *next_ptr;
+       rb_dlink_node *ptr;
+       rb_dlink_node *next_ptr;
        va_list args;
        buf_head_t linebuf;
 
@@ -1202,8 +1218,8 @@ kill_client_serv_butone(struct Client *one, struct Client *target_p, const char
        static char buf[BUFSIZE];
        va_list args;
        struct Client *client_p;
-       dlink_node *ptr;
-       dlink_node *next_ptr;
+       rb_dlink_node *ptr;
+       rb_dlink_node *next_ptr;
        buf_head_t linebuf_id;
        buf_head_t linebuf_name;