1 /*- 2 * Copyright (c) 1980 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.proprietary.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)fputc_.c 5.2 (Berkeley) 04/12/91"; 10 #endif /* not lint */ 11 12 /* 13 * write a character to a logical unit bypassing formatted I/O 14 * 15 * calling sequence: 16 * integer fputc 17 * ierror = fputc (unit, char) 18 * where: 19 * char will be sent to the logical unit 20 * ierror will be 0 if successful; a system error code otherwise. 21 */ 22 23 #include "../libI77/fiodefs.h" 24 #include "../libI77/f_errno.h" 25 26 extern unit units[]; /* logical units table from iolib */ 27 28 long fputc_(u, c, clen) 29 long *u; char *c; long clen; 30 { 31 int i; 32 unit *lu; 33 34 if (*u < 0 || *u >= MXUNIT) 35 return((long)(errno=F_ERUNIT)); 36 lu = &units[*u]; 37 if (!lu->ufd) 38 return((long)(errno=F_ERNOPEN)); 39 if (!lu->uwrt && ! nowwriting(lu)) 40 return((long)errno); 41 putc (*c, lu->ufd); 42 if (ferror(lu->ufd)) 43 { 44 i = errno; 45 clearerr(lu->ufd); 46 return((long)i); 47 } 48 return(0L); 49 } 50