Commit | Line | Data |
---|---|---|
30723849 DW |
1 | /* |
2 | char id_getc[] = "@(#)getc_.c 1.1"; | |
3 | * | |
4 | * get a character from the standard input | |
5 | * | |
6 | * calling sequence: | |
7 | * integer getc | |
8 | * ierror = getc (char) | |
9 | * where: | |
10 | * char will be read from the standard input, usually the terminal | |
11 | * ierror will be 0 if successful; a system error code otherwise. | |
12 | */ | |
13 | ||
14 | #include "../libI77/f_errno.h" | |
15 | #include "../libI77/fiodefs.h" | |
16 | ||
17 | extern unit units[]; /* logical units table from iolib */ | |
18 | ||
19 | long getc_(c, clen) | |
20 | char *c; long clen; | |
21 | { | |
22 | int i; | |
23 | ||
24 | if (!units[STDIN].ufd) | |
25 | return((long)(errno=F_ERNOPEN)); | |
26 | if ((i = getc (units[STDIN].ufd)) < 0) | |
27 | { | |
28 | if (feof(units[STDIN].ufd)) | |
29 | return(-1L); | |
30 | i = errno; | |
31 | clearerr(units[STDIN].ufd); | |
32 | return((long)i); | |
33 | } | |
34 | *c = i & 0177; | |
35 | return(0L); | |
36 | } |