write.c
370 Bytes
#include <sys/types.h>
#include <unistd.h>
#include "cbuf.h"
ssize_t
cbufWrite(Cbuf this, int fd)
{
ssize_t wwsize = 0;
size_t wsize = this->bused;
if (0 == wsize) return 0;
wwsize = write(fd, cbufGetRead(this), wsize);
switch (wwsize) {
case -1:
break;
default:
cbufIncRead(this, wwsize);
break;
}
return wwsize;
}
// vim: set ts=4 sw=4: