xref: /csrg-svn/usr.bin/f77/libU77/isatty_.c (revision 47944)
1*47944Sbostic /*-
2*47944Sbostic  * Copyright (c) 1980 The Regents of the University of California.
3*47944Sbostic  * All rights reserved.
44050Sdlw  *
5*47944Sbostic  * %sccs.include.proprietary.c%
623032Skre  */
723032Skre 
8*47944Sbostic #ifndef lint
9*47944Sbostic static char sccsid[] = "@(#)isatty_.c	5.2 (Berkeley) 04/12/91";
10*47944Sbostic #endif /* not lint */
11*47944Sbostic 
1223032Skre /*
134050Sdlw  * determine if stream is associated with a tty (async port)
144050Sdlw  *
154050Sdlw  * calling sequence:
164050Sdlw  *	logical	isatty, val
174050Sdlw  *	val = isatty (lunit)
184050Sdlw  * where:
194050Sdlw  *	val will be .TRUE. if lunit is associated with a 'tty'
204050Sdlw  */
214050Sdlw 
224050Sdlw #include	"../libI77/fiodefs.h"
234050Sdlw 
244050Sdlw extern unit units[];	/* logical units table from iolib */
254050Sdlw 
isatty_(u)264050Sdlw long isatty_(u)
274050Sdlw long *u;
284050Sdlw {
294050Sdlw 	int	i;
304050Sdlw 	unit	*lu;
314050Sdlw 
324050Sdlw 	if (*u < 0 || *u >= MXUNIT)
334050Sdlw 		return(0);
344050Sdlw 	lu = &units[*u];
354050Sdlw 	if (!lu->ufd)
364050Sdlw 		return(0);
374050Sdlw 	return((long)(isatty(fileno(lu->ufd)) != 0));
384050Sdlw }
39