]> 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 e5846dd4a038af7bc5a654ce7a74e761a4731ab0..99b5cb095bae2a481bc10c56327adfe1342f4ed8 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: irc-server.c,v 1.24 2002/12/12 12:24:18 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.24 2002/12/12 12:24:18 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,23 +189,23 @@ 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 );
                                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( str[strlen( str ) - 1] != ':' ) strlcat( str, ",", sizeof( str ));
+                               if( strchr( Channel_UserModes( chan, cl ), 'v' )) strlcat( str, "+", sizeof( str ));
+                               if( strchr( Channel_UserModes( chan, cl ), 'o' )) strlcat( str, "@", sizeof( str ));
+                               strlcat( str, Client_ID( cl ), sizeof( str ));
 
                                if( strlen( str ) > ( LINE_LEN - CLIENT_NICK_LEN - 8 ))
                                {
                                        /* 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": "" );
 
@@ -284,8 +285,7 @@ IRC_NJOIN( CLIENT *Client, REQUEST *Req )
        /* Falsche Anzahl Parameter? */
        if( Req->argc != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
 
-       strncpy( str, Req->argv[1], COMMAND_LEN - 1 );
-       str[COMMAND_LEN - 1] = '\0';
+       strlcpy( str, Req->argv[1], sizeof( str ));
 
        channame = Req->argv[0];
        ptr = strtok( str, "," );
@@ -315,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 */
@@ -360,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 )
        {