luasocket/src/io.c

33 lines
1.2 KiB
C
Raw Normal View History

/*=========================================================================*\
* Input/Output abstraction
* LuaSocket toolkit
*
2012-04-11 13:21:25 -07:00
* RCS ID: $Id: io.c,v 1.6 2005/09/29 06:11:41 diego Exp $
\*=========================================================================*/
2003-05-25 01:54:13 +00:00
#include "io.h"
/*=========================================================================*\
* Exported functions
\*=========================================================================*/
/*-------------------------------------------------------------------------*\
* Initializes C structure
\*-------------------------------------------------------------------------*/
2004-07-15 06:11:53 +00:00
void io_init(p_io io, p_send send, p_recv recv, p_error error, void *ctx) {
2003-05-25 01:54:13 +00:00
io->send = send;
io->recv = recv;
2004-07-15 06:11:53 +00:00
io->error = error;
2003-05-25 01:54:13 +00:00
io->ctx = ctx;
}
/*-------------------------------------------------------------------------*\
2004-07-15 06:11:53 +00:00
* I/O error strings
\*-------------------------------------------------------------------------*/
2004-07-15 06:11:53 +00:00
const char *io_strerror(int err) {
switch (err) {
case IO_DONE: return NULL;
case IO_CLOSED: return "closed";
2004-07-01 03:32:09 +00:00
case IO_TIMEOUT: return "timeout";
2004-07-15 06:11:53 +00:00
default: return "unknown error";
}
}