]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/channel.c
Clean up files for "ngircd-full" package, too ...
[ngircd-alex.git] / src / ngircd / channel.c
index 7f37dba6f3857420f720a136e079b6311a59b6a9..3c740ff0d406b94e9fe438fbb93d900157eec941 100644 (file)
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: channel.c,v 1.39 2002/12/25 13:22:43 alex Exp $";
+static char UNUSED id[] = "$Id: channel.c,v 1.43 2003/11/06 01:07:44 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
 #include <stdlib.h>
 #include <string.h>
 
-#include "conn.h"
+#include "conn-func.h"
 #include "client.h"
 
 #include "exp.h"
@@ -494,7 +494,7 @@ Channel_ModeAdd( CHANNEL *Chan, CHAR Mode )
        if( ! strchr( Chan->modes, x[0] ))
        {
                /* Client hat den Mode noch nicht -> setzen */
-               strcat( Chan->modes, x );
+               strlcat( Chan->modes, x, sizeof( Chan->modes ));
                return TRUE;
        }
        else return FALSE;
@@ -547,7 +547,7 @@ Channel_UserModeAdd( CHANNEL *Chan, CLIENT *Client, CHAR Mode )
        if( ! strchr( cl2chan->modes, x[0] ))
        {
                /* Client hat den Mode noch nicht -> setzen */
-               strcat( cl2chan->modes, x );
+               strlcat( cl2chan->modes, x, sizeof( cl2chan->modes ));
                return TRUE;
        }
        else return FALSE;
@@ -629,8 +629,7 @@ Channel_SetTopic( CHANNEL *Chan, CHAR *Topic )
        assert( Chan != NULL );
        assert( Topic != NULL );
        
-       strncpy( Chan->topic, Topic, CHANNEL_TOPIC_LEN - 1 );
-       Chan->topic[CHANNEL_TOPIC_LEN - 1] = '\0';
+       strlcpy( Chan->topic, Topic, sizeof( Chan->topic ));
 } /* Channel_SetTopic */
 
 
@@ -640,8 +639,7 @@ Channel_SetModes( CHANNEL *Chan, CHAR *Modes )
        assert( Chan != NULL );
        assert( Modes != NULL );
 
-       strncpy( Chan->modes, Modes, CHANNEL_MODE_LEN - 1 );
-       Chan->topic[CHANNEL_MODE_LEN - 1] = '\0';
+       strlcpy( Chan->modes, Modes, sizeof( Chan->modes ));
 } /* Channel_SetModes */
 
 
@@ -651,8 +649,7 @@ Channel_SetKey( CHANNEL *Chan, CHAR *Key )
        assert( Chan != NULL );
        assert( Key != NULL );
 
-       strncpy( Chan->key, Key, CLIENT_PASS_LEN - 1 );
-       Chan->key[CLIENT_PASS_LEN - 1] = '\0';
+       strlcpy( Chan->key, Key, sizeof( Chan->key ));
        Log( LOG_DEBUG, "Channel %s: Key is now \"%s\".", Chan->name, Chan->key );
 } /* Channel_SetKey */
 
@@ -672,7 +669,7 @@ Channel_Write( CHANNEL *Chan, CLIENT *From, CLIENT *Client, CHAR *Text )
 {
        BOOLEAN is_member, has_voice, is_op, ok;
 
-       /* Okay, Ziel ist ein Channel */
+       /* Okay, target is a channel */
        is_member = has_voice = is_op = FALSE;
        if( Channel_IsMemberOf( Chan, From ))
        {
@@ -681,14 +678,21 @@ Channel_Write( CHANNEL *Chan, CLIENT *From, CLIENT *Client, CHAR *Text )
                if( strchr( Channel_UserModes( Chan, From ), 'o' )) is_op = TRUE;
        }
 
-       /* pruefen, ob Client in Channel schreiben darf */
+       /* Check weather client is allowed to write to channel */
        ok = TRUE;
        if( strchr( Channel_Modes( Chan ), 'n' ) && ( ! is_member )) ok = FALSE;
        if( strchr( Channel_Modes( Chan ), 'm' ) && ( ! is_op ) && ( ! has_voice )) ok = FALSE;
+       
+       /* Is the client banned? */
+       if( Lists_CheckBanned( From, Chan ))
+       {
+               /* Client is banned, bus is he channel operator or has voice? */
+               if(( ! has_voice ) && ( ! is_op )) ok = FALSE;
+       }
 
        if( ! ok ) return IRC_WriteStrClient( From, ERR_CANNOTSENDTOCHAN_MSG, Client_ID( From ), Channel_Name( Chan ));
 
-       /* Text senden */
+       /* Send text */
        if( Client_Conn( From ) > NONE ) Conn_UpdateIdle( Client_Conn( From ));
        return IRC_WriteStrChannelPrefix( Client, Chan, From, TRUE, "PRIVMSG %s :%s", Channel_Name( Chan ), Text );
 } /* Channel_Write */
@@ -710,7 +714,7 @@ Channel_Create( CHAR *Name )
                return NULL;
        }
        c->next = NULL;
-       strncpy( c->name, Name, CHANNEL_NAME_LEN - 1 );
+       strlcpy( c->name, Name, sizeof( c->name ));
        c->name[CHANNEL_NAME_LEN - 1] = '\0';
        strcpy( c->modes, "" );
        strcpy( c->topic, "" );