head 1.6; access; symbols; locks; strict; comment @ * @; 1.6 date 92.02.03.17.57.22; author jromine; state Exp; branches; next 1.5; 1.5 date 92.02.03.16.36.16; author jromine; state Exp; branches; next 1.4; 1.4 date 90.04.05.15.03.23; author sources; state Exp; branches; next 1.3; 1.3 date 90.03.12.10.24.37; author sources; state Exp; branches; next 1.2; 1.2 date 90.02.09.11.08.37; author sources; state Exp; branches; next 1.1; 1.1 date 90.02.09.11.07.39; author sources; state Exp; branches; next ; desc @@ 1.6 log @STDC/SYS5/getpw @ text @/* ttym.c - miscellaneous routines */ #ifndef lint static char ident[] = "@@(#)$Id: ttym.c,v 1.5 1992/02/03 16:36:16 jromine Exp jromine $"; #endif lint #include #ifndef NSIG #include #endif NSIG #include static int ttyf (); /* */ static ttym (fd, command, line, user, vec) int fd; char *command, *line, *user, **vec; { TYPESIG (*pstat) (); char *ap, *term, *myself, *getlogin (), *rindex (), *ttyname (); struct passwd *pw; #ifndef __STDC__ #ifdef SYS5 struct passwd *getpwuid (); #endif #endif /* !__STDC__ */ if ((term = ap = ttyname (2)) && (term = rindex (term, '/'))) term++; if (term == NULL || *term == NULL) term = ap; if ((myself = getlogin ()) == NULL || *myself == NULL) myself = (pw = getpwuid (getuid ())) ? pw -> pw_name : NULL; pstat = signal (SIGPIPE, SIG_IGN); (void) write (fd, command, strlen (command)); (void) write (fd, "", 1); if (term) (void) write (fd, term, strlen (term)); (void) write (fd, "", 1); if (myself) (void) write (fd, myself, strlen (myself)); (void) write (fd, "", 1); if (line && *line) (void) write (fd, line, strlen (line)); (void) write (fd, "", 1); if (user && *user) (void) write (fd, user, strlen (user)); (void) write (fd, "", 1); if (vec) while (ap = *vec++) { (void) write (fd, ap, strlen (ap)); (void) write (fd, "", 1); } (void) write (fd, "", 1); (void) signal (SIGPIPE, pstat); } /* */ static int ttyv (fd) int fd; { int ifds, nbits; char c; struct timeval tv; ifds = 1 << fd; nbits = getdtablesize(); tv.tv_sec = SMLWAIT; tv.tv_usec = 0; if (select (nbits, &ifds, (int *) 0, (int *) 0, &tv) <= 0 || read (fd, &c, 1) != 1) return NOTOK; if (c == NULL) return fd; putc (c, stderr); (void) ttyf (fd, stderr); return NOTOK; } static int ttyf (fd, f) int fd; FILE * f; { int i; char buffer[BUFSIZ]; while ((i = read (fd, buffer, sizeof buffer)) > 0) (void) fwrite (buffer, sizeof (char), i, f); return i; } @ 1.5 log @fix @ text @d3 1 a3 1 static char ident[] = "@@(#)$Id: ttym.c,v 1.4 1990/04/05 15:03:23 sources Exp jromine $"; d32 1 d34 1 @ 1.4 log @add ID @ text @d3 1 a3 1 static char ident[] = "@@(#)$Id:$"; d30 4 a33 2 struct passwd *pw, *getpwuid (); @ 1.3 log @TYPESIG fixup @ text @d2 3 @ 1.2 log @ANSI compilance @ text @d20 1 a20 1 int (*pstat) (); @ 1.1 log @Initial revision @ text @d9 2 @