@echo 0
@rem ************************************************************************
@rem ****  wsklogin.scr - Logs in to FIBS (Winsock only) -- See           ***
@rem ****                 fibslogn.scr for dial-up login procedure.       ***
@rem ****                 Basically, this procedure decides               ***
@rem ****                 whether this is a guest login or not.           ***
@rem ****                 NB: guest logins are detected by watching for   ***
@rem ****                 a transition to online state from login prompt  ***
@rem ****                 without an intervening password prompt! Crude   ***
@rem ****                 but effective.                                  ***
@rem ************************************************************************


@rem Wait for the Login prompt.

@echo "\r\n** Logging in to FIBS...\r\n"
@wait "login: " 

@if "%FibsLoginName%" == ""
@    echo "\r** Please login manually.\r\n** The connect script will resume after login is complete\r\nlogin: "
@else 
@  if "%FibsPassword%" == ""
@    echo "\r** Please enter your password manually.\r\n** The connect script will resume after login is complete\r\nlogin: "
@  endif
@endif


@:Login

@if "%FibsLoginName%" != ""
@   send "%FibsLoginName%\r"
@else 
@endif


@rem If we get a cmd prompt before a password prompt, then we must be doing a 
@rem guest login!

@branch "Waiting for \"password: \""   "password: " Password "login: " Login "\n>" DoGuestLogin


@:Password
@if "%FibsPassword%" != ""
@   send "%FibsPassword%\r"
@else 
@endif

@branch "Waiting for command prompt" "login: " Login "authenticated." DoAuthenticated "\n>" DoNormalLogin

@:DoGuestLogin

@rem Must wait for registration before issuing the init commands, because
@rem normal commands don't work until registration is complete!
@  branch "" "\nYou are registered." 

@:DoAuthenticated
@wait "\n>"

@:DoNormalLogin
<initfibs.scr

