Commit | Line | Data |
---|---|---|
320df512 DW |
1 | /* |
2 | char id_fgetc[] = "@(#)fgetc_.c 1.1"; | |
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 | #include "../libI77/f_errno.h" | |
16 | ||
17 | extern unit units[]; /* logical units table from iolib */ | |
18 | ||
19 | long fgetc_(u, c, clen) | |
20 | long *u; char *c; long clen; | |
21 | { | |
22 | int i; | |
23 | ||
24 | if (*u < 0 || *u >= MXUNIT) | |
25 | return((long)(errno=F_ERARG)); | |
26 | if (!units[*u].ufd) | |
27 | return((long)(errno=F_ERNOPEN)); | |
28 | if ((i = getc (units[*u].ufd)) < 0) | |
29 | { | |
30 | if (feof(units[*u].ufd)) | |
31 | return(-1L); | |
32 | i = errno; | |
33 | clearerr(units[*u].ufd); | |
34 | return((long)i); | |
35 | } | |
36 | *c = i & 0177; | |
37 | return(0L); | |
38 | } |