summaryrefslogtreecommitdiff
path: root/src/libstddjb/iobuffer_init.c
blob: fc699a0ff01031de9bb84cc160675fbf0e8dc8c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* ISC license. */

#include <skalibs/iobuffer.h>

int iobuffer_init (iobuffer *b, int fdin, int fdout)
{
  if (!iobufferk_init(&b->x.k, fdin, fdout)) goto user ;
  if (!iobufferk_isworking(&b->x.k)) goto fk ;
  b->isk = 1 ;
  return 1 ;
 fk:
  iobufferk_finish(&b->x.k) ;
 user:
  if (!iobufferu_init(&b->x.u, fdin, fdout)) return 0 ;
  b->isk = 0 ;
  return 1 ;
}