diff options
author | Aki <please@ignore.pl> | 2021-02-24 01:04:57 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2021-02-24 01:04:57 +0100 |
commit | 4fdf60a4c9ce16dd459e05ad7664010ea45c43db (patch) | |
tree | b826d103c799f9e4b12fe87b1320a4972a8bab33 /stream.c | |
parent | a8bcb7a654691a9a41ba193f16dca38bdd65bfa0 (diff) | |
download | plop-4fdf60a4c9ce16dd459e05ad7664010ea45c43db.zip plop-4fdf60a4c9ce16dd459e05ad7664010ea45c43db.tar.gz plop-4fdf60a4c9ce16dd459e05ad7664010ea45c43db.tar.bz2 |
Started progress towards coroutine-based connection handling
Diffstat (limited to 'stream.c')
-rw-r--r-- | stream.c | 23 |
1 files changed, 23 insertions, 0 deletions
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 <lauxlib.h> +#include <lua.h> + +/// 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; +} |