Signed-off-by: Pierre Habouzit <madcoder@debian.org>
* Copyright © 2006-2007 Pierre Habouzit
*/
+#include <errno.h>
#include <stdio.h>
#include <unistd.h>
buffer_extend(buf, res);
return res;
}
+
+ssize_t buffer_write(buffer_t *buf, int fd)
+{
+ ssize_t res = write(fd, buf->data, buf->len);
+ if (res < 0) {
+ return errno == EINTR || errno == EAGAIN ? 0 : -1;
+ }
+ buffer_consume(buf, res);
+ return res;
+}
void buffer_consume(buffer_t *buf, ssize_t len);
ssize_t buffer_read(buffer_t *buf, int fd, ssize_t count);
+ssize_t buffer_write(buffer_t *buf, int fd);
#endif /* PFIXTOOLS_BUFFER_H */