build fd files in the directory specified in the config.
[AROS.git] / compiler / posixc / getpass.c
blob7931232520fe244403e5d00f05fdbd3b35f16589
1 /*
2 Copyright © 2017, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <sys/types.h>
8 #include <proto/exec.h>
10 #include <limits.h>
11 #include <string.h>
13 #include "__posixc_intbase.h"
15 /*****************************************************************************
17 NAME */
18 #include <unistd.h>
20 char * getpass(
22 /* SYNOPSIS */
23 const char *prompt)
25 /* FUNCTION
26 (obsolete) prompt for a password.
28 INPUTS
30 RESULT
32 NOTES
33 This function returns a pointer to a static buffer
34 containing (the first PASS_MAX bytes of) the password without the
35 trailing newline, terminated by a null byte ('\0').
37 Function is not re-entrant. Results will be overwritten by
38 subsequent calls.
40 EXAMPLE
42 BUGS
44 SEE ALSO
46 INTERNALS
48 ******************************************************************************/
50 struct PosixCBase *PosixCBase = __aros_getbase_PosixCBase();
51 struct PosixCIntBase *PosixCIntBase = (struct PosixCIntBase *)PosixCBase;
52 char *s;
54 /* quick and ugly... */
55 if ((prompt) &&
56 ((fputs(prompt, PosixCBase->_stdout) != EOF) &&
57 (fputs("\n", PosixCBase->_stdout) != EOF)))
59 fflush(PosixCBase->_stdout);
61 s = fgets(PosixCIntBase->passbuffer, PASS_MAX, PosixCBase->_stdin);
62 if (s)
64 /* strip trailing \n */
65 size_t sl = strlen(s);
66 if ( (sl > 0) && (s[sl-1] == '\n') )
68 s[sl-1] = '\0';
71 return s;