diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2020-01-10 10:35:55 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska-skaware@skarnet.org> | 2020-01-10 10:35:55 +0000 |
| commit | 9dafc75bb51c0f350330277a2e96b04f5a1c73b3 (patch) | |
| tree | d00d225400b981648d362e4c3bb56b46c0608b7c /src/libskabus/skabus_pub_sendvpm_async.c | |
| parent | 4a14a6b86a4a3c5ab8bc36e4c417a6783dfab463 (diff) | |
| download | skabus-9dafc75bb51c0f350330277a2e96b04f5a1c73b3.tar.gz | |
Add pub library and daemon
Diffstat (limited to 'src/libskabus/skabus_pub_sendvpm_async.c')
| -rw-r--r-- | src/libskabus/skabus_pub_sendvpm_async.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/libskabus/skabus_pub_sendvpm_async.c b/src/libskabus/skabus_pub_sendvpm_async.c new file mode 100644 index 0000000..b1bab4d --- /dev/null +++ b/src/libskabus/skabus_pub_sendvpm_async.c @@ -0,0 +1,25 @@ +/* ISC license. */ + +#include <string.h> +#include <sys/uio.h> +#include <errno.h> + +#include <skalibs/unixmessage.h> +#include <skalibs/skaclient.h> + +#include <skabus/pub.h> +#include "skabus-pub-internal.h" + +int skabus_pub_sendvpm_withfds_async (skabus_pub_t *a, char const *idstr, struct iovec const *v, unsigned int vlen, int const *fds, unsigned int nfds, unsigned char const *bits, skabus_pub_send_result_t *result) +{ + size_t idlen = strlen(idstr) ; + char tmp[2] = "+" ; + struct iovec vv[vlen + 2] ; + unixmessage_v_t m = { .v = vv, .vlen = vlen + 2, .fds = (int *)fds, .nfds = nfds } ; + if (idlen > SKABUS_PUB_IDSTR_SIZE) return (errno = ERANGE, 0) ; + tmp[1] = (unsigned char)idlen ; + vv[0].iov_base = tmp ; vv[0].iov_len = 2 ; + vv[1].iov_base = (char *)idstr ; vv[1].iov_len = idlen+1 ; + for (unsigned int i = 0 ; i < vlen ; i++) vv[2+i] = v[i] ; + return skaclient_putmsgv_and_close(&a->connection, &m, bits, &skabus_pub_send_cb, result) ; +} |
