+GLOBAL bool
+Channel_IsValidName( const char *Name )
+{
+ assert( Name != NULL );
+
+#ifdef STRICT_RFC
+ if (strlen(Name) <= 1)
+ return false;
+#endif
+ if (strchr("#&+", Name[0]) == NULL)
+ return false;
+ if (strlen(Name) >= CHANNEL_NAME_LEN)
+ return false;
+
+ return Name[strcspn(Name, " ,:\007")] == 0;
+} /* Channel_IsValidName */
+
+
+GLOBAL bool
+Channel_ModeAdd( CHANNEL *Chan, char Mode )
+{
+ /* set Mode.
+ * If the channel already had this mode, return false.
+ * If the channel mode was newly set return true.
+ */
+
+ char x[2];
+
+ assert( Chan != NULL );
+
+ x[0] = Mode; x[1] = '\0';
+ if( ! strchr( Chan->modes, x[0] ))
+ {
+ /* Channel does not have this mode yet, set it */
+ strlcat( Chan->modes, x, sizeof( Chan->modes ));
+ return true;
+ }
+ else return false;
+} /* Channel_ModeAdd */
+
+
+GLOBAL bool
+Channel_ModeDel( CHANNEL *Chan, char Mode )
+{
+ /* Delete mode.
+ * if the mode was removed return true.
+ * if the channel did not have the mode, return false.
+ */
+ char *p;
+
+ assert( Chan != NULL );
+
+ p = strchr( Chan->modes, Mode );
+ if( ! p ) return false;
+
+ /* Channel has mode -> delete */
+ while( *p )
+ {
+ *p = *(p + 1);
+ p++;
+ }
+ return true;
+} /* Channel_ModeDel */
+
+
+GLOBAL bool
+Channel_UserModeAdd( CHANNEL *Chan, CLIENT *Client, char Mode )
+{
+ /* Set Channel-User-Mode.
+ * if mode was newly set, return true.
+ * if the User already had this channel-mode, return false.
+ */
+
+ CL2CHAN *cl2chan;
+ char x[2];
+
+ assert( Chan != NULL );
+ assert( Client != NULL );
+
+ cl2chan = Get_Cl2Chan( Chan, Client );
+ assert( cl2chan != NULL );
+
+ x[0] = Mode; x[1] = '\0';
+ if( ! strchr( cl2chan->modes, x[0] ))
+ {
+ /* mode not set, -> set it */
+ strlcat( cl2chan->modes, x, sizeof( cl2chan->modes ));
+ return true;
+ }
+ else return false;
+} /* Channel_UserModeAdd */
+
+
+GLOBAL bool
+Channel_UserModeDel( CHANNEL *Chan, CLIENT *Client, char Mode )
+{
+ /* Delete Channel-User-Mode.
+ * If Mode was removed, return true.
+ * If User did not have the Channel-Mode, return false.
+ */
+
+ CL2CHAN *cl2chan;
+ char *p;
+
+ assert( Chan != NULL );
+ assert( Client != NULL );
+
+ cl2chan = Get_Cl2Chan( Chan, Client );
+ assert( cl2chan != NULL );
+
+ p = strchr( cl2chan->modes, Mode );
+ if( ! p ) return false;
+
+ /* Client has Mode -> delete */
+ while( *p )
+ {
+ *p = *(p + 1);
+ p++;
+ }
+ return true;
+} /* Channel_UserModeDel */
+
+
+GLOBAL char *
+Channel_UserModes( CHANNEL *Chan, CLIENT *Client )
+{
+ /* return Users' Channel-Modes */
+
+ CL2CHAN *cl2chan;
+
+ assert( Chan != NULL );
+ assert( Client != NULL );
+
+ cl2chan = Get_Cl2Chan( Chan, Client );
+ assert( cl2chan != NULL );
+
+ return cl2chan->modes;
+} /* Channel_UserModes */
+
+
+GLOBAL bool
+Channel_IsMemberOf( CHANNEL *Chan, CLIENT *Client )
+{
+ /* Test if Client is on Channel Chan */
+
+ assert( Chan != NULL );
+ assert( Client != NULL );
+ return Get_Cl2Chan(Chan, Client) != NULL;
+} /* Channel_IsMemberOf */
+
+
+GLOBAL char *
+Channel_Topic( CHANNEL *Chan )
+{
+ char *ret;
+ assert( Chan != NULL );
+ ret = array_start(&Chan->topic);
+ return ret ? ret : "";
+} /* Channel_Topic */
+
+
+#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)