summaryrefslogtreecommitdiff
path: root/src/libs6/s6_fdholder_retrieve_cb.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs6/s6_fdholder_retrieve_cb.c')
-rw-r--r--src/libs6/s6_fdholder_retrieve_cb.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/libs6/s6_fdholder_retrieve_cb.c b/src/libs6/s6_fdholder_retrieve_cb.c
new file mode 100644
index 0000000..9197b22
--- /dev/null
+++ b/src/libs6/s6_fdholder_retrieve_cb.c
@@ -0,0 +1,26 @@
+ /* ISC license. */
+
+#include <errno.h>
+#include <skalibs/error.h>
+#include <skalibs/unixmessage.h>
+#include <s6/s6-fdholder.h>
+
+int s6_fdholder_retrieve_cb (unixmessage_t const *m, void *p)
+{
+ register s6_fdholder_retrieve_result_t *res = p ;
+ if (m->len != 1) goto err ;
+ if (m->s[0])
+ {
+ if (m->nfds) goto err ;
+ res->err = m->s[0] ;
+ return 1 ;
+ }
+ if (m->nfds != 1) goto err ;
+ res->fd = m->fds[0] ;
+ res->err = 0 ;
+ return 1 ;
+
+ err:
+ unixmessage_drop(m) ;
+ return (errno = EPROTO, 0) ;
+}