Commit | Line | Data |
---|---|---|
494a7a96 | 1 | /* |
161423a6 RE |
2 | * Copyright (c) 1980 Regents of the University of California. |
3 | * All rights reserved. The Berkeley software License Agreement | |
4 | * specifies the terms and conditions for redistribution. | |
494a7a96 | 5 | * |
95f51977 | 6 | * @(#)putc_.c 5.1 6/7/85 |
161423a6 RE |
7 | */ |
8 | ||
9 | /* | |
494a7a96 DW |
10 | * write a character to the standard output |
11 | * | |
12 | * calling sequence: | |
13 | * integer putc | |
14 | * ierror = putc (char) | |
15 | * where: | |
16 | * char will be sent to the standard output, usually the terminal | |
17 | * ierror will be 0 if successful; a system error code otherwise. | |
18 | */ | |
19 | ||
20 | #include "../libI77/f_errno.h" | |
21 | #include "../libI77/fiodefs.h" | |
22 | ||
23 | extern unit units[]; /* logical units table from iolib */ | |
24 | ||
25 | long putc_(c, clen) | |
26 | char *c; long clen; | |
27 | { | |
70d9135d DW |
28 | int i; |
29 | unit *lu; | |
494a7a96 | 30 | |
70d9135d DW |
31 | lu = &units[STDOUT]; |
32 | if (!lu->ufd) | |
494a7a96 | 33 | return((long)(errno=F_ERNOPEN)); |
22557c76 DW |
34 | if (!lu->uwrt && ! nowwriting(lu)) |
35 | return((long)errno); | |
70d9135d DW |
36 | putc (*c, lu->ufd); |
37 | if (ferror(lu->ufd)) | |
494a7a96 DW |
38 | { |
39 | i = errno; | |
70d9135d | 40 | clearerr(lu->ufd); |
494a7a96 DW |
41 | return((long)i); |
42 | } | |
43 | return(0L); | |
44 | } |