skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

commit 5d6810d9eb833f923f1543fbb369823f7cd289df
parent 89cd43338a2a9bb768d715f1bb53987801be7c79
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date:   Fri,  5 Dec 2014 18:04:58 +0000

It's possible to statically initialize unixmessage_receiver_0

Diffstat:
Mpackage/deps.mak | 1-
Msrc/include/skalibs/skaclient.h | 2+-
Msrc/include/skalibs/unixmessage.h | 12++++++++++--
Dsrc/libunixonacid/skaclient_server_01x.c | 21---------------------
Msrc/libunixonacid/unixmessage_receiver_0.c | 7+------
5 files changed, 12 insertions(+), 31 deletions(-)

diff --git a/package/deps.mak b/package/deps.mak @@ -725,7 +725,6 @@ src/libunixonacid/skaclient_send.o src/libunixonacid/skaclient_send.lo: src/libu src/libunixonacid/skaclient_sendmsg.o src/libunixonacid/skaclient_sendmsg.lo: src/libunixonacid/skaclient_sendmsg.c src/include/skalibs/skaclient.h src/include/skalibs/tai.h src/include/skalibs/unixmessage.h src/libunixonacid/skaclient_sendmsgv.o src/libunixonacid/skaclient_sendmsgv.lo: src/libunixonacid/skaclient_sendmsgv.c src/include/skalibs/skaclient.h src/include/skalibs/tai.h src/include/skalibs/unixmessage.h src/libunixonacid/skaclient_sendv.o src/libunixonacid/skaclient_sendv.lo: src/libunixonacid/skaclient_sendv.c src/include/skalibs/siovec.h src/include/skalibs/skaclient.h src/include/skalibs/tai.h src/include/skalibs/unixmessage.h -src/libunixonacid/skaclient_server_01x.o src/libunixonacid/skaclient_server_01x.lo: src/libunixonacid/skaclient_server_01x.c src/include/skalibs/skaclient.h src/include/skalibs/tai.h src/include/skalibs/unixmessage.h src/libunixonacid/skaclient_server_ack.o src/libunixonacid/skaclient_server_ack.lo: src/libunixonacid/skaclient_server_ack.c src/include/skalibs/bytestr.h src/include/skalibs/djbunix.h src/include/skalibs/error.h src/include/skalibs/skaclient.h src/include/skalibs/unixmessage.h src/include/skalibs/webipc.h src/libunixonacid/skaclient_server_bidi_ack.o src/libunixonacid/skaclient_server_bidi_ack.lo: src/libunixonacid/skaclient_server_bidi_ack.c src/include/skalibs/skaclient.h src/include/skalibs/unixmessage.h src/libunixonacid/skaclient_server_init.o src/libunixonacid/skaclient_server_init.lo: src/libunixonacid/skaclient_server_init.c src/include/skalibs/skaclient.h src/include/skalibs/tai.h src/include/skalibs/unixmessage.h diff --git a/src/include/skalibs/skaclient.h b/src/include/skalibs/skaclient.h @@ -17,7 +17,7 @@ extern int skaclient_server_ack (unixmessage_t const *, unixmessage_sender_t *, extern int skaclient_server_bidi_ack (unixmessage_t const *, unixmessage_sender_t *, unixmessage_sender_t *, unixmessage_receiver_t *, char *, unsigned int, char *, unsigned int, char const *, unsigned int, char const *, unsigned int) ; extern int skaclient_server_init (unixmessage_receiver_t *, unixmessage_sender_t *, unixmessage_sender_t *, char const *, unsigned int, char const *, unsigned int, tain_t const *, tain_t *) ; #define skaclient_server_init_g(in, out, asyncout, before, beforelen, after, afterlen, deadline) skaclient_server_init(in, out, asyncout, before, beforelen, after, afterlen, (deadline), &STAMP) -extern int skaclient_server_01x_init (char const *, unsigned int, char const *, unsigned int, tain_t const *, tain_t *) ; +#define skaclient_server_01x_init(before, beforelen, after, afterlen, deadline, stamp) skaclient_server_init(unixmessage_receiver_0, unixmessage_sender_1, unixmessage_sender_x, before, beforelen, after, afterlen, deadline, stamp) #define skaclient_server_01x_init_g(before, beforelen, after, afterlen, deadline) skaclient_server_01x_init(before, beforelen, after, afterlen, (deadline), &STAMP) diff --git a/src/include/skalibs/unixmessage.h b/src/include/skalibs/unixmessage.h @@ -90,7 +90,16 @@ struct unixmessage_receiver_s unsigned int auxw ; } ; #define UNIXMESSAGE_RECEIVER_ZERO { .mainb = BUFFER_ZERO, .auxb = CBUFFER_ZERO, .mainlen = 0, .auxlen = 0, .data = STRALLOC_ZERO, .fds = { -1 }, .auxw = 0 } - +#define UNIXMESSAGE_RECEIVER_INIT(var, fd, s, n, auxs, auxn) \ +{ \ + .mainb = BUFFER_INIT_AUX(&unixmessage_read, fd, s, n, &(var).auxb), \ + .auxb = CBUFFER_INIT(auxs, auxn), \ + .mainlen = 0, \ + .auxlen = 0, \ + .data = STRALLOC_ZERO, \ + .auxw = 0 \ +} +#define UNIXMESSAGE_RECEIVER_DECLARE_AND_INIT(var, fd, s, n, auxs, auxn) unixmessage_receiver_t var = UNIXMESSAGE_RECEIVER_INIT(var, fd, s, n, auxs, auxn) 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) @@ -114,7 +123,6 @@ extern int unixmessage_timed_handle (unixmessage_receiver_t *, unixmessage_handl extern unixmessage_receiver_t unixmessage_receiver_0_ ; #define unixmessage_receiver_0 (&unixmessage_receiver_0_) -extern int unixmessage_receiver_0_init (void) ; extern unixmessage_sender_t unixmessage_sender_1_ ; #define unixmessage_sender_1 (&unixmessage_sender_1_) diff --git a/src/libunixonacid/skaclient_server_01x.c b/src/libunixonacid/skaclient_server_01x.c @@ -1,21 +0,0 @@ -/* 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/unixmessage_receiver_0.c b/src/libunixonacid/unixmessage_receiver_0.c @@ -7,9 +7,4 @@ 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_BUFSIZE, auxbuf, UNIXMESSAGE_AUXBUFSIZE) ; -} +UNIXMESSAGE_RECEIVER_DECLARE_AND_INIT(unixmessage_receiver_0_, 0, mainbuf, UNIXMESSAGE_BUFSIZE, auxbuf, UNIXMESSAGE_AUXBUFSIZE) ;