X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Fchannel.c;h=982d8335ea739acf07744728976b9296abfd997d;hp=4f0482d7ed68d2d0f901fcdf5f3df4c6ba0115b9;hb=10363b398e05604d2318c67b943e7a742cb25323;hpb=153aa0aac80468dead6e22617c6b86068da089d7 diff --git a/src/ngircd/channel.c b/src/ngircd/channel.c index 4f0482d7..982d8335 100644 --- a/src/ngircd/channel.c +++ b/src/ngircd/channel.c @@ -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.14 2002/02/27 15:21:21 alex Exp $ + * $Id: channel.c,v 1.18 2002/03/03 17:17:01 alex Exp $ * * channel.c: Management der Channels * * $Log: channel.c,v $ + * Revision 1.18 2002/03/03 17:17:01 alex + * - strncpy() und vsnprintf() kopieren nun etwas "optimierter" (1 Byte weniger) :-) + * + * 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. * @@ -76,7 +88,7 @@ #include #include "client.h" -#include "irc.h" +#include "irc-write.h" #include "log.h" #include "messages.h" @@ -311,10 +323,20 @@ GLOBAL CHANNEL *Channel_GetChannel( CL2CHAN *Cl2Chan ) GLOBAL BOOLEAN Channel_IsValidName( CHAR *Name ) { /* PrŸfen, 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 */ @@ -449,6 +471,23 @@ GLOBAL BOOLEAN Channel_IsMemberOf( CHANNEL *Chan, CLIENT *Client ) } /* 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 - 1 ); + Chan->topic[CHANNEL_TOPIC_LEN - 1] = '\0'; +} /* Channel_SetTopic */ + + LOCAL CHANNEL *New_Chan( CHAR *Name ) { /* Neue Channel-Struktur anlegen */ @@ -464,9 +503,10 @@ LOCAL CHANNEL *New_Chan( CHAR *Name ) return NULL; } c->next = NULL; - strncpy( c->name, Name, CHANNEL_NAME_LEN ); + strncpy( c->name, Name, CHANNEL_NAME_LEN - 1 ); c->name[CHANNEL_NAME_LEN - 1] = '\0'; strcpy( c->modes, "" ); + strcpy( c->topic, "" ); Log( LOG_DEBUG, "Created new channel structure for \"%s\".", Name );