]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/irc-channel.c
- ngircd wird nun gegen die libngportab gelinkt, die evtl. benoetigte
[ngircd-alex.git] / src / ngircd / irc-channel.c
index 1a1fd931a49693708365f1693ffcf92baed8e88f..79ccdd9adeaf299e3d0d073f60b08e100125d339 100644 (file)
@@ -9,30 +9,25 @@
  * 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.1 2002/03/03 17:15:11 alex Exp $
+ * $Id: irc-channel.c,v 1.4 2002/04/23 19:51:14 alex Exp $
  *
  * irc-channel.c: IRC-Channel-Befehle
- *
- * $Log: irc-channel.c,v $
- * Revision 1.1  2002/03/03 17:15:11  alex
- * - Source in weitere Module fuer IRC-Befehle aufgesplitted.
- *
  */
 
 
-#include <portab.h>
-#include "global.h"
+#include "portab.h"
 
-#include <imp.h>
+#include "imp.h"
 #include <assert.h>
 #include <string.h>
 
+#include "defines.h"
 #include "irc.h"
 #include "irc-write.h"
 #include "log.h"
 #include "messages.h"
 
-#include <exp.h>
+#include "exp.h"
 #include "irc-channel.h"
 
 
@@ -52,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 );
 
@@ -149,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 );
 
@@ -185,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 );
 
@@ -223,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- */