]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/irc-server.c
moved invite/ban lists to channel structure
[ngircd-alex.git] / src / ngircd / irc-server.c
index 3d64e1fe7ccfc6c56358be9e1ba55eb884a0496f..da9ba978b8b8b8ab442a05d259d474a5f3f2ac06 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: irc-server.c,v 1.41 2006/10/06 21:32:58 fw Exp $";
+static char UNUSED id[] = "$Id: irc-server.c,v 1.43 2006/12/07 17:57:20 fw Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -41,6 +41,50 @@ static char UNUSED id[] = "$Id: irc-server.c,v 1.41 2006/10/06 21:32:58 fw Exp $
 #include "irc-server.h"
 
 
+#ifdef IRCPLUS
+static bool
+Synchronize_Lists( CLIENT *Client )
+{
+       CHANNEL *c;
+       struct list_head *head;
+       struct list_elem *elem;
+
+       assert( Client != NULL );
+
+       c = Channel_First();
+
+       while (c) {
+               head = Channel_GetListBans(c);
+
+               elem = Lists_GetFirst(head);
+               while (elem) {
+                       if( ! IRC_WriteStrClient( Client, "MODE %s +b %s",
+                                       Channel_Name(c), Lists_GetMask(elem)))
+                       {
+                               return false;
+                       }
+                       elem = Lists_GetNext(elem);
+               }
+
+               head = Channel_GetListInvites(c);
+               elem = Lists_GetFirst(head);
+               while (elem) {
+                       if( ! IRC_WriteStrClient( Client, "MODE %s +I %s",
+                                       Channel_Name( c ), Lists_GetMask(elem)))
+                       {
+                               return false;
+                       }
+                       elem = Lists_GetNext(elem);
+               }
+               c = Channel_Next(c);
+       }
+       return true;
+}
+#endif
+
+
+
+
 /**
  * Handler for the IRC command "SERVER".
  * See RFC 2813 section 4.1.2.
@@ -67,9 +111,8 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
        if (Client_Type(Client) == CLIENT_GOTPASS) {
                /* We got a PASS command from the peer, and now a SERVER
                 * command: the peer tries to register itself as a server. */
-               Log(LOG_DEBUG,
-                   "Connection %d: got SERVER command (new server link) ...",
-                   Client_Conn(Client));
+               LogDebug("Connection %d: got SERVER command (new server link) ...",
+                       Client_Conn(Client));
 
                /* Falsche Anzahl Parameter? */
                if(( Req->argc != 2 ) && ( Req->argc != 3 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
@@ -269,9 +312,7 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
                            "Synchronizing INVITE- and BAN-lists ...");
 #endif
                        /* Synchronize INVITE- and BAN-lists */
-                       if (! Lists_SendInvites(Client))
-                               return DISCONNECTED;
-                       if (! Lists_SendBans(Client))
+                       if (!Synchronize_Lists(Client))
                                return DISCONNECTED;
                }
 #endif