Commit Diff


commit - 7709acf754cbf26b78f64638bc287164a8dce747
commit + 8a324b6d9c844da4e69875dfebd07dd2af3bc004
blob - d1b01daf6bba87e35a6fab8c36ba55b748db1d59
blob + 3f140064647f44241609bfb928793ee50670b974
--- src/ngircd/channel.c
+++ src/ngircd/channel.c
@@ -9,11 +9,15 @@
  * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
  * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
  *
- * $Id: channel.c,v 1.5 2002/01/21 00:12:29 alex Exp $
+ * $Id: channel.c,v 1.6 2002/01/26 18:41:55 alex Exp $
  *
  * channel.c: Management der Channels
  *
  * $Log: channel.c,v $
+ * Revision 1.6  2002/01/26 18:41:55  alex
+ * - CHANNEL- und CL2CHAN-Strukturen in Header verlegt,
+ * - einige neue Funktionen (Channel_GetChannel(), Channel_FirstMember(), ...)
+ *
  * Revision 1.5  2002/01/21 00:12:29  alex
  * - begonnen, Channels zu implementieren :-)
  *
@@ -33,6 +37,9 @@
  */
 
 
+#define __channel_c__
+
+
 #include <portab.h>
 #include "global.h"
 
@@ -50,28 +57,10 @@
 #include "channel.h"
 
 
-typedef struct _CHANNEL
-{
-	struct _CHANNEL *next;
-	CHAR name[CHANNEL_NAME_LEN];	/* Name des Channel */
-	CHAR modes[CHANNEL_MODE_LEN];	/* Channel-Modes */
-} CHANNEL;
-
-
-typedef struct _CLIENT2CHAN
-{
-	struct _CLIENT2CHAN *next;
-	CLIENT *client;
-	CHANNEL *channel;
-	CHAR modes[CHANNEL_MODE_LEN];	/* User-Modes in dem Channel */
-} CL2CHAN;
-
-
 LOCAL CHANNEL *My_Channels;
 LOCAL CL2CHAN *My_Cl2Chan;
 
 
-LOCAL CHANNEL *Get_Chan( CHAR *Name );
 LOCAL CHANNEL *New_Chan( CHAR *Name );
 LOCAL CL2CHAN *Get_Cl2Chan( CHANNEL *Chan, CLIENT *Client );
 LOCAL CL2CHAN *Add_Client( CHANNEL *Chan, CLIENT *Client );
@@ -128,7 +117,7 @@ GLOBAL BOOLEAN Channel_Join( CLIENT *Client, CHAR *Nam
 	}
 
 	/* Channel suchen */
-	chan = Get_Chan( Name );
+	chan = Channel_Search( Name );
 	if( chan )
 	{
 		/* Ist der Client bereits Mitglied? */
@@ -159,7 +148,7 @@ GLOBAL BOOLEAN Channel_Part( CLIENT *Client, CLIENT *O
 	assert( Name != NULL );
 
 	/* Channel suchen */
-	chan = Get_Chan( Name );
+	chan = Channel_Search( Name );
 	if(( ! chan ) || ( ! Get_Cl2Chan( chan, Client )))
 	{
 		IRC_WriteStrClient( Client, ERR_NOSUCHCHANNEL_MSG, Client_ID( Client ), Name );
@@ -204,7 +193,7 @@ GLOBAL INT Channel_Count( VOID )
 } /* Channel_Count */
 
 
-LOCAL CHANNEL *Get_Chan( CHAR *Name )
+GLOBAL CHANNEL *Channel_Search( CHAR *Name )
 {
 	/* Channel-Struktur suchen */
 	
@@ -218,9 +207,38 @@ LOCAL CHANNEL *Get_Chan( CHAR *Name )
 		c = c->next;
 	}
 	return NULL;
-} /* Get_Chan */
+} /* Channel_Search */
 
 
+GLOBAL CL2CHAN *Channel_FirstMember( CHANNEL *Chan )
+{
+	assert( Chan != NULL );
+	return Get_First_Cl2Chan( NULL, Chan );
+} /* Channel_IsMember */
+
+
+GLOBAL CL2CHAN *Channel_NextMember( CHANNEL *Chan, CL2CHAN *Cl2Chan )
+{
+	assert( Chan != NULL );
+	assert( Cl2Chan != NULL );
+	return Get_Next_Cl2Chan( Cl2Chan->next, NULL, Chan );
+} /* Channel_NextMember */
+
+
+GLOBAL CLIENT *Channel_GetClient( CL2CHAN *Cl2Chan )
+{
+	assert( Cl2Chan != NULL );
+	return Cl2Chan->client;
+} /* Channel_GetClient */
+
+
+GLOBAL CHANNEL *Channel_GetChannel( CL2CHAN *Cl2Chan )
+{
+	assert( Cl2Chan != NULL );
+	return Cl2Chan->channel;
+} /* Channel_GetChannel */
+
+
 LOCAL CHANNEL *New_Chan( CHAR *Name )
 {
 	/* Neue Channel-Struktur anlegen */
@@ -315,8 +333,9 @@ LOCAL BOOLEAN Remove_Client( CHANNEL *Chan, CLIENT *Cl
 	else My_Cl2Chan = cl2chan->next;
 	free( cl2chan );
 
+	if( Client_Conn( Origin ) > NONE ) IRC_WriteStrClientPrefix( Origin, Client, "PART %s :%s", c->name, Reason );
 	IRC_WriteStrServersPrefix( Origin, Client, "PART %s :%s", c->name, Reason );
-	IRC_WriteStrRelatedChannelPrefix( Origin, c->name, Client, "PART %s :%s", c->name, Reason );
+	IRC_WriteStrChannelPrefix( Origin, c, Client, "PART %s :%s", c->name, Reason );
 
 	Log( LOG_DEBUG, "User \"%s\" left channel \"%s\" (%s).", Client_Mask( Client ), c->name, Reason );
 
blob - 9ca60d319164590b90c0210bd28025cc67ab5103
blob + bba7d44508465d966a6b71e4bd2a68aea1def346
--- src/ngircd/channel.h
+++ src/ngircd/channel.h
@@ -9,11 +9,15 @@
  * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
  * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
  *
- * $Id: channel.h,v 1.6 2002/01/21 00:11:59 alex Exp $
+ * $Id: channel.h,v 1.7 2002/01/26 18:41:55 alex Exp $
  *
  * channel.h: Management der Channels (Header)
  *
  * $Log: channel.h,v $
+ * Revision 1.7  2002/01/26 18:41:55  alex
+ * - CHANNEL- und CL2CHAN-Strukturen in Header verlegt,
+ * - einige neue Funktionen (Channel_GetChannel(), Channel_FirstMember(), ...)
+ *
  * Revision 1.6  2002/01/21 00:11:59  alex
  * - Definition der CHANNEL-Struktur aus Header entfernt,
  * - neue Funktionen Channel_Join(), Channel_Part() und Channel_RemoveClient().
@@ -43,6 +47,31 @@
 #include "client.h"
 
 
+#ifdef __channel_c__
+
+typedef struct _CHANNEL
+{
+	struct _CHANNEL *next;
+	CHAR name[CHANNEL_NAME_LEN];	/* Name des Channel */
+	CHAR modes[CHANNEL_MODE_LEN];	/* Channel-Modes */
+} CHANNEL;
+
+typedef struct _CLIENT2CHAN
+{
+	struct _CLIENT2CHAN *next;
+	CLIENT *client;
+	CHANNEL *channel;
+	CHAR modes[CHANNEL_MODE_LEN];	/* User-Modes in dem Channel */
+} CL2CHAN;
+
+#else
+
+typedef POINTER CHANNEL;
+typedef POINTER CL2CHAN;
+
+#endif
+
+
 GLOBAL VOID Channel_Init( VOID );
 GLOBAL VOID Channel_Exit( VOID );
 
@@ -53,7 +82,15 @@ GLOBAL VOID Channel_RemoveClient( CLIENT *Client, CHAR
 
 GLOBAL INT Channel_Count( VOID );
 
+GLOBAL CHANNEL *Channel_Search( CHAR *Name );
 
+GLOBAL CL2CHAN *Channel_FirstMember( CHANNEL *Chan );
+GLOBAL CL2CHAN *Channel_NextMember( CHANNEL *Chan, CL2CHAN *Cl2Chan );
+
+GLOBAL CLIENT *Channel_GetClient( CL2CHAN *Cl2Chan );
+GLOBAL CHANNEL *Channel_GetChannel( CL2CHAN *Cl2Chan );
+
+
 #endif