* ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
*
- * Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
- * der GNU General Public License (GPL), wie von der Free Software Foundation
- * herausgegeben, weitergeben und/oder modifizieren, entweder unter Version 2
- * der Lizenz oder (wenn Sie es wuenschen) jeder spaeteren Version.
- * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
- * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * Please read the file COPYING, README and AUTHORS for more information.
*
- * $Id: channel.c,v 1.28 2002/06/09 13:15:58 alex Exp $
- *
- * channel.c: Management der Channels
+ * Channel management
*/
#include "portab.h"
+static char UNUSED id[] = "$Id: channel.c,v 1.35 2002/12/12 12:24:18 alex Exp $";
+
#include "imp.h"
#include <assert.h>
#include <stdlib.h>
LOCAL CL2CHAN *My_Cl2Chan;
-LOCAL CHANNEL *New_Chan PARAMS(( CHAR *Name ));
LOCAL CL2CHAN *Get_Cl2Chan PARAMS(( CHANNEL *Chan, CLIENT *Client ));
LOCAL CL2CHAN *Add_Client PARAMS(( CHANNEL *Chan, CLIENT *Client ));
LOCAL BOOLEAN Remove_Client PARAMS(( INT Type, CHANNEL *Chan, CLIENT *Client, CLIENT *Origin, CHAR *Reason, BOOLEAN InformServer ));
for( i = 0; i < Conf_Channel_Count; i++ )
{
/* Ist ein Name konfiguriert? */
- if( ! Conf_Channel[i].name ) continue;
+ if( ! Conf_Channel[i].name[0] ) continue;
/* Gueltiger Channel-Name? */
if( ! Channel_IsValidName( Conf_Channel[i].name ))
Log( LOG_ERR, "Can't create pre-defined channel: invalid name: \"%s\"!", Conf_Channel[i].name );
continue;
}
+
+ /* Gibt es den Channel bereits? */
+ chan = Channel_Search( Conf_Channel[i].name );
+ if( chan )
+ {
+ Log( LOG_INFO, "Can't create pre-defined channel \"%s\": name already in use.", Conf_Channel[i].name );
+ continue;
+ }
/* Channel anlegen */
- chan = New_Chan( Conf_Channel[i].name );
+ chan = Channel_Create( Conf_Channel[i].name );
if( chan )
{
- /* Verketten */
- chan->next = My_Channels;
- My_Channels = chan;
Channel_ModeAdd( chan, 'P' );
Channel_SetTopic( chan, Conf_Channel[i].topic );
c = Conf_Channel[i].modes;
else
{
/* Gibt es noch nicht? Dann neu anlegen: */
- chan = New_Chan( Name );
+ chan = Channel_Create( Name );
if( ! chan ) return FALSE;
-
- /* Verketten */
- chan->next = My_Channels;
- My_Channels = chan;
}
/* User dem Channel hinzufuegen */
} /* Channel_Quit */
-GLOBAL INT
+GLOBAL LONG
Channel_Count( VOID )
{
CHANNEL *c;
- INT count;
+ LONG count;
count = 0;
c = My_Channels;
} /* Channel_Count */
-GLOBAL INT
+GLOBAL LONG
Channel_MemberCount( CHANNEL *Chan )
{
CL2CHAN *cl2chan;
- INT count;
+ LONG count;
assert( Chan != NULL );
} /* Channel_SetTopic */
+GLOBAL VOID
+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';
+} /* Channel_SetModes */
+
+
+
GLOBAL BOOLEAN
Channel_Write( CHANNEL *Chan, CLIENT *From, CLIENT *Client, CHAR *Text )
{
} /* Channel_Write */
-
-LOCAL CHANNEL *
-New_Chan( CHAR *Name )
+GLOBAL CHANNEL *
+Channel_Create( CHAR *Name )
{
/* Neue Channel-Struktur anlegen */
strcpy( c->topic, "" );
c->hash = Hash( c->name );
+ /* Verketten */
+ c->next = My_Channels;
+ My_Channels = c;
+
Log( LOG_DEBUG, "Created new channel structure for \"%s\".", Name );
return c;
-} /* New_Chan */
+} /* Channel_Create */
LOCAL CL2CHAN *