]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/irc-server.c
- Renamed functions now found in "conn-zip.c".
[ngircd-alex.git] / src / ngircd / irc-server.c
index 6a6f4712febfcfc632a22f27aa111dcf7c289cae..99b5cb095bae2a481bc10c56327adfe1342f4ed8 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: irc-server.c,v 1.26 2002/12/26 16:48:14 alex Exp $";
+static char UNUSED id[] = "$Id: irc-server.c,v 1.30 2002/12/30 16:07:50 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -23,8 +23,9 @@ static char UNUSED id[] = "$Id: irc-server.c,v 1.26 2002/12/26 16:48:14 alex Exp
 #include <string.h>
 
 #include "resolve.h"
-#include "conf.h"
 #include "conn.h"
+#include "conn-zip.h"
+#include "conf.h"
 #include "client.h"
 #include "channel.h"
 #include "irc-write.h"
@@ -63,8 +64,8 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
                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 )
+               for( i = 0; i < MAX_SERVERS; i++ ) if( strcasecmp( Req->argv[0], Conf_Server[i].name ) == 0 ) break;
+               if( i >= MAX_SERVERS )
                {
                        /* Server ist nicht konfiguriert! */
                        Log( LOG_ERR, "Connection %d: Server \"%s\" not configured here!", Client_Conn( Client ), Req->argv[0] );
@@ -114,13 +115,13 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
                Log( LOG_NOTICE|LOG_snotice, "Server \"%s\" registered (connection %d, 1 hop - direct link).", Client_ID( Client ), con );
 
                Client_SetType( Client, CLIENT_SERVER );
-               Conn_SetServer( con, i );
+               Conf_SetServer( i, con );
 
 #ifdef USE_ZLIB
                /* Kompression initialisieren, wenn erforderlich */
                if( strchr( Client_Flags( Client ), 'Z' ))
                {
-                       if( ! Conn_InitZip( con ))
+                       if( ! Zip_InitConn( con ))
                        {
                                /* Fehler! */
                                Conn_Close( con, "Can't inizialize compression (zlib)!", NULL, FALSE );
@@ -188,7 +189,7 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
 
                        /* alle Member suchen */
                        cl2chan = Channel_FirstMember( chan );
-                       sprintf( str, "NJOIN %s :", Channel_Name( chan ));
+                       snprintf( str, sizeof( str ), "NJOIN %s :", Channel_Name( chan ));
                        while( cl2chan )
                        {
                                cl = Channel_GetClient( cl2chan );
@@ -204,7 +205,7 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
                                {
                                        /* Zeile senden */
                                        if( ! IRC_WriteStrClient( Client, "%s", str )) return DISCONNECTED;
-                                       sprintf( str, "NJOIN %s :", Channel_Name( chan ));
+                                       snprintf( str, sizeof( str ), "NJOIN %s :", Channel_Name( chan ));
                                }
                                
                                cl2chan = Channel_NextMember( chan, cl2chan );
@@ -257,7 +258,7 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
                }
 
                /* Log-Meldung zusammenbauen und ausgeben */
-               if(( Client_Hops( c ) > 1 ) && ( Req->prefix[0] )) sprintf( str, "connected to %s, ", Client_ID( from ));
+               if(( Client_Hops( c ) > 1 ) && ( Req->prefix[0] )) snprintf( str, sizeof( str ), "connected to %s, ", Client_ID( from ));
                else strcpy( str, "" );
                Log( LOG_NOTICE|LOG_snotice, "Server \"%s\" registered (via %s, %s%d hop%s).", Client_ID( c ), Client_ID( Client ), str, Client_Hops( c ), Client_Hops( c ) > 1 ? "s": "" );
 
@@ -314,7 +315,7 @@ IRC_NJOIN( CLIENT *Client, REQUEST *Req )
                        IRC_WriteStrChannelPrefix( Client, chan, c, FALSE, "JOIN :%s", channame );
 
                        /* Channel-User-Modes setzen */
-                       strcpy( modes, Channel_UserModes( chan, c ));
+                       strlcpy( modes, Channel_UserModes( chan, c ), sizeof( modes ));
                        if( modes[0] )
                        {
                                /* Modes im Channel bekannt machen */
@@ -359,9 +360,9 @@ IRC_SQUIT( CLIENT *Client, REQUEST *Req )
        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 ));
+               snprintf( msg, sizeof( msg ), "%s (SQUIT from %s).", Req->argv[1], Client_ID( Client ));
        }
-       else sprintf( msg, "Got SQUIT from %s.", Client_ID( Client ));
+       else snprintf( msg, sizeof( msg ), "Got SQUIT from %s.", Client_ID( Client ));
 
        if( Client_Conn( target ) > NONE )
        {