Rev 3386 | Rev 4327 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3386 | Rev 4263 | ||
---|---|---|---|
Line 34... | Line 34... | ||
34 | 34 | ||
35 | #include <libc.h> |
35 | #include <libc.h> |
36 | #include <unistd.h> |
36 | #include <unistd.h> |
37 | #include <stdio.h> |
37 | #include <stdio.h> |
38 | #include <io/io.h> |
38 | #include <io/io.h> |
- | 39 | #include <string.h> |
|
- | 40 | #include <errno.h> |
|
39 | 41 | ||
40 | const static char nl = '\n'; |
42 | const static char nl = '\n'; |
41 | 43 | ||
42 | int puts(const char *str) |
44 | int puts(const char *str) |
43 | { |
45 | { |
Line 85... | Line 87... | ||
85 | return EOF; |
87 | return EOF; |
86 | } |
88 | } |
87 | 89 | ||
88 | int putchar(int c) |
90 | int putchar(int c) |
89 | { |
91 | { |
- | 92 | char buf[STR_BOUNDS(1)]; |
|
90 | unsigned char ch = c; |
93 | size_t offs; |
- | 94 | ||
- | 95 | offs = 0; |
|
- | 96 | if (chr_encode(c, buf, &offs, STR_BOUNDS(1)) != EOK) |
|
- | 97 | return EOF; |
|
- | 98 | ||
91 | if (write_stdout((void *) &ch, 1) == 1) |
99 | if (write_stdout((void *) buf, offs) == offs) |
92 | return c; |
100 | return c; |
93 | 101 | ||
94 | return EOF; |
102 | return EOF; |
95 | } |
103 | } |
96 | 104 | ||
97 | int getchar(void) |
105 | int getchar(void) |
98 | { |
106 | { |
99 | unsigned char c; |
107 | unsigned char c; |
- | 108 | ||
- | 109 | flush_stdout(); |
|
100 | if (read_stdin((void *) &c, 1) == 1) |
110 | if (read_stdin((void *) &c, 1) == 1) |
101 | return c; |
111 | return c; |
102 | 112 | ||
103 | return EOF; |
113 | return EOF; |
104 | } |
114 | } |
105 | 115 | ||
- | 116 | int fflush(FILE *f) |
|
- | 117 | { |
|
- | 118 | (void) f; |
|
- | 119 | return flush_stdout(); |
|
- | 120 | } |
|
- | 121 | ||
106 | /** @} |
122 | /** @} |
107 | */ |
123 | */ |