summaryrefslogtreecommitdiff
path: root/src/libunixonacid/skaclient_start_async.c
blob: 467acd91bff2075f411b7c24a78b0ba4dbb46f4a (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
51
52
53
54
/* ISC license. */

#include <sys/types.h>
#include <errno.h>
#include <stdint.h>
#include <skalibs/error.h>
#include <skalibs/kolbak.h>
#include <skalibs/skaclient.h>
#include <skalibs/unixmessage.h>
#include <skalibs/webipc.h>
#include "skaclient-internal.h"

int skaclient_start_async (
  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,
  skaclient_cbdata_t *blah)
{
  int fd = ipc_stream_nbcoe() ;
  if (fd < 0) return 0 ;
  if ((!ipc_connect(fd, path) && !error_isalready(errno))
   || !skaclient_init(a, fd, bufss, bufsn, auxbufss, auxbufsn, bufas, bufan, auxbufas, auxbufan, q, qlen, before, beforelen))
  {
    int e = errno ;
    fd_close(fd) ;
    errno = e ;
    return 0 ;
  }
  a->pid = 0 ;
  a->options = options & ~SKACLIENT_OPTION_WAITPID ;
  if (!kolbak_enqueue(&a->kq, (unixmessage_handler_func_t_ref)&skaclient_start_cb, blah))
  {
    skaclient_end(a) ;
    return 0 ;
  }
  blah->a = a ;
  blah->after = after ;
  blah->afterlen = afterlen ;
  return 1 ;
}