luasocket/src/io.c

29 lines
986 B
C
Raw Normal View History

/*=========================================================================*\
* Input/Output abstraction
* LuaSocket toolkit
\*=========================================================================*/
2019-02-25 23:59:09 +01:00
#include "luasocket.h"
2003-05-25 03:54:13 +02:00
#include "io.h"
/*-------------------------------------------------------------------------*\
* Initializes C structure
\*-------------------------------------------------------------------------*/
2019-02-28 04:57:25 +01:00
void io_init(p_io io, p_send send, p_recv recv, p_error error, void *ctx) {
2003-05-25 03:54:13 +02:00
io->send = send;
io->recv = recv;
2004-07-15 08:11:53 +02:00
io->error = error;
2003-05-25 03:54:13 +02:00
io->ctx = ctx;
}
/*-------------------------------------------------------------------------*\
2004-07-15 08:11:53 +02:00
* I/O error strings
\*-------------------------------------------------------------------------*/
2019-02-28 04:57:25 +01:00
const char *io_strerror(int err) {
2004-07-15 08:11:53 +02:00
switch (err) {
case IO_DONE: return NULL;
case IO_CLOSED: return "closed";
2004-07-01 05:32:09 +02:00
case IO_TIMEOUT: return "timeout";
default: return "unknown error";
}
}