2003-06-26 11:47:49 -07:00
|
|
|
/*=========================================================================*\
|
|
|
|
* Input/Output abstraction
|
|
|
|
* LuaSocket toolkit
|
|
|
|
\*=========================================================================*/
|
2019-02-25 14:59:09 -08:00
|
|
|
#include "luasocket.h"
|
2003-05-24 18:54:13 -07:00
|
|
|
#include "io.h"
|
|
|
|
|
2003-06-26 11:47:49 -07:00
|
|
|
/*-------------------------------------------------------------------------*\
|
|
|
|
* Initializes C structure
|
|
|
|
\*-------------------------------------------------------------------------*/
|
2019-02-27 19:57:25 -08:00
|
|
|
void io_init(p_io io, p_send send, p_recv recv, p_error error, void *ctx) {
|
2003-05-24 18:54:13 -07:00
|
|
|
io->send = send;
|
|
|
|
io->recv = recv;
|
2004-07-14 23:11:53 -07:00
|
|
|
io->error = error;
|
2003-05-24 18:54:13 -07:00
|
|
|
io->ctx = ctx;
|
|
|
|
}
|
2003-06-26 11:47:49 -07:00
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------*\
|
2004-07-14 23:11:53 -07:00
|
|
|
* I/O error strings
|
2003-06-26 11:47:49 -07:00
|
|
|
\*-------------------------------------------------------------------------*/
|
2019-02-27 19:57:25 -08:00
|
|
|
const char *io_strerror(int err) {
|
2004-07-14 23:11:53 -07:00
|
|
|
switch (err) {
|
2004-01-17 16:04:20 -08:00
|
|
|
case IO_DONE: return NULL;
|
|
|
|
case IO_CLOSED: return "closed";
|
2004-06-30 20:32:09 -07:00
|
|
|
case IO_TIMEOUT: return "timeout";
|
2015-08-21 11:39:34 -07:00
|
|
|
default: return "unknown error";
|
2003-06-26 11:47:49 -07:00
|
|
|
}
|
|
|
|
}
|