xref: /csrg-svn/usr.bin/f77/libU77/putc_.c (revision 3894)
12408Sdlw /*
2*3894Sdlw char id_putc[] = "@(#)putc_.c	1.2";
32408Sdlw  *
42408Sdlw  * write a character to the standard output
52408Sdlw  *
62408Sdlw  * calling sequence:
72408Sdlw  *	integer putc
82408Sdlw  *	ierror =  putc (char)
92408Sdlw  * where:
102408Sdlw  *	char will be sent to the standard output, usually the terminal
112408Sdlw  *	ierror will be 0 if successful; a system error code otherwise.
122408Sdlw  */
132408Sdlw 
142408Sdlw #include	"../libI77/f_errno.h"
152408Sdlw #include	"../libI77/fiodefs.h"
162408Sdlw 
172408Sdlw extern unit units[];	/* logical units table from iolib */
182408Sdlw 
192408Sdlw long putc_(c, clen)
202408Sdlw char *c; long clen;
212408Sdlw {
22*3894Sdlw 	int	i;
23*3894Sdlw 	unit	*lu;
242408Sdlw 
25*3894Sdlw 	lu = &units[STDOUT];
26*3894Sdlw 	if (!lu->ufd)
272408Sdlw 		return((long)(errno=F_ERNOPEN));
28*3894Sdlw 	if (!lu->uwrt)
29*3894Sdlw 		nowwriting(lu);
30*3894Sdlw 	putc (*c, lu->ufd);
31*3894Sdlw 	if (ferror(lu->ufd))
322408Sdlw 	{
332408Sdlw 		i = errno;
34*3894Sdlw 		clearerr(lu->ufd);
352408Sdlw 		return((long)i);
362408Sdlw 	}
372408Sdlw 	return(0L);
382408Sdlw }
39