diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2014-12-04 16:30:20 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2014-12-04 16:30:20 +0000 |
commit | 82724c82fd69720a579a8b245637ac247c08c700 (patch) | |
tree | 1f805e13b5ebde8c3497c83914a317dd203bf263 /src/libunixonacid | |
parent | 8ddcb8ca23638109b0b4c31b2214cd0cad700b6a (diff) | |
download | skalibs-82724c82fd69720a579a8b245637ac247c08c700.tar.xz |
Better interface for simple skaclient servers
Diffstat (limited to 'src/libunixonacid')
-rw-r--r-- | src/libunixonacid/skaclient_server_01x.c | 21 | ||||
-rw-r--r-- | src/libunixonacid/skaclient_server_init.c | 10 | ||||
-rw-r--r-- | src/libunixonacid/unixmessage_receiver_0.c | 15 | ||||
-rw-r--r-- | src/libunixonacid/unixmessage_sender_1.c | 7 | ||||
-rw-r--r-- | src/libunixonacid/unixmessage_sender_x.c | 7 |
5 files changed, 54 insertions, 6 deletions
diff --git a/src/libunixonacid/skaclient_server_01x.c b/src/libunixonacid/skaclient_server_01x.c new file mode 100644 index 0000000..e55e8cd --- /dev/null +++ b/src/libunixonacid/skaclient_server_01x.c @@ -0,0 +1,21 @@ +/* ISC license. */ + +/* MT-unsafe */ + +#include <skalibs/tai.h> +#include <skalibs/unixmessage.h> +#include <skalibs/skaclient.h> + +int skaclient_server_01x_init (char const *before, unsigned int beforelen, char const *after, unsigned int afterlen, tain_t const *deadline, tain_t *stamp) +{ + return unixmessage_receiver_0_init() && skaclient_server_init( + unixmessage_receiver_0, + unixmessage_sender_1, + unixmessage_sender_x, + before, + beforelen, + after, + afterlen, + deadline, + stamp) ; +} diff --git a/src/libunixonacid/skaclient_server_init.c b/src/libunixonacid/skaclient_server_init.c index bd7c143..e44d0da 100644 --- a/src/libunixonacid/skaclient_server_init.c +++ b/src/libunixonacid/skaclient_server_init.c @@ -4,12 +4,10 @@ #include <skalibs/tai.h> #include <skalibs/unixmessage.h> -int skaclient_server_init (unixmessage_receiver_t *in, char *mainbuf, unsigned int mainlen, char *auxbuf, unsigned int auxlen, unixmessage_sender_t *out, unixmessage_sender_t *asyncout, char const *before, unsigned int beforelen, char const *after, unsigned int afterlen, tain_t const *deadline, tain_t *stamp) +int skaclient_server_init (unixmessage_receiver_t *in, unixmessage_sender_t *out, unixmessage_sender_t *asyncout, char const *before, unsigned int beforelen, char const *after, unsigned int afterlen, tain_t const *deadline, tain_t *stamp) { unixmessage_t m ; - if (!unixmessage_receiver_init(in, 0, mainbuf, mainlen, auxbuf, auxlen)) return 0 ; - unixmessage_sender_init(out, 1) ; - if (unixmessage_timed_receive(in, &m, deadline, stamp) < 0) return 0 ; - if (!skaclient_server_ack(&m, out, asyncout, before, beforelen, after, afterlen)) return 0 ; - return unixmessage_sender_timed_flush(out, deadline, stamp) ; + return (unixmessage_timed_receive(in, &m, deadline, stamp) >= 0) + && skaclient_server_ack(&m, out, asyncout, before, beforelen, after, afterlen) + && unixmessage_sender_timed_flush(out, deadline, stamp) ; } diff --git a/src/libunixonacid/unixmessage_receiver_0.c b/src/libunixonacid/unixmessage_receiver_0.c new file mode 100644 index 0000000..2b6f165 --- /dev/null +++ b/src/libunixonacid/unixmessage_receiver_0.c @@ -0,0 +1,15 @@ +/* ISC license. */ + +/* MT-unsafe */ + +#include <skalibs/unixmessage.h> + +static char mainbuf[UNIXMESSAGE_RECEIVER_MAINBUFSIZE] ; +static char auxbuf[UNIXMESSAGE_RECEIVER_AUXBUFSIZE] ; + +unixmessage_receiver_t unixmessage_receiver_0_ = UNIXMESSAGE_RECEIVER_ZERO ; + +int unixmessage_receiver_0_init () +{ + return unixmessage_receiver_init(&unixmessage_receiver_0_, 0, mainbuf, UNIXMESSAGE_RECEIVER_MAINBUFSIZE, auxbuf, UNIXMESSAGE_RECEIVER_AUXBUFSIZE) ; +} diff --git a/src/libunixonacid/unixmessage_sender_1.c b/src/libunixonacid/unixmessage_sender_1.c new file mode 100644 index 0000000..e01081d --- /dev/null +++ b/src/libunixonacid/unixmessage_sender_1.c @@ -0,0 +1,7 @@ +/* ISC license. */ + +/* MT-unsafe */ + +#include <skalibs/unixmessage.h> + +unixmessage_sender_t unixmessage_sender_1_ = UNIXMESSAGE_SENDER_INIT(1) ; diff --git a/src/libunixonacid/unixmessage_sender_x.c b/src/libunixonacid/unixmessage_sender_x.c new file mode 100644 index 0000000..da8659f --- /dev/null +++ b/src/libunixonacid/unixmessage_sender_x.c @@ -0,0 +1,7 @@ +/* ISC license. */ + +/* MT-unsafe */ + +#include <skalibs/unixmessage.h> + +unixmessage_sender_t unixmessage_sender_x_ = UNIXMESSAGE_SENDER_ZERO ; |