/*
* ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
+ * Copyright (c)2001-2005 by Alexander Barton (alex@barton.de)
*
* 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
#include "portab.h"
-static char UNUSED id[] = "$Id: channel.c,v 1.46 2005/03/19 18:43:48 fw Exp $";
+static char UNUSED id[] = "$Id: channel.c,v 1.52 2005/07/28 16:23:55 fw Exp $";
#include "imp.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
#include <strings.h>
+#include "defines.h"
#include "conn-func.h"
#include "client.h"
CHANNEL *chan;
char *c;
- int i;
+ unsigned int i;
for( i = 0; i < Conf_Channel_Count; i++ )
{
if( ! Channel_IsValidName( Conf_Channel[i].name ))
{
Log( LOG_ERR, "Can't create pre-defined channel: invalid name: \"%s\"!", Conf_Channel[i].name );
+ array_free(&Conf_Channel[i].topic);
continue;
}
if( chan )
{
Log( LOG_INFO, "Can't create pre-defined channel \"%s\": name already in use.", Conf_Channel[i].name );
+ array_free(&Conf_Channel[i].topic);
continue;
}
if( chan )
{
Channel_ModeAdd( chan, 'P' );
- Channel_SetTopic( chan, Conf_Channel[i].topic );
+ if (!array_copy(&chan->topic, &Conf_Channel[i].topic)) {
+ Log( LOG_WARNING, "Could not set topic for new pre-defined channel: %s",
+ strerror(errno));
+ }
+ array_free(&Conf_Channel[i].topic);
c = Conf_Channel[i].modes;
while( *c ) Channel_ModeAdd( chan, *c++ );
Log( LOG_INFO, "Created pre-defined channel \"%s\".", Conf_Channel[i].name );
while( c )
{
c_next = c->next;
+ array_free(&c->topic);
free( c );
c = c_next;
}
assert( Client != NULL );
assert( Reason != NULL );
+ IRC_WriteStrRelatedPrefix( Client, Client, false, "QUIT :%s", Reason );
+
c = My_Channels;
while( c )
{
GLOBAL char *
Channel_Topic( CHANNEL *Chan )
{
+ char *ret;
assert( Chan != NULL );
- return Chan->topic;
+ ret = array_start(&Chan->topic);
+ return ret ? ret : "";
} /* Channel_Topic */
GLOBAL void
Channel_SetTopic( CHANNEL *Chan, char *Topic )
{
+ size_t len;
assert( Chan != NULL );
assert( Topic != NULL );
-
- strlcpy( Chan->topic, Topic, sizeof( Chan->topic ));
+
+ len = strlen(Topic);
+ if (len < array_bytes(&Chan->topic))
+ array_free(&Chan->topic);
+
+ if (!array_copyb(&Chan->topic, Topic, len))
+ Log(LOG_WARNING, "could not set new Topic %s: %s", Topic, strerror(errno));
+
+ array_cat0(&Chan->topic);
} /* Channel_SetTopic */
c->hash = Hash( c->name );
c->next = My_Channels;
My_Channels = c;
-
+#ifdef DEBUG
Log( LOG_DEBUG, "Created new channel structure for \"%s\".", Name );
-
+#endif
return c;
} /* Channel_Create */
/* QUIT: andere Server wurden bereits informiert, vgl. Client_Destroy();
* hier also "nur" noch alle User in betroffenen Channeln infomieren */
assert( InformServer == false );
- IRC_WriteStrChannelPrefix( Origin, c, Origin, false, "QUIT :%s", Reason );
Log( LOG_DEBUG, "User \"%s\" left channel \"%s\" (%s).", Client_Mask( Client ), c->name, Reason );
break;
case REMOVE_KICK: