]> arthur.barton.de Git - ngircd.git/blobdiff - src/ngircd/channel.c
- Channel- und Nicknames werden nun ordentlich validiert.
[ngircd.git] / src / ngircd / channel.c
index 0ed2e3fe7bfe9bef248a71fc04149f8b0e2e6e4f..5b125b0e75b5a3da8fd11dc177198f8c778bd203 100644 (file)
@@ -9,11 +9,23 @@
  * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
  * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
  *
- * $Id: channel.c,v 1.13 2002/02/11 01:00:12 alex Exp $
+ * $Id: channel.c,v 1.17 2002/03/02 01:35:50 alex Exp $
  *
  * channel.c: Management der Channels
  *
  * $Log: channel.c,v $
+ * Revision 1.17  2002/03/02 01:35:50  alex
+ * - Channel- und Nicknames werden nun ordentlich validiert.
+ *
+ * Revision 1.16  2002/02/27 23:23:53  alex
+ * - Includes fuer einige Header bereinigt.
+ *
+ * Revision 1.15  2002/02/27 20:32:10  alex
+ * - neue Funktionen Channel_Topic() und Channel_SetTopic().
+ *
+ * Revision 1.14  2002/02/27 15:21:21  alex
+ * - neue Funktion Channel_IsMemberOf() implementiert.
+ *
  * Revision 1.13  2002/02/11 01:00:12  alex
  * - neue Funktionen Channel_ModeAdd(), Channel_ModeDel(), Channel_UserModes(),
  *   Channel_UserModeAdd(), Channel_UserModeDel().
@@ -73,7 +85,7 @@
 #include <string.h>
 
 #include "client.h"
-#include "irc.h"
+#include "irc-write.h"
 #include "log.h"
 #include "messages.h"
 
@@ -308,10 +320,20 @@ GLOBAL CHANNEL *Channel_GetChannel( CL2CHAN *Cl2Chan )
 GLOBAL BOOLEAN Channel_IsValidName( CHAR *Name )
 {
        /* Pr\9ffen, ob Name als Channelname gueltig */
+
+       CHAR *ptr, badchars[] = " ,:\x07";
        
        assert( Name != NULL );
 
        if(( Name[0] != '#' ) || ( strlen( Name ) >= CHANNEL_NAME_LEN )) return FALSE;
+
+       ptr = Name;
+       while( *ptr )
+       {
+               if( strchr( badchars, *ptr )) return FALSE;
+               ptr++;
+       }
+       
        return TRUE;
 } /* Channel_IsValidName */
 
@@ -434,6 +456,35 @@ GLOBAL CHAR *Channel_UserModes( CHANNEL *Chan, CLIENT *Client )
 } /* Channel_UserModes */
 
 
+GLOBAL BOOLEAN Channel_IsMemberOf( CHANNEL *Chan, CLIENT *Client )
+{
+       /* Pruefen, ob Client Mitglied in Channel ist */
+
+       assert( Chan != NULL );
+       assert( Client != NULL );
+
+       if( Get_Cl2Chan( Chan, Client )) return TRUE;
+       else return FALSE;
+} /* Channel_IsMemberOf */
+
+
+GLOBAL CHAR *Channel_Topic( CHANNEL *Chan )
+{
+       assert( Chan != NULL );
+       return Chan->topic;
+} /* Channel_Topic */
+
+
+GLOBAL VOID Channel_SetTopic( CHANNEL *Chan, CHAR *Topic )
+{
+       assert( Chan != NULL );
+       assert( Topic != NULL );
+       
+       strncpy( Chan->topic, Topic, CHANNEL_TOPIC_LEN );
+       Chan->topic[CHANNEL_TOPIC_LEN - 1] = '\0';
+} /* Channel_SetTopic */
+
+
 LOCAL CHANNEL *New_Chan( CHAR *Name )
 {
        /* Neue Channel-Struktur anlegen */
@@ -452,6 +503,7 @@ LOCAL CHANNEL *New_Chan( CHAR *Name )
        strncpy( c->name, Name, CHANNEL_NAME_LEN );
        c->name[CHANNEL_NAME_LEN - 1] = '\0';
        strcpy( c->modes, "" );
+       strcpy( c->topic, "" );
 
        Log( LOG_DEBUG, "Created new channel structure for \"%s\".", Name );