From b3d095e6d37ebf1efc5df299fa80d4c71da765ee Mon Sep 17 00:00:00 2001 From: NicJA Date: Sun, 30 Apr 2017 00:57:48 +0000 Subject: [PATCH] implement a "basic" getpass git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@54621 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- compiler/posixc/getpass.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/compiler/posixc/getpass.c b/compiler/posixc/getpass.c index b6af8c81b0..60ef1fd60e 100644 --- a/compiler/posixc/getpass.c +++ b/compiler/posixc/getpass.c @@ -5,12 +5,11 @@ #include -#include #include -#include +#include +#include -#include "__vfork.h" #include "__posixc_intbase.h" /***************************************************************************** @@ -47,7 +46,26 @@ ******************************************************************************/ { - struct PosixCIntBase *PosixCIntBase = (struct PosixCIntBase *)__aros_getbase_PosixCBase(); - - return PosixCIntBase->passbuffer; + struct PosixCBase *PosixCBase = __aros_getbase_PosixCBase(); + struct PosixCIntBase *PosixCIntBase = (struct PosixCIntBase *)PosixCBase; + char *s; + + /* quick and ugly... */ + if ((prompt) && + ((fputs(prompt, PosixCBase->_stdout) != EOF) && + (fputs("\n", PosixCBase->_stdout) != EOF))) + { + fflush(PosixCBase->_stdout); + } + s = fgets(PosixCIntBase->passbuffer, PASS_MAX, PosixCBase->_stdin); + if (s) + { + /* strip trailing \n */ + size_t sl = strlen(s); + if ( (sl > 0) && (s[sl-1] == '\n') ) + { + s[sl-1] = '\0'; + } + } + return s; } -- 2.11.4.GIT