skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

skaclient_start.c (1093B)


      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_start (
     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 *path,
     22   uint32_t options,
     23   char const *before,
     24   size_t beforelen,
     25   char const *after,
     26   size_t afterlen,
     27   tain const *deadline,
     28   tain *stamp)
     29 {
     30   skaclient_cbdata blah ;
     31   unixmessage m ;
     32   int r ;
     33   if (!skaclient_start_async(a, bufss, bufsn, auxbufss, auxbufsn, bufas, bufan, auxbufas, auxbufan, q, qlen, path, options, before, beforelen, after, afterlen, &blah)) return 0 ;
     34   if (!skaclient_timed_flush(a, deadline, stamp))
     35   {
     36     int e = errno ;
     37     skaclient_end(a) ;
     38     errno = e ;
     39     return 0 ;
     40   }
     41   r = unixmessage_timed_receive(&a->syncin, &m, deadline, stamp) ;
     42   if (r < 1)
     43   {
     44     int e = errno ;
     45     if (!r) e = EPIPE ;
     46     skaclient_end(a) ;
     47     errno = e ;
     48     return 0 ;
     49   }
     50   return kolbak_call(&m, &a->kq) ;
     51 }