#include #include #include #include char * getpass(prompt) const char *prompt; { static char buf[81]; char *ret; struct sgttyb oldsb, newsb; fflush(stdin); gtty(0, &oldsb); newsb = oldsb; newsb.sg_flags &= ~ECHO; stty(0, &newsb); fputs(prompt, stderr); fflush(stderr); buf[0] = buf[81] = 0; if((ret = fgets(buf, 80, stdin)) != 0) { /* null terminate string */ buf[strlen(buf) - 1] = 0; } stty(0, &oldsb); return ret; }