about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2010-11-15 19:36:21 +0100
committerAlexander Barton <alex@barton.de>2010-11-15 19:36:21 +0100
commitde6f08cc040240fdec662f18fb51d95859c4ab5a (patch)
tree5dff4e11356184950f2327f9c179e9adf9a80445
parent678d5411e23b3361ef32617f520d051109de8eef (diff)
parent7321be2ccd861f1a260e16bf8ddbd32490fbc340 (diff)
downloadngircd-de6f08cc040240fdec662f18fb51d95859c4ab5a.tar.gz
ngircd-de6f08cc040240fdec662f18fb51d95859c4ab5a.zip
Merge branch 'numeric-329'
* numeric-329:
  New numeric 329: get channel creation time on "MODE #chan" commands
  Save channel creation time; new function Channel_CreationTime()
-rw-r--r--src/ngircd/channel.c11
-rw-r--r--src/ngircd/channel.h2
-rw-r--r--src/ngircd/irc-mode.c13
-rw-r--r--src/ngircd/messages.h1
4 files changed, 25 insertions, 2 deletions
diff --git a/src/ngircd/channel.c b/src/ngircd/channel.c
index 175f23b2..edbbc38b 100644
--- a/src/ngircd/channel.c
+++ b/src/ngircd/channel.c
@@ -697,6 +697,14 @@ Channel_TopicWho(CHANNEL *Chan)
 	return Chan->topic_who;
 } /* Channel_TopicWho */
 
+
+GLOBAL unsigned int
+Channel_CreationTime(CHANNEL *Chan)
+{
+	assert(Chan != NULL);
+	return (unsigned int) Chan->creation_time;
+} /* Channel_CreationTime */
+
 #endif
 
 
@@ -834,6 +842,9 @@ Channel_Create( const char *Name )
 	strlcpy( c->name, Name, sizeof( c->name ));
 	c->hash = Hash( c->name );
 	c->next = My_Channels;
+#ifndef STRICT_RFC
+	c->creation_time = time(NULL);
+#endif
 	My_Channels = c;
 	LogDebug("Created new channel structure for \"%s\".", Name);
 	return c;
diff --git a/src/ngircd/channel.h b/src/ngircd/channel.h
index 46e7e13a..030f9109 100644
--- a/src/ngircd/channel.h
+++ b/src/ngircd/channel.h
@@ -30,6 +30,7 @@ typedef struct _CHANNEL
 	char modes[CHANNEL_MODE_LEN];	/* Channel modes */
 	array topic;			/* Topic of the channel */
 #ifndef STRICT_RFC
+	time_t creation_time;		/* Channel creation time */
 	time_t topic_time;		/* Time when topic was set */
 	char topic_who[CLIENT_NICK_LEN];/* Nickname of user that set topic */
 #endif
@@ -118,6 +119,7 @@ GLOBAL CHANNEL *Channel_Create PARAMS(( const char *Name ));
 #ifndef STRICT_RFC
 GLOBAL unsigned int Channel_TopicTime PARAMS(( CHANNEL *Chan ));
 GLOBAL char *Channel_TopicWho PARAMS(( CHANNEL *Chan ));
+GLOBAL unsigned int Channel_CreationTime PARAMS(( CHANNEL *Chan ));
 #endif
 
 GLOBAL bool Channel_AddInvite PARAMS((CHANNEL *c, const char *Mask, bool OnlyOnce ));
diff --git a/src/ngircd/irc-mode.c b/src/ngircd/irc-mode.c
index df464a7d..a4c1d89b 100644
--- a/src/ngircd/irc-mode.c
+++ b/src/ngircd/irc-mode.c
@@ -294,8 +294,17 @@ Channel_Mode_Answer_Request(CLIENT *Origin, CHANNEL *Channel)
 	if (the_args[0])
 		strlcat(the_modes, the_args, sizeof(the_modes));
 
-	return IRC_WriteStrClient(Origin, RPL_CHANNELMODEIS_MSG,
-		Client_ID(Origin), Channel_Name(Channel), the_modes);
+	if (!IRC_WriteStrClient(Origin, RPL_CHANNELMODEIS_MSG,
+				Client_ID(Origin), Channel_Name(Channel),
+				the_modes))
+		return DISCONNECTED;
+#ifndef STRICT_RFC
+	if (!IRC_WriteStrClient(Origin, RPL_CREATIONTIME_MSG,
+				  Client_ID(Origin), Channel_Name(Channel),
+				  Channel_CreationTime(Channel)))
+		return DISCONNECTED;
+#endif
+	return CONNECTED;
 }
 
 
diff --git a/src/ngircd/messages.h b/src/ngircd/messages.h
index 03ddc363..900d2ff1 100644
--- a/src/ngircd/messages.h
+++ b/src/ngircd/messages.h
@@ -65,6 +65,7 @@
 #define RPL_LIST_MSG			"322 %s %s %ld :%s"
 #define RPL_LISTEND_MSG			"323 %s :End of LIST"
 #define RPL_CHANNELMODEIS_MSG		"324 %s %s +%s"
+#define RPL_CREATIONTIME_MSG		"329 %s %s %ld"
 #define RPL_NOTOPIC_MSG			"331 %s %s :No topic is set"
 #define RPL_TOPIC_MSG			"332 %s %s :%s"
 #define RPL_TOPICSETBY_MSG		"333 %s %s %s %u"