skaclient_startf.c (1161B)
1 /* ISC license. */ 2 3 #include <errno.h> 4 5 #include <skalibs/kolbak.h> 6 #include <skalibs/skaclient.h> 7 #include "skaclient-internal.h" 8 9 int skaclient_startf ( 10 skaclient *a, 11 char *bufss, 12 size_t bufsn, 13 char *auxbufss, 14 size_t auxbufsn, 15 char *bufas, 16 size_t bufan, 17 char *auxbufas, 18 size_t auxbufan, 19 kolbak_closure *q, 20 size_t qlen, 21 char const *prog, 22 char const *const *argv, 23 char const *const *envp, 24 uint32_t options, 25 char const *before, 26 size_t beforelen, 27 char const *after, 28 size_t afterlen, 29 tain const *deadline, 30 tain *stamp) 31 { 32 skaclient_cbdata blah ; 33 unixmessage m ; 34 int r ; 35 if (!skaclient_startf_async(a, bufss, bufsn, auxbufss, auxbufsn, bufas, bufan, auxbufas, auxbufan, q, qlen, prog, argv, envp, options, before, beforelen, after, afterlen, &blah)) return 0 ; 36 if (!skaclient_timed_flush(a, deadline, stamp)) 37 { 38 int e = errno ; 39 skaclient_end(a) ; 40 errno = e ; 41 return 0 ; 42 } 43 r = unixmessage_timed_receive(&a->syncin, &m, deadline, stamp) ; 44 if (r < 1) 45 { 46 int e = errno ; 47 if (!r) e = EPIPE ; 48 skaclient_end(a) ; 49 errno = e ; 50 return 0 ; 51 } 52 return kolbak_call(&m, &a->kq) ; 53 }