Commit | Line | Data |
---|---|---|
30f8fdec | 1 | /* |
22557c76 | 2 | char id_fputc[] = @(#)fputc_.c 1.4"; |
30f8fdec DW |
3 | * |
4 | * write a character to a logical unit bypassing formatted I/O | |
5 | * | |
6 | * calling sequence: | |
7 | * integer fputc | |
8 | * ierror = fputc (unit, char) | |
9 | * where: | |
10 | * char will be sent to the 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 fputc_(u, c, clen) | |
20 | long *u; char *c; long clen; | |
21 | { | |
70d9135d DW |
22 | int i; |
23 | unit *lu; | |
30f8fdec DW |
24 | |
25 | if (*u < 0 || *u >= MXUNIT) | |
abb67f25 | 26 | return((long)(errno=F_ERUNIT)); |
70d9135d DW |
27 | lu = &units[*u]; |
28 | if (!lu->ufd) | |
30f8fdec | 29 | return((long)(errno=F_ERNOPEN)); |
22557c76 DW |
30 | if (!lu->uwrt && ! nowwriting(lu)) |
31 | return((long)errno); | |
70d9135d DW |
32 | putc (*c, lu->ufd); |
33 | if (ferror(lu->ufd)) | |
30f8fdec DW |
34 | { |
35 | i = errno; | |
70d9135d | 36 | clearerr(lu->ufd); |
30f8fdec DW |
37 | return((long)i); |
38 | } | |
39 | return(0L); | |
40 | } |