home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / minix / libsrc~1.z / libsrc~1 / getpass.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-28  |  512 b   |  28 lines

  1. #include "lib.h"
  2. #include <stdio.h>
  3. #include <sgtty.h>
  4.  
  5. static char pwdbuf[9];
  6.  
  7. char * getpass(prompt)
  8. _CONST char *prompt;
  9. {
  10.         int i = 0, save;
  11.     struct sgttyb tty;
  12.  
  13.     prints(prompt);
  14.     fflush(stdout);
  15.     ioctl(0, TIOCGETP, &tty);
  16.     save = tty.sg_flags;
  17.     tty.sg_flags = tty.sg_flags & ~ECHO;
  18.     ioctl(0, TIOCSETP, &tty);
  19.     i = read(0, pwdbuf, 9);
  20.     while (pwdbuf[i - 1] != '\n')
  21.         read(0, &pwdbuf[i - 1], 1);
  22.     pwdbuf[i - 1] = '\0';
  23.     tty.sg_flags = save;
  24.     ioctl(0, TIOCSETP, &tty);
  25.     prints("\n");
  26.     return(pwdbuf);
  27. }
  28.