12409Sdlw /* 2*23014Skre * Copyright (c) 1980 Regents of the University of California. 3*23014Skre * All rights reserved. The Berkeley software License Agreement 4*23014Skre * specifies the terms and conditions for redistribution. 52409Sdlw * 6*23014Skre * @(#)fputc_.c 5.1 06/07/85 7*23014Skre */ 8*23014Skre 9*23014Skre /* 102409Sdlw * write a character to a logical unit bypassing formatted I/O 112409Sdlw * 122409Sdlw * calling sequence: 132409Sdlw * integer fputc 142409Sdlw * ierror = fputc (unit, char) 152409Sdlw * where: 162409Sdlw * char will be sent to the logical unit 172409Sdlw * ierror will be 0 if successful; a system error code otherwise. 182409Sdlw */ 192409Sdlw 202409Sdlw #include "../libI77/fiodefs.h" 212409Sdlw #include "../libI77/f_errno.h" 222409Sdlw 232409Sdlw extern unit units[]; /* logical units table from iolib */ 242409Sdlw 252409Sdlw long fputc_(u, c, clen) 262409Sdlw long *u; char *c; long clen; 272409Sdlw { 283893Sdlw int i; 293893Sdlw unit *lu; 302409Sdlw 312409Sdlw if (*u < 0 || *u >= MXUNIT) 322577Sdlw return((long)(errno=F_ERUNIT)); 333893Sdlw lu = &units[*u]; 343893Sdlw if (!lu->ufd) 352409Sdlw return((long)(errno=F_ERNOPEN)); 364112Sdlw if (!lu->uwrt && ! nowwriting(lu)) 374112Sdlw return((long)errno); 383893Sdlw putc (*c, lu->ufd); 393893Sdlw if (ferror(lu->ufd)) 402409Sdlw { 412409Sdlw i = errno; 423893Sdlw clearerr(lu->ufd); 432409Sdlw return((long)i); 442409Sdlw } 452409Sdlw return(0L); 462409Sdlw } 47