skaclient_start_async.c (1185B)
1 /* ISC license. */ 2 3 #include <errno.h> 4 5 #include <skalibs/error.h> 6 #include <skalibs/kolbak.h> 7 #include <skalibs/skaclient.h> 8 #include <skalibs/unixmessage.h> 9 #include <skalibs/djbunix.h> 10 #include <skalibs/socket.h> 11 #include "skaclient-internal.h" 12 13 int skaclient_start_async ( 14 skaclient *a, 15 char *bufss, 16 size_t bufsn, 17 char *auxbufss, 18 size_t auxbufsn, 19 char *bufas, 20 size_t bufan, 21 char *auxbufas, 22 size_t auxbufan, 23 kolbak_closure *q, 24 size_t qlen, 25 char const *path, 26 uint32_t options, 27 char const *before, 28 size_t beforelen, 29 char const *after, 30 size_t afterlen, 31 skaclient_cbdata *blah) 32 { 33 int fd = ipc_stream_nbcoe() ; 34 if (fd < 0) return 0 ; 35 if ((!ipc_connect(fd, path) && !error_isalready(errno)) 36 || !skaclient_init(a, fd, bufss, bufsn, auxbufss, auxbufsn, bufas, bufan, auxbufas, auxbufan, q, qlen, before, beforelen)) 37 { 38 fd_close(fd) ; 39 return 0 ; 40 } 41 a->pid = 0 ; 42 a->options = options & ~SKACLIENT_OPTION_WAITPID ; 43 if (!kolbak_enqueue(&a->kq, (unixmessage_handler_func_ref)&skaclient_start_cb, blah)) 44 { 45 skaclient_end(a) ; 46 return 0 ; 47 } 48 blah->a = a ; 49 blah->after = after ; 50 blah->afterlen = afterlen ; 51 return 1 ; 52 }