blob: 45d81d8de7f168049fe203c842f5ed2454b8ca6c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
/* ISC license. */
#include <sys/types.h>
#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 ;
}
}
|