summaryrefslogtreecommitdiff
path: root/src/libunixonacid/skaclient_start.c
blob: d78a1e31258f39c31fa5f3a90f7322c80d9fc124 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* ISC license. */

#include <errno.h>
#include <skalibs/kolbak.h>
#include <skalibs/skaclient.h>
#include "skaclient-internal.h"

int skaclient_start (
  skaclient_t *a,
  char *bufss,
  size_t bufsn,
  char *auxbufss,
  size_t auxbufsn,
  char *bufas,
  size_t bufan,
  char *auxbufas,
  size_t auxbufan,
  kolbak_closure_t *q,
  size_t qlen,
  char const *path,
  uint32_t options,
  char const *before,
  size_t beforelen,
  char const *after,
  size_t afterlen,
  tain_t const *deadline,
  tain_t *stamp)
{
  skaclient_cbdata_t blah ;
  unixmessage_t m ;
  int r ;
  if (!skaclient_start_async(a, bufss, bufsn, auxbufss, auxbufsn, bufas, bufan, auxbufas, auxbufan, q, qlen, path, options, before, beforelen, after, afterlen, &blah)) return 0 ;
  if (!skaclient_timed_flush(a, deadline, stamp))
  {
    int e = errno ;
    skaclient_end(a) ;
    errno = e ;
    return 0 ;
  }
  r = unixmessage_timed_receive(&a->syncin, &m, deadline, stamp) ;
  if (r < 1)
  {
    int e = errno ;
    if (!r) e = EPIPE ;
    skaclient_end(a) ;
    errno = e ;
    return 0 ;
  }
  return kolbak_call(&m, &a->kq) ;
}