summaryrefslogtreecommitdiff
path: root/lib/libc/stdio/setvbuf.c
diff options
context:
space:
mode:
authorKacper <kacper@mail.openlinux.dev>2025-12-07 20:10:31 +0100
committerKacper <kacper@mail.openlinux.dev>2025-12-07 20:10:31 +0100
commitfc00c656c96528112d05cf0edf8631bd5eaea446 (patch)
treea6e0e6c588191a8bd1c64afc3b7a258e3e66c236 /lib/libc/stdio/setvbuf.c
Add build system scaffolding and libc headers
Diffstat (limited to 'lib/libc/stdio/setvbuf.c')
-rw-r--r--lib/libc/stdio/setvbuf.c20
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;
+}