Commit Diff


commit - 46a191caf6bff88f8e4cf1a577ba33a60efb015e
commit + 84706af7fec9243f84a3c11a3492f64b3af1cbe6
blob - aaf38d1b73e856b368cd4baa02dd9a02cce72020
blob + edb0f6205dfee3ac896142aa931e0a6fef5c9f2c
--- src/ngircd/channel.c
+++ src/ngircd/channel.c
@@ -17,12 +17,13 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: channel.c,v 1.51 2005/07/11 14:11:35 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"
@@ -87,6 +88,7 @@ Channel_InitPredefined( void )
 		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;
 		}
 
@@ -95,6 +97,7 @@ Channel_InitPredefined( void )
 		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;
 		}
 		
@@ -103,7 +106,11 @@ Channel_InitPredefined( void )
 		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 );
@@ -124,6 +131,7 @@ Channel_Exit( void )
 	while( c )
 	{
 		c_next = c->next;
+		array_free(&c->topic);
 		free( c );
 		c = c_next;
 	}
@@ -621,18 +629,28 @@ Channel_IsMemberOf( CHANNEL *Chan, CLIENT *Client )
 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 */
 
 
@@ -720,9 +738,9 @@ Channel_Create( char *Name )
 	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 */
 
blob - 1bc185a9fa21d05350abccbcc66b6419f9f6ef58
blob + 493161b034cb1433fc2690b0e08e4a66259413fb
--- src/ngircd/channel.h
+++ src/ngircd/channel.h
@@ -8,7 +8,7 @@
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
- * $Id: channel.h,v 1.27 2005/03/19 18:43:48 fw Exp $
+ * $Id: channel.h,v 1.28 2005/07/28 16:23:55 fw Exp $
  *
  * Channel management (header)
  */
@@ -21,6 +21,7 @@
 #if defined(__channel_c__) | defined(S_SPLINT_S)
 
 #include "defines.h"
+#include "array.h"
 
 typedef struct _CHANNEL
 {
@@ -28,7 +29,7 @@ typedef struct _CHANNEL
 	char name[CHANNEL_NAME_LEN];	/* Name of the channel */
 	UINT32 hash;			/* Hash of the (lowecase!) name */
 	char modes[CHANNEL_MODE_LEN];	/* Channel modes */
-	char topic[CHANNEL_TOPIC_LEN];	/* Topic of the channel */
+	array topic;			/* Topic of the channel */
 	char key[CLIENT_PASS_LEN];	/* Channel key ("password", mode "k" ) */
 	long maxusers;			/* Maximum number of members (mode "l") */
 } CHANNEL;
blob - a10d1be0167e06c24908a1996b00dc5228714890
blob + 0764d2c7d96d720f700860221543479f07f86567
--- src/ngircd/conf.c
+++ src/ngircd/conf.c
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: conf.c,v 1.80 2005/07/17 18:58:04 fw Exp $";
+static char UNUSED id[] = "$Id: conf.c,v 1.81 2005/07/28 16:23:55 fw Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -98,6 +98,7 @@ Conf_Test( void )
 	struct passwd *pwd;
 	struct group *grp;
 	unsigned int i;
+	char *topic;
 
 	Use_Log = false;
 	Set_Defaults( true );
@@ -187,7 +188,8 @@ Conf_Test( void )
 		puts( "[CHANNEL]" );
 		printf( "  Name = %s\n", Conf_Channel[i].name );
 		printf( "  Modes = %s\n", Conf_Channel[i].modes );
-		printf( "  Topic = %s\n", Conf_Channel[i].topic );
+		topic = (char*)array_start(&Conf_Channel[i].topic);
+		printf( "  Topic = %s\n", topic ? topic : "");
 		puts( "" );
 	}
 	
@@ -508,15 +510,14 @@ Read_Config( void )
 				else New_Server_Idx = i;
 				continue;
 			}
-			if( strcasecmp( section, "[CHANNEL]" ) == 0 )
-			{
-				if( Conf_Channel_Count + 1 > MAX_DEFCHANNELS ) Config_Error( LOG_ERR, "Too many pre-defined channels configured." );
-				else
-				{
+			if( strcasecmp( section, "[CHANNEL]" ) == 0 ) {
+				if( Conf_Channel_Count + 1 > MAX_DEFCHANNELS ) {
+					Config_Error( LOG_ERR, "Too many pre-defined channels configured." );
+				} else {
 					/* Initialize new channel structure */
 					strcpy( Conf_Channel[Conf_Channel_Count].name, "" );
 					strcpy( Conf_Channel[Conf_Channel_Count].modes, "" );
-					strcpy( Conf_Channel[Conf_Channel_Count].topic, "" );
+					array_free(&Conf_Channel[Conf_Channel_Count].topic);
 					Conf_Channel_Count++;
 				}
 				continue;
@@ -934,7 +935,7 @@ Handle_CHANNEL( int Line, char *Var, char *Arg )
 	if( strcasecmp( Var, "Topic" ) == 0 )
 	{
 		/* Initial topic */
-		if( strlcpy( Conf_Channel[Conf_Channel_Count - 1].topic, Arg, sizeof( Conf_Channel[Conf_Channel_Count - 1].topic )) >= sizeof( Conf_Channel[Conf_Channel_Count - 1].topic ))
+		if (!array_copys( &Conf_Channel[Conf_Channel_Count - 1].topic, Arg))
 			Config_Error_TooLong( Line, Var );
  
 		return;
blob - a97526c61e606e89eee7fdecc3ecd682bfa41eb6
blob + e312cccad1b0f5228dbc38db10e3b081eed52f75
--- src/ngircd/conf.h
+++ src/ngircd/conf.h
@@ -8,7 +8,7 @@
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
- * $Id: conf.h,v 1.35 2005/07/11 14:11:35 fw Exp $
+ * $Id: conf.h,v 1.36 2005/07/28 16:23:55 fw Exp $
  *
  * Configuration management (header)
  */
@@ -20,6 +20,7 @@
 #include <time.h>
 
 #include "defines.h"
+#include "array.h"
 #include "portab.h"
 
 typedef struct _Conf_Oper
@@ -48,7 +49,7 @@ typedef struct _Conf_Channel
 {
 	char name[CHANNEL_NAME_LEN];	/* Name of the channel */
 	char modes[CHANNEL_MODE_LEN];	/* Initial channel modes */
-	char topic[CHANNEL_TOPIC_LEN];	/* Initial topic */
+	array topic;			/* Initial topic */
 } CONF_CHANNEL;
 
 
blob - 8feb5b86e21687c8144fa4d62742f4e7b6d73ede
blob + 70800c3d65c4d2354eb9ce9662720786c4020678
--- src/ngircd/defines.h
+++ src/ngircd/defines.h
@@ -8,7 +8,7 @@
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
- * $Id: defines.h,v 1.55 2005/07/08 16:18:39 alex Exp $
+ * $Id: defines.h,v 1.56 2005/07/28 16:23:55 fw Exp $
  */
 
 
@@ -62,7 +62,6 @@
 #define CHANNEL_NAME_LEN 51		/* Max. length of a channel name, see
 					   RFC 2812 section 1.3 */
 #define CHANNEL_MODE_LEN 9		/* Max. length of channel modes */
-#define CHANNEL_TOPIC_LEN 128		/* Max. length of a channel topic */
 
 #define COMMAND_LEN 513			/* Max. IRC command length, see. RFC
 					   2812 section 3.2 */
blob - db04a9c33140e51c169d2f6e25c10ebb085d55e0
blob + 603d1167330d25dedcb65ad2611e48c1cb220052
--- src/ngircd/irc-login.c
+++ src/ngircd/irc-login.c
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: irc-login.c,v 1.44 2005/06/04 12:32:09 fw Exp $";
+static char UNUSED id[] = "$Id: irc-login.c,v 1.45 2005/07/28 16:23:55 fw Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -542,7 +542,8 @@ Hello_User( CLIENT *Client )
 #endif
 
 	/* Features */
-	if( ! IRC_WriteStrClient( Client, RPL_ISUPPORT_MSG, Client_ID( Client ), CLIENT_NICK_LEN - 1, CHANNEL_TOPIC_LEN - 1, CLIENT_AWAY_LEN - 1, Conf_MaxJoins )) return DISCONNECTED;
+	if( ! IRC_WriteStrClient( Client, RPL_ISUPPORT_MSG, Client_ID( Client ), CLIENT_NICK_LEN - 1,
+			COMMAND_LEN - 23, CLIENT_AWAY_LEN - 1, Conf_MaxJoins )) return DISCONNECTED;
 
 	Client_SetType( Client, CLIENT_USER );