From 7115c12fbc9aae1cd46fdf049697a27fb996181a Mon Sep 17 00:00:00 2001 From: Diego Nehab Date: Thu, 1 Jul 2004 03:32:09 +0000 Subject: Moving on to beta2. --- src/io.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/io.c') diff --git a/src/io.c b/src/io.c index 612454b..30595c7 100644 --- a/src/io.c +++ b/src/io.c @@ -12,34 +12,34 @@ /*-------------------------------------------------------------------------*\ * Initializes C structure \*-------------------------------------------------------------------------*/ -void io_init(p_io io, p_send send, p_recv recv, void *ctx) -{ +void io_init(p_io io, p_send send, p_recv recv, p_geterr geterr, void *ctx) { io->send = send; io->recv = recv; + io->geterr = geterr; io->ctx = ctx; } /*-------------------------------------------------------------------------*\ * Translate error codes to Lua \*-------------------------------------------------------------------------*/ -const char *io_strerror(int code) -{ +const char *io_strerror(int code) { switch (code) { case IO_DONE: return NULL; - case IO_TIMEOUT: return "timeout"; - case IO_RETRY: return "retry"; case IO_CLOSED: return "closed"; - case IO_REFUSED: return "refused"; + case IO_TIMEOUT: return "timeout"; + case IO_CLIPPED: return "clipped"; default: return "unknown error"; } } /*-------------------------------------------------------------------------*\ -* Translate error codes to Lua +* Push error message from code or from driver \*-------------------------------------------------------------------------*/ -void io_pusherror(lua_State *L, int code) +void io_pusherror(lua_State *L, p_io io, int code) { - const char *err = io_strerror(code); + const char *err = NULL; + if (code < IO_USER) err = io_strerror(code); + else err = io->geterr(io->ctx, code); if (err) lua_pushstring(L, err); else lua_pushnil(L); } -- cgit v1.2.3-55-g6feb