home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mntlib25.zoo / getpass.c < prev    next >
C/C++ Source or Header  |  1992-09-17  |  524b  |  29 lines

  1. #include <ioctl.h>
  2. #include <stdio.h>
  3. #include <unistd.h>
  4. #include <string.h>
  5.  
  6. char *
  7. getpass(prompt)
  8.     const char *prompt;
  9. {
  10.     static char buf[81];
  11.         char *ret;
  12.     struct sgttyb oldsb, newsb;
  13.  
  14.     fflush(stdin);
  15.     gtty(0, &oldsb);
  16.     newsb = oldsb;
  17.     newsb.sg_flags &= ~ECHO;
  18.     stty(0, &newsb);
  19.     fputs(prompt, stderr); fflush(stderr);
  20.     buf[0] = buf[81] = 0;
  21.     if((ret = fgets(buf, 80, stdin)) != 0)
  22.     {
  23.         /* null terminate string */
  24.         buf[strlen(buf) - 1] = 0;
  25.     }
  26.     stty(0, &oldsb);
  27.     return ret;
  28. }
  29.