X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Firc-channel.c;h=79ccdd9adeaf299e3d0d073f60b08e100125d339;hp=041073b542766d52ad055f1a603f6a252349dfe0;hb=cf029a81acfeee1bd591f17a9716811736fe4114;hpb=ca33cbda05902b0009058d369f88c0a7a43b1bbe diff --git a/src/ngircd/irc-channel.c b/src/ngircd/irc-channel.c index 041073b5..79ccdd9a 100644 --- a/src/ngircd/irc-channel.c +++ b/src/ngircd/irc-channel.c @@ -9,7 +9,7 @@ * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS. * - * $Id: irc-channel.c,v 1.2 2002/03/12 14:37:52 alex Exp $ + * $Id: irc-channel.c,v 1.4 2002/04/23 19:51:14 alex Exp $ * * irc-channel.c: IRC-Channel-Befehle */ @@ -47,7 +47,7 @@ GLOBAL BOOLEAN IRC_JOIN( CLIENT *Client, REQUEST *Req ) if(( Req->argc > 1 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command ); /* Wer ist der Absender? */ - if( Client_Type( Client ) == CLIENT_SERVER ) target = Client_GetFromID( Req->prefix ); + if( Client_Type( Client ) == CLIENT_SERVER ) target = Client_Search( Req->prefix ); else target = Client; if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix ); @@ -144,7 +144,7 @@ GLOBAL BOOLEAN IRC_PART( CLIENT *Client, REQUEST *Req ) if(( Req->argc > 2 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command ); /* Wer ist der Absender? */ - if( Client_Type( Client ) == CLIENT_SERVER ) target = Client_GetFromID( Req->prefix ); + if( Client_Type( Client ) == CLIENT_SERVER ) target = Client_Search( Req->prefix ); else target = Client; if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix ); @@ -180,7 +180,7 @@ GLOBAL BOOLEAN IRC_TOPIC( CLIENT *Client, REQUEST *Req ) /* Falsche Anzahl Parameter? */ if(( Req->argc < 1 ) || ( Req->argc > 2 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command ); - if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_GetFromID( Req->prefix ); + if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix ); else from = Client; if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix ); @@ -218,4 +218,45 @@ GLOBAL BOOLEAN IRC_TOPIC( CLIENT *Client, REQUEST *Req ) } /* IRC_TOPIC */ +GLOBAL BOOLEAN IRC_LIST( CLIENT *Client, REQUEST *Req ) +{ + CHAR *pattern; + CHANNEL *chan; + + assert( Client != NULL ); + assert( Req != NULL ); + + if( Client_Type( Client ) != CLIENT_USER ) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client )); + + /* Falsche Anzahl Parameter? */ + if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command ); + + if( Req->argc > 0 ) pattern = strtok( Req->argv[0], "," ); + else pattern = "*"; + + while( pattern ) + { + /* alle Channel durchgehen */ + chan = Channel_First( ); + while( chan ) + { + /* Passt die Suchmaske auf diesen Channel? Bisher werden hier + * "regular expressions" aber noch nicht unterstuetzt ... */ + if(( strcasecmp( pattern, Channel_Name( chan )) == 0 ) || ( strcmp( pattern, "*" ) == 0 )) + { + /* Treffer! */ + if( ! IRC_WriteStrClient( Client, RPL_LIST_MSG, Client_ID( Client), Channel_Name( chan ), Channel_MemberCount( chan ), Channel_Topic( chan ))) return DISCONNECTED; + } + chan = Channel_Next( chan ); + } + + /* naechsten Namen ermitteln */ + if( Req->argc > 0 ) pattern = strtok( NULL, "," ); + else pattern = NULL; + } + + return IRC_WriteStrClient( Client, RPL_LISTEND_MSG, Client_ID( Client )); +} /* IRC_LIST */ + + /* -eof- */