commit b7eb5f66dc93647d502572b5289ce3c6ba129463 from: Alexander Barton date: Fri Dec 13 17:22:57 2002 UTC - new function Channel_CountForUser(). commit - 427be23b6ed4091cdca0fd9ddc36bcd99e6ee06d commit + b7eb5f66dc93647d502572b5289ce3c6ba129463 blob - 9e1820f01b8ff4753da9c130ca1cec8276216718 blob + 5cd24128fe1e5449ad8ef258887ff24c80a2112d --- src/ngircd/channel.c +++ src/ngircd/channel.c @@ -17,7 +17,7 @@ #include "portab.h" -static char UNUSED id[] = "$Id: channel.c,v 1.35 2002/12/12 12:24:18 alex Exp $"; +static char UNUSED id[] = "$Id: channel.c,v 1.36 2002/12/13 17:22:57 alex Exp $"; #include "imp.h" #include @@ -290,8 +290,32 @@ Channel_MemberCount( CHANNEL *Chan ) } return count; } /* Channel_MemberCount */ + + +GLOBAL INT +Channel_CountForUser( CHANNEL *Chan, CLIENT *Client ) +{ + /* Count number of channels a user is member of. */ + + CL2CHAN *cl2chan; + INT count; + + assert( Chan != NULL ); + assert( Client != NULL ); + + count = 0; + cl2chan = My_Cl2Chan; + while( cl2chan ) + { + if( cl2chan->client == Client ) count++; + cl2chan = cl2chan->next; + } + return count; +} /* Channel_CountForUser */ + + GLOBAL CHAR * Channel_Name( CHANNEL *Chan ) { blob - 30aed645434596adc8abbe73338a7483589f2d39 blob + f2ef35e1673c701744c7f7de7b73a0f1160b0fe9 --- 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.23 2002/12/12 12:23:43 alex Exp $ + * $Id: channel.h,v 1.24 2002/12/13 17:22:57 alex Exp $ * * Channel management (header) */ @@ -47,54 +47,55 @@ typedef POINTER CL2CHAN; #endif -GLOBAL VOID Channel_Init PARAMS((VOID )); -GLOBAL VOID Channel_InitPredefined PARAMS(( VOID )); -GLOBAL VOID Channel_Exit PARAMS((VOID )); +GLOBAL VOID Channel_Init PARAMS(( VOID )); +GLOBAL VOID Channel_InitPredefined PARAMS(( VOID )); +GLOBAL VOID Channel_Exit PARAMS(( VOID )); -GLOBAL BOOLEAN Channel_Join PARAMS((CLIENT *Client, CHAR *Name )); -GLOBAL BOOLEAN Channel_Part PARAMS((CLIENT *Client, CLIENT *Origin, CHAR *Name, CHAR *Reason )); +GLOBAL BOOLEAN Channel_Join PARAMS(( CLIENT *Client, CHAR *Name )); +GLOBAL BOOLEAN Channel_Part PARAMS(( CLIENT *Client, CLIENT *Origin, CHAR *Name, CHAR *Reason )); -GLOBAL VOID Channel_Quit PARAMS((CLIENT *Client, CHAR *Reason )); +GLOBAL VOID Channel_Quit PARAMS(( CLIENT *Client, CHAR *Reason )); -GLOBAL VOID Channel_Kick PARAMS(( CLIENT *Client, CLIENT *Origin, CHAR *Name, CHAR *Reason )); +GLOBAL VOID Channel_Kick PARAMS(( CLIENT *Client, CLIENT *Origin, CHAR *Name, CHAR *Reason )); -GLOBAL LONG Channel_Count PARAMS((VOID )); -GLOBAL LONG Channel_MemberCount PARAMS((CHANNEL *Chan )); +GLOBAL LONG Channel_Count PARAMS(( VOID )); +GLOBAL LONG Channel_MemberCount PARAMS(( CHANNEL *Chan )); +GLOBAL INT Channel_CountForUser PARAMS(( CHANNEL *Chan, CLIENT *Client )); -GLOBAL CHAR *Channel_Name PARAMS((CHANNEL *Chan )); -GLOBAL CHAR *Channel_Modes PARAMS((CHANNEL *Chan )); -GLOBAL CHAR *Channel_Topic PARAMS((CHANNEL *Chan )); +GLOBAL CHAR *Channel_Name PARAMS(( CHANNEL *Chan )); +GLOBAL CHAR *Channel_Modes PARAMS(( CHANNEL *Chan )); +GLOBAL CHAR *Channel_Topic PARAMS(( CHANNEL *Chan )); -GLOBAL VOID Channel_SetTopic PARAMS((CHANNEL *Chan, CHAR *Topic )); -GLOBAL VOID Channel_SetModes PARAMS((CHANNEL *Chan, CHAR *Modes )); +GLOBAL VOID Channel_SetTopic PARAMS(( CHANNEL *Chan, CHAR *Topic )); +GLOBAL VOID Channel_SetModes PARAMS(( CHANNEL *Chan, CHAR *Modes )); -GLOBAL CHANNEL *Channel_Search PARAMS((CHAR *Name )); +GLOBAL CHANNEL *Channel_Search PARAMS(( CHAR *Name )); -GLOBAL CHANNEL *Channel_First PARAMS((VOID )); -GLOBAL CHANNEL *Channel_Next PARAMS((CHANNEL *Chan )); +GLOBAL CHANNEL *Channel_First PARAMS(( VOID )); +GLOBAL CHANNEL *Channel_Next PARAMS(( CHANNEL *Chan )); -GLOBAL CL2CHAN *Channel_FirstMember PARAMS((CHANNEL *Chan )); -GLOBAL CL2CHAN *Channel_NextMember PARAMS((CHANNEL *Chan, CL2CHAN *Cl2Chan )); -GLOBAL CL2CHAN *Channel_FirstChannelOf PARAMS((CLIENT *Client )); -GLOBAL CL2CHAN *Channel_NextChannelOf PARAMS((CLIENT *Client, CL2CHAN *Cl2Chan )); +GLOBAL CL2CHAN *Channel_FirstMember PARAMS(( CHANNEL *Chan )); +GLOBAL CL2CHAN *Channel_NextMember PARAMS(( CHANNEL *Chan, CL2CHAN *Cl2Chan )); +GLOBAL CL2CHAN *Channel_FirstChannelOf PARAMS(( CLIENT *Client )); +GLOBAL CL2CHAN *Channel_NextChannelOf PARAMS(( CLIENT *Client, CL2CHAN *Cl2Chan )); -GLOBAL CLIENT *Channel_GetClient PARAMS((CL2CHAN *Cl2Chan )); -GLOBAL CHANNEL *Channel_GetChannel PARAMS((CL2CHAN *Cl2Chan )); +GLOBAL CLIENT *Channel_GetClient PARAMS(( CL2CHAN *Cl2Chan )); +GLOBAL CHANNEL *Channel_GetChannel PARAMS(( CL2CHAN *Cl2Chan )); -GLOBAL BOOLEAN Channel_IsValidName PARAMS((CHAR *Name )); +GLOBAL BOOLEAN Channel_IsValidName PARAMS(( CHAR *Name )); -GLOBAL BOOLEAN Channel_ModeAdd PARAMS((CHANNEL *Chan, CHAR Mode )); -GLOBAL BOOLEAN Channel_ModeDel PARAMS((CHANNEL *Chan, CHAR Mode )); +GLOBAL BOOLEAN Channel_ModeAdd PARAMS(( CHANNEL *Chan, CHAR Mode )); +GLOBAL BOOLEAN Channel_ModeDel PARAMS(( CHANNEL *Chan, CHAR Mode )); -GLOBAL BOOLEAN Channel_UserModeAdd PARAMS((CHANNEL *Chan, CLIENT *Client, CHAR Mode )); -GLOBAL BOOLEAN Channel_UserModeDel PARAMS((CHANNEL *Chan, CLIENT *Client, CHAR Mode )); -GLOBAL CHAR *Channel_UserModes PARAMS((CHANNEL *Chan, CLIENT *Client )); +GLOBAL BOOLEAN Channel_UserModeAdd PARAMS(( CHANNEL *Chan, CLIENT *Client, CHAR Mode )); +GLOBAL BOOLEAN Channel_UserModeDel PARAMS(( CHANNEL *Chan, CLIENT *Client, CHAR Mode )); +GLOBAL CHAR *Channel_UserModes PARAMS(( CHANNEL *Chan, CLIENT *Client )); -GLOBAL BOOLEAN Channel_IsMemberOf PARAMS((CHANNEL *Chan, CLIENT *Client )); +GLOBAL BOOLEAN Channel_IsMemberOf PARAMS(( CHANNEL *Chan, CLIENT *Client )); -GLOBAL BOOLEAN Channel_Write PARAMS((CHANNEL *Chan, CLIENT *From, CLIENT *Client, CHAR *Text )); +GLOBAL BOOLEAN Channel_Write PARAMS(( CHANNEL *Chan, CLIENT *From, CLIENT *Client, CHAR *Text )); -GLOBAL CHANNEL *Channel_Create PARAMS((CHAR *Name )); +GLOBAL CHANNEL *Channel_Create PARAMS(( CHAR *Name )); #endif