xref: /csrg-svn/usr.bin/f77/libU77/isatty_.c (revision 4050)
1*4050Sdlw /*
2*4050Sdlw char id_isatty[] = "@(#)isatty_.c	1.1";
3*4050Sdlw  *
4*4050Sdlw  * determine if stream is associated with a tty (async port)
5*4050Sdlw  *
6*4050Sdlw  * calling sequence:
7*4050Sdlw  *	logical	isatty, val
8*4050Sdlw  *	val = isatty (lunit)
9*4050Sdlw  * where:
10*4050Sdlw  *	val will be .TRUE. if lunit is associated with a 'tty'
11*4050Sdlw  */
12*4050Sdlw 
13*4050Sdlw #include	"../libI77/fiodefs.h"
14*4050Sdlw 
15*4050Sdlw extern unit units[];	/* logical units table from iolib */
16*4050Sdlw 
17*4050Sdlw long isatty_(u)
18*4050Sdlw long *u;
19*4050Sdlw {
20*4050Sdlw 	int	i;
21*4050Sdlw 	unit	*lu;
22*4050Sdlw 
23*4050Sdlw 	if (*u < 0 || *u >= MXUNIT)
24*4050Sdlw 		return(0);
25*4050Sdlw 	lu = &units[*u];
26*4050Sdlw 	if (!lu->ufd)
27*4050Sdlw 		return(0);
28*4050Sdlw 	return((long)(isatty(fileno(lu->ufd)) != 0));
29*4050Sdlw }
30