]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/irc-mode.c
Fixed propagation of channel mode 'P' on server links.
[ngircd-alex.git] / src / ngircd / irc-mode.c
index fa3730813e98eaf2b88f511f5f40e149b23aefb2..c26984d8208ec5eb0e4201bd2bebe694dd0b6097 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: irc-mode.c,v 1.46 2006/08/12 11:56:24 fw Exp $";
+static char UNUSED id[] = "$Id: irc-mode.c,v 1.50 2007/10/14 12:08:57 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -164,6 +164,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
                {
                        case 'i': /* Invisible */
                        case 's': /* Server messages */
+                       case 'w': /* Wallops messages */
                                x[0] = *mode_ptr;
                                break;
 
@@ -268,7 +269,7 @@ Channel_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel )
                        switch( *mode_ptr )
                        {
                                case 'l':
-                                       snprintf( argadd, sizeof( argadd ), " %ld", Channel_MaxUsers( Channel ));
+                                       snprintf( argadd, sizeof( argadd ), " %lu", Channel_MaxUsers( Channel ));
                                        strlcat( the_args, argadd, sizeof( the_args ));
                                        break;
                                case 'k':
@@ -431,16 +432,21 @@ Channel_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel )
                                break;
 
                        case 'P': /* Persistent channel */
-                               if( modeok )
-                               {
-                                       if( set && ( ! Client_OperByMe( Client )))
-                                       {
-                                               /* Only IRC operators are allowed to set P mode */
-                                               ok = IRC_WriteStrClient( Origin, ERR_NOPRIVILEGES_MSG, Client_ID( Origin ));
-                                       }
-                                       else x[0] = 'P';
-                               }
-                               else ok = IRC_WriteStrClient( Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( Origin ), Channel_Name( Channel ));
+                               if (modeok) {
+                                       /* Only IRC operators are allowed to
+                                        * set the 'P' channel mode! */
+                                       if (set && ! (Client_OperByMe(Client)
+                                           || Client_Type(Client) == CLIENT_SERVER)) {
+                                               ok = IRC_WriteStrClient(Origin,
+                                                       ERR_NOPRIVILEGES_MSG,
+                                                       Client_ID(Origin));
+                                       } else
+                                               x[0] = 'P';
+                               } else
+                                       ok = IRC_WriteStrClient(Origin,
+                                               ERR_CHANOPRIVSNEEDED_MSG,
+                                               Client_ID(Origin),
+                                               Channel_Name(Channel));
                                break;
 
                        /* --- Channel user modes --- */
@@ -477,7 +483,7 @@ Channel_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel )
                                        Req->argv[arg_arg][0] = '\0';
                                        arg_arg++;
                                }
-                               else Lists_ShowInvites( Origin, Channel );
+                               else Channel_ShowInvites( Origin, Channel );
                                break;
 
                        case 'b': /* Ban lists */
@@ -493,7 +499,7 @@ Channel_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel )
                                        Req->argv[arg_arg][0] = '\0';
                                        arg_arg++;
                                }
-                               else Lists_ShowBans( Origin, Channel );
+                               else Channel_ShowBans( Origin, Channel );
                                break;
 
                        default:
@@ -644,11 +650,13 @@ Add_Invite( CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, char *Pattern )
 
        mask = Lists_MakeMask( Pattern );
 
-       already = Lists_IsInviteEntry( mask, Channel );
-       
-       if( ! Lists_AddInvited( mask, Channel, false )) return CONNECTED;
-       
-       if(( Client_Type( Prefix ) == CLIENT_SERVER ) && ( already == true)) return CONNECTED;
+       already = Lists_CheckDupeMask(Channel_GetListInvites(Channel), mask );
+       if (!already) {
+               if( ! Channel_AddInvite(Channel, mask, false ))
+                       return CONNECTED;
+       }
+       if ( already && ( Client_Type( Prefix ) == CLIENT_SERVER ))
+               return CONNECTED;
 
        return Send_ListChange( "+I", Prefix, Client, Channel, mask );
 } /* Add_Invite */
@@ -666,11 +674,13 @@ Add_Ban( CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, char *Pattern )
 
        mask = Lists_MakeMask( Pattern );
 
-       already = Lists_IsBanEntry( mask, Channel );
-
-       if( ! Lists_AddBanned( mask, Channel )) return CONNECTED;
-
-       if(( Client_Type( Prefix ) == CLIENT_SERVER ) && ( already == true)) return CONNECTED;
+       already = Lists_CheckDupeMask(Channel_GetListBans(Channel), mask );
+       if (!already) {
+               if( ! Channel_AddBan(Channel, mask))
+                       return CONNECTED;
+       }
+       if ( already && ( Client_Type( Prefix ) == CLIENT_SERVER ))
+               return CONNECTED;
 
        return Send_ListChange( "+b", Prefix, Client, Channel, mask );
 } /* Add_Ban */
@@ -686,7 +696,7 @@ Del_Invite( CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, char *Pattern )
        assert( Pattern != NULL );
 
        mask = Lists_MakeMask( Pattern );
-       Lists_DelInvited( mask, Channel );
+       Lists_Del(Channel_GetListInvites(Channel), mask);
        return Send_ListChange( "-I", Prefix, Client, Channel, mask );
 } /* Del_Invite */
 
@@ -701,7 +711,7 @@ Del_Ban( CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, char *Pattern )
        assert( Pattern != NULL );
 
        mask = Lists_MakeMask( Pattern );
-       Lists_DelBanned( mask, Channel );
+       Lists_Del(Channel_GetListBans(Channel), mask);
        return Send_ListChange( "-b", Prefix, Client, Channel, mask );
 } /* Del_Ban */