summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/skalibs/skaclient.h6
-rw-r--r--src/include/skalibs/unixmessage.h16
-rw-r--r--src/libunixonacid/skaclient_server_01x.c21
-rw-r--r--src/libunixonacid/skaclient_server_init.c10
-rw-r--r--src/libunixonacid/unixmessage_receiver_0.c15
-rw-r--r--src/libunixonacid/unixmessage_sender_1.c7
-rw-r--r--src/libunixonacid/unixmessage_sender_x.c7
7 files changed, 74 insertions, 8 deletions
diff --git a/src/include/skalibs/skaclient.h b/src/include/skalibs/skaclient.h
index a057d50..3c7f6db 100644
--- a/src/include/skalibs/skaclient.h
+++ b/src/include/skalibs/skaclient.h
@@ -15,8 +15,10 @@
extern int skaclient_server_ack (unixmessage_t const *, unixmessage_sender_t *, unixmessage_sender_t *, char const *, unsigned int, char const *, unsigned int) ;
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 *, char *, unsigned int, char *, unsigned int, 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, mainbuf, mainlen, auxbuf, auxlen, out, asyncout, before, beforelen, after, afterlen, deadline) skaclient_server_init(in, mainbuf, mainlen, auxbuf, auxlen, out, asyncout, before, beforelen, after, afterlen, (deadline), &STAMP)
+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_g(before, beforelen, after, afterlen, deadline) skaclient_server_01x_init(before, beforelen, after, afterlen, (deadline), &STAMP)
/* Client part: the rest of this file */
diff --git a/src/include/skalibs/unixmessage.h b/src/include/skalibs/unixmessage.h
index 69d6717..accc258 100644
--- a/src/include/skalibs/unixmessage.h
+++ b/src/include/skalibs/unixmessage.h
@@ -100,4 +100,20 @@ extern int unixmessage_handle (unixmessage_receiver_t *, unixmessage_handler_fun
extern int unixmessage_timed_handle (unixmessage_receiver_t *, unixmessage_handler_func_t *, void *, tain_t const *, tain_t *) ;
#define unixmessage_timed_handle_g(b, f, p, deadline) unixmessage_timed_handle(b, f, p, (deadline), &STAMP)
+
+ /* 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) ;
+
+extern unixmessage_sender_t unixmessage_sender_1_ ;
+#define unixmessage_sender_1 (&unixmessage_sender_1_)
+
+extern unixmessage_sender_t unixmessage_sender_x_ ;
+#define unixmessage_sender_x (&unixmessage_sender_x_)
+
#endif
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 ;