12410Sdlw /* 2*23012Skre * Copyright (c) 1980 Regents of the University of California. 3*23012Skre * All rights reserved. The Berkeley software License Agreement 4*23012Skre * specifies the terms and conditions for redistribution. 52410Sdlw * 6*23012Skre * @(#)fgetc_.c 5.1 06/07/85 7*23012Skre */ 8*23012Skre 9*23012Skre /* 102410Sdlw * get a character from a logical unit bypassing formatted I/O 112410Sdlw * 122410Sdlw * calling sequence: 132410Sdlw * integer fgetc 142410Sdlw * ierror = fgetc (unit, char) 152410Sdlw * where: 162410Sdlw * char will return a character from logical unit 172410Sdlw * ierror will be 0 if successful; a system error code otherwise. 182410Sdlw */ 192410Sdlw 202410Sdlw #include "../libI77/fiodefs.h" 212410Sdlw #include "../libI77/f_errno.h" 222410Sdlw 232410Sdlw extern unit units[]; /* logical units table from iolib */ 242410Sdlw 252410Sdlw long fgetc_(u, c, clen) 262410Sdlw long *u; char *c; long clen; 272410Sdlw { 283895Sdlw int i; 293895Sdlw unit *lu; 302410Sdlw 312410Sdlw if (*u < 0 || *u >= MXUNIT) 322576Sdlw return((long)(errno=F_ERUNIT)); 333895Sdlw lu = &units[*u]; 343895Sdlw if (!lu->ufd) 352410Sdlw return((long)(errno=F_ERNOPEN)); 364110Sdlw if (lu->uwrt && ! nowreading(lu)) 374110Sdlw return((long)errno); 383895Sdlw if ((i = getc (lu->ufd)) < 0) 392410Sdlw { 403895Sdlw if (feof(lu->ufd)) 412410Sdlw return(-1L); 422410Sdlw i = errno; 433895Sdlw clearerr(lu->ufd); 442410Sdlw return((long)i); 452410Sdlw } 4618452Sralph *c = i; 472410Sdlw return(0L); 482410Sdlw } 49