1: /* $Header: getXNSpass.c,v 2.0 85/11/21 07:22:25 jqj Exp $ */
   2: /*
   3:  * contains: getXNSpass
   4:  * based on the standard library routine getpass(), it is modified
   5:  * for XNS passwords, which may be of almost arbitrary length
   6:  */
   7: 
   8: /* $Log:	getXNSpass.c,v $
   9:  * Revision 2.0  85/11/21  07:22:25  jqj
  10:  * 4.3BSD standard release
  11:  *
  12:  * Revision 1.1  85/03/26  06:29:09  jqj
  13:  * Initial revision
  14:  *
  15:  * Revision 1.1  85/03/26  06:29:09  jqj
  16:  * Initial revision
  17:  *
  18:  */
  19: 
  20: /* @(#)getpass.c	4.3 (Berkeley) 5/16/84 */
  21: #include <stdio.h>
  22: #include <signal.h>
  23: #include <sgtty.h>
  24: #define PASSLEN 80
  25: 
  26: char *
  27: getXNSpass(prompt)
  28: char *prompt;
  29: {
  30:     struct sgttyb ttyb;
  31:     int flags;
  32:     register char *p;
  33:     register c;
  34:     FILE *fi;
  35:     static char pbuf[PASSLEN+1];
  36:     int (*signal())();
  37:     int (*sig)();
  38: 
  39:     if ((fi = fdopen(open("/dev/tty", 2), "r")) == NULL)
  40:         fi = stdin;
  41:     else
  42:         setbuf(fi, (char *)NULL);
  43:     sig = signal(SIGINT, SIG_IGN);
  44:     ioctl(fileno(fi), TIOCGETP, &ttyb);
  45:     flags = ttyb.sg_flags;
  46:     ttyb.sg_flags &= ~ECHO;
  47:     ioctl(fileno(fi), TIOCSETP, &ttyb);
  48:     fprintf(stderr, "%s", prompt); fflush(stderr);
  49:     for (p=pbuf; (c = getc(fi))!='\n' && c!=EOF;) {
  50:         if (p < &pbuf[PASSLEN])
  51:             *p++ = c;
  52:     }
  53:     *p = '\0';
  54:     fprintf(stderr, "\n"); fflush(stderr);
  55:     ttyb.sg_flags = flags;
  56:     ioctl(fileno(fi), TIOCSETP, &ttyb);
  57:     signal(SIGINT, sig);
  58:     if (fi != stdin)
  59:         fclose(fi);
  60:     return(pbuf);
  61: }

Defined functions

getXNSpass defined in line 26; never used

Defined macros

PASSLEN defined in line 24; used 2 times
Last modified: 1986-03-13
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 938
Valid CSS Valid XHTML 1.0 Strict