Commit Diff


commit - 8dd92fbcd8b08dc55d5e8d723959c8cc9fff7d6f
commit + 2ee05c9a6856d78f996dfbc991452e4cc1c58c37
blob - 2902c3cccdc5caab22293da7317ad16b72093e9b
blob + ad2110a312e3045a0b939a3c2e0caf599564d466
--- MacOSX/ngircd.pbproj/project.pbxproj
+++ MacOSX/ngircd.pbproj/project.pbxproj
@@ -100,7 +100,7 @@
 				PRODUCT_NAME = ngircd;
 				REZ_EXECUTABLE = YES;
 				SECTORDER_FLAGS = "";
-				WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas";
+				WARNING_CFLAGS = "-Wall";
 			};
 			dependencies = (
 			);
@@ -131,6 +131,9 @@
 				F51DBB15022D95E801A85B04,
 				F51DBB19022D995501A85B04,
 				F51DBB1D022D9D8F01A85B04,
+				F57C88870232853501A85B04,
+				F57C888B0232884501A85B04,
+				F57C888F02328D7201A85B04,
 			);
 			isa = PBXHeadersBuildPhase;
 			name = Headers;
@@ -150,6 +153,9 @@
 				F51DBB16022D95E801A85B04,
 				F51DBB1A022D995501A85B04,
 				F51DBB1E022D9D8F01A85B04,
+				F57C88880232853501A85B04,
+				F57C888C0232884501A85B04,
+				F57C889002328D7201A85B04,
 			);
 			isa = PBXSourcesBuildPhase;
 			name = Sources;
@@ -399,10 +405,16 @@
 				F52162DB01C7BCDC012300F4,
 				F51D180201C8FDD001E11C2E,
 				F51D180301C8FDD001E11C2E,
+				F57C888D02328D7201A85B04,
+				F57C888E02328D7201A85B04,
 				F51DBB1B022D9D8F01A85B04,
 				F51DBB1C022D9D8F01A85B04,
 				F51DBB17022D995501A85B04,
 				F51DBB18022D995501A85B04,
+				F57C88850232853501A85B04,
+				F57C88860232853501A85B04,
+				F57C88890232884501A85B04,
+				F57C888A0232884501A85B04,
 				F51DBB13022D95E801A85B04,
 				F51DBB14022D95E801A85B04,
 				F52162BB01C7B904012300F4,
@@ -696,10 +708,76 @@
 		};
 		F576ABFF01D61D7401A85B03 = {
 			fileRef = F576ABFE01D61D7401A85B03;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		F57C88850232853501A85B04 = {
+			isa = PBXFileReference;
+			path = "irc-oper.c";
+			refType = 4;
+		};
+		F57C88860232853501A85B04 = {
+			isa = PBXFileReference;
+			path = "irc-oper.h";
+			refType = 4;
+		};
+		F57C88870232853501A85B04 = {
+			fileRef = F57C88860232853501A85B04;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		F57C88880232853501A85B04 = {
+			fileRef = F57C88850232853501A85B04;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		F57C88890232884501A85B04 = {
+			isa = PBXFileReference;
+			path = "irc-server.c";
+			refType = 4;
+		};
+		F57C888A0232884501A85B04 = {
+			isa = PBXFileReference;
+			path = "irc-server.h";
+			refType = 4;
+		};
+		F57C888B0232884501A85B04 = {
+			fileRef = F57C888A0232884501A85B04;
 			isa = PBXBuildFile;
 			settings = {
 			};
 		};
+		F57C888C0232884501A85B04 = {
+			fileRef = F57C88890232884501A85B04;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		F57C888D02328D7201A85B04 = {
+			isa = PBXFileReference;
+			path = "irc-channel.c";
+			refType = 4;
+		};
+		F57C888E02328D7201A85B04 = {
+			isa = PBXFileReference;
+			path = "irc-channel.h";
+			refType = 4;
+		};
+		F57C888F02328D7201A85B04 = {
+			fileRef = F57C888E02328D7201A85B04;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		F57C889002328D7201A85B04 = {
+			fileRef = F57C888D02328D7201A85B04;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
 	};
 	rootObject = 08FB7793FE84155DC02AAC07;
 }
blob - da20e909ee31a7b2c9bc14a2137b0673d9c7e7f7
blob + 505e632c92c9982d0cdba27f88fadb4d7fd39925
--- src/ngircd/Makefile.am
+++ src/ngircd/Makefile.am
@@ -9,9 +9,12 @@
 # Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
 # der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
 #
-# $Id: Makefile.am,v 1.13 2002/02/27 23:22:09 alex Exp $
+# $Id: Makefile.am,v 1.14 2002/03/03 17:15:11 alex Exp $
 #
 # $Log: Makefile.am,v $
+# Revision 1.14  2002/03/03 17:15:11  alex
+# - Source in weitere Module fuer IRC-Befehle aufgesplitted.
+#
 # Revision 1.13  2002/02/27 23:22:09  alex
 # - einige Header umgestellt, neue Source-Dateien irc-xxx.c
 #
@@ -57,10 +60,12 @@
 sbin_PROGRAMS = ngircd
 
 ngircd_SOURCES = ngircd.c channel.c client.c conf.c conn.c irc.c \
-	irc-login.c irc-mode.c irc-write.c log.c parse.c tool.c
+	irc-channel.c irc-login.c irc-mode.c irc-oper.c irc-server.c \
+	irc-write.c log.c parse.c tool.c
 
 noinst_HEADERS = ngircd.h channel.h client.h conf.h conn.h irc.h \
-	irc-login.h irc-mode.h irc-write.h log.h parse.h tool.h \
+	irc-channel.h irc-login.h irc-mode.h irc-oper.h irc-server.h \
+	irc-write.h log.h parse.h tool.h \
 	global.h messages.h defines.h
 
 clean-local:
blob - 46670536b501a8fa1db3dece23c3cba37491b10d
blob + 61c016369d266cadeed932bea4f9204da0bf12d2
--- src/ngircd/irc-login.c
+++ src/ngircd/irc-login.c
@@ -9,18 +9,20 @@
  * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
  * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
  *
- * $Id: irc-login.c,v 1.2 2002/03/02 00:49:11 alex Exp $
+ * $Id: irc-login.c,v 1.3 2002/03/03 17:15:11 alex Exp $
  *
  * irc-login.c: Anmeldung und Abmeldung im IRC
  *
  * $Log: irc-login.c,v $
+ * Revision 1.3  2002/03/03 17:15:11  alex
+ * - Source in weitere Module fuer IRC-Befehle aufgesplitted.
+ *
  * Revision 1.2  2002/03/02 00:49:11  alex
  * - Bei der USER-Registrierung wird NICK nicht mehr sofort geforwarded,
  *   sondern erst dann, wenn auch ein gueltiges USER empfangen wurde.
  *
  * Revision 1.1  2002/02/27 23:26:21  alex
  * - Modul aus irc.c bzw. irc.h ausgegliedert.
- *
  */
 
 
@@ -85,273 +87,8 @@ GLOBAL BOOLEAN IRC_PASS( CLIENT *Client, REQUEST *Req 
 	}
 	else return IRC_WriteStrClient( Client, ERR_ALREADYREGISTRED_MSG, Client_ID( Client ));
 } /* IRC_PASS */
-
-
-GLOBAL BOOLEAN IRC_SERVER( CLIENT *Client, REQUEST *Req )
-{
-	CHAR str[LINE_LEN], *ptr;
-	CLIENT *from, *c, *cl;
-	CL2CHAN *cl2chan;
-	INT max_hops, i;
-	CHANNEL *chan;
-	BOOLEAN ok;
-	
-	assert( Client != NULL );
-	assert( Req != NULL );
-
-	/* Fehler liefern, wenn kein lokaler Client */
-	if( Client_Conn( Client ) <= NONE ) return IRC_WriteStrClient( Client, ERR_UNKNOWNCOMMAND_MSG, Client_ID( Client ), Req->command );
-
-	if( Client_Type( Client ) == CLIENT_GOTPASSSERVER )
-	{
-		/* Verbindung soll als Server-Server-Verbindung registriert werden */
-		Log( LOG_DEBUG, "Connection %d: got SERVER command (new server link) ...", Client_Conn( Client ));
-
-		/* Falsche Anzahl Parameter? */
-		if(( Req->argc != 2 ) && ( Req->argc != 3 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
-
-		/* Ist dieser Server bei uns konfiguriert? */
-		for( i = 0; i < Conf_Server_Count; i++ ) if( strcasecmp( Req->argv[0], Conf_Server[i].name ) == 0 ) break;
-		if( i >= Conf_Server_Count )
-		{
-			/* Server ist nicht konfiguriert! */
-			Log( LOG_ERR, "Connection %d: Server \"%s\" not configured here!", Client_Conn( Client ), Req->argv[0] );
-			Conn_Close( Client_Conn( Client ), NULL, "Server not configured here", TRUE );
-			return DISCONNECTED;
-		}
-		if( strcmp( Client_Password( Client ), Conf_Server[i].pwd ) != 0 )
-		{
-			/* Falsches Passwort */
-			Log( LOG_ERR, "Connection %d: Bad password for server \"%s\"!", Client_Conn( Client ), Req->argv[0] );
-			Conn_Close( Client_Conn( Client ), NULL, "Bad password", TRUE );
-			return DISCONNECTED;
-		}
-		
-		/* Ist ein Server mit dieser ID bereits registriert? */
-		if( ! Client_CheckID( Client, Req->argv[0] )) return DISCONNECTED;
-
-		/* Server-Strukturen fuellen ;-) */
-		Client_SetID( Client, Req->argv[0] );
-		Client_SetHops( Client, 1 );
-		Client_SetInfo( Client, Req->argv[Req->argc - 1] );
-		
-		/* Meldet sich der Server bei uns an? */
-		if( Req->argc == 2 )
-		{
-			/* Unseren SERVER- und PASS-Befehl senden */
-			ok = TRUE;
-			if( ! IRC_WriteStrClient( Client, "PASS %s "PASSSERVERADD, Conf_Server[i].pwd )) ok = FALSE;
-			else ok = IRC_WriteStrClient( Client, "SERVER %s 1 :%s", Conf_ServerName, Conf_ServerInfo );
-			if( ! ok )
-			{
-				Conn_Close( Client_Conn( Client ), "Unexpected server behavior!", NULL, FALSE );
-				return DISCONNECTED;
-			}
-			Client_SetIntroducer( Client, Client );
-			Client_SetToken( Client, 1 );
-		}
-		else  Client_SetToken( Client, atoi( Req->argv[1] ));
-
-		Log( LOG_NOTICE, "Server \"%s\" registered (connection %d, 1 hop - direct link).", Client_ID( Client ), Client_Conn( Client ));
-
-		Client_SetType( Client, CLIENT_SERVER );
-
-		/* maximalen Hop Count ermitteln */
-		max_hops = 0;
-		c = Client_First( );
-		while( c )
-		{
-			if( Client_Hops( c ) > max_hops ) max_hops = Client_Hops( c );
-			c = Client_Next( c );
-		}
-		
-		/* Alle bisherigen Server dem neuen Server bekannt machen,
-		 * die bisherigen Server ueber den neuen informierenn */
-		for( i = 0; i < ( max_hops + 1 ); i++ )
-		{
-			c = Client_First( );
-			while( c )
-			{
-				if(( Client_Type( c ) == CLIENT_SERVER ) && ( c != Client ) && ( c != Client_ThisServer( )) && ( Client_Hops( c ) == i ))
-				{
-					if( Client_Conn( c ) > NONE )
-					{
-						/* Dem gefundenen Server gleich den neuen
-						 * Server bekannt machen */
-						if( ! IRC_WriteStrClient( c, "SERVER %s %d %d :%s", Client_ID( Client ), Client_Hops( Client ) + 1, Client_MyToken( Client ), Client_Info( Client ))) return DISCONNECTED;
-					}
-					
-					/* Den neuen Server ueber den alten informieren */
-					if( ! IRC_WriteStrClientPrefix( Client, Client_Hops( c ) == 1 ? Client_ThisServer( ) : Client_Introducer( c ), "SERVER %s %d %d :%s", Client_ID( c ), Client_Hops( c ) + 1, Client_MyToken( c ), Client_Info( c ))) return DISCONNECTED;
-				}
-				c = Client_Next( c );
-			}
-		}
-
-		/* alle User dem neuen Server bekannt machen */
-		c = Client_First( );
-		while( c )
-		{
-			if( Client_Type( c ) == CLIENT_USER )
-			{
-				/* User an neuen Server melden */
-				if( ! IRC_WriteStrClient( Client, "NICK %s %d %s %s %d +%s :%s", Client_ID( c ), Client_Hops( c ) + 1, Client_User( c ), Client_Hostname( c ), Client_MyToken( Client_Introducer( c )), Client_Modes( c ), Client_Info( c ))) return DISCONNECTED;
-			}
-			c = Client_Next( c );
-		}
-
-		/* Channels dem neuen Server bekannt machen */
-		chan = Channel_First( );
-		while( chan )
-		{
-			sprintf( str, "NJOIN %s :", Channel_Name( chan ));
-
-			/* alle Member suchen */
-			cl2chan = Channel_FirstMember( chan );
-			while( cl2chan )
-			{
-				cl = Channel_GetClient( cl2chan );
-				assert( cl != NULL );
-
-				/* Nick, ggf. mit Modes, anhaengen */
-				if( str[strlen( str ) - 1] != ':' ) strcat( str, "," );
-				if( strchr( Channel_UserModes( chan, cl ), 'v' )) strcat( str, "+" );
-				if( strchr( Channel_UserModes( chan, cl ), 'o' )) strcat( str, "@" );
-				strcat( str, Client_ID( cl ));
-
-				if( strlen( str ) > ( LINE_LEN - CLIENT_NICK_LEN - 4 ))
-				{
-					/* Zeile senden */
-					if( ! IRC_WriteStrClient( Client, str )) return DISCONNECTED;
-					sprintf( str, "NJOIN %s :", Channel_Name( chan ));
-				}
-				
-				cl2chan = Channel_NextMember( chan, cl2chan );
-			}
-
-			/* noch Daten da? */
-			if( str[strlen( str ) - 1] != ':')
-			{
-				/* Ja; Also senden ... */
-				if( ! IRC_WriteStrClient( Client, str )) return DISCONNECTED;
-			}
-
-			/* naechsten Channel suchen */
-			chan = Channel_Next( chan );
-		}
-		
-		return CONNECTED;
-	}
-	else if( Client_Type( Client ) == CLIENT_SERVER )
-	{
-		/* Neuer Server wird im Netz angekuendigt */
 
-		/* Falsche Anzahl Parameter? */
-		if( Req->argc != 4 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
 
-		/* Ist ein Server mit dieser ID bereits registriert? */
-		if( ! Client_CheckID( Client, Req->argv[0] )) return DISCONNECTED;
-
-		/* Ueberfluessige Hostnamen aus Info-Text entfernen */
-		ptr = strchr( Req->argv[3] + 2, '[' );
-		if( ! ptr ) ptr = Req->argv[3];
-
-		from = Client_GetFromID( Req->prefix );
-		if( ! from )
-		{
-			/* Hm, Server, der diesen einfuehrt, ist nicht bekannt!? */
-			Log( LOG_ALERT, "Unknown ID in prefix of SERVER: \"%s\"! (on connection %d)", Req->prefix, Client_Conn( Client ));
-			Conn_Close( Client_Conn( Client ), NULL, "Unknown ID in prefix of SERVER", TRUE );
-			return DISCONNECTED;
-		}
-
-		/* Neue Client-Struktur anlegen */
-		c = Client_NewRemoteServer( Client, Req->argv[0], from, atoi( Req->argv[1] ), atoi( Req->argv[2] ), ptr, TRUE );
-		if( ! c )
-		{
-			/* Neue Client-Struktur konnte nicht angelegt werden */
-			Log( LOG_ALERT, "Can't create client structure for server! (on connection %d)", Client_Conn( Client ));
-			Conn_Close( Client_Conn( Client ), NULL, "Can't allocate client structure for remote server", TRUE );
-			return DISCONNECTED;
-		}
-
-		/* Log-Meldung zusammenbauen und ausgeben */
-		if(( Client_Hops( c ) > 1 ) && ( Req->prefix[0] )) sprintf( str, "connected to %s, ", Client_ID( from ));
-		else strcpy( str, "" );
-		Log( LOG_NOTICE, "Server \"%s\" registered (via %s, %s%d hop%s).", Client_ID( c ), Client_ID( Client ), str, Client_Hops( c ), Client_Hops( c ) > 1 ? "s": "" );
-
-		/* Andere Server informieren */
-		IRC_WriteStrServersPrefix( Client, from, "SERVER %s %d %d :%s", Client_ID( c ), Client_Hops( c ) + 1, Client_MyToken( c ), Client_Info( c ));
-
-		return CONNECTED;
-	}
-	else return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
-} /* IRC_SERVER */
-
-
-GLOBAL BOOLEAN IRC_NJOIN( CLIENT *Client, REQUEST *Req )
-{
-	CHAR *channame, *ptr, modes[8];
-	BOOLEAN is_op, is_voiced;
-	CHANNEL *chan;
-	CLIENT *c;
-	
-	assert( Client != NULL );
-	assert( Req != NULL );
-
-	if( Client_Type( Client ) != CLIENT_SERVER ) return IRC_WriteStrClient( Client, ERR_NOTREGISTEREDSERVER_MSG, Client_ID( Client ));
-
-	/* Falsche Anzahl Parameter? */
-	if( Req->argc != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
-
-	channame = Req->argv[0];
-	ptr = strtok( Req->argv[1], "," );
-	while( ptr )
-	{
-		is_op = is_voiced = FALSE;
-		
-		/* Prefixe abschneiden */
-		while(( *ptr == '@' ) || ( *ptr == '+' ))
-		{
-			if( *ptr == '@' ) is_op = TRUE;
-			if( *ptr == '+' ) is_voiced = TRUE;
-			ptr++;
-		}
-
-		c = Client_GetFromID( ptr );
-		if( c )
-		{
-			Channel_Join( c, channame );
-			chan = Channel_Search( channame );
-			assert( chan != NULL );
-			
-			if( is_op ) Channel_UserModeAdd( chan, c, 'o' );
-			if( is_voiced ) Channel_UserModeAdd( chan, c, 'v' );
-
-			/* im Channel bekannt machen */
-			IRC_WriteStrChannelPrefix( Client, chan, c, FALSE, "JOIN :%s", channame );
-
-			/* Channel-User-Modes setzen */
-			strcpy( modes, Channel_UserModes( chan, c ));
-			if( modes[0] )
-			{
-				/* Modes im Channel bekannt machen */
-				IRC_WriteStrChannelPrefix( Client, chan, Client, FALSE, "MODE %s +%s %s", channame, modes, Client_ID( c ));
-			}
-		}
-		else Log( LOG_ERR, "Got NJOIN for unknown nick \"%s\" for channel \"%s\"!", ptr, channame );
-		
-		/* naechsten Nick suchen */
-		ptr = strtok( NULL, "," );
-	}
-
-	/* an andere Server weiterleiten */
-	IRC_WriteStrServersPrefix( Client, Client_ThisServer( ), "NJOIN %s :%s", Req->argv[0], Req->argv[1] );
-
-	return CONNECTED;
-} /* IRC_NJOIN */
-
-
 GLOBAL BOOLEAN IRC_NICK( CLIENT *Client, REQUEST *Req )
 {
 	CLIENT *intr_c, *target, *c;
@@ -553,55 +290,6 @@ GLOBAL BOOLEAN IRC_QUIT( CLIENT *Client, REQUEST *Req 
 } /* IRC_QUIT */
 
 
-GLOBAL BOOLEAN IRC_SQUIT( CLIENT *Client, REQUEST *Req )
-{
-	CLIENT *target;
-	CHAR msg[LINE_LEN + 64];
-	
-	assert( Client != NULL );
-	assert( Req != NULL );
-
-	/* SQUIT ist nur fuer Server erlaubt */
-	if( Client_Type( Client ) != CLIENT_SERVER ) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
-
-	/* Falsche Anzahl Parameter? */
-	if( Req->argc != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
-
-	Log( LOG_DEBUG, "Got SQUIT from %s for \"%s\": \"%s\" ...", Client_ID( Client ), Req->argv[0], Req->argv[1] );
-	
-	/* SQUIT an alle Server weiterleiten */
-	IRC_WriteStrServers( Client, "SQUIT %s :%s", Req->argv[0], Req->argv[1] );
-
-	target = Client_GetFromID( Req->argv[0] );
-	if( ! target )
-	{
-		Log( LOG_ERR, "Got SQUIT from %s for unknown server \"%s\"!?", Client_ID( Client ), Req->argv[0] );
-		return CONNECTED;
-	}
-
-	if( Req->argv[1][0] )
-	{
-		if( strlen( Req->argv[1] ) > LINE_LEN ) Req->argv[1][LINE_LEN] = '\0';
-		sprintf( msg, "%s (SQUIT from %s).", Req->argv[1], Client_ID( Client ));
-	}
-	else sprintf( msg, "Got SQUIT from %s.", Client_ID( Client ));
-
-	if( Client_Conn( target ) > NONE )
-	{
-		/* dieser Server hat die Connection */
-		if( Req->argv[1][0] ) Conn_Close( Client_Conn( target ), msg, Req->argv[1], TRUE );
-		else Conn_Close( Client_Conn( target ), msg, NULL, TRUE );
-		return DISCONNECTED;
-	}
-	else
-	{
-		/* Verbindung hielt anderer Server */
-		Client_Destroy( target, msg, Req->argv[1] );
-		return CONNECTED;
-	}
-} /* IRC_SQUIT */
-
-
 GLOBAL BOOLEAN IRC_PING( CLIENT *Client, REQUEST *Req )
 {
 	CLIENT *target, *from;
blob - /dev/null
blob + 1a1fd931a49693708365f1693ffcf92baed8e88f (mode 644)
--- /dev/null
+++ src/ngircd/irc-channel.c
@@ -0,0 +1,226 @@
+/*
+ * ngIRCd -- The Next Generation IRC Daemon
+ * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
+ *
+ * Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
+ * der GNU General Public License (GPL), wie von der Free Software Foundation
+ * herausgegeben, weitergeben und/oder modifizieren, entweder unter Version 2
+ * der Lizenz oder (wenn Sie es wuenschen) jeder spaeteren Version.
+ * 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 $
+ *
+ * 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 <imp.h>
+#include <assert.h>
+#include <string.h>
+
+#include "irc.h"
+#include "irc-write.h"
+#include "log.h"
+#include "messages.h"
+
+#include <exp.h>
+#include "irc-channel.h"
+
+
+GLOBAL BOOLEAN IRC_JOIN( CLIENT *Client, REQUEST *Req )
+{
+	CHAR *channame, *flags, *topic, modes[8];
+	BOOLEAN is_new_chan;
+	CLIENT *target;
+	CHANNEL *chan;
+
+	assert( Client != NULL );
+	assert( Req != NULL );
+
+	if(( Client_Type( Client ) != CLIENT_USER ) && ( Client_Type( Client ) != CLIENT_SERVER )) 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 );
+
+	/* Wer ist der Absender? */
+	if( Client_Type( Client ) == CLIENT_SERVER ) target = Client_GetFromID( Req->prefix );
+	else target = Client;
+	if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
+
+	/* Channel-Namen durchgehen */
+	channame = strtok( Req->argv[0], "," );
+	while( channame )
+	{
+		/* wird der Channel neu angelegt? */
+		flags = NULL;
+
+		if( Channel_Search( channame )) is_new_chan = FALSE;
+		else is_new_chan = TRUE;
+
+		/* Hat ein Server Channel-User-Modes uebergeben? */
+		if( Client_Type( Client ) == CLIENT_SERVER )
+		{
+			/* Channel-Flags extrahieren */
+			flags = strchr( channame, 0x7 );
+			if( flags ) *flags++ = '\0';
+		}
+
+		/* neuer Channel udn lokaler Client? */
+		if( is_new_chan && ( Client_Type( Client ) == CLIENT_USER ))
+		{
+			/* Dann soll der Client Channel-Operator werden! */
+			flags = "o";
+		}
+
+		/* Channel joinen (und ggf. anlegen) */
+		if( ! Channel_Join( target, channame ))
+		{
+			/* naechsten Namen ermitteln */
+			channame = strtok( NULL, "," );
+			continue;
+		}
+		chan = Channel_Search( channame );
+		assert( chan != NULL );
+
+		/* Modes setzen (wenn vorhanden) */
+		while( flags && *flags )
+		{
+			Channel_UserModeAdd( chan, target, *flags );
+			flags++;
+		}
+
+		/* Muessen Modes an andere Server gemeldet werden? */
+		strcpy( &modes[1], Channel_UserModes( chan, target ));
+		if( modes[1] ) modes[0] = 0x7;
+		else modes[0] = '\0';
+
+		/* An andere Server weiterleiten */
+		IRC_WriteStrServersPrefix( Client, target, "JOIN :%s%s", channame, modes );
+
+		/* im Channel bekannt machen */
+		IRC_WriteStrChannelPrefix( Client, chan, target, FALSE, "JOIN :%s", channame );
+		if( modes[1] )
+		{
+			/* Modes im Channel bekannt machen */
+			IRC_WriteStrChannelPrefix( Client, chan, target, FALSE, "MODE %s %s :%s", channame, modes, Client_ID( target ));
+		}
+
+		if( Client_Type( Client ) == CLIENT_USER )
+		{
+			/* an Client bestaetigen */
+			IRC_WriteStrClientPrefix( Client, target, "JOIN :%s", channame );
+
+			/* Topic an Client schicken */
+			topic = Channel_Topic( chan );
+			if( *topic ) IRC_WriteStrClient( Client, RPL_TOPIC_MSG, Client_ID( Client ), channame, topic );
+
+			/* Mitglieder an Client Melden */
+			IRC_Send_NAMES( Client, chan );
+			IRC_WriteStrClient( Client, RPL_ENDOFNAMES_MSG, Client_ID( Client ), Channel_Name( chan ));
+		}
+
+		/* naechsten Namen ermitteln */
+		channame = strtok( NULL, "," );
+	}
+	return CONNECTED;
+} /* IRC_JOIN */
+
+
+GLOBAL BOOLEAN IRC_PART( CLIENT *Client, REQUEST *Req )
+{
+	CLIENT *target;
+	CHAR *chan;
+
+	assert( Client != NULL );
+	assert( Req != NULL );
+
+	if(( Client_Type( Client ) != CLIENT_USER ) && ( Client_Type( Client ) != CLIENT_SERVER )) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
+
+	/* Falsche Anzahl Parameter? */
+	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 );
+	else target = Client;
+	if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
+
+	/* Channel-Namen durchgehen */
+	chan = strtok( Req->argv[0], "," );
+	while( chan )
+	{
+		if( ! Channel_Part( target, Client, chan, Req->argc > 1 ? Req->argv[1] : Client_ID( target )))
+		{
+			/* naechsten Namen ermitteln */
+			chan = strtok( NULL, "," );
+			continue;
+		}
+
+		/* naechsten Namen ermitteln */
+		chan = strtok( NULL, "," );
+	}
+	return CONNECTED;
+} /* IRC_PART */
+
+
+GLOBAL BOOLEAN IRC_TOPIC( CLIENT *Client, REQUEST *Req )
+{
+	CHANNEL *chan;
+	CLIENT *from;
+	CHAR *topic;
+
+	assert( Client != NULL );
+	assert( Req != NULL );
+
+	if(( Client_Type( Client ) != CLIENT_USER ) && ( Client_Type( Client ) != CLIENT_SERVER )) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
+
+	/* 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 );
+	else from = Client;
+	if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
+
+	/* Welcher Channel? */
+	chan = Channel_Search( Req->argv[0] );
+	if( ! chan ) return IRC_WriteStrClient( from, ERR_NOTONCHANNEL_MSG, Client_ID( from ), Req->argv[0] );
+
+	/* Ist der User Mitglied in dem Channel? */
+	if( ! Channel_IsMemberOf( chan, from )) return IRC_WriteStrClient( from, ERR_NOTONCHANNEL_MSG, Client_ID( from ), Req->argv[0] );
+
+	if( Req->argc == 1 )
+	{
+		/* Topic erfragen */
+		topic = Channel_Topic( chan );
+		if( *topic ) return IRC_WriteStrClient( from, RPL_TOPIC_MSG, Client_ID( from ), Channel_Name( chan ), topic );
+		else return IRC_WriteStrClient( from, RPL_NOTOPIC_MSG, Client_ID( from ), Channel_Name( chan ));
+	}
+
+	if( strchr( Channel_Modes( chan ), 't' ))
+	{
+		/* Topic Lock. Ist der User ein Channel Operator? */
+		if( ! strchr( Channel_UserModes( chan, from ), 'o' )) return IRC_WriteStrClient( from, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( from ), Channel_Name( chan ));
+	}
+
+	/* Topic setzen */
+	Channel_SetTopic( chan, Req->argv[1] );
+	Log( LOG_DEBUG, "User \"%s\" set topic on \"%s\": %s", Client_Mask( from ), Channel_Name( chan ), Req->argv[1][0] ? Req->argv[1] : "<none>" );
+
+	/* im Channel bekannt machen und an Server weiterleiten */
+	IRC_WriteStrServersPrefix( Client, from, "TOPIC %s :%s", Req->argv[0], Req->argv[1] );
+	IRC_WriteStrChannelPrefix( Client, chan, from, FALSE, "TOPIC %s :%s", Req->argv[0], Req->argv[1] );
+
+	if( Client_Type( Client ) == CLIENT_USER ) return IRC_WriteStrClientPrefix( Client, Client, "TOPIC %s :%s", Req->argv[0], Req->argv[1] );
+	else return CONNECTED;
+} /* IRC_TOPIC */
+
+
+/* -eof- */
blob - 5c53aee8eedb3434a7679a249592c113420bc0f5
blob + 17a7c533babea9e3262ec37d36c1cfc97135c731
--- src/ngircd/irc-login.h
+++ src/ngircd/irc-login.h
@@ -9,14 +9,16 @@
  * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
  * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
  *
- * $Id: irc-login.h,v 1.1 2002/02/27 23:26:21 alex Exp $
+ * $Id: irc-login.h,v 1.2 2002/03/03 17:15:11 alex Exp $
  *
  * irc-login.h: Anmeldung und Abmeldung im IRC (Header)
  *
  * $Log: irc-login.h,v $
+ * Revision 1.2  2002/03/03 17:15:11  alex
+ * - Source in weitere Module fuer IRC-Befehle aufgesplitted.
+ *
  * Revision 1.1  2002/02/27 23:26:21  alex
  * - Modul aus irc.c bzw. irc.h ausgegliedert.
- *
  */
 
 
@@ -30,12 +32,9 @@
 GLOBAL BOOLEAN IRC_PASS( CLIENT *Client, REQUEST *Req );
 GLOBAL BOOLEAN IRC_NICK( CLIENT *Client, REQUEST *Req );
 GLOBAL BOOLEAN IRC_USER( CLIENT *Client, REQUEST *Req );
-GLOBAL BOOLEAN IRC_SERVER( CLIENT *Client, REQUEST *Req );
-GLOBAL BOOLEAN IRC_NJOIN( CLIENT *Client, REQUEST *Req );
 GLOBAL BOOLEAN IRC_PING( CLIENT *Client, REQUEST *Req );
 GLOBAL BOOLEAN IRC_PONG( CLIENT *Client, REQUEST *Req );
 GLOBAL BOOLEAN IRC_QUIT( CLIENT *Client, REQUEST *Req );
-GLOBAL BOOLEAN IRC_SQUIT( CLIENT *Client, REQUEST *Req );
 
 
 #endif
blob - /dev/null
blob + 3796d560a3522dd96bc7c85ebe1c3613972e9e5a (mode 644)
--- /dev/null
+++ src/ngircd/irc-channel.h
@@ -0,0 +1,38 @@
+/*
+ * ngIRCd -- The Next Generation IRC Daemon
+ * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
+ *
+ * Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
+ * der GNU General Public License (GPL), wie von der Free Software Foundation
+ * herausgegeben, weitergeben und/oder modifizieren, entweder unter Version 2
+ * der Lizenz oder (wenn Sie es wuenschen) jeder spaeteren Version.
+ * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
+ * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
+ *
+ * $Id: irc-channel.h,v 1.1 2002/03/03 17:15:11 alex Exp $
+ *
+ * irc-channel.h: IRC-Channel-Befehle (Header)
+ *
+ * $Log: irc-channel.h,v $
+ * Revision 1.1  2002/03/03 17:15:11  alex
+ * - Source in weitere Module fuer IRC-Befehle aufgesplitted.
+ *
+ */
+
+
+#ifndef __irc_channel_h__
+#define __irc_channel_h__
+
+#include "parse.h"
+#include "client.h"
+
+
+GLOBAL BOOLEAN IRC_JOIN( CLIENT *Client, REQUEST *Req );
+GLOBAL BOOLEAN IRC_PART( CLIENT *Client, REQUEST *Req );
+GLOBAL BOOLEAN IRC_TOPIC( CLIENT *Client, REQUEST *Req );
+
+
+#endif
+
+
+/* -eof- */
blob - 3b9e903d4c92eb29d83f8cabe6f606e3f1648e7b
blob + 99e31050dc4ed55e9b05ac83ab8f1703908ca20e
--- src/ngircd/irc.c
+++ src/ngircd/irc.c
@@ -9,11 +9,14 @@
  * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
  * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
  *
- * $Id: irc.c,v 1.83 2002/02/28 00:48:26 alex Exp $
+ * $Id: irc.c,v 1.84 2002/03/03 17:15:11 alex Exp $
  *
  * irc.c: IRC-Befehle
  *
  * $Log: irc.c,v $
+ * Revision 1.84  2002/03/03 17:15:11  alex
+ * - Source in weitere Module fuer IRC-Befehle aufgesplitted.
+ *
  * Revision 1.83  2002/02/28 00:48:26  alex
  * - Forwarding von TOPIC an andere Server gefixed. Hoffentlich ;-)
  *
@@ -187,87 +190,6 @@ GLOBAL BOOLEAN IRC_NOTICE( CLIENT *Client, REQUEST *Re
 } /* IRC_NOTICE */
 
 
-GLOBAL BOOLEAN IRC_OPER( CLIENT *Client, REQUEST *Req )
-{
-	INT i;
-	
-	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 != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
-
-	/* Operator suchen */
-	for( i = 0; i < Conf_Oper_Count; i++)
-	{
-		if( Conf_Oper[i].name[0] && Conf_Oper[i].pwd[0] && ( strcmp( Conf_Oper[i].name, Req->argv[0] ) == 0 )) break;
-	}
-	if( i >= Conf_Oper_Count )
-	{
-		Log( LOG_WARNING, "Got invalid OPER from \"%s\": Name \"%s\" not configured!", Client_Mask( Client ), Req->argv[0] );
-		return IRC_WriteStrClient( Client, ERR_PASSWDMISMATCH_MSG, Client_ID( Client ));
-	}
-
-	/* Stimmt das Passwort? */
-	if( strcmp( Conf_Oper[i].pwd, Req->argv[1] ) != 0 )
-	{
-		Log( LOG_WARNING, "Got invalid OPER from \"%s\": Bad password for \"%s\"!", Client_Mask( Client ), Conf_Oper[i].name );
-		return IRC_WriteStrClient( Client, ERR_PASSWDMISMATCH_MSG, Client_ID( Client ));
-	}
-	
-	if( ! Client_HasMode( Client, 'o' ))
-	{
-		/* noch kein o-Mode gesetzt */
-		Client_ModeAdd( Client, 'o' );
-		if( ! IRC_WriteStrClient( Client, "MODE %s :+o", Client_ID( Client ))) return DISCONNECTED;
-		IRC_WriteStrServersPrefix( NULL, Client, "MODE %s :+o", Client_ID( Client ));
-	}
-
-	if( ! Client_OperByMe( Client )) Log( LOG_NOTICE, "Got valid OPER from \"%s\", user is an IRC operator now.", Client_Mask( Client ));
-
-	Client_SetOperByMe( Client, TRUE );
-	return IRC_WriteStrClient( Client, RPL_YOUREOPER_MSG, Client_ID( Client ));
-} /* IRC_OPER */
-
-
-GLOBAL BOOLEAN IRC_DIE( CLIENT *Client, REQUEST *Req )
-{
-	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 != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
-
-	if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client ));
-
-	Log( LOG_NOTICE, "Got DIE command from \"%s\", going down!", Client_Mask( Client ));
-	NGIRCd_Quit = TRUE;
-	return CONNECTED;
-} /* IRC_DIE */
-
-
-GLOBAL BOOLEAN IRC_RESTART( CLIENT *Client, REQUEST *Req )
-{
-	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 != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
-
-	if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client ));
-
-	Log( LOG_NOTICE, "Got RESTART command from \"%s\", going down!", Client_Mask( Client ));
-	NGIRCd_Restart = TRUE;
-	return CONNECTED;
-} /* IRC_RESTART */
-
-
 GLOBAL BOOLEAN IRC_NAMES( CLIENT *Client, REQUEST *Req )
 {
 	CHAR rpl[COMMAND_LEN], *ptr;
@@ -498,6 +420,20 @@ GLOBAL BOOLEAN IRC_WHOIS( CLIENT *Client, REQUEST *Req
 } /* IRC_WHOIS */
 
 
+GLOBAL BOOLEAN IRC_WHO( CLIENT *Client, REQUEST *Req )
+{
+	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 > 2 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
+	
+	return CONNECTED;
+} /* IRC_WHO */
+
+
 GLOBAL BOOLEAN IRC_USERHOST( CLIENT *Client, REQUEST *Req )
 {
 	CHAR rpl[COMMAND_LEN];
@@ -636,193 +572,6 @@ GLOBAL BOOLEAN IRC_LINKS( CLIENT *Client, REQUEST *Req
 } /* IRC_LINKS */
 
 
-GLOBAL BOOLEAN IRC_JOIN( CLIENT *Client, REQUEST *Req )
-{
-	CHAR *channame, *flags, *topic, modes[8];
-	BOOLEAN is_new_chan;
-	CLIENT *target;
-	CHANNEL *chan;
-	
-	assert( Client != NULL );
-	assert( Req != NULL );
-
-	if(( Client_Type( Client ) != CLIENT_USER ) && ( Client_Type( Client ) != CLIENT_SERVER )) 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 );
-
-	/* Wer ist der Absender? */
-	if( Client_Type( Client ) == CLIENT_SERVER ) target = Client_GetFromID( Req->prefix );
-	else target = Client;
-	if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
-	
-	/* Channel-Namen durchgehen */
-	channame = strtok( Req->argv[0], "," );
-	while( channame )
-	{
-		/* wird der Channel neu angelegt? */
-		flags = NULL;
-
-		if( Channel_Search( channame )) is_new_chan = FALSE;
-		else is_new_chan = TRUE;
-
-		/* Hat ein Server Channel-User-Modes uebergeben? */
-		if( Client_Type( Client ) == CLIENT_SERVER )
-		{
-			/* Channel-Flags extrahieren */
-			flags = strchr( channame, 0x7 );
-			if( flags ) *flags++ = '\0';
-		}
-
-		/* neuer Channel udn lokaler Client? */
-		if( is_new_chan && ( Client_Type( Client ) == CLIENT_USER ))
-		{
-			/* Dann soll der Client Channel-Operator werden! */
-			flags = "o";
-		}
-
-		/* Channel joinen (und ggf. anlegen) */
-		if( ! Channel_Join( target, channame ))
-		{
-			/* naechsten Namen ermitteln */
-			channame = strtok( NULL, "," );
-			continue;
-		}
-		chan = Channel_Search( channame );
-		assert( chan != NULL );
-
-		/* Modes setzen (wenn vorhanden) */
-		while( flags && *flags )
-		{
-			Channel_UserModeAdd( chan, target, *flags );
-			flags++;
-		}
-
-		/* Muessen Modes an andere Server gemeldet werden? */
-		strcpy( &modes[1], Channel_UserModes( chan, target ));
-		if( modes[1] ) modes[0] = 0x7;
-		else modes[0] = '\0';
-
-		/* An andere Server weiterleiten */
-		IRC_WriteStrServersPrefix( Client, target, "JOIN :%s%s", channame, modes );
-
-		/* im Channel bekannt machen */
-		IRC_WriteStrChannelPrefix( Client, chan, target, FALSE, "JOIN :%s", channame );
-		if( modes[1] )
-		{
-			/* Modes im Channel bekannt machen */
-			IRC_WriteStrChannelPrefix( Client, chan, target, FALSE, "MODE %s %s :%s", channame, modes, Client_ID( target ));
-		}
-
-		if( Client_Type( Client ) == CLIENT_USER )
-		{
-			/* an Client bestaetigen */
-			IRC_WriteStrClientPrefix( Client, target, "JOIN :%s", channame );
-
-			/* Topic an Client schicken */
-			topic = Channel_Topic( chan );
-			if( *topic ) IRC_WriteStrClient( Client, RPL_TOPIC_MSG, Client_ID( Client ), channame, topic );
-
-			/* Mitglieder an Client Melden */
-			IRC_Send_NAMES( Client, chan );
-			IRC_WriteStrClient( Client, RPL_ENDOFNAMES_MSG, Client_ID( Client ), Channel_Name( chan ));
-		}
-		
-		/* naechsten Namen ermitteln */
-		channame = strtok( NULL, "," );
-	}
-	return CONNECTED;
-} /* IRC_JOIN */
-
-
-GLOBAL BOOLEAN IRC_PART( CLIENT *Client, REQUEST *Req )
-{
-	CLIENT *target;
-	CHAR *chan;
-
-	assert( Client != NULL );
-	assert( Req != NULL );
-
-	if(( Client_Type( Client ) != CLIENT_USER ) && ( Client_Type( Client ) != CLIENT_SERVER )) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
-
-	/* Falsche Anzahl Parameter? */
-	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 );
-	else target = Client;
-	if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
-
-	/* Channel-Namen durchgehen */
-	chan = strtok( Req->argv[0], "," );
-	while( chan )
-	{
-		if( ! Channel_Part( target, Client, chan, Req->argc > 1 ? Req->argv[1] : Client_ID( target )))
-		{
-			/* naechsten Namen ermitteln */
-			chan = strtok( NULL, "," );
-			continue;
-		}
-
-		/* naechsten Namen ermitteln */
-		chan = strtok( NULL, "," );
-	}
-	return CONNECTED;
-} /* IRC_PART */
-
-
-GLOBAL BOOLEAN IRC_TOPIC( CLIENT *Client, REQUEST *Req )
-{
-	CHANNEL *chan;
-	CLIENT *from;
-	CHAR *topic;
-	
-	assert( Client != NULL );
-	assert( Req != NULL );
-
-	if(( Client_Type( Client ) != CLIENT_USER ) && ( Client_Type( Client ) != CLIENT_SERVER )) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
-
-	/* 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 );
-	else from = Client;
-	if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
-
-	/* Welcher Channel? */
-	chan = Channel_Search( Req->argv[0] );
-	if( ! chan ) return IRC_WriteStrClient( from, ERR_NOTONCHANNEL_MSG, Client_ID( from ), Req->argv[0] );
-
-	/* Ist der User Mitglied in dem Channel? */
-	if( ! Channel_IsMemberOf( chan, from )) return IRC_WriteStrClient( from, ERR_NOTONCHANNEL_MSG, Client_ID( from ), Req->argv[0] );
-
-	if( Req->argc == 1 )
-	{
-		/* Topic erfragen */
-		topic = Channel_Topic( chan );
-		if( *topic ) return IRC_WriteStrClient( from, RPL_TOPIC_MSG, Client_ID( from ), Channel_Name( chan ), topic );
-		else return IRC_WriteStrClient( from, RPL_NOTOPIC_MSG, Client_ID( from ), Channel_Name( chan ));
-	}
-
-	if( strchr( Channel_Modes( chan ), 't' ))
-	{
-		/* Topic Lock. Ist der User ein Channel Operator? */
-		if( ! strchr( Channel_UserModes( chan, from ), 'o' )) return IRC_WriteStrClient( from, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( from ), Channel_Name( chan ));
-	}
-
-	/* Topic setzen */
-	Channel_SetTopic( chan, Req->argv[1] );
-	Log( LOG_DEBUG, "User \"%s\" set topic on \"%s\": %s", Client_Mask( from ), Channel_Name( chan ), Req->argv[1][0] ? Req->argv[1] : "<none>" );
-
-	/* im Channel bekannt machen und an Server weiterleiten */
-	IRC_WriteStrServersPrefix( Client, from, "TOPIC %s :%s", Req->argv[0], Req->argv[1] );
-	IRC_WriteStrChannelPrefix( Client, chan, from, FALSE, "TOPIC %s :%s", Req->argv[0], Req->argv[1] );
-
-	if( Client_Type( Client ) == CLIENT_USER ) return IRC_WriteStrClientPrefix( Client, Client, "TOPIC %s :%s", Req->argv[0], Req->argv[1] );
-	else return CONNECTED;
-} /* IRC_TOPIC */
-
-
 GLOBAL BOOLEAN IRC_VERSION( CLIENT *Client, REQUEST *Req )
 {
 	CLIENT *target, *prefix;
blob - /dev/null
blob + d71bcaaf6ccccef7b7f34ee85586364d6ffd1020 (mode 644)
--- /dev/null
+++ src/ngircd/irc-oper.c
@@ -0,0 +1,120 @@
+/*
+ * ngIRCd -- The Next Generation IRC Daemon
+ * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
+ *
+ * Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
+ * der GNU General Public License (GPL), wie von der Free Software Foundation
+ * herausgegeben, weitergeben und/oder modifizieren, entweder unter Version 2
+ * der Lizenz oder (wenn Sie es wuenschen) jeder spaeteren Version.
+ * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
+ * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
+ *
+ * $Id: irc-oper.c,v 1.1 2002/03/03 17:15:11 alex Exp $
+ *
+ * irc-oper.c: IRC-Operator-Befehle
+ *
+ * $Log: irc-oper.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 <imp.h>
+#include <assert.h>
+
+#include "ngircd.h"
+#include "conf.h"
+#include "irc-write.h"
+#include "log.h"
+#include "messages.h"
+
+#include <exp.h>
+#include "irc-oper.h"
+
+
+GLOBAL BOOLEAN IRC_OPER( CLIENT *Client, REQUEST *Req )
+{
+	INT i;
+
+	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 != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
+
+	/* Operator suchen */
+	for( i = 0; i < Conf_Oper_Count; i++)
+	{
+		if( Conf_Oper[i].name[0] && Conf_Oper[i].pwd[0] && ( strcmp( Conf_Oper[i].name, Req->argv[0] ) == 0 )) break;
+	}
+	if( i >= Conf_Oper_Count )
+	{
+		Log( LOG_WARNING, "Got invalid OPER from \"%s\": Name \"%s\" not configured!", Client_Mask( Client ), Req->argv[0] );
+		return IRC_WriteStrClient( Client, ERR_PASSWDMISMATCH_MSG, Client_ID( Client ));
+	}
+
+	/* Stimmt das Passwort? */
+	if( strcmp( Conf_Oper[i].pwd, Req->argv[1] ) != 0 )
+	{
+		Log( LOG_WARNING, "Got invalid OPER from \"%s\": Bad password for \"%s\"!", Client_Mask( Client ), Conf_Oper[i].name );
+		return IRC_WriteStrClient( Client, ERR_PASSWDMISMATCH_MSG, Client_ID( Client ));
+	}
+
+	if( ! Client_HasMode( Client, 'o' ))
+	{
+		/* noch kein o-Mode gesetzt */
+		Client_ModeAdd( Client, 'o' );
+		if( ! IRC_WriteStrClient( Client, "MODE %s :+o", Client_ID( Client ))) return DISCONNECTED;
+		IRC_WriteStrServersPrefix( NULL, Client, "MODE %s :+o", Client_ID( Client ));
+	}
+
+	if( ! Client_OperByMe( Client )) Log( LOG_NOTICE, "Got valid OPER from \"%s\", user is an IRC operator now.", Client_Mask( Client ));
+
+	Client_SetOperByMe( Client, TRUE );
+	return IRC_WriteStrClient( Client, RPL_YOUREOPER_MSG, Client_ID( Client ));
+} /* IRC_OPER */
+
+
+GLOBAL BOOLEAN IRC_DIE( CLIENT *Client, REQUEST *Req )
+{
+	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 != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
+
+	if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client ));
+
+	Log( LOG_NOTICE, "Got DIE command from \"%s\", going down!", Client_Mask( Client ));
+	NGIRCd_Quit = TRUE;
+	return CONNECTED;
+} /* IRC_DIE */
+
+
+GLOBAL BOOLEAN IRC_RESTART( CLIENT *Client, REQUEST *Req )
+{
+	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 != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
+
+	if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client ));
+
+	Log( LOG_NOTICE, "Got RESTART command from \"%s\", going down!", Client_Mask( Client ));
+	NGIRCd_Restart = TRUE;
+	return CONNECTED;
+} /* IRC_RESTART */
+
+
+/* -eof- */
blob - e951b50ab604e033d2052ff7f6c5d3c044f059c3
blob + e02516ef9a13e777a00c31f35d03249f7b8a79fc
--- src/ngircd/irc.h
+++ src/ngircd/irc.h
@@ -9,11 +9,14 @@
  * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
  * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
  *
- * $Id: irc.h,v 1.27 2002/02/27 23:26:36 alex Exp $
+ * $Id: irc.h,v 1.28 2002/03/03 17:15:11 alex Exp $
  *
  * irc.h: IRC-Befehle (Header)
  *
  * $Log: irc.h,v $
+ * Revision 1.28  2002/03/03 17:15:11  alex
+ * - Source in weitere Module fuer IRC-Befehle aufgesplitted.
+ *
  * Revision 1.27  2002/02/27 23:26:36  alex
  * - einige Funktionen in irc-xxx-Module ausgegliedert.
  *
@@ -51,18 +54,11 @@ GLOBAL BOOLEAN IRC_NAMES( CLIENT *Client, REQUEST *Req
 GLOBAL BOOLEAN IRC_ISON( CLIENT *Client, REQUEST *Req );
 GLOBAL BOOLEAN IRC_WHOIS( CLIENT *Client, REQUEST *Req );
 GLOBAL BOOLEAN IRC_USERHOST( CLIENT *Client, REQUEST *Req );
+GLOBAL BOOLEAN IRC_WHO( CLIENT *Client, REQUEST *Req );
 
-GLOBAL BOOLEAN IRC_OPER( CLIENT *Client, REQUEST *Req );
-GLOBAL BOOLEAN IRC_DIE( CLIENT *Client, REQUEST *Req );
-GLOBAL BOOLEAN IRC_RESTART( CLIENT *Client, REQUEST *Req );
-
 GLOBAL BOOLEAN IRC_ERROR( CLIENT *Client, REQUEST *Req );
 GLOBAL BOOLEAN IRC_KILL( CLIENT *Client, REQUEST *Req );
 
-GLOBAL BOOLEAN IRC_JOIN( CLIENT *Client, REQUEST *Req );
-GLOBAL BOOLEAN IRC_PART( CLIENT *Client, REQUEST *Req );
-GLOBAL BOOLEAN IRC_TOPIC( CLIENT *Client, REQUEST *Req );
-
 GLOBAL BOOLEAN IRC_Send_NAMES( CLIENT *Client, CHANNEL *Chan );
 GLOBAL BOOLEAN IRC_Send_LUSERS( CLIENT *Client );
 GLOBAL BOOLEAN IRC_Show_MOTD( CLIENT *Client );
blob - /dev/null
blob + c9e27a16c88a341c5e0bfe22eaef4504a569f40f (mode 644)
--- /dev/null
+++ src/ngircd/irc-oper.h
@@ -0,0 +1,38 @@
+/*
+ * ngIRCd -- The Next Generation IRC Daemon
+ * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
+ *
+ * Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
+ * der GNU General Public License (GPL), wie von der Free Software Foundation
+ * herausgegeben, weitergeben und/oder modifizieren, entweder unter Version 2
+ * der Lizenz oder (wenn Sie es wuenschen) jeder spaeteren Version.
+ * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
+ * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
+ *
+ * $Id: irc-oper.h,v 1.1 2002/03/03 17:15:11 alex Exp $
+ *
+ * irc-oper.h: IRC-Operator-Befehle (Header)
+ *
+ * $Log: irc-oper.h,v $
+ * Revision 1.1  2002/03/03 17:15:11  alex
+ * - Source in weitere Module fuer IRC-Befehle aufgesplitted.
+ *
+ */
+
+
+#ifndef __irc_oper_h__
+#define __irc_oper_h__
+
+#include "parse.h"
+#include "client.h"
+
+
+GLOBAL BOOLEAN IRC_OPER( CLIENT *Client, REQUEST *Req );
+GLOBAL BOOLEAN IRC_DIE( CLIENT *Client, REQUEST *Req );
+GLOBAL BOOLEAN IRC_RESTART( CLIENT *Client, REQUEST *Req );
+
+
+#endif
+
+
+/* -eof- */
blob - /dev/null
blob + fcceccc6dd235b05c673d5d3118025daccf789c2 (mode 644)
--- /dev/null
+++ src/ngircd/irc-server.c
@@ -0,0 +1,355 @@
+/*
+ * ngIRCd -- The Next Generation IRC Daemon
+ * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
+ *
+ * Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
+ * der GNU General Public License (GPL), wie von der Free Software Foundation
+ * herausgegeben, weitergeben und/oder modifizieren, entweder unter Version 2
+ * der Lizenz oder (wenn Sie es wuenschen) jeder spaeteren Version.
+ * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
+ * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
+ *
+ * $Id: irc-server.c,v 1.1 2002/03/03 17:15:11 alex Exp $
+ *
+ * irc-server.c: IRC-Befehle fuer Server-Links
+ *
+ * $Log: irc-server.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 <imp.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "conf.h"
+#include "irc-write.h"
+#include "log.h"
+#include "messages.h"
+
+#include <exp.h>
+#include "irc-server.h"
+
+
+GLOBAL BOOLEAN IRC_SERVER( CLIENT *Client, REQUEST *Req )
+{
+	CHAR str[LINE_LEN], *ptr;
+	CLIENT *from, *c, *cl;
+	CL2CHAN *cl2chan;
+	INT max_hops, i;
+	CHANNEL *chan;
+	BOOLEAN ok;
+	
+	assert( Client != NULL );
+	assert( Req != NULL );
+
+	/* Fehler liefern, wenn kein lokaler Client */
+	if( Client_Conn( Client ) <= NONE ) return IRC_WriteStrClient( Client, ERR_UNKNOWNCOMMAND_MSG, Client_ID( Client ), Req->command );
+
+	if( Client_Type( Client ) == CLIENT_GOTPASSSERVER )
+	{
+		/* Verbindung soll als Server-Server-Verbindung registriert werden */
+		Log( LOG_DEBUG, "Connection %d: got SERVER command (new server link) ...", Client_Conn( Client ));
+
+		/* Falsche Anzahl Parameter? */
+		if(( Req->argc != 2 ) && ( Req->argc != 3 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
+
+		/* Ist dieser Server bei uns konfiguriert? */
+		for( i = 0; i < Conf_Server_Count; i++ ) if( strcasecmp( Req->argv[0], Conf_Server[i].name ) == 0 ) break;
+		if( i >= Conf_Server_Count )
+		{
+			/* Server ist nicht konfiguriert! */
+			Log( LOG_ERR, "Connection %d: Server \"%s\" not configured here!", Client_Conn( Client ), Req->argv[0] );
+			Conn_Close( Client_Conn( Client ), NULL, "Server not configured here", TRUE );
+			return DISCONNECTED;
+		}
+		if( strcmp( Client_Password( Client ), Conf_Server[i].pwd ) != 0 )
+		{
+			/* Falsches Passwort */
+			Log( LOG_ERR, "Connection %d: Bad password for server \"%s\"!", Client_Conn( Client ), Req->argv[0] );
+			Conn_Close( Client_Conn( Client ), NULL, "Bad password", TRUE );
+			return DISCONNECTED;
+		}
+		
+		/* Ist ein Server mit dieser ID bereits registriert? */
+		if( ! Client_CheckID( Client, Req->argv[0] )) return DISCONNECTED;
+
+		/* Server-Strukturen fuellen ;-) */
+		Client_SetID( Client, Req->argv[0] );
+		Client_SetHops( Client, 1 );
+		Client_SetInfo( Client, Req->argv[Req->argc - 1] );
+		
+		/* Meldet sich der Server bei uns an? */
+		if( Req->argc == 2 )
+		{
+			/* Unseren SERVER- und PASS-Befehl senden */
+			ok = TRUE;
+			if( ! IRC_WriteStrClient( Client, "PASS %s "PASSSERVERADD, Conf_Server[i].pwd )) ok = FALSE;
+			else ok = IRC_WriteStrClient( Client, "SERVER %s 1 :%s", Conf_ServerName, Conf_ServerInfo );
+			if( ! ok )
+			{
+				Conn_Close( Client_Conn( Client ), "Unexpected server behavior!", NULL, FALSE );
+				return DISCONNECTED;
+			}
+			Client_SetIntroducer( Client, Client );
+			Client_SetToken( Client, 1 );
+		}
+		else  Client_SetToken( Client, atoi( Req->argv[1] ));
+
+		Log( LOG_NOTICE, "Server \"%s\" registered (connection %d, 1 hop - direct link).", Client_ID( Client ), Client_Conn( Client ));
+
+		Client_SetType( Client, CLIENT_SERVER );
+
+		/* maximalen Hop Count ermitteln */
+		max_hops = 0;
+		c = Client_First( );
+		while( c )
+		{
+			if( Client_Hops( c ) > max_hops ) max_hops = Client_Hops( c );
+			c = Client_Next( c );
+		}
+		
+		/* Alle bisherigen Server dem neuen Server bekannt machen,
+		 * die bisherigen Server ueber den neuen informierenn */
+		for( i = 0; i < ( max_hops + 1 ); i++ )
+		{
+			c = Client_First( );
+			while( c )
+			{
+				if(( Client_Type( c ) == CLIENT_SERVER ) && ( c != Client ) && ( c != Client_ThisServer( )) && ( Client_Hops( c ) == i ))
+				{
+					if( Client_Conn( c ) > NONE )
+					{
+						/* Dem gefundenen Server gleich den neuen
+						 * Server bekannt machen */
+						if( ! IRC_WriteStrClient( c, "SERVER %s %d %d :%s", Client_ID( Client ), Client_Hops( Client ) + 1, Client_MyToken( Client ), Client_Info( Client ))) return DISCONNECTED;
+					}
+					
+					/* Den neuen Server ueber den alten informieren */
+					if( ! IRC_WriteStrClientPrefix( Client, Client_Hops( c ) == 1 ? Client_ThisServer( ) : Client_Introducer( c ), "SERVER %s %d %d :%s", Client_ID( c ), Client_Hops( c ) + 1, Client_MyToken( c ), Client_Info( c ))) return DISCONNECTED;
+				}
+				c = Client_Next( c );
+			}
+		}
+
+		/* alle User dem neuen Server bekannt machen */
+		c = Client_First( );
+		while( c )
+		{
+			if( Client_Type( c ) == CLIENT_USER )
+			{
+				/* User an neuen Server melden */
+				if( ! IRC_WriteStrClient( Client, "NICK %s %d %s %s %d +%s :%s", Client_ID( c ), Client_Hops( c ) + 1, Client_User( c ), Client_Hostname( c ), Client_MyToken( Client_Introducer( c )), Client_Modes( c ), Client_Info( c ))) return DISCONNECTED;
+			}
+			c = Client_Next( c );
+		}
+
+		/* Channels dem neuen Server bekannt machen */
+		chan = Channel_First( );
+		while( chan )
+		{
+			sprintf( str, "NJOIN %s :", Channel_Name( chan ));
+
+			/* alle Member suchen */
+			cl2chan = Channel_FirstMember( chan );
+			while( cl2chan )
+			{
+				cl = Channel_GetClient( cl2chan );
+				assert( cl != NULL );
+
+				/* Nick, ggf. mit Modes, anhaengen */
+				if( str[strlen( str ) - 1] != ':' ) strcat( str, "," );
+				if( strchr( Channel_UserModes( chan, cl ), 'v' )) strcat( str, "+" );
+				if( strchr( Channel_UserModes( chan, cl ), 'o' )) strcat( str, "@" );
+				strcat( str, Client_ID( cl ));
+
+				if( strlen( str ) > ( LINE_LEN - CLIENT_NICK_LEN - 4 ))
+				{
+					/* Zeile senden */
+					if( ! IRC_WriteStrClient( Client, str )) return DISCONNECTED;
+					sprintf( str, "NJOIN %s :", Channel_Name( chan ));
+				}
+				
+				cl2chan = Channel_NextMember( chan, cl2chan );
+			}
+
+			/* noch Daten da? */
+			if( str[strlen( str ) - 1] != ':')
+			{
+				/* Ja; Also senden ... */
+				if( ! IRC_WriteStrClient( Client, str )) return DISCONNECTED;
+			}
+
+			/* naechsten Channel suchen */
+			chan = Channel_Next( chan );
+		}
+		
+		return CONNECTED;
+	}
+	else if( Client_Type( Client ) == CLIENT_SERVER )
+	{
+		/* Neuer Server wird im Netz angekuendigt */
+
+		/* Falsche Anzahl Parameter? */
+		if( Req->argc != 4 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
+
+		/* Ist ein Server mit dieser ID bereits registriert? */
+		if( ! Client_CheckID( Client, Req->argv[0] )) return DISCONNECTED;
+
+		/* Ueberfluessige Hostnamen aus Info-Text entfernen */
+		ptr = strchr( Req->argv[3] + 2, '[' );
+		if( ! ptr ) ptr = Req->argv[3];
+
+		from = Client_GetFromID( Req->prefix );
+		if( ! from )
+		{
+			/* Hm, Server, der diesen einfuehrt, ist nicht bekannt!? */
+			Log( LOG_ALERT, "Unknown ID in prefix of SERVER: \"%s\"! (on connection %d)", Req->prefix, Client_Conn( Client ));
+			Conn_Close( Client_Conn( Client ), NULL, "Unknown ID in prefix of SERVER", TRUE );
+			return DISCONNECTED;
+		}
+
+		/* Neue Client-Struktur anlegen */
+		c = Client_NewRemoteServer( Client, Req->argv[0], from, atoi( Req->argv[1] ), atoi( Req->argv[2] ), ptr, TRUE );
+		if( ! c )
+		{
+			/* Neue Client-Struktur konnte nicht angelegt werden */
+			Log( LOG_ALERT, "Can't create client structure for server! (on connection %d)", Client_Conn( Client ));
+			Conn_Close( Client_Conn( Client ), NULL, "Can't allocate client structure for remote server", TRUE );
+			return DISCONNECTED;
+		}
+
+		/* Log-Meldung zusammenbauen und ausgeben */
+		if(( Client_Hops( c ) > 1 ) && ( Req->prefix[0] )) sprintf( str, "connected to %s, ", Client_ID( from ));
+		else strcpy( str, "" );
+		Log( LOG_NOTICE, "Server \"%s\" registered (via %s, %s%d hop%s).", Client_ID( c ), Client_ID( Client ), str, Client_Hops( c ), Client_Hops( c ) > 1 ? "s": "" );
+
+		/* Andere Server informieren */
+		IRC_WriteStrServersPrefix( Client, from, "SERVER %s %d %d :%s", Client_ID( c ), Client_Hops( c ) + 1, Client_MyToken( c ), Client_Info( c ));
+
+		return CONNECTED;
+	}
+	else return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
+} /* IRC_SERVER */
+
+
+GLOBAL BOOLEAN IRC_NJOIN( CLIENT *Client, REQUEST *Req )
+{
+	CHAR *channame, *ptr, modes[8];
+	BOOLEAN is_op, is_voiced;
+	CHANNEL *chan;
+	CLIENT *c;
+	
+	assert( Client != NULL );
+	assert( Req != NULL );
+
+	if( Client_Type( Client ) != CLIENT_SERVER ) return IRC_WriteStrClient( Client, ERR_NOTREGISTEREDSERVER_MSG, Client_ID( Client ));
+
+	/* Falsche Anzahl Parameter? */
+	if( Req->argc != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
+
+	channame = Req->argv[0];
+	ptr = strtok( Req->argv[1], "," );
+	while( ptr )
+	{
+		is_op = is_voiced = FALSE;
+		
+		/* Prefixe abschneiden */
+		while(( *ptr == '@' ) || ( *ptr == '+' ))
+		{
+			if( *ptr == '@' ) is_op = TRUE;
+			if( *ptr == '+' ) is_voiced = TRUE;
+			ptr++;
+		}
+
+		c = Client_GetFromID( ptr );
+		if( c )
+		{
+			Channel_Join( c, channame );
+			chan = Channel_Search( channame );
+			assert( chan != NULL );
+			
+			if( is_op ) Channel_UserModeAdd( chan, c, 'o' );
+			if( is_voiced ) Channel_UserModeAdd( chan, c, 'v' );
+
+			/* im Channel bekannt machen */
+			IRC_WriteStrChannelPrefix( Client, chan, c, FALSE, "JOIN :%s", channame );
+
+			/* Channel-User-Modes setzen */
+			strcpy( modes, Channel_UserModes( chan, c ));
+			if( modes[0] )
+			{
+				/* Modes im Channel bekannt machen */
+				IRC_WriteStrChannelPrefix( Client, chan, Client, FALSE, "MODE %s +%s %s", channame, modes, Client_ID( c ));
+			}
+		}
+		else Log( LOG_ERR, "Got NJOIN for unknown nick \"%s\" for channel \"%s\"!", ptr, channame );
+		
+		/* naechsten Nick suchen */
+		ptr = strtok( NULL, "," );
+	}
+
+	/* an andere Server weiterleiten */
+	IRC_WriteStrServersPrefix( Client, Client_ThisServer( ), "NJOIN %s :%s", Req->argv[0], Req->argv[1] );
+
+	return CONNECTED;
+} /* IRC_NJOIN */
+
+
+GLOBAL BOOLEAN IRC_SQUIT( CLIENT *Client, REQUEST *Req )
+{
+	CLIENT *target;
+	CHAR msg[LINE_LEN + 64];
+
+	assert( Client != NULL );
+	assert( Req != NULL );
+
+	/* SQUIT ist nur fuer Server erlaubt */
+	if( Client_Type( Client ) != CLIENT_SERVER ) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
+
+	/* Falsche Anzahl Parameter? */
+	if( Req->argc != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
+
+	Log( LOG_DEBUG, "Got SQUIT from %s for \"%s\": \"%s\" ...", Client_ID( Client ), Req->argv[0], Req->argv[1] );
+
+	/* SQUIT an alle Server weiterleiten */
+	IRC_WriteStrServers( Client, "SQUIT %s :%s", Req->argv[0], Req->argv[1] );
+
+	target = Client_GetFromID( Req->argv[0] );
+	if( ! target )
+	{
+		Log( LOG_ERR, "Got SQUIT from %s for unknown server \"%s\"!?", Client_ID( Client ), Req->argv[0] );
+		return CONNECTED;
+	}
+
+	if( Req->argv[1][0] )
+	{
+		if( strlen( Req->argv[1] ) > LINE_LEN ) Req->argv[1][LINE_LEN] = '\0';
+		sprintf( msg, "%s (SQUIT from %s).", Req->argv[1], Client_ID( Client ));
+	}
+	else sprintf( msg, "Got SQUIT from %s.", Client_ID( Client ));
+
+	if( Client_Conn( target ) > NONE )
+	{
+		/* dieser Server hat die Connection */
+		if( Req->argv[1][0] ) Conn_Close( Client_Conn( target ), msg, Req->argv[1], TRUE );
+		else Conn_Close( Client_Conn( target ), msg, NULL, TRUE );
+		return DISCONNECTED;
+	}
+	else
+	{
+		/* Verbindung hielt anderer Server */
+		Client_Destroy( target, msg, Req->argv[1] );
+		return CONNECTED;
+	}
+} /* IRC_SQUIT */
+
+
+/* -eof- */
blob - /dev/null
blob + f6d66696e68fb956bed6ec4d16c855714fa5acd8 (mode 644)
--- /dev/null
+++ src/ngircd/irc-server.h
@@ -0,0 +1,38 @@
+/*
+ * ngIRCd -- The Next Generation IRC Daemon
+ * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
+ *
+ * Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
+ * der GNU General Public License (GPL), wie von der Free Software Foundation
+ * herausgegeben, weitergeben und/oder modifizieren, entweder unter Version 2
+ * der Lizenz oder (wenn Sie es wuenschen) jeder spaeteren Version.
+ * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
+ * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
+ *
+ * $Id: irc-server.h,v 1.1 2002/03/03 17:15:12 alex Exp $
+ *
+ * irc-server.h: IRC-Befehle fuer Server-Links (Header)
+ *
+ * $Log: irc-server.h,v $
+ * Revision 1.1  2002/03/03 17:15:12  alex
+ * - Source in weitere Module fuer IRC-Befehle aufgesplitted.
+ *
+ */
+
+
+#ifndef __irc_server_h__
+#define __irc_server_h__
+
+#include "parse.h"
+#include "client.h"
+
+
+GLOBAL BOOLEAN IRC_SERVER( CLIENT *Client, REQUEST *Req );
+GLOBAL BOOLEAN IRC_NJOIN( CLIENT *Client, REQUEST *Req );
+GLOBAL BOOLEAN IRC_SQUIT( CLIENT *Client, REQUEST *Req );
+
+
+#endif
+
+
+/* -eof- */