From 9bc8a11afeed3569736b89754012e3ca22ee10f6 Mon Sep 17 00:00:00 2001 From: pommicket Date: Sun, 20 Feb 2022 13:18:21 -0800 Subject: conclusion --- 05/musl-0.6.0/src/stdio/setvbuf.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 05/musl-0.6.0/src/stdio/setvbuf.c (limited to '05/musl-0.6.0/src/stdio/setvbuf.c') diff --git a/05/musl-0.6.0/src/stdio/setvbuf.c b/05/musl-0.6.0/src/stdio/setvbuf.c new file mode 100644 index 0000000..2985d3f --- /dev/null +++ b/05/musl-0.6.0/src/stdio/setvbuf.c @@ -0,0 +1,22 @@ +#include "stdio_impl.h" + +/* This function makes no attempt to protect the user from his/her own + * stupidity. If called any time but when then ISO C standard specifically + * allows it, all hell can and will break loose, especially with threads! + * + * This implementation ignores all arguments except the buffering type, + * and uses the existing buffer allocated alongside the FILE object. + * In the case of stderr where the preexisting buffer is length 1, it + * is not possible to set line buffering or full buffering. */ + +int setvbuf(FILE *f, char *buf, int type, size_t size) +{ + f->lbf = EOF; + + if (type == _IONBF) + f->buf_size = 1; + else if (type == _IOLBF) + f->lbf = '\n'; + + return 0; +} -- cgit v1.2.3