about summary refs log tree commit diff
path: root/src/libunixonacid/unixmessage_receiver_init.c
blob: 430ccac2ba2dd23ddf76f7f890ac2aaa39ef4edf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/* ISC license. */

#include <errno.h>
#include <skalibs/cbuffer.h>
#include <skalibs/stralloc.h>
#include <skalibs/unixmessage.h>

int unixmessage_receiver_init (unixmessage_receiver_t *b, int fd, char *mainbuf, unsigned int mainlen, char *auxbuf, unsigned int auxlen)
{
  if (!cbuffer_init(&b->mainb, mainbuf, mainlen)
   || !cbuffer_init(&b->auxb, auxbuf, auxlen)) return 0 ;
  b->fd = fd ;
  b->mainlen = b->auxlen = 0 ;
  b->maindata = stralloc_zero ;
  b->auxdata = stralloc_zero ;
  b->fds_ok = 3 ;
  return 1 ;
}