From c62d9852a19f6a93ac2c5eaffa823d44b2ef256a Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sat, 18 May 2013 21:47:51 +0800 Subject: [PATCH] Usermode/init,login - Updated to new PTY code --- Usermode/Applications/init_src/main.c | 2 +- Usermode/Applications/login_src/main.c | 25 ++++++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Usermode/Applications/init_src/main.c b/Usermode/Applications/init_src/main.c index 1cdf98b6..b3740f3e 100644 --- a/Usermode/Applications/init_src/main.c +++ b/Usermode/Applications/init_src/main.c @@ -426,7 +426,7 @@ int SpawnCommand(int c_stdin, int c_stdout, int c_stderr, char **ArgV) int SpawnKTerm(tInitProgram *Program) { - const char fmt[] = "/Devices/VTerm/%i"; + const char fmt[] = "/Devices/pts/vt%ic"; char path[sizeof(fmt)]; snprintf(path, sizeof(path), fmt, Program->TypeInfo.KTerm.ID); diff --git a/Usermode/Applications/login_src/main.c b/Usermode/Applications/login_src/main.c index bc9013d4..e151ff94 100644 --- a/Usermode/Applications/login_src/main.c +++ b/Usermode/Applications/login_src/main.c @@ -1,7 +1,9 @@ /* * Acess 2 Login + * - By John Hodge (thePowersGang) */ #include "header.h" +#include // Enable/disable echo // === CONSTANTS === #define BUFLEN 1024 @@ -70,6 +72,16 @@ char *_GetString(int bEcho) int pos = 0; char ch; + struct ptymode mode; + const int is_pty = (_SysIOCtl(0, DRV_IOCTL_TYPE, NULL) == DRV_TYPE_TERMINAL); + + // Clear PTY echo + if( !bEcho && is_pty ) { + _SysIOCtl(0, PTY_IOCTL_GETMODE, &mode); + mode.InputMode &= ~PTYIMODE_ECHO; + _SysIOCtl(0, PTY_IOCTL_SETMODE, &mode); + } + // Read in text while( (ch = fgetc(stdin)) != -1 && ch != '\n' ) { @@ -91,18 +103,17 @@ char *_GetString(int bEcho) else ret[pos++] = ch; - // Don't echo out to the screen - if( bEcho ) { - fputc(ch, stdout); - fflush(stdout); - } - if(pos == BUFLEN-1) break; } ret[pos] = '\0'; + + // Re-set echo + if( !bEcho && is_pty ) { + mode.InputMode |= PTYIMODE_ECHO; + _SysIOCtl(0, PTY_IOCTL_SETMODE, &mode); + } - printf("\n"); return strdup(ret); } -- 2.20.1