Commit | Line | Data |
---|---|---|
82492b51 KB |
1 | /*- |
2 | * Copyright (c) 1980 The Regents of the University of California. | |
3 | * All rights reserved. | |
494a7a96 | 4 | * |
ad787160 C |
5 | * This module is believed to contain source code proprietary to AT&T. |
6 | * Use and redistribution is subject to the Berkeley Software License | |
7 | * Agreement and your Software Agreement with AT&T (Western Electric). | |
161423a6 RE |
8 | */ |
9 | ||
82492b51 | 10 | #ifndef lint |
ad787160 | 11 | static char sccsid[] = "@(#)putc_.c 5.2 (Berkeley) 4/12/91"; |
82492b51 KB |
12 | #endif /* not lint */ |
13 | ||
161423a6 | 14 | /* |
494a7a96 DW |
15 | * write a character to the standard output |
16 | * | |
17 | * calling sequence: | |
18 | * integer putc | |
19 | * ierror = putc (char) | |
20 | * where: | |
21 | * char will be sent to the standard output, usually the terminal | |
22 | * ierror will be 0 if successful; a system error code otherwise. | |
23 | */ | |
24 | ||
25 | #include "../libI77/f_errno.h" | |
26 | #include "../libI77/fiodefs.h" | |
27 | ||
28 | extern unit units[]; /* logical units table from iolib */ | |
29 | ||
30 | long putc_(c, clen) | |
31 | char *c; long clen; | |
32 | { | |
70d9135d DW |
33 | int i; |
34 | unit *lu; | |
494a7a96 | 35 | |
70d9135d DW |
36 | lu = &units[STDOUT]; |
37 | if (!lu->ufd) | |
494a7a96 | 38 | return((long)(errno=F_ERNOPEN)); |
22557c76 DW |
39 | if (!lu->uwrt && ! nowwriting(lu)) |
40 | return((long)errno); | |
70d9135d DW |
41 | putc (*c, lu->ufd); |
42 | if (ferror(lu->ufd)) | |
494a7a96 DW |
43 | { |
44 | i = errno; | |
70d9135d | 45 | clearerr(lu->ufd); |
494a7a96 DW |
46 | return((long)i); |
47 | } | |
48 | return(0L); | |
49 | } |