home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / security / login_1 / c / get next >
Text File  |  1995-08-29  |  515b  |  35 lines

  1. /* vi:tabstop=4:shiftwidth=4:smartindent
  2.  *
  3.  * get.c - Obtains a line from the input, with or without
  4.  *         echoing. char *line should point to a 1K buffer.
  5.  *
  6.  */
  7. #include <stdio.h>
  8. #include <unistd.h>
  9.  
  10. void get(char *prompt, char *line, int echo)
  11. {
  12.     if (feof(stdin))
  13.     {
  14.         putchar('\n');
  15.         freopen("/dev/tty", "r", stdin);
  16.     }
  17.  
  18.     printf("%s", prompt);
  19.     fflush(stdout);
  20.  
  21.     if (!echo)
  22.     {
  23.         os_vdu(21);
  24.     }
  25.  
  26.     fgets(line, 1024, stdin);
  27.     line[strlen(line)-1] = '\0';
  28.  
  29.     if (!echo)
  30.     {
  31.         os_vdu(6);
  32.         putchar('\n');
  33.     }
  34. }
  35.