summaryrefslogtreecommitdiff
path: root/src/libskabus/skabus_pub_send_cb.c
blob: 008a28029a90ddbfbd0588974c06a547032d054c (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
/* ISC license. */

#include <errno.h>

#include <skalibs/posixishard.h>
#include <skalibs/uint64.h>
#include <skalibs/unixmessage.h>

#include <skabus/pub.h>

int skabus_pub_send_cb (unixmessage const *m, void *p)
{
  skabus_pub_send_result_t *r = p ;
  if (!m->len || m->nfds) return (errno = EPROTO, 0) ;
  if (m->s[0])
  {
    r->u = 0 ;
    r->err = m->s[0] ;
    return 1 ;
  }
  if (m->len != 9) return (errno = EPROTO, 0) ;
  uint64_unpack_big(m->s + 1, &r->u) ;
  r->err = 0 ;
  return 1 ;
}