diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/skalibs/skaclient.h | 6 | ||||
-rw-r--r-- | src/include/skalibs/unixmessage.h | 14 | ||||
-rw-r--r-- | src/libunixonacid/unixmessage_receiver_0.c | 6 | ||||
-rw-r--r-- | src/libunixonacid/unixmessage_sender_timed_flush.c | 3 |
4 files changed, 17 insertions, 12 deletions
diff --git a/src/include/skalibs/skaclient.h b/src/include/skalibs/skaclient.h index 3c7f6db..602adce 100644 --- a/src/include/skalibs/skaclient.h +++ b/src/include/skalibs/skaclient.h @@ -66,13 +66,13 @@ extern int skaclient_startf_async (skaclient_t *, char *, unsigned int, char *, #define skaclient_startf_async_b(a, sb, prog, argv, envp, options, before, beforelen, after, afterlen, blah) skaclient_startf_async(a, (sb)->bufs, sizeof((sb)->bufs), (sb)->auxbufs, sizeof((sb)->auxbufs), (sb)->bufa, sizeof((sb)->bufa), (sb)->auxbufa, sizeof((sb)->auxbufa), (sb)->q, sizeof((sb)->q), prog, argv, envp, options, before, beforelen, after, afterlen, blah) extern int skaclient_start (skaclient_t *, char *, unsigned int, char *, unsigned int, char *, unsigned int, char *, unsigned int, kolbak_closure_t *, unsigned int, char const *, char const *, unsigned int, char const *, unsigned int, tain_t const *, tain_t *) ; -#define skaclient_start_b(a, sb, path, before, beforelen, after, afterlen, deadline, stamp) skaclient_start((a, (sb)->bufs, sizeof((sb)->bufs), (sb)->auxbufs, sizeof((sb)->auxbufs), (sb)->bufa, sizeof((sb)->bufa), (sb)->auxbufa, sizeof((sb)->auxbufa), (sb)->q, sizeof((sb)->q), path, before, beforelen, after, afterlen, deadline, stamp) +#define skaclient_start_b(a, sb, path, before, beforelen, after, afterlen, deadline, stamp) skaclient_start(a, (sb)->bufs, sizeof((sb)->bufs), (sb)->auxbufs, sizeof((sb)->auxbufs), (sb)->bufa, sizeof((sb)->bufa), (sb)->auxbufa, sizeof((sb)->auxbufa), (sb)->q, sizeof((sb)->q), path, before, beforelen, after, afterlen, deadline, stamp) #define skaclient_start_g(a, bufs, bufsn, auxbufs, auxbufsn, bufa, bufan, auxbufa, auxbufan, q, qlen, path, before, beforelen, after, afterlen, deadline) skaclient_start(a, bufs, bufsn, auxbufs, auxbufsn, bufa, bufan, auxbufa, auxbufan, q, qlen, path, before, beforelen, after, afterlen, (deadline), &STAMP) #define skaclient_start_b_g(a, sb, path, before, beforelen, after, afterlen, deadline) skaclient_start_b(a, sb, path, before, beforelen, after, afterlen, (deadline), &STAMP) extern int skaclient_startf (skaclient_t *, char *, unsigned int, char *, unsigned int, char *, unsigned int, char *, unsigned int, kolbak_closure_t *, unsigned int, char const *, char const *const *, char const *const *, uint32, char const *, unsigned int, char const *, unsigned int, tain_t const *, tain_t *) ; -#define skaclient_startf_b(a, sb, prog, argv, envp, before, beforelen, after, afterlen, deadline, stamp) skaclient_start((a, (sb)->bufs, sizeof((sb)->bufs), (sb)->auxbufs, sizeof((sb)->auxbufs), (sb)->bufa, sizeof((sb)->bufa), (sb)->auxbufa, sizeof((sb)->auxbufa), (sb)->q, sizeof((sb)->q), prog, argv, envp, before, beforelen, after, afterlen, deadline, stamp) -#define skaclient_startf_g(a, bufs, bufsn, auxbufs, auxbufsn, bufa, bufan, auxbufa, auxbufan, q, qlen, prog, argv, envp, options, before, beforelen, after, afterlen, deadline) skaclient_startf(a, bufs, bufsn, auxbufs, auxbufsn, bufa, bufan, auxbufa, auxbufan, q, qlen, prog, argv, envp, options, before, beforelen, after, afterlen, (deadline), &STAMP) +#define skaclient_startf_b(a, sb, prog, argv, envp, options, before, beforelen, after, afterlen, deadline, stamp) skaclient_startf(a, (sb)->bufs, sizeof((sb)->bufs), (sb)->auxbufs, sizeof((sb)->auxbufs), (sb)->bufa, sizeof((sb)->bufa), (sb)->auxbufa, sizeof((sb)->auxbufa), (sb)->q, sizeof((sb)->q), prog, argv, envp, options, before, beforelen, after, afterlen, deadline, stamp) +#define skaclient_startf_g(a, bufs, bufsn, auxbufs, auxbufsn, bufa, bufan, auxbufa, auxbufan, q, qlen, prog, argv, envp, options, before, beforelen, after, afterlen, deadline) skaclient_startf(a, bufs, bufsn, auxbufs, auxbufsn, bufa, bufan, auxbufa, auxbufan, q, qlen, prog, argv, envp, options, before, beforelen, after, afterlen, (deadline), &STAMP) #define skaclient_startf_b_g(a, sb, prog, argv, envp, options, before, beforelen, after, afterlen, deadline) skaclient_startf_b(a, sb, prog, argv, envp, options, before, beforelen, after, afterlen, (deadline), &STAMP) extern int skaclient_putmsg_and_close (skaclient_t *, unixmessage_t const *, unsigned char const *, unixmessage_handler_func_t *, void *) ; diff --git a/src/include/skalibs/unixmessage.h b/src/include/skalibs/unixmessage.h index accc258..58c11eb 100644 --- a/src/include/skalibs/unixmessage.h +++ b/src/include/skalibs/unixmessage.h @@ -11,6 +11,9 @@ #include <skalibs/stralloc.h> #include <skalibs/tai.h> + + /* Message */ + typedef struct unixmessage_s unixmessage_t, *unixmessage_t_ref ; struct unixmessage_s { @@ -33,12 +36,14 @@ struct unixmessage_v_s #define UNIXMESSAGE_V_ZERO { .v = 0, .vlen = 0, .fds = 0, .nfds = 0 } extern unixmessage_v_t const unixmessage_v_zero ; - #define UNIXMESSAGE_BUFSIZE 2049 #define UNIXMESSAGE_AUXBUFSIZE 2049 #define UNIXMESSAGE_MAXFDS 256 #define UNIXMESSAGE_MAXREADS 32 + + /* Sender */ + typedef struct unixmessage_sender_s unixmessage_sender_t, *unixmessage_sender_t_ref ; struct unixmessage_sender_s { @@ -56,6 +61,7 @@ extern void unixmessage_sender_init (unixmessage_sender_t *, int) ; extern void unixmessage_sender_free (unixmessage_sender_t *) ; #define unixmessage_sender_fd(b) ((b)->fd) extern int unixmessage_sender_getfd (unixmessage_sender_t const *) gccattr_pure ; +#define unixmessage_sender_isempty(b) (!genalloc_len(unsigned int, &(b)->offsets)) extern int unixmessage_put_and_close (unixmessage_sender_t *, unixmessage_t const *, unsigned char const *) ; #define unixmessage_put(b, m) unixmessage_put_and_close(b, m, unixmessage_bits_closenone) @@ -70,6 +76,8 @@ extern int unixmessage_sender_timed_flush (unixmessage_sender_t *, tain_t const #define unixmessage_sender_timed_flush_g(sender, deadline) unixmessage_sender_timed_flush(sender, (deadline), &STAMP) + /* Receiver */ + typedef struct unixmessage_receiver_s unixmessage_receiver_t, *unixmessage_receiver_t_ref ; struct unixmessage_receiver_s { @@ -86,6 +94,7 @@ struct unixmessage_receiver_s extern int unixmessage_receiver_init (unixmessage_receiver_t *, int, char *, unsigned int, char *, unsigned int) ; extern void unixmessage_receiver_free (unixmessage_receiver_t *) ; #define unixmessage_receiver_fd(b) buffer_fd(&(b)->mainb) +#define unixmessage_receiver_isempty(b) (buffer_isempty(&(b)->mainb) && cbuffer_isempty(&(b)->auxb)) extern int unixmessage_receive (unixmessage_receiver_t *, unixmessage_t *) ; extern int unixmessage_timed_receive (unixmessage_receiver_t *, unixmessage_t *, tain_t const *, tain_t *) ; @@ -103,9 +112,6 @@ extern int unixmessage_timed_handle (unixmessage_receiver_t *, unixmessage_handl /* Globals */ -#define UNIXMESSAGE_RECEIVER_MAINBUFSIZE 4097 -#define UNIXMESSAGE_RECEIVER_AUXBUFSIZE 4097 - extern unixmessage_receiver_t unixmessage_receiver_0_ ; #define unixmessage_receiver_0 (&unixmessage_receiver_0_) extern int unixmessage_receiver_0_init (void) ; diff --git a/src/libunixonacid/unixmessage_receiver_0.c b/src/libunixonacid/unixmessage_receiver_0.c index 2b6f165..b43bdfb 100644 --- a/src/libunixonacid/unixmessage_receiver_0.c +++ b/src/libunixonacid/unixmessage_receiver_0.c @@ -4,12 +4,12 @@ #include <skalibs/unixmessage.h> -static char mainbuf[UNIXMESSAGE_RECEIVER_MAINBUFSIZE] ; -static char auxbuf[UNIXMESSAGE_RECEIVER_AUXBUFSIZE] ; +static char mainbuf[UNIXMESSAGE_BUFSIZE] ; +static char auxbuf[UNIXMESSAGE_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) ; + return unixmessage_receiver_init(&unixmessage_receiver_0_, 0, mainbuf, UNIXMESSAGE_BUFSIZE, auxbuf, UNIXMESSAGE_AUXBUFSIZE) ; } diff --git a/src/libunixonacid/unixmessage_sender_timed_flush.c b/src/libunixonacid/unixmessage_sender_timed_flush.c index 74e4937..e144c82 100644 --- a/src/libunixonacid/unixmessage_sender_timed_flush.c +++ b/src/libunixonacid/unixmessage_sender_timed_flush.c @@ -1,14 +1,13 @@ /* ISC license. */ #include <skalibs/functypes.h> -#include <skalibs/genalloc.h> #include <skalibs/tai.h> #include <skalibs/unix-timed.h> #include <skalibs/unixmessage.h> static int unixmessage_sender_isnonempty (unixmessage_sender_t *b) { - return !!genalloc_len(unsigned int, &b->offsets) ; + return !unixmessage_sender_isempty(b) ; } int unixmessage_sender_timed_flush (unixmessage_sender_t *b, tain_t const *deadline, tain_t *stamp) |