| 3201 | } |
| 3202 | |
| 3203 | static int stdio_stream_write_init(FILE *stream) |
| 3204 | { |
| 3205 | if (!(stream->flags & STDIO_FLAG_WRITE) || |
| 3206 | (stream->flags & STDIO_FLAG_ERROR)) |
| 3207 | { |
| 3208 | errno = EINVAL; |
| 3209 | return EOF; |
| 3210 | } |
| 3211 | if (stream->flags & STDIO_FLAG_READING) |
| 3212 | fflush_unlocked(stream); |
| 3213 | stream->flags |= STDIO_FLAG_WRITING; |
| 3214 | if (!(stream->flags & STDIO_FLAG_INITED) && |
| 3215 | stdio_stream_buf_init(stream) < 0) |
| 3216 | return EOF; |
| 3217 | if (stream->write_ptr >= stream->write_end && |
| 3218 | stdio_stream_write(stream) < 0) |
| 3219 | return EOF; |
| 3220 | return 0; |
| 3221 | } |
| 3222 | |
| 3223 | static void stdio_stream_free(FILE *stream) |
| 3224 | { |
no test coverage detected