summaryrefslogtreecommitdiff
path: root/src/libunixonacid/skaclient_server_ack.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2014-09-18 18:55:44 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2014-09-18 18:55:44 +0000
commit3534b428629be185e096be99e3bd5fdfe32d5544 (patch)
tree210ef3198ed66bc7f7b7bf6a85e4579f455e5a36 /src/libunixonacid/skaclient_server_ack.c
downloadskalibs-3534b428629be185e096be99e3bd5fdfe32d5544.tar.xz
initial commit with rc for skalibs-2.0.0.0
Diffstat (limited to 'src/libunixonacid/skaclient_server_ack.c')
-rw-r--r--src/libunixonacid/skaclient_server_ack.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/libunixonacid/skaclient_server_ack.c b/src/libunixonacid/skaclient_server_ack.c
new file mode 100644
index 0000000..31ee9fe
--- /dev/null
+++ b/src/libunixonacid/skaclient_server_ack.c
@@ -0,0 +1,30 @@
+/* ISC license. */
+
+#include <errno.h>
+#include <skalibs/bytestr.h>
+#include <skalibs/djbunix.h>
+#include <skalibs/error.h>
+#include <skalibs/skaclient.h>
+#include <skalibs/unixmessage.h>
+#include <skalibs/webipc.h>
+
+int skaclient_server_ack (unixmessage_t const *clientmsg, unixmessage_sender_t *out, unixmessage_sender_t *asyncout, char const *before, unsigned int beforelen, char const *after, unsigned int afterlen)
+{
+ int fd[2] ;
+ unixmessage_t m = { .s = (char *)after, .len = afterlen, .fds = fd, .nfds = 1 } ;
+ static unsigned char const bits = 0xff ;
+ if (clientmsg->nfds
+ || clientmsg->len != beforelen
+ || byte_diff(clientmsg->s, beforelen, before)) return (errno = EPROTO, 0) ;
+ if (ipc_pair_nbcoe(fd) < 0) return 0 ;
+ unixmessage_sender_init(asyncout, fd[1]) ;
+ if (!unixmessage_put_and_close(out, &m, &bits))
+ {
+ int e = errno ;
+ fd_close(fd[1]) ;
+ fd_close(fd[0]) ;
+ errno = e ;
+ return 0 ;
+ }
+ return 1 ;
+}