get_line.c
375 Bytes
#include <sys/types.h>
#include <string.h>
#include "cbuf.h"
char *
cbufGetLine(Cbuf this)
{
char * nl = cbufMemchr(this, '\n');
char * ret = NULL;
if (NULL != nl) {
size_t len = cbufAddrIndex(this, nl) + 1;
*nl = 0;
*(nl-1) = ('\r' == *(nl-1))? 0 : *(nl-1);
ret = cbufGetRead(this);
cbufIncRead(this, len);
}
return ret;
}
// vim: set ts=4 sw=4: