diff options
Diffstat (limited to 'src/libstddjb/buffer_putall.c')
-rw-r--r-- | src/libstddjb/buffer_putall.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libstddjb/buffer_putall.c b/src/libstddjb/buffer_putall.c new file mode 100644 index 0000000..16facc2 --- /dev/null +++ b/src/libstddjb/buffer_putall.c @@ -0,0 +1,16 @@ +/* ISC license. */ + +#include <errno.h> +#include <skalibs/buffer.h> + +int buffer_putall (buffer *b, char const *s, unsigned int len, unsigned int *written) +{ + if (*written > len) return (errno = EINVAL, 0) ; + for (;;) + { + *written += buffer_putnoflush(b, s + *written, len - *written) ; + if (*written >= len) return 1 ; + buffer_flush(b) ; + if (buffer_isfull(b)) return 0 ; + } +} |