another possibility would be to use an asynchronous check of the 'Serial' object, something like:
static char buffer; /* make it bigger if you need it bigger */
static int bufpos = 0;
char c1 = Serial.read();
if(c1 == '\n') // newline?
process_command_string(buffer); // process my command
else if(c1 != '\r' && bufpos < sizeof(buffer) - 1) // buffer length check, ignore return
buffer[bufpos++] = c1;
buffer[bufpos] = 0;
... /* other processing here */
The 'process_command_string()' function would then interpret whatever command string was typed in, including a response to a 'login' prompt. It would be done asynchronously, so you don't have to block to read anything. Then you would use state variables (similar to what was described in the last post) to control what 'loop' does, whether it idles or performs a specific function based on the 'login' or 'not logged in' state.
unrelated - an obligatory 'Use ALLMAN style it's more readable than K&R' jibe, heh heh heh
/ me regularly modifies preferences.txt to have these two lines:
then you don't need to compress things vertically any more using 'K&R' style. You can add more vertical white space (like ALLMAN style) to make the code more readable.