xref: /original-bsd/usr.bin/f77/libU77/putc_.c (revision fbed46ce)
1 /*
2 char id_putc[] = "@(#)putc_.c	1.3";
3  *
4  * write a character to the standard output
5  *
6  * calling sequence:
7  *	integer putc
8  *	ierror =  putc (char)
9  * where:
10  *	char will be sent to the standard output, usually the terminal
11  *	ierror will be 0 if successful; a system error code otherwise.
12  */
13 
14 #include	"../libI77/f_errno.h"
15 #include	"../libI77/fiodefs.h"
16 
17 extern unit units[];	/* logical units table from iolib */
18 
19 long putc_(c, clen)
20 char *c; long clen;
21 {
22 	int	i;
23 	unit	*lu;
24 
25 	lu = &units[STDOUT];
26 	if (!lu->ufd)
27 		return((long)(errno=F_ERNOPEN));
28 	if (!lu->uwrt && ! nowwriting(lu))
29 		return((long)errno);
30 	putc (*c, lu->ufd);
31 	if (ferror(lu->ufd))
32 	{
33 		i = errno;
34 		clearerr(lu->ufd);
35 		return((long)i);
36 	}
37 	return(0L);
38 }
39