| 3180 | } |
| 3181 | |
| 3182 | static int stdio_stream_read_init(FILE *stream) |
| 3183 | { |
| 3184 | if (!(stream->flags & STDIO_FLAG_READ) || |
| 3185 | (stream->flags & STDIO_FLAG_ERROR) || |
| 3186 | (stream->flags & STDIO_FLAG_EOF)) |
| 3187 | { |
| 3188 | errno = EINVAL; |
| 3189 | return EOF; |
| 3190 | } |
| 3191 | if (stream->flags & STDIO_FLAG_WRITING) |
| 3192 | fflush_unlocked(stream); |
| 3193 | stream->flags |= STDIO_FLAG_READING; |
| 3194 | if (!(stream->flags & STDIO_FLAG_INITED) && |
| 3195 | stdio_stream_buf_init(stream) < 0) |
| 3196 | return EOF; |
| 3197 | if (stream->read_ptr >= stream->read_end && |
| 3198 | stdio_stream_read(stream) < 0) |
| 3199 | return EOF; |
| 3200 | return 0; |
| 3201 | } |
| 3202 | |
| 3203 | static int stdio_stream_write_init(FILE *stream) |
| 3204 | { |
no test coverage detected