% auth.sl - Routine to allow connecting to servers that require %
% authentication.  Written by Curtiss Howard, 1998.             %

variable ReceiveStr;

% This function is called basically the same way connect(); is. %
% Please note that this performs no real checking as to whether %
% or not this login succeeded (but you'll know if it doesn't    %
% since the server will drop the connection :)).                %

define auth_connect (Server, Port, User, Password)
{
	raw_connect (Server, Port);
        
        if (connected)
	{
        	printf ("linleech> Attempting to login as user %s... ", User);
		raw_receive();
        	raw_send (sprintf ("AUTHINFO USER %s\r\n", User));
        	raw_receive();
                raw_send (sprintf ("AUTHINFO PASS %s\r\n", Password));
                ReceiveStr = raw_receive();
                
                if ((ReceiveStr[0] == '5') and (ReceiveStr[1] == '0') and
			(ReceiveStr[2] == '2'))
		{
			% Code 502 -- error authenticating. %

			printf ("failure.\n");
		}
		
		else
		{
			printf ("okay.\n");
		}
	}
}