skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

skagetln.c (421B)


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