int get_username_and_password(char ** username, int * username_length, char ** password, int * password_length) { fputs("login: "******"passwd: ",stdout); setupTerminal(); unsigned int password_position = 0; unsigned int saw_EOL = 0; unsigned int read_password = 0; while (!read_password) { char hidden_character; hidden_character = getchar(); if (hidden_character == '\b' || (int) hidden_character == 127) { if (password_position > 0) { puts("\b \b"); password_position--; } } else if (hidden_character == '\n' || hidden_character == '\r') { saw_EOL = 1; puts("\n"); read_password = 1; } else if (hidden_character != 0) { (*password)[password_position] = hidden_character; password_position++; } if (*password_length <= password_position) { read_password = 1; } } if (!saw_EOL) { exit(1); } (*password)[password_position] = '\0'; resetTerminal(); return 0; }
void run_the_VM() { assert(! bootstrapping, "don't get screwed again by this"); Memory->scavenge(); SignalInterface::initialize(); initHProfiler(); IntervalTimer::start_all(); ResourceMark mark; InteractiveScanner scanner; VMScanner = &scanner; resetTerminal(); if (startUpSelfFile) { ResourceMark m; FileScanner scnr(startUpSelfFile); if (scnr.fileError) { fatalNoMenu1("Couldn't read file %s!\n\n", startUpSelfFile); } else { lprintf("Reading %s...", scnr.fileName()); (void) evalExpressions(&scnr); lprintf("done\n"); } } // After reading a snapshot we need to evaluate the snapshot actions. if (postReadSnapshot) { postReadSnapshot = false; eval("snapshotAction postRead", "<postRead Snapshot>"); } // The read-eval-print loop for (;;) { ResourceMark m; fint line, len; const char* source = NULL; Parser parser(VMScanner, false); resetTerminal(); VMScanner->start_line("VM# "); processes->idle = true; if (VMScanner->is_done()) break; processes->idle = false; Expr* e = parser.readExpr(line, source, len); // dont fail if (e) { preservedObj x(e); oop res = e->Eval(true, false, true); assert(currentProcess->isClean(), "vm process should be clean now"); if (res == badOop) { VMScanner->reset(); clearerr(stdin); // don't get hung on ^D } } if (Memory->needs_scavenge()) Memory->scavenge(); } lprintf("\n"); # if TARGET_IS_PROFILED lprintf("Writing profile statistics...\n"); # endif clearerr(stdin); OS::handle_suspend_and_resume(true); // make sure stdin is in normal mode OS::terminate(0); }