diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2003-06-26 18:47:49 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2003-06-26 18:47:49 +0000 |
| commit | 71f6bb60bf2b7457091c7106190f92ab7e51f7c6 (patch) | |
| tree | 8ad3668667bd3da3c34f7ff7ae0a9a7a4daa4679 /src/io.c | |
| parent | f330540576031528f0daac231c61d4dd06e8ba1e (diff) | |
| download | luasocket-71f6bb60bf2b7457091c7106190f92ab7e51f7c6.tar.gz luasocket-71f6bb60bf2b7457091c7106190f92ab7e51f7c6.tar.bz2 luasocket-71f6bb60bf2b7457091c7106190f92ab7e51f7c6.zip | |
Finished implementation of LuaSocket 2.0 alpha on Linux.
Some testing still needed.
Diffstat (limited to 'src/io.c')
| -rw-r--r-- | src/io.c | 40 |
1 files changed, 40 insertions, 0 deletions
| @@ -1,8 +1,48 @@ | |||
| 1 | /*=========================================================================*\ | ||
| 2 | * Input/Output abstraction | ||
| 3 | * LuaSocket toolkit | ||
| 4 | * | ||
| 5 | * RCS ID: $Id$ | ||
| 6 | \*=========================================================================*/ | ||
| 1 | #include "io.h" | 7 | #include "io.h" |
| 2 | 8 | ||
| 9 | /*=========================================================================*\ | ||
| 10 | * Exported functions | ||
| 11 | \*=========================================================================*/ | ||
| 12 | /*-------------------------------------------------------------------------*\ | ||
| 13 | * Initializes C structure | ||
| 14 | \*-------------------------------------------------------------------------*/ | ||
| 3 | void io_init(p_io io, p_send send, p_recv recv, void *ctx) | 15 | void io_init(p_io io, p_send send, p_recv recv, void *ctx) |
| 4 | { | 16 | { |
| 5 | io->send = send; | 17 | io->send = send; |
| 6 | io->recv = recv; | 18 | io->recv = recv; |
| 7 | io->ctx = ctx; | 19 | io->ctx = ctx; |
| 8 | } | 20 | } |
| 21 | |||
| 22 | /*-------------------------------------------------------------------------*\ | ||
| 23 | * Translate error codes to Lua | ||
| 24 | \*-------------------------------------------------------------------------*/ | ||
| 25 | void io_pusherror(lua_State *L, int code) | ||
| 26 | { | ||
| 27 | switch (code) { | ||
| 28 | case IO_DONE: | ||
| 29 | lua_pushnil(L); | ||
| 30 | break; | ||
| 31 | case IO_TIMEOUT: | ||
| 32 | lua_pushstring(L, "timeout"); | ||
| 33 | break; | ||
| 34 | case IO_LIMITED: | ||
| 35 | lua_pushstring(L, "limited"); | ||
| 36 | break; | ||
| 37 | case IO_CLOSED: | ||
| 38 | lua_pushstring(L, "closed"); | ||
| 39 | break; | ||
| 40 | case IO_REFUSED: | ||
| 41 | lua_pushstring(L, "refused"); | ||
| 42 | break; | ||
| 43 | default: | ||
| 44 | lua_pushstring(L, "unknown error"); | ||
| 45 | break; | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
