summaryrefslogtreecommitdiff
path: root/src/libs6/ftrigr_subscribe.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-12-22 17:37:09 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-12-22 17:37:09 +0000
commitd7242bda59ec2ec056508b39cb532b5e7318dd13 (patch)
treeffb04351e694d0f7935062127daf0d1b47ebf3d2 /src/libs6/ftrigr_subscribe.c
parentda7304bbbfb90ced7a00acf5dbca0319d89fcc3a (diff)
downloads6-d7242bda59ec2ec056508b39cb532b5e7318dd13.tar.xz
Port ftrigr and s6lock to textclient
Diffstat (limited to 'src/libs6/ftrigr_subscribe.c')
-rw-r--r--src/libs6/ftrigr_subscribe.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/libs6/ftrigr_subscribe.c b/src/libs6/ftrigr_subscribe.c
index cbbde1e..72b87dc 100644
--- a/src/libs6/ftrigr_subscribe.c
+++ b/src/libs6/ftrigr_subscribe.c
@@ -9,15 +9,15 @@
#include <skalibs/tai.h>
#include <skalibs/stralloc.h>
#include <skalibs/gensetdyn.h>
-#include <skalibs/skaclient.h>
+#include <skalibs/textclient.h>
#include <s6/ftrigr.h>
uint16_t ftrigr_subscribe (ftrigr_t *a, char const *path, char const *re, uint32_t options, tain_t const *deadline, tain_t *stamp)
{
size_t pathlen = strlen(path) ;
size_t relen = strlen(re) ;
+ ftrigr1_t ft = { .options = options, .state = FR1STATE_LISTENING, .what = STRALLOC_ZERO } ;
uint32_t i ;
- char err ;
char tmp[15] = "--L" ;
struct iovec v[3] = { { .iov_base = tmp, .iov_len = 15 }, { .iov_base = (char *)path, .iov_len = pathlen + 1 }, { .iov_base = (char *)re, .iov_len = relen + 1 } } ;
if (!gensetdyn_new(&a->data, &i)) return 0 ;
@@ -30,23 +30,13 @@ uint16_t ftrigr_subscribe (ftrigr_t *a, char const *path, char const *re, uint32
uint32_pack_big(tmp+3, options) ;
uint32_pack_big(tmp+7, (uint32_t)pathlen) ;
uint32_pack_big(tmp+11, (uint32_t)relen) ;
- if (!skaclient_sendv(&a->connection, v, 3, &skaclient_default_cb, &err, deadline, stamp))
+ if (!textclient_commandv(&a->connection, v, 3, deadline, stamp))
{
int e = errno ;
gensetdyn_delete(&a->data, i) ;
errno = e ;
return 0 ;
}
- if (err)
- {
- gensetdyn_delete(&a->data, i) ;
- return (errno = err, 0) ;
- }
- {
- ftrigr1_t *p = GENSETDYN_P(ftrigr1_t, &a->data, i) ;
- p->options = options ;
- p->state = FR1STATE_LISTENING ;
- p->what = stralloc_zero ;
- }
+ *GENSETDYN_P(ftrigr1_t, &a->data, i) = ft ;
return (uint16_t)(i+1) ;
}