1*47944Sbostic /*- 2*47944Sbostic * Copyright (c) 1980 The Regents of the University of California. 3*47944Sbostic * All rights reserved. 42410Sdlw * 5*47944Sbostic * %sccs.include.proprietary.c% 623012Skre */ 723012Skre 8*47944Sbostic #ifndef lint 9*47944Sbostic static char sccsid[] = "@(#)fgetc_.c 5.2 (Berkeley) 04/12/91"; 10*47944Sbostic #endif /* not lint */ 11*47944Sbostic 1223012Skre /* 132410Sdlw * get a character from a logical unit bypassing formatted I/O 142410Sdlw * 152410Sdlw * calling sequence: 162410Sdlw * integer fgetc 172410Sdlw * ierror = fgetc (unit, char) 182410Sdlw * where: 192410Sdlw * char will return a character from logical unit 202410Sdlw * ierror will be 0 if successful; a system error code otherwise. 212410Sdlw */ 222410Sdlw 232410Sdlw #include "../libI77/fiodefs.h" 242410Sdlw #include "../libI77/f_errno.h" 252410Sdlw 262410Sdlw extern unit units[]; /* logical units table from iolib */ 272410Sdlw fgetc_(u,c,clen)282410Sdlwlong fgetc_(u, c, clen) 292410Sdlw long *u; char *c; long clen; 302410Sdlw { 313895Sdlw int i; 323895Sdlw unit *lu; 332410Sdlw 342410Sdlw if (*u < 0 || *u >= MXUNIT) 352576Sdlw return((long)(errno=F_ERUNIT)); 363895Sdlw lu = &units[*u]; 373895Sdlw if (!lu->ufd) 382410Sdlw return((long)(errno=F_ERNOPEN)); 394110Sdlw if (lu->uwrt && ! nowreading(lu)) 404110Sdlw return((long)errno); 413895Sdlw if ((i = getc (lu->ufd)) < 0) 422410Sdlw { 433895Sdlw if (feof(lu->ufd)) 442410Sdlw return(-1L); 452410Sdlw i = errno; 463895Sdlw clearerr(lu->ufd); 472410Sdlw return((long)i); 482410Sdlw } 4918452Sralph *c = i; 502410Sdlw return(0L); 512410Sdlw } 52