1: /* 2: char id_fgetc[] = "@(#)fgetc_.c 1.4"; 3: * 4: * get a character from a logical unit bypassing formatted I/O 5: * 6: * calling sequence: 7: * integer fgetc 8: * ierror = fgetc (unit, char) 9: * where: 10: * char will return a character from logical unit 11: * ierror will be 0 if successful; a system error code otherwise. 12: */ 13: 14: #include "../libI77/fiodefs.h" 15: 16: extern unit units[]; /* logical units table from iolib */ 17: 18: ftnint fgetc_(u, c, clen) 19: ftnint *u; char *c; ftnlen clen; 20: { 21: int i; 22: unit *lu; 23: 24: if (*u < 0 || *u >= MXUNIT) 25: return((ftnint)(errno=F_ERUNIT)); 26: lu = &units[*u]; 27: if (!lu->ufd) 28: return((ftnint)(errno=F_ERNOPEN)); 29: if (lu->uwrt && ! nowreading(lu)) 30: return((ftnint)errno); 31: if ((i = getc (lu->ufd)) < 0) 32: { 33: if (feof(lu->ufd)) 34: return((ftnint) -1); 35: i = errno; 36: clearerr(lu->ufd); 37: return((ftnint)i); 38: } 39: *c = i & 0177; 40: return((ftnint) 0); 41: }