1 #include "dact.h"
2 
3 #ifndef HAVE_GETPASS
4 #ifdef HAVE_UNISTD_H
5 #include <unistd.h>
6 #endif
7 #ifdef HAVE_STRING_H
8 #include <string.h>
9 #endif
10 #ifdef HAVE_STRINGS_H
11 #include <strings.h>
12 #endif
13 #ifdef HAVE_STDIO_H
14 #include <stdio.h>
15 #endif
16 
17 #include "getpass.h"
18 
getpass(const char * prompt)19 char *getpass(const char *prompt) {
20 	static char buf[127];
21 	FILE *fp=NULL;
22 
23 	fprintf(stderr, "%s", prompt);
24 	fp=fopen("/dev/tty", "w");
25 	if (fp==NULL) fp=stdin;
26 	fgets(buf, sizeof(buf), fp);
27 	while (buf[strlen(buf)-1]<' ') buf[strlen(buf)-1]='\0';
28 	if (fp!=stdin) fclose(fp);
29 	return(buf);
30 }
31 #endif
32