]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - src/send.c
s_log.* -> logger.* (s_foo looks ugly, lets try to get rid of it)
[irc/rqf/shadowircd.git] / src / send.c
index bd4adea8e457449c5efccd490a294a6e57ac5c74..9cbfae734cd5d3b36207fd66df3b5a301ed07407 100644 (file)
@@ -25,7 +25,6 @@
  */
 
 #include "stdinc.h"
-#include "tools.h"
 #include "send.h"
 #include "channel.h"
 #include "class.h"
 #include "irc_string.h"
 #include "ircd.h"
 #include "numeric.h"
-#include "commio.h"
 #include "s_serv.h"
 #include "sprintf_irc.h"
 #include "s_conf.h"
 #include "s_newconf.h"
-#include "linebuf.h"
-#include "s_log.h"
-#include "memory.h"
+#include "logger.h"
 #include "hook.h"
 #include "monitor.h"
 
@@ -50,6 +46,8 @@
 /* send the message to the link the target is attached to */
 #define send_linebuf(a,b) _send_linebuf((a->from ? a->from : a) ,b)
 
+static void send_queued_write(rb_fde_t *F, void *data);
+
 unsigned long current_serial = 0L;
 
 /* send_linebuf()
@@ -70,19 +68,19 @@ _send_linebuf(struct Client *to, buf_head_t *linebuf)
        if(!MyConnect(to) || IsIOError(to))
                return 0;
 
-       if(linebuf_len(&to->localClient->buf_sendq) > get_sendq(to))
+       if(rb_linebuf_len(&to->localClient->buf_sendq) > get_sendq(to))
        {
                if(IsServer(to))
                {
                        sendto_realops_snomask(SNO_GENERAL, L_ALL,
                                             "Max SendQ limit exceeded for %s: %u > %lu",
                                             get_server_name(to, HIDE_IP),
-                                            linebuf_len(&to->localClient->buf_sendq), 
+                                            rb_linebuf_len(&to->localClient->buf_sendq), 
                                             get_sendq(to));
 
                        ilog(L_SERVER, "Max SendQ limit exceeded for %s: %u > %lu",
                             log_client_name(to, SHOW_IP),
-                            linebuf_len(&to->localClient->buf_sendq), 
+                            rb_linebuf_len(&to->localClient->buf_sendq), 
                             get_sendq(to));
                }
 
@@ -97,7 +95,7 @@ _send_linebuf(struct Client *to, buf_head_t *linebuf)
                /* just attach the linebuf to the sendq instead of
                 * generating a new one
                 */
-               linebuf_attach(&to->localClient->buf_sendq, linebuf);
+               rb_linebuf_attach(&to->localClient->buf_sendq, linebuf);
        }
 
        /*
@@ -107,8 +105,8 @@ _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);
+       if(rb_linebuf_len(&to->localClient->buf_sendq) > 0)
+               send_queued(to);
        return 0;
 }
 
@@ -124,30 +122,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;
@@ -160,14 +135,16 @@ send_linebuf_remote(struct Client *to, struct Client *from, buf_head_t *linebuf)
  * side effects - write is rescheduled if queue isnt emptied
  */
 void
-send_queued_write(int fd, void *data)
+send_queued(struct Client *to)
 {
-       struct Client *to = data;
        int retlen;
-       int flags;
 #ifdef USE_IODEBUG_HOOKS
        hook_data_int hd;
 #endif
+       rb_fde_t *F = to->localClient->F;
+       if (!F)
+               return;
+
        /* cant write anything to a dead socket. */
        if(IsIOError(to))
                return;
@@ -179,10 +156,10 @@ send_queued_write(int fd, void *data)
                             to->localClient->buf_sendq.writeofs;
 #endif
 
-       if(linebuf_len(&to->localClient->buf_sendq))
+       if(rb_linebuf_len(&to->localClient->buf_sendq))
        {
                while ((retlen =
-                       linebuf_flush(to->localClient->fd, &to->localClient->buf_sendq)) > 0)
+                       rb_linebuf_flush(F, &to->localClient->buf_sendq)) > 0)
                {
                        /* We have some data written .. update counters */
 #ifdef USE_IODEBUG_HOOKS
@@ -210,19 +187,29 @@ send_queued_write(int fd, void *data)
                        }
                }
 
-               if(retlen == 0 || (retlen < 0 && !ignoreErrno(errno)))
+               if(retlen == 0 || (retlen < 0 && !rb_ignore_errno(errno)))
                {
                        dead_link(to);
                        return;
                }
        }
-       if(ignoreErrno(errno))
-               flags = COMM_SELECT_WRITE|COMM_SELECT_RETRY;
-       else
-               flags = COMM_SELECT_WRITE;
-       if(linebuf_len(&to->localClient->buf_sendq))
-       comm_setselect(fd, FDLIST_IDLECLIENT, flags,
-                              send_queued_write, to, 0);
+       if(rb_linebuf_len(&to->localClient->buf_sendq))
+       rb_setselect(to->localClient->F, RB_SELECT_WRITE,
+                              send_queued_write, to);
+}
+
+/* send_queued_write()
+ *
+ * inputs      - fd to have queue sent, client we're sending to
+ * outputs     - contents of queue
+ * side effects - write is scheduled if queue isnt emptied
+ */
+static void
+send_queued_write(rb_fde_t *F, void *data)
+{
+       struct Client *to = data;
+       /*ClearFlush(to);*/
+       send_queued(to);
 }
 
 /* send_queued_slink_write()
@@ -247,14 +234,14 @@ send_queued_slink_write(int fd, void *data)
        /* Next, lets try to write some data */
        if(to->localClient->slinkq)
        {
-               retlen = write(to->localClient->ctrlfd,
+               /* retlen = write(to->localClient->ctrlfd,
                              to->localClient->slinkq + to->localClient->slinkq_ofs,
-                             to->localClient->slinkq_len);
+                             to->localClient->slinkq_len); */
 
                if(retlen < 0)
                {
                        /* If we have a fatal error */
-                       if(!ignoreErrno(errno))
+                       if(!rb_ignore_errno(errno))
                        {
                                dead_link(to);
                                return;
@@ -276,16 +263,16 @@ send_queued_slink_write(int fd, void *data)
                        else
                        {
                                to->localClient->slinkq_ofs = 0;
-                               MyFree(to->localClient->slinkq);
+                               rb_free(to->localClient->slinkq);
                                to->localClient->slinkq = NULL;
                        }
                }
        }
 
        /* if we have any more data, reschedule a write */
-       if(to->localClient->slinkq_len)
-               comm_setselect(to->localClient->ctrlfd, FDLIST_IDLECLIENT,
-                              COMM_SELECT_WRITE|COMM_SELECT_RETRY, send_queued_slink_write, to, 0);
+       /* if(to->localClient->slinkq_len)
+               rb_setselect(to->localClient->ctrlfd,
+                              RB_SELECT_WRITE, send_queued_slink_write, to); */
 }
 
 /* sendto_one()
@@ -307,15 +294,15 @@ sendto_one(struct Client *target_p, const char *pattern, ...)
        if(IsIOError(target_p))
                return;
 
-       linebuf_newbuf(&linebuf);
+       rb_linebuf_newbuf(&linebuf);
 
        va_start(args, pattern);
-       linebuf_putmsg(&linebuf, pattern, &args, NULL);
+       rb_linebuf_putmsg(&linebuf, pattern, &args, NULL);
        va_end(args);
 
        _send_linebuf(target_p, &linebuf);
 
-       linebuf_donebuf(&linebuf);
+       rb_linebuf_donebuf(&linebuf);
 
 }
 
@@ -348,16 +335,16 @@ sendto_one_prefix(struct Client *target_p, struct Client *source_p,
                return;
        }
 
-       linebuf_newbuf(&linebuf);
+       rb_linebuf_newbuf(&linebuf);
        va_start(args, pattern);
-       linebuf_putmsg(&linebuf, pattern, &args,
+       rb_linebuf_putmsg(&linebuf, pattern, &args,
                       ":%s %s %s ",
                       get_id(source_p, target_p),
                       command, get_id(target_p, target_p));
        va_end(args);
 
        _send_linebuf(dest_p, &linebuf);
-       linebuf_donebuf(&linebuf);
+       rb_linebuf_donebuf(&linebuf);
 }
 
 /* sendto_one_notice()
@@ -389,15 +376,15 @@ sendto_one_notice(struct Client *target_p, const char *pattern, ...)
                return;
        }
 
-       linebuf_newbuf(&linebuf);
+       rb_linebuf_newbuf(&linebuf);
        va_start(args, pattern);
-       linebuf_putmsg(&linebuf, pattern, &args,
+       rb_linebuf_putmsg(&linebuf, pattern, &args,
                       ":%s NOTICE %s ",
                       get_id(&me, target_p), *(to = get_id(target_p, target_p)) != '\0' ? to : "*");
        va_end(args);
 
        _send_linebuf(dest_p, &linebuf);
-       linebuf_donebuf(&linebuf);
+       rb_linebuf_donebuf(&linebuf);
 }
 
 
@@ -430,16 +417,16 @@ sendto_one_numeric(struct Client *target_p, int numeric, const char *pattern, ..
                return;
        }
 
-       linebuf_newbuf(&linebuf);
+       rb_linebuf_newbuf(&linebuf);
        va_start(args, pattern);
-       linebuf_putmsg(&linebuf, pattern, &args,
+       rb_linebuf_putmsg(&linebuf, pattern, &args,
                       ":%s %03d %s ",
                       get_id(&me, target_p),
                       numeric, *(to = get_id(target_p, target_p)) != '\0' ? to : "*");
        va_end(args);
 
        _send_linebuf(dest_p, &linebuf);
-       linebuf_donebuf(&linebuf);
+       rb_linebuf_donebuf(&linebuf);
 }
 
 /*
@@ -465,23 +452,23 @@ 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 != '#')
                        return;
 
-       linebuf_newbuf(&linebuf);
+       rb_linebuf_newbuf(&linebuf);
        va_start(args, format);
-       linebuf_putmsg(&linebuf, format, &args, NULL);
+       rb_linebuf_putmsg(&linebuf, format, &args, NULL);
        va_end(args);
 
-       DLINK_FOREACH_SAFE(ptr, next_ptr, serv_list.head)
+       RB_DLINK_FOREACH_SAFE(ptr, next_ptr, serv_list.head)
        {
                target_p = ptr->data;
 
@@ -500,7 +487,7 @@ sendto_server(struct Client *one, struct Channel *chptr, unsigned long caps,
                _send_linebuf(target_p, &linebuf);
        }
 
-       linebuf_donebuf(&linebuf);
+       rb_linebuf_donebuf(&linebuf);
 
 }
 
@@ -516,37 +503,37 @@ sendto_channel_flags(struct Client *one, int type, struct Client *source_p,
 {
        static char buf[BUFSIZE];
        va_list args;
-       buf_head_t linebuf_local;
-       buf_head_t linebuf_name;
-       buf_head_t linebuf_id;
+       buf_head_t rb_linebuf_local;
+       buf_head_t rb_linebuf_name;
+       buf_head_t rb_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);
-       linebuf_newbuf(&linebuf_id);
+       rb_linebuf_newbuf(&rb_linebuf_local);
+       rb_linebuf_newbuf(&rb_linebuf_name);
+       rb_linebuf_newbuf(&rb_linebuf_id);
 
        current_serial++;
 
        va_start(args, pattern);
-       ircvsnprintf(buf, sizeof(buf), pattern, args);
+       rb_vsnprintf(buf, sizeof(buf), pattern, args);
        va_end(args);
 
        if(IsServer(source_p))
-               linebuf_putmsg(&linebuf_local, NULL, NULL,
+               rb_linebuf_putmsg(&rb_linebuf_local, NULL, NULL,
                               ":%s %s", source_p->name, buf);
        else
-               linebuf_putmsg(&linebuf_local, NULL, NULL,
+               rb_linebuf_putmsg(&rb_linebuf_local, NULL, NULL,
                               ":%s!%s@%s %s",
                               source_p->name, source_p->username, 
                               source_p->host, buf);
 
-       linebuf_putmsg(&linebuf_name, NULL, NULL, ":%s %s", source_p->name, buf);
-       linebuf_putmsg(&linebuf_id, NULL, NULL, ":%s %s", use_id(source_p), buf);
+       rb_linebuf_putmsg(&rb_linebuf_name, NULL, NULL, ":%s %s", source_p->name, buf);
+       rb_linebuf_putmsg(&rb_linebuf_id, NULL, NULL, ":%s %s", use_id(source_p), buf);
 
-       DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->members.head)
+       RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->members.head)
        {
                msptr = ptr->data;
                target_p = msptr->client_p;
@@ -571,20 +558,20 @@ sendto_channel_flags(struct Client *one, int type, struct Client *source_p,
                        if(target_p->from->serial != current_serial)
                        {
                                if(has_id(target_p->from))
-                                       send_linebuf_remote(target_p, source_p, &linebuf_id);
+                                       send_linebuf_remote(target_p, source_p, &rb_linebuf_id);
                                else
-                                       send_linebuf_remote(target_p, source_p, &linebuf_name);
+                                       send_linebuf_remote(target_p, source_p, &rb_linebuf_name);
 
                                target_p->from->serial = current_serial;
                        }
                }
                else
-                       _send_linebuf(target_p, &linebuf_local);
+                       _send_linebuf(target_p, &rb_linebuf_local);
        }
 
-       linebuf_donebuf(&linebuf_local);
-       linebuf_donebuf(&linebuf_name);
-       linebuf_donebuf(&linebuf_id);
+       rb_linebuf_donebuf(&rb_linebuf_local);
+       rb_linebuf_donebuf(&rb_linebuf_name);
+       rb_linebuf_donebuf(&rb_linebuf_id);
 }
 
 
@@ -601,16 +588,16 @@ 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); 
+       rb_linebuf_newbuf(&linebuf); 
        
        va_start(args, pattern);
-       linebuf_putmsg(&linebuf, pattern, &args, NULL);
+       rb_linebuf_putmsg(&linebuf, pattern, &args, NULL);
        va_end(args);
 
-       DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->locmembers.head)
+       RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->locmembers.head)
        {
                msptr = ptr->data;
                target_p = msptr->client_p;
@@ -624,7 +611,7 @@ sendto_channel_local(int type, struct Channel *chptr, const char *pattern, ...)
                _send_linebuf(target_p, &linebuf);
        }
 
-       linebuf_donebuf(&linebuf);
+       rb_linebuf_donebuf(&linebuf);
 }
 
 /* sendto_channel_local_butone()
@@ -641,16 +628,16 @@ 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); 
+       rb_linebuf_newbuf(&linebuf); 
        
        va_start(args, pattern);
-       linebuf_putmsg(&linebuf, pattern, &args, NULL);
+       rb_linebuf_putmsg(&linebuf, pattern, &args, NULL);
        va_end(args);
 
-       DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->locmembers.head)
+       RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->locmembers.head)
        {
                msptr = ptr->data;
                target_p = msptr->client_p;
@@ -667,7 +654,7 @@ sendto_channel_local_butone(struct Client *one, int type, struct Channel *chptr,
                _send_linebuf(target_p, &linebuf);
        }
 
-       linebuf_donebuf(&linebuf);
+       rb_linebuf_donebuf(&linebuf);
 }
 
 /*
@@ -684,29 +671,29 @@ 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;
        struct membership *mscptr;
        buf_head_t linebuf;
 
-       linebuf_newbuf(&linebuf);
+       rb_linebuf_newbuf(&linebuf);
        va_start(args, pattern);
-       linebuf_putmsg(&linebuf, pattern, &args, NULL);
+       rb_linebuf_putmsg(&linebuf, pattern, &args, NULL);
        va_end(args);
 
        ++current_serial;
 
-       DLINK_FOREACH_SAFE(ptr, next_ptr, user->user->channel.head)
+       RB_DLINK_FOREACH_SAFE(ptr, next_ptr, user->user->channel.head)
        {
                mscptr = ptr->data;
                chptr = mscptr->chptr;
 
-               DLINK_FOREACH_SAFE(uptr, next_uptr, chptr->locmembers.head)
+               RB_DLINK_FOREACH_SAFE(uptr, next_uptr, chptr->locmembers.head)
                {
                        msptr = uptr->data;
                        target_p = msptr->client_p;
@@ -726,7 +713,7 @@ sendto_common_channels_local(struct Client *user, const char *pattern, ...)
        if(MyConnect(user) && (user->serial != current_serial))
                send_linebuf(user, &linebuf);
 
-       linebuf_donebuf(&linebuf);
+       rb_linebuf_donebuf(&linebuf);
 }
 
 /*
@@ -742,31 +729,31 @@ 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;
        struct membership *mscptr;
        buf_head_t linebuf;
 
-       linebuf_newbuf(&linebuf);
+       rb_linebuf_newbuf(&linebuf);
        va_start(args, pattern);
-       linebuf_putmsg(&linebuf, pattern, &args, NULL);
+       rb_linebuf_putmsg(&linebuf, pattern, &args, NULL);
        va_end(args);
 
        ++current_serial;
        /* Skip them -- jilles */
        user->serial = current_serial;
 
-       DLINK_FOREACH_SAFE(ptr, next_ptr, user->user->channel.head)
+       RB_DLINK_FOREACH_SAFE(ptr, next_ptr, user->user->channel.head)
        {
                mscptr = ptr->data;
                chptr = mscptr->chptr;
 
-               DLINK_FOREACH_SAFE(uptr, next_uptr, chptr->locmembers.head)
+               RB_DLINK_FOREACH_SAFE(uptr, next_uptr, chptr->locmembers.head)
                {
                        msptr = uptr->data;
                        target_p = msptr->client_p;
@@ -780,7 +767,7 @@ sendto_common_channels_local_butone(struct Client *user, const char *pattern, ..
                }
        }
 
-       linebuf_donebuf(&linebuf);
+       rb_linebuf_donebuf(&linebuf);
 }
 
 /* sendto_match_butone()
@@ -796,53 +783,53 @@ 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;
-       buf_head_t linebuf_local;
-       buf_head_t linebuf_name;
-       buf_head_t linebuf_id;
+       rb_dlink_node *ptr;
+       rb_dlink_node *next_ptr;
+       buf_head_t rb_linebuf_local;
+       buf_head_t rb_linebuf_name;
+       buf_head_t rb_linebuf_id;
 
-       linebuf_newbuf(&linebuf_local);
-       linebuf_newbuf(&linebuf_name);
-       linebuf_newbuf(&linebuf_id);
+       rb_linebuf_newbuf(&rb_linebuf_local);
+       rb_linebuf_newbuf(&rb_linebuf_name);
+       rb_linebuf_newbuf(&rb_linebuf_id);
 
        va_start(args, pattern);
-       ircvsnprintf(buf, sizeof(buf), pattern, args);
+       rb_vsnprintf(buf, sizeof(buf), pattern, args);
        va_end(args);
 
        if(IsServer(source_p))
-               linebuf_putmsg(&linebuf_local, NULL, NULL,
+               rb_linebuf_putmsg(&rb_linebuf_local, NULL, NULL,
                               ":%s %s", source_p->name, buf);
        else
-               linebuf_putmsg(&linebuf_local, NULL, NULL,
+               rb_linebuf_putmsg(&rb_linebuf_local, NULL, NULL,
                               ":%s!%s@%s %s",
                               source_p->name, source_p->username, 
                               source_p->host, buf);
 
-       linebuf_putmsg(&linebuf_name, NULL, NULL, ":%s %s", source_p->name, buf);
-       linebuf_putmsg(&linebuf_id, NULL, NULL, ":%s %s", use_id(source_p), buf);
+       rb_linebuf_putmsg(&rb_linebuf_name, NULL, NULL, ":%s %s", source_p->name, buf);
+       rb_linebuf_putmsg(&rb_linebuf_id, NULL, NULL, ":%s %s", use_id(source_p), buf);
 
        if(what == MATCH_HOST)
        {
-               DLINK_FOREACH_SAFE(ptr, next_ptr, lclient_list.head)
+               RB_DLINK_FOREACH_SAFE(ptr, next_ptr, lclient_list.head)
                {
                        target_p = ptr->data;
 
                        if(match(mask, target_p->host))
-                               _send_linebuf(target_p, &linebuf_local);
+                               _send_linebuf(target_p, &rb_linebuf_local);
                }
        }
        /* what = MATCH_SERVER, if it doesnt match us, just send remote */
        else if(match(mask, me.name))
        {
-               DLINK_FOREACH_SAFE(ptr, next_ptr, lclient_list.head)
+               RB_DLINK_FOREACH_SAFE(ptr, next_ptr, lclient_list.head)
                {
                        target_p = ptr->data;
-                       _send_linebuf(target_p, &linebuf_local);
+                       _send_linebuf(target_p, &rb_linebuf_local);
                }
        }
 
-       DLINK_FOREACH(ptr, serv_list.head)
+       RB_DLINK_FOREACH(ptr, serv_list.head)
        {
                target_p = ptr->data;
 
@@ -850,14 +837,14 @@ sendto_match_butone(struct Client *one, struct Client *source_p,
                        continue;
 
                if(has_id(target_p))
-                       send_linebuf_remote(target_p, source_p, &linebuf_id);
+                       send_linebuf_remote(target_p, source_p, &rb_linebuf_id);
                else
-                       send_linebuf_remote(target_p, source_p, &linebuf_name);
+                       send_linebuf_remote(target_p, source_p, &rb_linebuf_name);
        }
 
-       linebuf_donebuf(&linebuf_local);
-       linebuf_donebuf(&linebuf_id);
-       linebuf_donebuf(&linebuf_name);
+       rb_linebuf_donebuf(&rb_linebuf_local);
+       rb_linebuf_donebuf(&rb_linebuf_id);
+       rb_linebuf_donebuf(&rb_linebuf_name);
 }
 
 /* sendto_match_servs()
@@ -872,29 +859,29 @@ 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;
+       buf_head_t rb_linebuf_id;
+       buf_head_t rb_linebuf_name;
 
        if(EmptyString(mask))
                return;
 
-       linebuf_newbuf(&linebuf_id);
-       linebuf_newbuf(&linebuf_name);
+       rb_linebuf_newbuf(&rb_linebuf_id);
+       rb_linebuf_newbuf(&rb_linebuf_name);
 
        va_start(args, pattern);
-       ircvsnprintf(buf, sizeof(buf), pattern, args);
+       rb_vsnprintf(buf, sizeof(buf), pattern, args);
        va_end(args);
 
-       linebuf_putmsg(&linebuf_id, NULL, NULL, 
+       rb_linebuf_putmsg(&rb_linebuf_id, NULL, NULL, 
                        ":%s %s", use_id(source_p), buf);
-       linebuf_putmsg(&linebuf_name, NULL, NULL, 
+       rb_linebuf_putmsg(&rb_linebuf_name, NULL, NULL, 
                        ":%s %s", source_p->name, buf);
 
        current_serial++;
 
-       DLINK_FOREACH(ptr, global_serv_list.head)
+       RB_DLINK_FOREACH(ptr, global_serv_list.head)
        {
                target_p = ptr->data;
 
@@ -919,14 +906,14 @@ sendto_match_servs(struct Client *source_p, const char *mask, int cap,
                                continue;
 
                        if(has_id(target_p->from))
-                               _send_linebuf(target_p->from, &linebuf_id);
+                               _send_linebuf(target_p->from, &rb_linebuf_id);
                        else
-                               _send_linebuf(target_p->from, &linebuf_name);
+                               _send_linebuf(target_p->from, &rb_linebuf_name);
                }
        }
 
-       linebuf_donebuf(&linebuf_id);
-       linebuf_donebuf(&linebuf_name);
+       rb_linebuf_donebuf(&rb_linebuf_id);
+       rb_linebuf_donebuf(&rb_linebuf_name);
 }
 
 /* sendto_monitor()
@@ -941,16 +928,16 @@ sendto_monitor(struct monitor *monptr, const char *pattern, ...)
        va_list args;
        buf_head_t linebuf;
        struct Client *target_p;
-       dlink_node *ptr;
-       dlink_node *next_ptr;
+       rb_dlink_node *ptr;
+       rb_dlink_node *next_ptr;
        
-       linebuf_newbuf(&linebuf); 
+       rb_linebuf_newbuf(&linebuf); 
        
        va_start(args, pattern);
-       linebuf_putmsg(&linebuf, pattern, &args, NULL);
+       rb_linebuf_putmsg(&linebuf, pattern, &args, NULL);
        va_end(args);
 
-       DLINK_FOREACH_SAFE(ptr, next_ptr, monptr->users.head)
+       RB_DLINK_FOREACH_SAFE(ptr, next_ptr, monptr->users.head)
        {
                target_p = ptr->data;
 
@@ -960,7 +947,7 @@ sendto_monitor(struct monitor *monptr, const char *pattern, ...)
                _send_linebuf(target_p, &linebuf);
        }
 
-       linebuf_donebuf(&linebuf);
+       rb_linebuf_donebuf(&linebuf);
 }
 
 /* sendto_anywhere()
@@ -976,25 +963,25 @@ sendto_anywhere(struct Client *target_p, struct Client *source_p,
        va_list args;
        buf_head_t linebuf;
 
-       linebuf_newbuf(&linebuf);
+       rb_linebuf_newbuf(&linebuf);
 
        va_start(args, pattern);
 
        if(MyClient(target_p))
        {
                if(IsServer(source_p))
-                       linebuf_putmsg(&linebuf, pattern, &args, ":%s %s %s ",
+                       rb_linebuf_putmsg(&linebuf, pattern, &args, ":%s %s %s ",
                                       source_p->name, command, 
                                       target_p->name);
                else
-                       linebuf_putmsg(&linebuf, pattern, &args, 
+                       rb_linebuf_putmsg(&linebuf, pattern, &args, 
                                       ":%s!%s@%s %s %s ", 
                                       source_p->name, source_p->username,
                                       source_p->host, command,
                                       target_p->name);
        }
        else
-               linebuf_putmsg(&linebuf, pattern, &args, ":%s %s %s ",
+               rb_linebuf_putmsg(&linebuf, pattern, &args, ":%s %s %s ",
                               get_id(source_p, target_p), command,
                               get_id(target_p, target_p));
        va_end(args);
@@ -1004,7 +991,7 @@ sendto_anywhere(struct Client *target_p, struct Client *source_p,
        else
                send_linebuf_remote(target_p, source_p, &linebuf);
 
-       linebuf_donebuf(&linebuf);
+       rb_linebuf_donebuf(&linebuf);
 }
 
 /* sendto_realops_flags()
@@ -1017,19 +1004,19 @@ 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;
 
-       linebuf_newbuf(&linebuf);
+       rb_linebuf_newbuf(&linebuf);
 
        va_start(args, pattern);
-       linebuf_putmsg(&linebuf, pattern, &args, 
+       rb_linebuf_putmsg(&linebuf, pattern, &args, 
                       ":%s NOTICE * :*** Notice -- ", me.name);
        va_end(args);
 
-       DLINK_FOREACH_SAFE(ptr, next_ptr, local_oper_list.head)
+       RB_DLINK_FOREACH_SAFE(ptr, next_ptr, local_oper_list.head)
        {
                client_p = ptr->data;
 
@@ -1044,7 +1031,7 @@ sendto_realops_flags(int flags, int level, const char *pattern, ...)
                        _send_linebuf(client_p, &linebuf);
        }
 
-       linebuf_donebuf(&linebuf);
+       rb_linebuf_donebuf(&linebuf);
 }
 
 /* sendto_realops_snomask()
@@ -1059,12 +1046,12 @@ 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;
 
-       linebuf_newbuf(&linebuf);
+       rb_linebuf_newbuf(&linebuf);
 
        /* Be very sure not to do things like "Trying to send to myself"
         * L_NETWIDE, otherwise infinite recursion may result! -- jilles */
@@ -1072,9 +1059,9 @@ sendto_realops_snomask(int flags, int level, const char *pattern, ...)
        {
                /* rather a lot of copying around, oh well -- jilles */
                va_start(args, pattern);
-               ircvsnprintf(buf, sizeof(buf), pattern, args);
+               rb_vsnprintf(buf, sizeof(buf), pattern, args);
                va_end(args);
-               linebuf_putmsg(&linebuf, pattern, NULL, 
+               rb_linebuf_putmsg(&linebuf, pattern, NULL, 
                                ":%s NOTICE * :*** Notice -- %s", me.name, buf);
                snobuf = construct_snobuf(flags);
                if (snobuf[1] != '\0')
@@ -1090,13 +1077,13 @@ sendto_realops_snomask(int flags, int level, const char *pattern, ...)
        else
        {
                va_start(args, pattern);
-               linebuf_putmsg(&linebuf, pattern, &args, 
+               rb_linebuf_putmsg(&linebuf, pattern, &args, 
                                ":%s NOTICE * :*** Notice -- ", me.name);
                va_end(args);
        }
        level &= ~L_NETWIDE;
 
-       DLINK_FOREACH_SAFE(ptr, next_ptr, local_oper_list.head)
+       RB_DLINK_FOREACH_SAFE(ptr, next_ptr, local_oper_list.head)
        {
                client_p = ptr->data;
 
@@ -1111,7 +1098,7 @@ sendto_realops_snomask(int flags, int level, const char *pattern, ...)
                        _send_linebuf(client_p, &linebuf);
        }
 
-       linebuf_donebuf(&linebuf);
+       rb_linebuf_donebuf(&linebuf);
 }
 /* sendto_realops_snomask_from()
  *
@@ -1124,19 +1111,19 @@ 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;
 
-       linebuf_newbuf(&linebuf);
+       rb_linebuf_newbuf(&linebuf);
 
        va_start(args, pattern);
-       linebuf_putmsg(&linebuf, pattern, &args, 
+       rb_linebuf_putmsg(&linebuf, pattern, &args, 
                       ":%s NOTICE * :*** Notice -- ", source_p->name);
        va_end(args);
 
-       DLINK_FOREACH_SAFE(ptr, next_ptr, local_oper_list.head)
+       RB_DLINK_FOREACH_SAFE(ptr, next_ptr, local_oper_list.head)
        {
                client_p = ptr->data;
 
@@ -1151,7 +1138,7 @@ sendto_realops_snomask_from(int flags, int level, struct Client *source_p,
                        _send_linebuf(client_p, &linebuf);
        }
 
-       linebuf_donebuf(&linebuf);
+       rb_linebuf_donebuf(&linebuf);
 }
 
 /*
@@ -1167,25 +1154,25 @@ 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;
 
-       linebuf_newbuf(&linebuf);
+       rb_linebuf_newbuf(&linebuf);
 
        va_start(args, pattern);
 
        if(IsPerson(source_p))
-               linebuf_putmsg(&linebuf, pattern, &args,
+               rb_linebuf_putmsg(&linebuf, pattern, &args,
                               ":%s!%s@%s WALLOPS :", source_p->name,
                               source_p->username, source_p->host);
        else
-               linebuf_putmsg(&linebuf, pattern, &args, ":%s WALLOPS :", source_p->name);
+               rb_linebuf_putmsg(&linebuf, pattern, &args, ":%s WALLOPS :", source_p->name);
 
        va_end(args);
 
-       DLINK_FOREACH_SAFE(ptr, next_ptr, IsPerson(source_p) && flags == UMODE_WALLOP ? lclient_list.head : local_oper_list.head)
+       RB_DLINK_FOREACH_SAFE(ptr, next_ptr, IsPerson(source_p) && flags == UMODE_WALLOP ? lclient_list.head : local_oper_list.head)
        {
                client_p = ptr->data;
 
@@ -1193,7 +1180,7 @@ sendto_wallops_flags(int flags, struct Client *source_p, const char *pattern, ..
                        _send_linebuf(client_p, &linebuf);
        }
 
-       linebuf_donebuf(&linebuf);
+       rb_linebuf_donebuf(&linebuf);
 }
 
 /* kill_client()
@@ -1208,15 +1195,15 @@ kill_client(struct Client *target_p, struct Client *diedie, const char *pattern,
        va_list args;
        buf_head_t linebuf;
 
-       linebuf_newbuf(&linebuf);
+       rb_linebuf_newbuf(&linebuf);
 
        va_start(args, pattern);
-       linebuf_putmsg(&linebuf, pattern, &args, ":%s KILL %s :",
+       rb_linebuf_putmsg(&linebuf, pattern, &args, ":%s KILL %s :",
                      get_id(&me, target_p), get_id(diedie, target_p));
        va_end(args);
 
        send_linebuf(target_p, &linebuf);
-       linebuf_donebuf(&linebuf);
+       rb_linebuf_donebuf(&linebuf);
 }
 
 
@@ -1237,24 +1224,24 @@ 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;
-       buf_head_t linebuf_id;
-       buf_head_t linebuf_name;
+       rb_dlink_node *ptr;
+       rb_dlink_node *next_ptr;
+       buf_head_t rb_linebuf_id;
+       buf_head_t rb_linebuf_name;
 
-       linebuf_newbuf(&linebuf_name);
-       linebuf_newbuf(&linebuf_id);
+       rb_linebuf_newbuf(&rb_linebuf_name);
+       rb_linebuf_newbuf(&rb_linebuf_id);
        
        va_start(args, pattern);
-       ircvsnprintf(buf, sizeof(buf), pattern, args);
+       rb_vsnprintf(buf, sizeof(buf), pattern, args);
        va_end(args);
 
-       linebuf_putmsg(&linebuf_name, NULL, NULL, ":%s KILL %s :%s",
+       rb_linebuf_putmsg(&rb_linebuf_name, NULL, NULL, ":%s KILL %s :%s",
                       me.name, target_p->name, buf);
-       linebuf_putmsg(&linebuf_id, NULL, NULL, ":%s KILL %s :%s",
+       rb_linebuf_putmsg(&rb_linebuf_id, NULL, NULL, ":%s KILL %s :%s",
                       use_id(&me), use_id(target_p), buf);
 
-       DLINK_FOREACH_SAFE(ptr, next_ptr, serv_list.head)
+       RB_DLINK_FOREACH_SAFE(ptr, next_ptr, serv_list.head)
        {
                client_p = ptr->data;
 
@@ -1266,11 +1253,11 @@ kill_client_serv_butone(struct Client *one, struct Client *target_p, const char
                        continue;
 
                if(has_id(client_p))
-                       _send_linebuf(client_p, &linebuf_id);
+                       _send_linebuf(client_p, &rb_linebuf_id);
                else
-                       _send_linebuf(client_p, &linebuf_name);
+                       _send_linebuf(client_p, &rb_linebuf_name);
        }
 
-       linebuf_donebuf(&linebuf_id);
-       linebuf_donebuf(&linebuf_name);
+       rb_linebuf_donebuf(&rb_linebuf_id);
+       rb_linebuf_donebuf(&rb_linebuf_name);
 }