blob: 206bc542e3b1dbf6f17cd8639a10899c2ccc0eb2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
/* ISC license. */
#include <errno.h>
#include <skalibs/buffer.h>
#include <skalibs/stralloc.h>
#include <skalibs/skamisc.h>
int skagetln (buffer *b, stralloc *sa, char sep)
{
size_t start = sa->len ;
for (;;)
{
ssize_t r = skagetln_nofill(b, sa, sep) ;
if (r) return r ;
r = buffer_fill(b) ;
if (r < 0) return r ;
if (!r) return (sa->s && (sa->len > start)) ? (errno = EPIPE, -1) : 0 ;
}
}
|