about summary refs log tree commit diff stats
path: root/src/luasec/luasocket/io.h
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-11-21 15:55:52 -0800
committerKartik K. Agaram <vc@akkartik.com>2021-11-21 15:55:52 -0800
commit5a484efe8c72a929382c96555a31129f8d2a55c8 (patch)
tree60f6b76e3c06dbc1bfb9fe9e978475256e8a8f6d /src/luasec/luasocket/io.h
parent3b44b9827d5e9c6554c5600c45d832d4e6eb50f8 (diff)
downloadteliva-5a484efe8c72a929382c96555a31129f8d2a55c8.tar.gz
https now working!
Still extremely ugly:
- I've inlined all the namespaces under ssl, so you need to know that
  context and config are related to ssl.
- luasec comes with its own copy of luasocket. I haven't deduped that
  yet.
Diffstat (limited to 'src/luasec/luasocket/io.h')
-rw-r--r--src/luasec/luasocket/io.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/luasec/luasocket/io.h b/src/luasec/luasocket/io.h
new file mode 100644
index 0000000..b1f35ad
--- /dev/null
+++ b/src/luasec/luasocket/io.h
@@ -0,0 +1,65 @@
+#ifndef IO_H
+#define IO_H
+/*=========================================================================*\
+* Input/Output abstraction
+* LuaSocket toolkit
+*
+* This module defines the interface that LuaSocket expects from the
+* transport layer for streamed input/output. The idea is that if any
+* transport implements this interface, then the buffer.c functions
+* automatically work on it.
+*
+* The module socket.h implements this interface, and thus the module tcp.h
+* is very simple.
+\*=========================================================================*/
+#include <stdio.h>
+#include "../../lua.h"
+
+#include "timeout.h"
+
+/* IO error codes */
+enum {
+    IO_DONE = 0,        /* operation completed successfully */
+    IO_TIMEOUT = -1,    /* operation timed out */
+    IO_CLOSED = -2,     /* the connection has been closed */
+	IO_UNKNOWN = -3     
+};
+
+/* interface to error message function */
+typedef const char *(*p_error) (
+    void *ctx,          /* context needed by send */
+    int err             /* error code */
+);
+
+/* interface to send function */
+typedef int (*p_send) (
+    void *ctx,          /* context needed by send */
+    const char *data,   /* pointer to buffer with data to send */
+    size_t count,       /* number of bytes to send from buffer */
+    size_t *sent,       /* number of bytes sent uppon return */
+    p_timeout tm        /* timeout control */
+);
+
+/* interface to recv function */
+typedef int (*p_recv) (
+    void *ctx,          /* context needed by recv */
+    char *data,         /* pointer to buffer where data will be written */
+    size_t count,       /* number of bytes to receive into buffer */
+    size_t *got,        /* number of bytes received uppon return */
+    p_timeout tm        /* timeout control */
+);
+
+/* IO driver definition */
+typedef struct t_io_ {
+    void *ctx;          /* context needed by send/recv */
+    p_send send;        /* send function pointer */
+    p_recv recv;        /* receive function pointer */
+    p_error error;      /* strerror function */
+} t_io;
+typedef t_io *p_io;
+
+void io_init(p_io io, p_send send, p_recv recv, p_error error, void *ctx);
+const char *io_strerror(int err);
+
+#endif /* IO_H */
+