From 4fdf60a4c9ce16dd459e05ad7664010ea45c43db Mon Sep 17 00:00:00 2001 From: Aki Date: Wed, 24 Feb 2021 01:04:57 +0100 Subject: Started progress towards coroutine-based connection handling --- stream.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 stream.c (limited to 'stream.c') diff --git a/stream.c b/stream.c new file mode 100644 index 0000000..d6a5254 --- /dev/null +++ b/stream.c @@ -0,0 +1,23 @@ +#include "stream.h" + +#include +#include + +/// Creates and pushes new Stream into the Lua stack. +/// \param L Lua state to push to +/// \param fd File descriptor used by stream +/// \return TODO +int stream_push_new(lua_State * L, const int fd) +{ + struct stream * s = lua_newuserdata(L, sizeof(struct stream)); + s->fd = fd; + + if (1 == luaL_newmetatable(L, "stream")) + { + // TODO: initialize metatable for stream + } + + lua_setmetatable(L, -2); + + return LUA_OK; +} -- cgit v1.1