+#ifndef STRICT_RFC
+
+GLOBAL unsigned int
+Channel_TopicTime(CHANNEL *Chan)
+{
+ assert(Chan != NULL);
+ return (unsigned int) Chan->topic_time;
+} /* Channel_TopicTime */
+
+
+GLOBAL char *
+Channel_TopicWho(CHANNEL *Chan)
+{
+ assert(Chan != NULL);
+ return Chan->topic_who;
+} /* Channel_TopicWho */
+
+#endif
+
+
+GLOBAL void
+Channel_SetTopic(CHANNEL *Chan, CLIENT *Client, char *Topic)
+{
+ size_t len;
+ assert( Chan != NULL );
+ assert( Topic != NULL );
+
+ len = strlen(Topic);
+ if (len < array_bytes(&Chan->topic))
+ array_free(&Chan->topic);
+
+ if (len >= COMMAND_LEN || !array_copyb(&Chan->topic, Topic, len+1))
+ Log(LOG_WARNING, "could not set new Topic \"%s\" on %s: %s",
+ Topic, Chan->name, strerror(errno));
+#ifndef STRICT_RFC
+ Chan->topic_time = time(NULL);
+ if (Client != NULL && Client_Type(Client) != CLIENT_SERVER)
+ strlcpy(Chan->topic_who, Client_ID(Client),
+ sizeof Chan->topic_who);
+ else
+ strlcpy(Chan->topic_who, DEFAULT_TOPIC_ID,
+ sizeof Chan->topic_who);
+#else
+ (void) Client;
+#endif
+} /* Channel_SetTopic */
+
+
+GLOBAL void
+Channel_SetModes( CHANNEL *Chan, char *Modes )
+{
+ assert( Chan != NULL );
+ assert( Modes != NULL );
+
+ strlcpy( Chan->modes, Modes, sizeof( Chan->modes ));
+} /* Channel_SetModes */
+
+
+GLOBAL void
+Channel_SetKey( CHANNEL *Chan, char *Key )
+{
+ assert( Chan != NULL );
+ assert( Key != NULL );
+
+ strlcpy( Chan->key, Key, sizeof( Chan->key ));
+ LogDebug("Channel %s: Key is now \"%s\".", Chan->name, Chan->key );
+} /* Channel_SetKey */
+
+
+GLOBAL void
+Channel_SetMaxUsers(CHANNEL *Chan, unsigned long Count)
+{
+ assert( Chan != NULL );
+
+ Chan->maxusers = Count;
+ LogDebug("Channel %s: Member limit is now %lu.", Chan->name, Chan->maxusers );
+} /* Channel_SetMaxUsers */
+
+
+static bool
+Can_Send_To_Channel(CHANNEL *Chan, CLIENT *From)
+{
+ bool is_member, has_voice, is_op;
+
+ is_member = has_voice = is_op = false;
+
+ if (Channel_IsMemberOf(Chan, From)) {
+ is_member = true;
+ if (strchr(Channel_UserModes(Chan, From), 'v'))
+ has_voice = true;
+ if (strchr(Channel_UserModes(Chan, From), 'o'))
+ is_op = true;
+ }
+
+ /*
+ * Is the client allowed to write to channel?
+ *
+ * If channel mode n set: non-members cannot send to channel.
+ * If channel mode m set: need voice.
+ */
+ if (strchr(Channel_Modes(Chan), 'n') && !is_member)
+ return false;
+
+ if (is_op || has_voice)
+ return true;
+
+ if (strchr(Channel_Modes(Chan), 'm'))
+ return false;
+
+ return !Lists_Check(&Chan->list_bans, From);
+}
+
+
+GLOBAL bool
+Channel_Write(CHANNEL *Chan, CLIENT *From, CLIENT *Client, const char *Text)
+{
+ if (!Can_Send_To_Channel(Chan, From))
+ return IRC_WriteStrClient(From, ERR_CANNOTSENDTOCHAN_MSG, Client_ID(From), Channel_Name(Chan));
+
+ if (Client_Conn(From) > NONE)
+ Conn_UpdateIdle(Client_Conn(From));
+
+ return IRC_WriteStrChannelPrefix(Client, Chan, From, true,
+ "PRIVMSG %s :%s", Channel_Name(Chan), Text);
+}
+
+
+GLOBAL bool
+Channel_Notice(CHANNEL *Chan, CLIENT *From, CLIENT *Client, const char *Text)
+{
+ if (!Can_Send_To_Channel(Chan, From))
+ return true; /* no error, see RFC 2812 */
+
+ if (Client_Conn(From) > NONE)
+ Conn_UpdateIdle(Client_Conn(From));
+
+ return IRC_WriteStrChannelPrefix(Client, Chan, From, true,
+ "NOTICE %s :%s", Channel_Name(Chan), Text);
+}
+
+
+GLOBAL CHANNEL *
+Channel_Create( char *Name )
+{
+ /* Create new CHANNEL structure and add it to linked list */