diff options
Diffstat (limited to 'lib/libc/stdio/setvbuf.c')
| -rw-r--r-- | lib/libc/stdio/setvbuf.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/libc/stdio/setvbuf.c b/lib/libc/stdio/setvbuf.c new file mode 100644 index 00000000..56d7196c --- /dev/null +++ b/lib/libc/stdio/setvbuf.c @@ -0,0 +1,20 @@ +#include <io.h> +#include <stdio.h> + +int setvbuf(FILE *restrict stream, char *restrict buf, int type, size_t size) +{ + if (type != _IOFBF && type != _IOLBF && type != _IONBF) + return -1; + if (type != _IONBF && (buf == NULL || size == 0)) + return -1; + + if (stream->fd < 0) + return -1; + + stream->buf = buf; + stream->buf_size = size; + stream->buf_pos = 0; + stream->type = type; + + return 0; +} |
